14 #include "art/Framework/Core/ModuleMacros.h" 
   15 #include "art/Framework/Core/EDAnalyzer.h" 
   16 #include "art/Framework/Principal/Run.h" 
   17 #include "art/Framework/Principal/Handle.h" 
   18 #include "art/Framework/Principal/Provenance.h" 
   19 #include "canvas/Utilities/InputTag.h" 
   20 #include "messagefacility/MessageLogger/MessageLogger.h" 
   21 #include "fhiclcpp/types/OptionalTable.h" 
   22 #include "fhiclcpp/types/OptionalAtom.h" 
   23 #include "fhiclcpp/types/Atom.h" 
   24 #include "cetlib_except/exception.h" 
   33 namespace art { 
class Event; }
 
   43 namespace geo { 
class GeometryInfoCheck; }
 
   49     fhicl::OptionalAtom<std::string> 
Name {
 
   51       fhicl::Comment{ 
"Name of the geometry (if omitted, any will do)" }
 
   56       fhicl::Comment{ 
"Whether the presence of this item is mandatory" },
 
   67       fhicl::Comment{ 
"Information to check about geometry" }
 
   73         { 
"Information to check about geometry (legacy from RunData)" }
 
   82   virtual void beginRun(art::Run 
const& run) 
override;
 
   84   virtual void analyze(art::Event 
const&)
 override {}
 
  115     (fhicl::OptionalTable<GeometryInfoConfig> 
const& config);
 
  126   bool case_insensitive_equal(std::string 
const& 
a, std::string 
const& b) {
 
  128     return std::equal(a.begin(), a.end(), b.begin(), b.end(),
 
  131           return ::tolower(static_cast<unsigned char>(a))
 
  132             == ::tolower(static_cast<unsigned char>(b));
 
  142   { 
"GeometryConfigurationWriter" };
 
  147   : art::EDAnalyzer(config)
 
  148   , fCheckInfo(makeGeometryInfoCheckInfo(config().GeometryInfo))
 
  149   , fLegacyCheckInfo(makeGeometryInfoCheckInfo(config().GeometryLegacyInfo))
 
  159     mf::LogDebug log { 
"GeometryInfoCheck" };
 
  160     log << 
"Configuration:" 
  161       << 
"\n - geometry configuration check:";
 
  163       if (
fCheckInfo->detectorName.empty()) log << 
" (any name)";
 
  164       else log << 
" must match '" << 
fCheckInfo->detectorName << 
"'";
 
  165       log << 
" [" << (
fCheckInfo->required? 
"mandatory": 
"optional") << 
"]";
 
  167     else log << 
"not requested";
 
  169     log << 
"\n - legacy geometry configuration information check:";
 
  173       log << 
" [" << (
fLegacyCheckInfo->required? 
"mandatory": 
"optional") << 
"]";
 
  175     else log << 
"not requested";
 
  186   if (fCheckInfo) CheckGeometryInfo(run, fCheckInfo.value());
 
  187   if (fLegacyCheckInfo) CheckLegacyGeometryInfo(run, fLegacyCheckInfo.value());
 
  197   mf::LogDebug log { 
"GeometryInfoCheck" };
 
  198   log << 
"Check on geometry information.";
 
  203   art::Handle<sumdata::GeometryConfigurationInfo> hInfo;
 
  204   if (!run.getByLabel(GeometryConfigurationWriterTag, hInfo)) {
 
  205     log << 
"\nNo information found.";
 
  208     log << 
"\nUnfortunately, that was required...";
 
  209     throw cet::exception(
"GeometryInfoCheck")
 
  210       << 
"Required geometry information not found as '" 
  211       << GeometryConfigurationWriterTag.encode() << 
"'\n";
 
  216     << 
"\nFound geometry information (version " << 
info.dataVersion << 
")" 
  217       << 
" from '" << hInfo.provenance()->inputTag().encode() << 
"'" 
  218     << 
"\nGeometry name is '" << 
info.detectorName << 
"'." 
  227     throw cet::exception(
"GeometryInfoCheck")
 
  228       << 
"Geometry information reports an unexpected name '" 
  245   mf::LogDebug log { 
"GeometryInfoCheck" };
 
  246   log << 
"Check on legacy geometry information.";
 
  254   if (hInfoList.empty()) {
 
  255     log << 
"\nNo information found.";
 
  258     log << 
"\nUnfortunately, that was required...";
 
  259     throw cet::exception(
"GeometryInfoCheck")
 
  260       << 
"No legacy geometry information found!\n";
 
  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)";
 
  270       log << 
" (this will be used for the check)";
 
  276     << 
"\nFound legacy geometry information " 
  277     << 
"\nGeometry name is '" << 
info.DetName() << 
"'." 
  286     throw cet::exception(
"GeometryInfoCheck")
 
  287       << 
"Geometry legacy information reports an unexpected name '" 
  301   (fhicl::OptionalTable<GeometryInfoConfig> 
const& config)
 
  302   -> std::optional<GeometryInfoCheckInfo>
 
  305   if (!config(infoConfig)) 
return {};
 
  311   return { std::move(info) };
 
GeometryInfoCheck(Parameters const &config)
 
void CheckLegacyGeometryInfo(art::Run const &run, GeometryInfoCheckInfo const &config) const 
 
static std::optional< GeometryInfoCheckInfo > makeGeometryInfoCheckInfo(fhicl::OptionalTable< GeometryInfoConfig > const &config)
Fills a GeometryInfoCheckInfo out of the specified configuration. 
 
fhicl::OptionalTable< GeometryInfoConfig > GeometryLegacyInfo
 
virtual void beginRun(art::Run const &run) override
 
fhicl::Atom< bool > Required
 
BEGIN_PROLOG vertical distance to the surface Name
 
bool equal(double a, double b)
Comparison tolerance, in centimeters. 
 
Description of the current configuration of detector geometry. 
 
art::EDAnalyzer::Table< Config > Parameters
 
std::string detectorName
Name of the detector; empty: don't check. 
 
bool required
Whether the information must be present. 
 
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. 
 
void CheckGeometryInfo(art::Run const &run, GeometryInfoCheckInfo const &config) const 
 
virtual void analyze(art::Event const &) override
 
art framework interface to geometry description 
 
Description of the current configuration of detector geometry. 
 
fhicl::OptionalAtom< std::string > Name
 
fhicl::OptionalTable< GeometryInfoConfig > GeometryInfo
 
std::optional< GeometryInfoCheckInfo > fCheckInfo
Information on the check on the regular geometry information.