All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | List of all members
geo::GeometryConfigurationWriter Class Reference

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

Inheritance diagram for geo::GeometryConfigurationWriter:

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...
 

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:

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:

Service dependencies

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

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

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

Member Function Documentation

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

Converts the legacy data into geometry configuration information.

Definition at line 227 of file GeometryConfigurationWriter_service.cc.

228 {
229 
231 
232  // we use the simplest version 1 data format (legacy format)
234  confInfo.detectorName = data.DetName();
235 
236  MF_LOG_DEBUG("GeometryConfigurationInfo")
237  << "Built geometry configuration information from run data:\n" << confInfo;
238 
239  return makeInfoPtr(std::move(confInfo));
240 
241 } // 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&lt;sumdata::GeometryConfigurationInfo&gt;.
unsigned int DataVersion_t
Type used for the version of data.
Description of the current configuration of detector geometry.
auto geo::GeometryConfigurationWriter::extractInfoFromGeometry ( )
staticprivate

Creates configuration information based on the current Geometry service.

Definition at line 176 of file GeometryConfigurationWriter_service.cc.

176  {
177 
179  = art::ServiceHandle<geo::Geometry>()->configurationInfo();
180 
181  MF_LOG_DEBUG("GeometryConfigurationWriter")
182  << "Geometry configuration information from service:\n" << confInfo;
183 
184  return makeInfoPtr(std::move(confInfo));
185 
186 } // geo::GeometryConfigurationWriter::extractInfoFromGeometry()
static InfoPtr_t makeInfoPtr(sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique&lt;sumdata::GeometryConfigurationInfo&gt;.
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 155 of file GeometryConfigurationWriter_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 } // 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 203 of file GeometryConfigurationWriter_service.cc.

205 {
206 
207  sumdata::RunData const* runData = readRunData(run);
208 
209  return runData? convertRunDataToGeometryInformation(*runData): InfoPtr_t{};
210 
211 } // 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 126 of file GeometryConfigurationWriter_service.cc.

127  { return std::make_unique<sumdata::GeometryConfigurationInfo>(info); }
void geo::GeometryConfigurationWriter::postReadRun ( art::Run &  run)
overrideprivatevirtual

Writes the information from the service configuration into the run.

Definition at line 143 of file GeometryConfigurationWriter_service.cc.

143  {
144 
146 
147  if (!confInfo) confInfo = extractInfoFromGeometry();
148 
149  run.put(std::move(confInfo), art::fullRun());
150 
151 } // geo::GeometryConfigurationWriter::postReadRun()
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 191 of file GeometryConfigurationWriter_service.cc.

192 {
193 
194  art::Handle<sumdata::GeometryConfigurationInfo> infoHandle;
195  return
196  run.getByLabel(art::InputTag{"GeometryConfigurationWriter"}, infoHandle)
197  ? makeInfoPtr(*infoHandle): InfoPtr_t{};
198 
199 } // geo::GeometryConfigurationWriter::hasGeometryInformation()
static InfoPtr_t makeInfoPtr(sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique&lt;sumdata::GeometryConfigurationInfo&gt;.
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 * geo::GeometryConfigurationWriter::readRunData ( art::Run &  run) const
private

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

Definition at line 216 of file GeometryConfigurationWriter_service.cc.

217 {
218  //std::vector<art::Handle<sumdata::RunData>> allRunData;
219  //run.getManyByType(allRunData);
220  auto allRunData = run.getMany<sumdata::RunData>();
221  return allRunData.empty()? nullptr: allRunData.front().product();
222 } // geo::GeometryConfigurationWriter::readRunData()

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