LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
geo::GeometryConfigurationWriter Class Reference

Writes geometry configuration information into art runs. More...

Inheritance diagram for geo::GeometryConfigurationWriter:
art::ProducingService art::ProductRegistryHelper

Classes

struct  Config
 Service configuration. More...
 

Public Types

using Parameters = art::ServiceTable< Config >
 

Public Member Functions

 GeometryConfigurationWriter (Parameters const &)
 
void setModuleDescription (ModuleDescription const &)
 
void registerCallbacks (ProducingServiceSignals &)
 
void doPostReadRun (RunPrincipal &)
 
void doPostReadSubRun (SubRunPrincipal &)
 
void doPostReadEvent (EventPrincipal &)
 

Static Public Attributes

static constexpr bool service_handle_allowed {false}
 

Private Types

using InfoPtr_t = std::unique_ptr< sumdata::GeometryConfigurationInfo >
 Alias for the pointer to the data product object to be put into the run. More...
 

Private Member Functions

void postReadRun (art::Run &run) override
 Writes the information from the service configuration into the run. More...
 
InfoPtr_t previousInfo (art::Run const &run) const
 Loads the geometry information from the run (either directly or legacy). More...
 
void verifyConsistentConfigs (sumdata::GeometryConfigurationInfo const &A, sumdata::GeometryConfigurationInfo const &B, art::RunID const &id) const
 
InfoPtr_t readGeometryInformation (art::Run const &run) const
 Reads geometry information from the run (returns null pointer if none). More...
 
InfoPtr_t makeInfoFromRunData (art::Run const &run) const
 
sumdata::RunData const * readRunData (art::Run const &run) const
 Returns a pointer to the sumdata::RunData in run (nullptr if none). More...
 

Static Private Member Functions

static InfoPtr_t extractInfoFromGeometry ()
 Creates configuration information based on the current Geometry service. More...
 

Private Attributes

bool fFatalConfCheck
 

Detailed Description

Writes geometry configuration information into art runs.

If included in the configuration, the version of the geometry is checked after each run is read from the input source.

services: {
Geometry: @local::experiment_geometry
# ...
}

The compatibility check is currently very silly, but it can improved in future versions. This check is the same as the legacy check, that verifies that the configured detector name (geo::GeometryCore::DetectorName()) has not changed.

Configuration

  • SkipConfigurationCheck (boolean, default: false): if set to true, failure of configuration consistency check described below is not fatal and it will just produce a warning on each failure;

The configuration check is described in the documentation of geo::Geometry service.

Produced data products

The service guarantees that configuration information of type sumdata::GeometryConfigurationInfo is present into the run, accessible with an input tag GeometryConfigurationWriter:

  • if such information is already available in the run, no further information is added
  • legacy: if there is no such information, but there is a sumdata::RunData data product, a reduced version of the configuration information is created from the information in that data product (the first one, if multiple are present)
  • finally, if no information is present neither in the full sumdata::GeometryConfigurationInfo form nor in the legacy sumdata::RunData form, information is put together based on the current configuration of the Geometry service.

Service dependencies

  • Geometry service (for obtaining the current configuration to put into the event)

Design details

  • the choice of delegating the writing of data product to a producing service rather than to modules is driven by the fact that there is a way to enforce this service to be actually run, and that no further instrumentation is needed;
  • the choice of putting the configuration information in the art::Run is driven by the fact that the run is the highest available container; job-level data products (art::Results) behave very differently from the others and are not currently interfaced with a producing service;
  • the information in sumdata::GeometryConfigurationInfo should be compact enough not to bloat the data files with very few events per run, as it may be for the selection of rare processes or signatures.

Definition at line 96 of file GeometryConfigurationWriter_service.cc.

Member Typedef Documentation

Alias for the pointer to the data product object to be put into the run.

Definition at line 111 of file GeometryConfigurationWriter_service.cc.

Constructor & Destructor Documentation

geo::GeometryConfigurationWriter::GeometryConfigurationWriter ( Parameters const &  p)

Definition at line 204 of file GeometryConfigurationWriter_service.cc.

205  : fFatalConfCheck{not p().SkipConfigurationCheck()}
206 {
207  produces<sumdata::GeometryConfigurationInfo, art::InRun>();
208 }

