Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | List of all members
gar::geo::GeometryGArConfigurationWriter Class Reference

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

Inheritance diagram for gar::geo::GeometryGArConfigurationWriter:
art::ProducingService art::ProductRegistryHelper

Classes

struct  Config
 Service configuration. More...
 

Public Types

using Parameters = art::ServiceTable< Config >
 

Public Member Functions

 GeometryGArConfigurationWriter (Parameters const &)
 Constructor: gets its configuration and does nothing with it. More...
 
- Public Member Functions inherited from art::ProducingService
 ProducingService ()
 
virtual ~ProducingService () noexcept
 
void setModuleDescription (ModuleDescription const &)
 
void registerCallbacks (ProducingServiceSignals &)
 
void doPostReadRun (RunPrincipal &)
 
void doPostReadSubRun (SubRunPrincipal &)
 
void doPostReadEvent (EventPrincipal &)
 

Private Types

using InfoPtr_t = std::unique_ptr< gar::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
 
gar::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 (gar::sumdata::RunData const &data)
 Converts the legacy data into geometry configuration information. More...
 
static InfoPtr_t makeInfoPtr (gar::sumdata::GeometryConfigurationInfo const &info)
 Alias to std::make_unique<sumdata::GeometryConfigurationInfo>. More...
 

Additional Inherited Members

- Static Public Attributes inherited from art::ProducingService
static constexpr bool service_handle_allowed {false}
 

Detailed Description

Writes geometry configuration information into art runs.

This service is part of the mandatory version check of gar::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 gar::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 GeometryGArConfigurationWriter:

Service dependencies

Definition at line 83 of file GeometryGArConfigurationWriter_service.cc.

Member Typedef Documentation

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

Definition at line 105 of file GeometryGArConfigurationWriter_service.cc.

Definition at line 92 of file GeometryGArConfigurationWriter_service.cc.

Constructor & Destructor Documentation

gar::geo::GeometryGArConfigurationWriter::GeometryGArConfigurationWriter ( Parameters const &  )

Constructor: gets its configuration and does nothing with it.

Definition at line 137 of file GeometryGArConfigurationWriter_service.cc.

138 {
139  produces<gar::sumdata::GeometryConfigurationInfo, art::InRun>();
140 }

Member Function Documentation

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

Converts the legacy data into geometry configuration information.

Definition at line 221 of file GeometryGArConfigurationWriter_service.cc.

