18 #include "art/Framework/Principal/Run.h"
19 #include "art/Framework/Services/Registry/ActivityRegistry.h"
20 #include "art/Framework/Services/Registry/ServiceHandle.h"
21 #include "messagefacility/MessageLogger/MessageLogger.h"
22 #include "canvas/Utilities/InputTag.h"
23 #include "canvas/Utilities/Exception.h"
24 #include "fhiclcpp/types/Table.h"
25 #include "fhiclcpp/ParameterSet.h"
26 #include "cetlib_except/exception.h"
27 #include "cetlib/search_path.h"
42 Geometry::Geometry(fhicl::ParameterSet
const& pset, art::ActivityRegistry ®)
44 , fRelPath (pset.
get<
std::string >(
"RelativePath",
"" ))
45 , fDisableWiresInG4 (pset.
get<
bool >(
"DisableWiresInG4",
false))
46 , fNonFatalConfCheck(pset.
get<
bool >(
"SkipConfigurationCheck",
false))
47 , fSortingParameters(pset.
get<fhicl::ParameterSet>(
"SortingParameters", fhicl::ParameterSet() ))
48 , fBuilderParameters(pset.
get<fhicl::ParameterSet>(
"Builder", fhicl::ParameterSet() ))
51 if (pset.has_key(
"ForceUseFCLOnly")) {
52 throw art::Exception(art::errors::Configuration)
53 <<
"Geometry service does not support `ForceUseFCLOnly` configuration parameter any more.\n";
68 std::string
GDMLFileName = pset.get<std::string>(
"GDML");
69 std::string
ROOTFileName = pset.get<std::string>(
"GDML");
87 mf::LogWarning(
"Geometry") <<
"Geometry used for " << run.id()
88 <<
" is incompatible with the one configured in the job.";
91 throw cet::exception(
"Geometry")
92 <<
"Geometry used for run " << run.id()
93 <<
" is incompatible with the one configured in the job!"
94 <<
"\n=== job configuration " << std::string(50,
'=')
96 <<
"\n=== run configuration " << std::string(50,
'=')
97 <<
"\n" << inputGeomInfo
98 <<
"\n======================" << std::string(50,
'=')
111 art::ServiceHandle<geo::ExptGeoHelperInterface const> helper{};
114 if (!channelMapAlg) {
115 throw cet::exception(
"ChannelMapLoadFail")
116 <<
" failed to load new channel map";
123 std::string gdmlfile, std::string ,
130 ROOTFileName.append(gdmlfile);
141 cet::search_path
const sp{
"FW_SEARCH_PATH"};
143 std::string GDMLfile;
145 throw cet::exception(
"Geometry")
146 <<
"cannot find the gdml geometry file:"
148 <<
"\nbail ungracefully.\n";
151 std::string ROOTfile;
152 if( !sp.find_file(ROOTFileName, ROOTfile) ) {
153 throw cet::exception(
"Geometry")
154 <<
"cannot find the root geometry file:\n"
155 <<
"\n" << ROOTFileName
156 <<
"\nbail ungracefully.\n";
160 fhicl::Table<geo::GeometryBuilderStandard::Config>
const config{
fBuilderParameters, {
"tool_type"}};
174 (fhicl::ParameterSet
const& config)
185 fConfInfo = std::move(confInfo);
187 MF_LOG_TRACE(
"Geometry")
188 <<
"Geometry configuration information:\n" << fConfInfo;
197 MF_LOG_DEBUG(
"Geometry") <<
"New geometry information:\n" << other;
199 return CompareConfigurationInfo(fConfInfo, other);
205 (art::Run
const& run)
210 (art::InputTag{
"GeometryConfigurationWriter"});
212 catch (art::Exception
const&
e) {
213 throw art::Exception{
215 "Can't read geometry configuration information.\n"
216 "Is `GeometryConfigurationWriter` service configured?\n",
239 mf::LogWarning(
"Geometry") <<
"Geometry::CompareConfigurationInfo(): "
240 "invalid version for configuration A:\n" <<
A;
244 mf::LogWarning(
"Geometry") <<
"Geometry::CompareConfigurationInfo(): "
245 "invalid version for configuration B:\n" << B;
252 assert(commonVersion >= 1);
255 mf::LogWarning(
"Geometry") <<
"Geometry::CompareConfigurationInfo(): "
256 "detector name mismatch: '" << A.
detectorName <<
"' vs. '"
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Utilities related to art service access.
fhicl::ParameterSet fSortingParameters
Parameter set to define the channel map sorting.
DataVersion_t dataVersion
Version of the data in this object (0 is invalid version).
std::string geometryServiceConfiguration
geo::Geometry service configuration, as FHiCL table.
void FillGeometryConfigurationInfo(fhicl::ParameterSet const &config)
Fills the service configuration information into fConfInfo.
static bool CompareConfigurationInfo(sumdata::GeometryConfigurationInfo const &A, sumdata::GeometryConfigurationInfo const &B)
Returns if A and B are compatible geometry service configurations.
bool CheckConfigurationInfo(sumdata::GeometryConfigurationInfo const &other) const
Returns if the other configuration is compatible with our current.
void preBeginRun(art::Run const &run)
Updates the geometry if needed at the beginning of each new run.
static sumdata::GeometryConfigurationInfo const & ReadConfigurationInfo(art::Run const &run)
Reads and returns the geometry configuration information from the run.
bool isDataValid() const noexcept
Protocol: whether the data content is valid.
fhicl::ParameterSet fBuilderParameters
Parameter set for geometry builder.
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
void LoadNewGeometry(std::string gdmlfile, std::string rootfile, bool bForceReload=false)
Expands the provided paths and loads the geometry description(s)
Interface to a service that handles any experiment-specific knowledge that is needed by the Geometry ...
Description of geometry of one entire detector.
void LoadGeometryFile(std::string gdmlfile, std::string rootfile, geo::GeometryBuilder &builder, bool bForceReload=false)
Loads the geometry information from the specified files.
sumdata::GeometryConfigurationInfo fConfInfo
Summary of service configuration.
Description of the current configuration of detector geometry.
Standard implementation of geometry extractor.
unsigned int DataVersion_t
Type used for the version of data.
void ApplyChannelMap(std::unique_ptr< geo::ChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
Extracts of LArSoft geometry information from ROOT.
void InitializeChannelMap()
art framework interface to geometry description
Description of the current configuration of detector geometry.