Member Function Documentation

void art::ProducingService::doPostReadEvent ( EventPrincipal ep)
inherited

Definition at line 54 of file ProducingService.cc.

References e, art::EventPrincipal::makeEvent(), art::ProducingService::mc_, and art::ProducingService::postReadEvent().

Referenced by art::ProducingService::registerCallbacks().

55  {
56  auto e = ep.makeEvent(mc_);
58  e.commitProducts(true, &expectedProducts<InEvent>());
59  }
virtual void postReadEvent(Event &)
Float_t e
Definition: plot.C:35
void art::ProducingService::doPostReadRun ( RunPrincipal rp)
inherited

Definition at line 38 of file ProducingService.cc.

References art::RangeSet::forRun(), art::RunPrincipal::makeRun(), art::ProducingService::mc_, art::ProducingService::postReadRun(), r, and art::RunPrincipal::runID().

Referenced by art::ProducingService::registerCallbacks().

39  {
40  auto r = rp.makeRun(mc_, RangeSet::forRun(rp.runID()));
41  postReadRun(r);
42  r.commitProducts();
43  }
TRandom r
Definition: spectrum.C:23
virtual void postReadRun(Run &)
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
void art::ProducingService::doPostReadSubRun ( SubRunPrincipal srp)
inherited

Definition at line 46 of file ProducingService.cc.

References art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ProducingService::mc_, art::ProducingService::postReadSubRun(), and art::SubRunPrincipal::subRunID().

Referenced by art::ProducingService::registerCallbacks().

47  {
48  auto sr = srp.makeSubRun(mc_, RangeSet::forSubRun(srp.subRunID()));
49  postReadSubRun(sr);
50  sr.commitProducts();
51  }
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
virtual void postReadSubRun(SubRun &)
auto geo::GeometryConfigurationWriter::extractInfoFromGeometry ( )
staticprivate

Creates configuration information based on the current Geometry service.

Definition at line 238 of file GeometryConfigurationWriter_service.cc.

References MF_LOG_DEBUG.

Referenced by postReadRun().

239 {
240 
242  art::ServiceHandle<geo::Geometry>()->configurationInfo();
243 
244  MF_LOG_DEBUG("GeometryConfigurationWriter")
245  << "Geometry configuration information from service:\n"
246  << confInfo;
247 
248  return makeInfoPtr(std::move(confInfo));
249 }
#define MF_LOG_DEBUG(id)
Description of the current configuration of detector geometry.
auto geo::GeometryConfigurationWriter::makeInfoFromRunData ( art::Run const &  run) const
private

Upgrades legacy sumdata::RunData in run to geometry information (returns null pointer if no legacy information is present).

Definition at line 284 of file GeometryConfigurationWriter_service.cc.

References readRunData().

Referenced by previousInfo().

285 {
286  sumdata::RunData const* runData = readRunData(run);
287  return runData ? convertRunDataToGeometryInformation(*runData) : InfoPtr_t{};
288 }
std::unique_ptr< sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
sumdata::RunData const * readRunData(art::Run const &run) const
Returns a pointer to the sumdata::RunData in run (nullptr if none).
void geo::GeometryConfigurationWriter::postReadRun ( art::Run run)
overrideprivatevirtual

Writes the information from the service configuration into the run.

Reimplemented from art::ProducingService.

Definition at line 211 of file GeometryConfigurationWriter_service.cc.

References extractInfoFromGeometry(), art::fullRun(), art::Run::id(), previousInfo(), art::Run::put(), and verifyConsistentConfigs().

212 {
213  auto previousConfInfo = previousInfo(run);
214  auto currentConfInfo = extractInfoFromGeometry();
215  if (previousConfInfo && currentConfInfo) {
216  verifyConsistentConfigs(*previousConfInfo, *currentConfInfo, run.id());
217  }
218 
219  InfoPtr_t confInfo = previousConfInfo ? std::move(previousConfInfo) : std::move(currentConfInfo);
220  run.put(std::move(confInfo), art::fullRun());
221 }
RunID id() const
Definition: Run.cc:21
constexpr auto fullRun()
void verifyConsistentConfigs(sumdata::GeometryConfigurationInfo const &A, sumdata::GeometryConfigurationInfo const &B, art::RunID const &id) const
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Run.h:121
STL namespace.
std::unique_ptr< sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
static InfoPtr_t extractInfoFromGeometry()
Creates configuration information based on the current Geometry service.
InfoPtr_t previousInfo(art::Run const &run) const
Loads the geometry information from the run (either directly or legacy).
auto geo::GeometryConfigurationWriter::previousInfo ( art::Run const &  run) const
private