222 {
223 
225 
226  // we use the simplest version 1 data format (legacy format)
228  confInfo.detectorName = data.DetName();
229 
230  MF_LOG_DEBUG("GeometryGArConfigurationWriter")
231  << "Built geometry configuration information from run data:\n"
232  << confInfo;
233 
234  return makeInfoPtr(std::move(confInfo));
235 
236 } // gar::geo::GeometryGArConfigurationWriter::convertRunDataToGeometryInformation()
DataVersion_t dataVersion
Version of the data in this object (0 is invalid version).
Description of the current configuration of detector geometry.
def move(depos, offset)
Definition: depos.py:107
unsigned int DataVersion_t
Type used for the version of data.
static InfoPtr_t makeInfoPtr(gar::sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.
#define MF_LOG_DEBUG(id)
auto gar::geo::GeometryGArConfigurationWriter::extractInfoFromGeometry ( )
staticprivate

Creates configuration information based on the current Geometry service.

Definition at line 176 of file GeometryGArConfigurationWriter_service.cc.

176  {
177 
179 
180  MF_LOG_DEBUG("GeometryGArConfigurationWriter") << "Geometry configuration information from service:\n"
181  << confInfo;
182 
183  return makeInfoPtr(std::move(confInfo));
184 
185 } // gar::geo::GeometryGArConfigurationWriter::extractInfoFromGeometry()
Description of the current configuration of detector geometry.
def move(depos, offset)
Definition: depos.py:107
static InfoPtr_t makeInfoPtr(gar::sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.
#define MF_LOG_DEBUG(id)
auto gar::geo::GeometryGArConfigurationWriter::loadInfo ( art::Run run) const
private

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

Definition at line 156 of file GeometryGArConfigurationWriter_service.cc.

157 {
158 
159  /*
160  * Read geometry configuration information from the run:
161  *
162  * 1. first attempt to directly read information from past runs of this
163  * service
164  * 2. if none is found, attempt reading legacy information and upgrade it
165  * 3. if no legacy information is found either, return a null pointer
166  *
167  */
169 
170  return info ? std::move(info) : makeInfoFromRunData(run);
171 
172 } // gar::geo::GeometryGArConfigurationWriter::loadInfo()
std::unique_ptr< gar::sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
def move(depos, offset)
Definition: depos.py:107
InfoPtr_t readGeometryInformation(art::Run &run) const
Reads geometry information from the run (returns null pointer if none).
auto gar::geo::GeometryGArConfigurationWriter::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 202 of file GeometryGArConfigurationWriter_service.cc.

203 {
204 
205  gar::sumdata::RunData const* runData = readRunData(run);
206  return runData ? convertRunDataToGeometryInformation(*runData): InfoPtr_t{};
207 
208 } // gar::geo::GeometryGArConfigurationWriter::makeInfoFromRunData()
std::unique_ptr< gar::sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
gar::sumdata::RunData const * readRunData(art::Run &run) const
Returns a pointer to the sumdata::RunData in run (nullptr if none).
static InfoPtr_t convertRunDataToGeometryInformation(gar::sumdata::RunData const &data)
Converts the legacy data into geometry configuration information.
static InfoPtr_t gar::geo::GeometryGArConfigurationWriter::makeInfoPtr ( gar::sumdata::GeometryConfigurationInfo const &  info)
inlinestaticprivate

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

Definition at line 128 of file GeometryGArConfigurationWriter_service.cc.

128 { return std::make_unique<gar::sumdata::GeometryConfigurationInfo>(info); }
void gar::geo::GeometryGArConfigurationWriter::postReadRun ( art::Run run)
overrideprivatevirtual

Writes the information from the service configuration into the run.

Reimplemented from art::ProducingService.

Definition at line 144 of file GeometryGArConfigurationWriter_service.cc.

144  {
145 
147 
148  if (!confInfo) confInfo = extractInfoFromGeometry();
149 
150  run.put(std::move(confInfo), art::fullRun());
151 
152 } // gar::geo::GeometryGArConfigurationWriter::postReadRun()
constexpr auto fullRun()
std::unique_ptr< gar::sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
InfoPtr_t loadInfo(art::Run &run) const
Loads the geometry information from the run (either directly or legacy).
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
static InfoPtr_t extractInfoFromGeometry()
Creates configuration information based on the current Geometry service.
auto gar::geo::GeometryGArConfigurationWriter::readGeometryInformation ( art::Run run) const
private

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

Definition at line 189 of file GeometryGArConfigurationWriter_service.cc.

190 {
191  auto infoHandle = run.getHandle<gar::sumdata::GeometryConfigurationInfo>(art::InputTag{"GeometryGArConfigurationWriter"});
192  if (infoHandle)
193  {
194  return makeInfoPtr(*infoHandle);
195  }
196  return InfoPtr_t{};
197 
198 } // gar::geo::GeometryGArConfigurationWriter::hasGeometryInformation()
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::unique_ptr< gar::sumdata::GeometryConfigurationInfo > InfoPtr_t
Alias for the pointer to the data product object to be put into the run.
Description of the current configuration of detector geometry.
static InfoPtr_t makeInfoPtr(gar::sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.
gar::sumdata::RunData const * gar::geo::GeometryGArConfigurationWriter::readRunData ( art::Run run) const
private

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

Definition at line 212 of file GeometryGArConfigurationWriter_service.cc.

213 {
214  auto allRunData = run.getMany<gar::sumdata::RunData>();
215 
216  return allRunData.empty() ? nullptr: allRunData.front().product();
217 } // gar::geo::GeometryGArConfigurationWriter::readRunData()
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
Definition: DataViewImpl.h:479

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