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

Classes

struct  Config
 
struct  GeometryInfoCheckInfo
 
struct  GeometryInfoConfig
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 GeometryInfoCheck (Parameters const &config)
 
virtual void beginRun (art::Run const &run) override
 
virtual void analyze (art::Event const &) override
 

Private Member Functions

void CheckGeometryInfo (art::Run const &run, GeometryInfoCheckInfo const &config) const
 
void CheckLegacyGeometryInfo (art::Run const &run, GeometryInfoCheckInfo const &config) const
 

Static Private Member Functions

static std::optional
< GeometryInfoCheckInfo
makeGeometryInfoCheckInfo (fhicl::OptionalTable< GeometryInfoConfig > const &config)
 Fills a GeometryInfoCheckInfo out of the specified configuration. More...
 

Private Attributes

std::optional
< GeometryInfoCheckInfo
fCheckInfo
 Information on the check on the regular geometry information. More...
 
std::optional
< GeometryInfoCheckInfo
fLegacyCheckInfo
 Information on the check on the legacy geometry information. More...
 

Static Private Attributes

static art::InputTag const GeometryConfigurationWriterTag { "GeometryConfigurationWriter" }
 The name of the tag for the geometry information. More...
 

Detailed Description

Definition at line 44 of file GeometryInfoCheck_module.cc.

Member Typedef Documentation

using geo::GeometryInfoCheck::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 78 of file GeometryInfoCheck_module.cc.

Constructor & Destructor Documentation

geo::GeometryInfoCheck::GeometryInfoCheck ( Parameters const &  config)
explicit

Definition at line 146 of file GeometryInfoCheck_module.cc.

147  : art::EDAnalyzer(config)
148  , fCheckInfo(makeGeometryInfoCheckInfo(config().GeometryInfo))
149  , fLegacyCheckInfo(makeGeometryInfoCheckInfo(config().GeometryLegacyInfo))
150 {
151 
152  if (fCheckInfo)
153  consumes<sumdata::GeometryConfigurationInfo>(GeometryConfigurationWriterTag);
154  if (fLegacyCheckInfo) consumesMany<sumdata::RunData>();
155 
156 
157  // --- BEGIN -- Configuration dump -------------------------------------------
158  {
159  mf::LogDebug log { "GeometryInfoCheck" };
160  log << "Configuration:"
161  << "\n - geometry configuration check:";
162  if (fCheckInfo) {
163  if (fCheckInfo->detectorName.empty()) log << " (any name)";
164  else log << " must match '" << fCheckInfo->detectorName << "'";
165  log << " [" << (fCheckInfo->required? "mandatory": "optional") << "]";
166  }
167  else log << "not requested";
168 
169  log << "\n - legacy geometry configuration information check:";
170  if (fLegacyCheckInfo) {
171  if (fLegacyCheckInfo->detectorName.empty()) log << " (any name)";
172  else log << " must match '" << fLegacyCheckInfo->detectorName << "'";
173  log << " [" << (fLegacyCheckInfo->required? "mandatory": "optional") << "]";
174  }
175  else log << "not requested";
176 
177  }
178  // --- END -- Configuration dump ---------------------------------------------
179 
180 } // geo::GeometryInfoCheck::GeometryInfoCheck()
static std::optional< GeometryInfoCheckInfo > makeGeometryInfoCheckInfo(fhicl::OptionalTable< GeometryInfoConfig > const &config)
Fills a GeometryInfoCheckInfo out of the specified configuration.
std::optional< GeometryInfoCheckInfo > fLegacyCheckInfo
Information on the check on the legacy geometry information.
static art::InputTag const GeometryConfigurationWriterTag
The name of the tag for the geometry information.
std::optional< GeometryInfoCheckInfo > fCheckInfo
Information on the check on the regular geometry information.

Member Function Documentation

virtual void geo::GeometryInfoCheck::analyze ( art::Event const &  )
inlineoverridevirtual

Definition at line 84 of file GeometryInfoCheck_module.cc.

84 {}
void geo::GeometryInfoCheck::beginRun ( art::Run const &  run)
overridevirtual

Definition at line 184 of file GeometryInfoCheck_module.cc.

184  {
185 
186  if (fCheckInfo) CheckGeometryInfo(run, fCheckInfo.value());
188 
189 } // geo::GeometryInfoCheck::beginRun()
void CheckLegacyGeometryInfo(art::Run const &run, GeometryInfoCheckInfo const &config) const
std::optional< GeometryInfoCheckInfo > fLegacyCheckInfo
Information on the check on the legacy geometry information.
void CheckGeometryInfo(art::Run const &run, GeometryInfoCheckInfo const &config) const
std::optional< GeometryInfoCheckInfo > fCheckInfo
Information on the check on the regular geometry information.
void geo::GeometryInfoCheck::CheckGeometryInfo ( art::Run const &  run,
GeometryInfoCheckInfo const &  config 
) const
private

Performs a geometry information check.

Exceptions
cet::exceptionon check failures

Definition at line 194 of file GeometryInfoCheck_module.cc.

195 {
196 
197  mf::LogDebug log { "GeometryInfoCheck" };
198  log << "Check on geometry information.";
199 
200  //
201  // fetch geometry information
202  //
203  art::Handle<sumdata::GeometryConfigurationInfo> hInfo;
204  if (!run.getByLabel(GeometryConfigurationWriterTag, hInfo)) {
205  log << "\nNo information found.";
206  if (!config.required) return; // well... all ok?
207 
208  log << "\nUnfortunately, that was required...";
209  throw cet::exception("GeometryInfoCheck")
210  << "Required geometry information not found as '"
211  << GeometryConfigurationWriterTag.encode() << "'\n";
212  } // if no info
213 
214  sumdata::GeometryConfigurationInfo const& info { *hInfo };
215  log
216  << "\nFound geometry information (version " << info.dataVersion << ")"
217  << " from '" << hInfo.provenance()->inputTag().encode() << "'"
218  << "\nGeometry name is '" << info.detectorName << "'."
219  ;
220 
221  //
222  // check: the name
223  //
224  if (!config.detectorName.empty()
225  && !case_insensitive_equal(info.detectorName, config.detectorName)
226  ) {
227  throw cet::exception("GeometryInfoCheck")
228  << "Geometry information reports an unexpected name '"
229  << info.detectorName << "' ('" << config.detectorName << "' expected)\n"
230  ;
231  } // if
232 
233  //
234  // all checks done
235  //
236 
237 } // geo::GeometryInfoCheck::CheckGeometryInfo()
static art::InputTag const GeometryConfigurationWriterTag
The name of the tag for the geometry information.
Description of the current configuration of detector geometry.
void geo::GeometryInfoCheck::CheckLegacyGeometryInfo ( art::Run const &  run,
GeometryInfoCheckInfo const &  config 
) const
private

Performs a legacy geometry information check

Exceptions
cet::exceptionon check failures

Definition at line 242 of file GeometryInfoCheck_module.cc.

243 {
244 
245  mf::LogDebug log { "GeometryInfoCheck" };
246  log << "Check on legacy geometry information.";
247 
248  //
249  // fetch geometry information
250  //
251  //std::vector<art::Handle<sumdata::RunData>> hInfoList;
252  //run.getManyByType(hInfoList);
253  auto hInfoList = run.getMany<sumdata::RunData>();
254  if (hInfoList.empty()) {
255  log << "\nNo information found.";
256  if (!config.required) return; // well... all ok?
257 
258  log << "\nUnfortunately, that was required...";
259  throw cet::exception("GeometryInfoCheck")
260  << "No legacy geometry information found!\n";
261  } // if no info
262 
263  log << "\nFound " << hInfoList.size() << " legacy geometry records:";
264  art::Handle<sumdata::RunData> const* hInfo = nullptr;
265  for (auto const& handle: hInfoList) {
266  log << "\n - " << handle.provenance()->inputTag().encode();
267  if (handle.failedToGet()) log << " (not present)";
268  else if (!hInfo) {
269  hInfo = &handle;
270  log << " (this will be used for the check)";
271  }
272  } // for all handles
273 
274  sumdata::RunData const& info { *(hInfo->product()) };
275  log
276  << "\nFound legacy geometry information "
277  << "\nGeometry name is '" << info.DetName() << "'."
278  ;
279 
280  //
281  // check: the name
282  //
283  if (!config.detectorName.empty()
284  && !case_insensitive_equal(info.DetName(), config.detectorName)
285  ) {
286  throw cet::exception("GeometryInfoCheck")
287  << "Geometry legacy information reports an unexpected name '"
288  << info.DetName() << "' ('" << config.detectorName << "' expected)\n"
289  ;
290  } // if
291 
292  //
293  // all checks done
294  //
295 
296 } // geo::GeometryInfoCheck::CheckLegacyGeometryInfo()
auto geo::GeometryInfoCheck::makeGeometryInfoCheckInfo ( fhicl::OptionalTable< GeometryInfoConfig > const &  config)
staticprivate

Fills a GeometryInfoCheckInfo out of the specified configuration.

Definition at line 301 of file GeometryInfoCheck_module.cc.

303 {
304  GeometryInfoConfig infoConfig;
305  if (!config(infoConfig)) return {};
306 
307  GeometryInfoCheckInfo info;
308  info.required = infoConfig.Required();
309  infoConfig.Name(info.detectorName); // so far, not specifying it defaults to empty
310 
311  return { std::move(info) };
312 } // geo::GeometryInfoCheck::makeGeometryInfoCheckInfo()

Member Data Documentation

std::optional<GeometryInfoCheckInfo> geo::GeometryInfoCheck::fCheckInfo
private

Information on the check on the regular geometry information.

Definition at line 94 of file GeometryInfoCheck_module.cc.

std::optional<GeometryInfoCheckInfo> geo::GeometryInfoCheck::fLegacyCheckInfo
private

Information on the check on the legacy geometry information.

Definition at line 97 of file GeometryInfoCheck_module.cc.

art::InputTag const geo::GeometryInfoCheck::GeometryConfigurationWriterTag { "GeometryConfigurationWriter" }
staticprivate

The name of the tag for the geometry information.

Definition at line 111 of file GeometryInfoCheck_module.cc.


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