Loads the geometry information from the run (either directly or legacy).

Read geometry configuration information from the run:

  1. first attempt to directly read information from past runs of this service
  2. if none is found, attempt reading legacy information and upgrade it
  3. if no legacy information is found either, return a null pointer

Definition at line 224 of file GeometryConfigurationWriter_service.cc.

References makeInfoFromRunData(), and readGeometryInformation().

Referenced by postReadRun().

225 {
234  return info ? std::move(info) : makeInfoFromRunData(run);
235 }
InfoPtr_t makeInfoFromRunData(art::Run const &run) const
InfoPtr_t readGeometryInformation(art::Run const &run) const
Reads geometry information from the run (returns null pointer if none).
std::unique_ptr< sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
auto geo::GeometryConfigurationWriter::readGeometryInformation ( art::Run const &  run) const
private

Reads geometry information from the run (returns null pointer if none).

Definition at line 273 of file GeometryConfigurationWriter_service.cc.

Referenced by previousInfo().

275 {
276  if (auto h = run.getHandle<sumdata::GeometryConfigurationInfo>(
277  art::InputTag{"GeometryConfigurationWriter"})) {
278  return makeInfoPtr(*h);
279  }
280  return nullptr;
281 }
Description of the current configuration of detector geometry.
sumdata::RunData const * geo::GeometryConfigurationWriter::readRunData ( art::Run const &  run) const
private

Returns a pointer to the sumdata::RunData in run (nullptr if none).

Definition at line 291 of file GeometryConfigurationWriter_service.cc.

References DEFINE_ART_PRODUCING_SERVICE, and art::ProductRetriever::getMany().

Referenced by makeInfoFromRunData().

292 {
293  auto allRunData = run.getMany<sumdata::RunData>();
294  return allRunData.empty() ? nullptr : allRunData.front().product();
295 }
void art::ProducingService::registerCallbacks ( ProducingServiceSignals cbReg)
inherited
void art::ProducingService::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 21 of file ProducingService.cc.

References art::ProducingService::mc_.

22  {
23  // We choose the one-argument constructor since the path
24  // information is irrelevant when the doPostRead* functions are
25  // invoked.
26  mc_ = ModuleContext{md};
27  }
void geo::GeometryConfigurationWriter::verifyConsistentConfigs ( sumdata::GeometryConfigurationInfo const &  A,
sumdata::GeometryConfigurationInfo const &  B,
art::RunID const &  id 
) const
private

Verifies that the geometry configurations for the current and previous processes are consistent.

Definition at line 252 of file GeometryConfigurationWriter_service.cc.

References fFatalConfCheck.

Referenced by postReadRun().

256 {
257  auto consistentInfo = compareConfigurationInfo(A, B);
258  if (consistentInfo) { return; }
259 
260  if (fFatalConfCheck) {
261  cet::HorizontalRule rule{50};
262  throw cet::exception("GeometryConfiguration")
263  << "Geometry used for run " << id << " is incompatible with the one configured in the job!"
264  << "\n=== job configuration " << rule('=') << "\n"
265  << B << "\n=== run configuration " << rule('=') << "\n"
266  << A << "\n======================" << rule('=') << "\n";
267  }
268  mf::LogWarning("GeometryConfiguration")
269  << "Geometry used for " << id << " is incompatible with the one configured in the job.";
270 }
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

bool geo::GeometryConfigurationWriter::fFatalConfCheck
private

Definition at line 135 of file GeometryConfigurationWriter_service.cc.

Referenced by verifyConsistentConfigs().

constexpr bool art::ProducingService::service_handle_allowed {false}
staticinherited

Definition at line 19 of file ProducingService.h.


The documentation for this class was generated from the following file: