LArSoft  v09_90_00
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 &)
 Constructor: gets its configuration and does nothing with it. More...
 
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

virtual void postReadRun (art::Run &run) override
 Writes the information from the service configuration into the run. More...
 
InfoPtr_t loadInfo (art::Run &run) const
 Loads the geometry information from the run (either directly or legacy). More...
 
InfoPtr_t readGeometryInformation (art::Run &run) const
 Reads geometry information from the run (returns null pointer if none). More...
 
InfoPtr_t makeInfoFromRunData (art::Run &run) const
 
sumdata::RunData const * readRunData (art::Run &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...
 
static InfoPtr_t convertRunDataToGeometryInformation (sumdata::RunData const &data)
 Converts the legacy data into geometry configuration information. More...
 
static InfoPtr_t makeInfoPtr (sumdata::GeometryConfigurationInfo const &info)
 Alias to std::make_unique<sumdata::GeometryConfigurationInfo>. More...
 

Detailed Description

Writes geometry configuration information into art runs.

This service is part of the mandatory version check of geo::Geometry service. It does not require any special configuration, but it must be listed in the configuration in order for Geometry to work:

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

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)

Definition at line 80 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 99 of file GeometryConfigurationWriter_service.cc.

Constructor & Destructor Documentation

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

Constructor: gets its configuration and does nothing with it.

Definition at line 131 of file GeometryConfigurationWriter_service.cc.

132 {
133  produces<sumdata::GeometryConfigurationInfo, art::InRun>();
134 }

Member Function Documentation

auto geo::GeometryConfigurationWriter::convertRunDataToGeometryInformation ( sumdata::RunData const &  data)
staticprivate

Converts the legacy data into geometry configuration information.

Definition at line 213 of file GeometryConfigurationWriter_service.cc.

References sumdata::GeometryConfigurationInfo::dataVersion, DEFINE_ART_PRODUCING_SERVICE, sumdata::GeometryConfigurationInfo::detectorName, makeInfoPtr(), and MF_LOG_DEBUG.

Referenced by makeInfoFromRunData().

215 {
216 
218 
219  // we use the simplest version 1 data format (legacy format)
221  confInfo.detectorName = data.DetName();
222 
223  MF_LOG_DEBUG("GeometryConfigurationInfo")
224  << "Built geometry configuration information from run data:\n"
225  << confInfo;
226 
227  return makeInfoPtr(std::move(confInfo));
228 
229 } // geo::GeometryConfigurationWriter::convertRunDataToGeometryInformation()
DataVersion_t dataVersion
Version of the data in this object (0 is invalid version).
static InfoPtr_t makeInfoPtr(sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.
unsigned int DataVersion_t
Type used for the version of data.
#define MF_LOG_DEBUG(id)
Description of the current configuration of detector geometry.
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 168 of file GeometryConfigurationWriter_service.cc.

References makeInfoPtr(), and MF_LOG_DEBUG.

Referenced by postReadRun().

169 {
170 
172  art::ServiceHandle<geo::Geometry>()->configurationInfo();
173 
174  MF_LOG_DEBUG("GeometryConfigurationWriter")
175  << "Geometry configuration information from service:\n"
176  << confInfo;
177 
178  return makeInfoPtr(std::move(confInfo));
179 
180 } // geo::GeometryConfigurationWriter::extractInfoFromGeometry()
static InfoPtr_t makeInfoPtr(sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.
#define MF_LOG_DEBUG(id)
Description of the current configuration of detector geometry.
auto geo::GeometryConfigurationWriter::loadInfo ( art::Run run) const
private

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

Definition at line 149 of file GeometryConfigurationWriter_service.cc.

References makeInfoFromRunData(), and readGeometryInformation().

Referenced by postReadRun().

150 {
151 
152  /*
153  * Read geometry configuration information from the run:
154  *
155  * 1. first attempt to directly read information from past runs of this
156  * service
157  * 2. if none is found, attempt reading legacy information and upgrade it
158  * 3. if no legacy information is found either, return a null pointer
159  *
160  */
162 
163  return info ? std::move(info) : makeInfoFromRunData(run);
164 
165 } // geo::GeometryConfigurationWriter::loadInfo()
std::unique_ptr< sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
InfoPtr_t readGeometryInformation(art::Run &run) const
Reads geometry information from the run (returns null pointer if none).
auto geo::GeometryConfigurationWriter::makeInfoFromRunData ( art::Run run) const
private

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

Definition at line 194 of file GeometryConfigurationWriter_service.cc.

References convertRunDataToGeometryInformation(), and readRunData().

Referenced by loadInfo().

195 {
196 
197  sumdata::RunData const* runData = readRunData(run);
198 
199  return runData ? convertRunDataToGeometryInformation(*runData) : InfoPtr_t{};
200 
201 } // geo::GeometryConfigurationWriter::makeInfoFromRunData()
static InfoPtr_t convertRunDataToGeometryInformation(sumdata::RunData const &data)
Converts the legacy data into geometry configuration information.
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 &run) const
Returns a pointer to the sumdata::RunData in run (nullptr if none).
static InfoPtr_t geo::GeometryConfigurationWriter::makeInfoPtr ( sumdata::GeometryConfigurationInfo const &  info)
inlinestaticprivate

Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.

Definition at line 121 of file GeometryConfigurationWriter_service.cc.

Referenced by convertRunDataToGeometryInformation(), extractInfoFromGeometry(), and readGeometryInformation().

122  {
123  return std::make_unique<sumdata::GeometryConfigurationInfo>(info);
124  }
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 137 of file GeometryConfigurationWriter_service.cc.

References extractInfoFromGeometry(), art::fullRun(), loadInfo(), and art::Run::put().

138 {
139 
141 
142  if (!confInfo) confInfo = extractInfoFromGeometry();
143 
144  run.put(std::move(confInfo), art::fullRun());
145 
146 } // geo::GeometryConfigurationWriter::postReadRun()
constexpr auto fullRun()
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Run.h:121
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 loadInfo(art::Run &run) const
Loads the geometry information from the run (either directly or legacy).
auto geo::GeometryConfigurationWriter::readGeometryInformation ( art::Run run) const
private

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

Definition at line 183 of file GeometryConfigurationWriter_service.cc.

References makeInfoPtr().

Referenced by loadInfo().

184 {
185 
187  return run.getByLabel(art::InputTag{"GeometryConfigurationWriter"}, infoHandle) ?
188  makeInfoPtr(*infoHandle) :
189  InfoPtr_t{};
190 
191 } // geo::GeometryConfigurationWriter::hasGeometryInformation()
static InfoPtr_t makeInfoPtr(sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.
std::unique_ptr< sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
sumdata::RunData const * geo::GeometryConfigurationWriter::readRunData ( art::Run run) const
private

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

Definition at line 204 of file GeometryConfigurationWriter_service.cc.

References art::ProductRetriever::getMany().

Referenced by makeInfoFromRunData().

205 {
206  //std::vector<art::Handle<sumdata::RunData>> allRunData;
207  //run.getManyByType(allRunData);
208  auto allRunData = run.getMany<sumdata::RunData>();
209  return allRunData.empty() ? nullptr : allRunData.front().product();
210 } // geo::GeometryConfigurationWriter::readRunData()
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
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  }

Member Data Documentation

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: