16 #include "art/Framework/Core/ProducingService.h"
17 #include "art/Framework/Principal/Handle.h"
18 #include "art/Framework/Principal/Run.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "canvas/Utilities/InputTag.h"
21 #include "messagefacility/MessageLogger/MessageLogger.h"
28 namespace geo {
class GeometryConfigurationWriter; }
102 using InfoPtr_t = std::unique_ptr<sumdata::GeometryConfigurationInfo>;
127 {
return std::make_unique<sumdata::GeometryConfigurationInfo>(
info); }
138 produces<sumdata::GeometryConfigurationInfo, art::InRun>();
147 if (!confInfo) confInfo = extractInfoFromGeometry();
149 run.put(std::move(confInfo), art::fullRun());
170 return info? std::move(info): makeInfoFromRunData(run);
179 = art::ServiceHandle<geo::Geometry>()->configurationInfo();
181 MF_LOG_DEBUG(
"GeometryConfigurationWriter")
182 <<
"Geometry configuration information from service:\n" << confInfo;
184 return makeInfoPtr(std::move(confInfo));
194 art::Handle<sumdata::GeometryConfigurationInfo> infoHandle;
196 run.getByLabel(art::InputTag{
"GeometryConfigurationWriter"}, infoHandle)
209 return runData? convertRunDataToGeometryInformation(*runData):
InfoPtr_t{};
216 (art::Run& run)
const
221 return allRunData.empty()?
nullptr: allRunData.front().product();
236 MF_LOG_DEBUG(
"GeometryConfigurationInfo")
237 <<
"Built geometry configuration information from run data:\n" << confInfo;
239 return makeInfoPtr(std::move(confInfo));
Writes geometry configuration information into art runs.
std::string const & DetName() const
DataVersion_t dataVersion
Version of the data in this object (0 is invalid version).
GeometryConfigurationWriter(Parameters const &)
Constructor: gets its configuration and does nothing with it.
InfoPtr_t makeInfoFromRunData(art::Run &run) const
static InfoPtr_t makeInfoPtr(sumdata::GeometryConfigurationInfo const &info)
Alias to std::make_unique<sumdata::GeometryConfigurationInfo>.
art::ServiceTable< Config > Parameters
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.
InfoPtr_t readGeometryInformation(art::Run &run) const
Reads geometry information from the run (returns null pointer if none).
static InfoPtr_t extractInfoFromGeometry()
Creates configuration information based on the current Geometry service.
Description of the current configuration of detector geometry.
unsigned int DataVersion_t
Type used for the version of data.
sumdata::RunData const * readRunData(art::Run &run) const
Returns a pointer to the sumdata::RunData in run (nullptr if none).
virtual void postReadRun(art::Run &run) override
Writes the information from the service configuration into the run.
art framework interface to geometry description
Description of the current configuration of detector geometry.
InfoPtr_t loadInfo(art::Run &run) const
Loads the geometry information from the run (either directly or legacy).