LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
DumpGeometry_module.cc
Go to the documentation of this file.
1 
9 // LArSoft libraries
18 
19 // framework libraries
25 #include "fhiclcpp/types/Atom.h"
26 #include "fhiclcpp/types/Comment.h"
27 #include "fhiclcpp/types/Name.h"
29 
30 // C/C++ standard libraries
31 #include <string>
32 
33 namespace geo {
34  class DumpGeometry;
35 }
36 
51 
52 public:
53  struct Config {
54  using Name = fhicl::Name;
56 
58  Name("outputCategory"),
59  Comment(
60  "name of message facility output category to stream the information into (INFO level)"),
61  "DumpGeometry"};
62 
63  }; // struct Config
64 
66 
67  explicit DumpGeometry(Parameters const& config);
68 
69  // Plugins should not be copied or assigned.
70  DumpGeometry(DumpGeometry const&) = delete;
71  DumpGeometry(DumpGeometry&&) = delete;
72  DumpGeometry& operator=(DumpGeometry const&) = delete;
73  DumpGeometry& operator=(DumpGeometry&&) = delete;
74 
75  // Required functions
76  virtual void analyze(art::Event const&) override {}
77 
79  virtual void beginJob() override;
80 
82  virtual void beginRun(art::Run const& run) override;
83 
84 private:
85  std::string fOutputCategory;
86  std::string fLastDetectorName;
87 
89  template <typename Stream>
90  void dumpGeometry(Stream&& out,
91  geo::GeometryCore const* geom,
92  geo::WireReadoutGeom const* wireGeom,
93  geo::AuxDetGeometryCore const* auxGeom) const;
94 
96  template <typename Stream>
97  void dump(Stream&& out, geo::GeometryCore const& geom);
98 
100  bool shouldDumpGeometry(geo::GeometryCore const& geom) const;
101 
102 }; // class geo::DumpGeometry
103 
104 //==============================================================================
105 //=== Module implementation
106 //===
107 
108 //------------------------------------------------------------------------------
110  : EDAnalyzer(config), fOutputCategory(config().outputCategory())
111 {}
112 
113 //------------------------------------------------------------------------------
115 {
116 
117  auto const& geom = *(lar::providerFrom<geo::Geometry>());
119 
120 } // geo::DumpGeometry::beginJob()
121 
122 //------------------------------------------------------------------------------
124 {
125 
126  auto const& geom = *(lar::providerFrom<geo::Geometry>());
127  if (shouldDumpGeometry(geom)) {
129  log << "\nGeometry used in " << run.id() << ":\n";
130  dump(log, geom);
131  }
132 
133 } // geo::DumpGeometry::beginRun()
134 
135 //------------------------------------------------------------------------------
136 template <typename Stream>
138  geo::GeometryCore const* geom,
139  geo::WireReadoutGeom const* wireGeom,
140  geo::AuxDetGeometryCore const* auxDetGeom) const
141 {
142 
143  out << "Detector description: '" << (geom ? geom->GDMLFile() : "unknown") << "'\n";
144 
145  geo::WireReadoutDumper const dumper{geom, wireGeom, auxDetGeom};
146  out << dumper.toStream();
147 
148 } // geo::DumpGeometry::dumpGeometryCore()
149 
150 //------------------------------------------------------------------------------
151 template <typename Stream>
152 void geo::DumpGeometry::dump(Stream&& out, geo::GeometryCore const& geom)
153 {
154 
156  auto const& wireGeom = art::ServiceHandle<geo::WireReadout>()->Get();
157  auto const& auxDetGeom = art::ServiceHandle<geo::AuxDetGeometry>()->GetProvider();
158  dumpGeometry(out, &geom, &wireGeom, &auxDetGeom);
159 
160 } // geo::DumpGeometry::dump()
161 
162 //------------------------------------------------------------------------------
164 {
165 
166  // only dump if not already dumped
167  return geom.DetectorName() != fLastDetectorName;
168 
169 } // geo::DumpGeometry::shouldDumpGeometry()
170 
171 //------------------------------------------------------------------------------
173 
174 //==============================================================================
Utilities related to art service access.
RunID id() const
Definition: Run.cc:21
DumpGeometry(Parameters const &config)
std::string fLastDetectorName
Name of the last geometry dumped.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
Describes on screen the current geometry.
Description of physical geometry of one set of auxiliary detectors.
Definition: Run.h:37
void dump(Stream &&out, geo::GeometryCore const &geom)
Dumps the geometry and records it.
Access the description of auxiliary detector geometry.
Access the description of the physical detector geometry.
virtual void beginRun(art::Run const &run) override
Dumps the geometry if changed from the previous run.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
Interface for a class providing readout channel mapping to geometry.
DumpGeometry & operator=(DumpGeometry const &)=delete
art framework interface to geometry description for auxiliary detectors
Description of the physical geometry of one entire detector.
Definition: GeometryCore.h:91
fhicl::Atom< std::string > outputCategory
Algorithm dumping the full detector geometry down to wires.
std::string fOutputCategory
Name of the category for output.
virtual void beginJob() override
Dumps the geometry at once.
virtual void analyze(art::Event const &) override
std::string const & GDMLFile() const
Returns the full directory path to the GDML file source.
Definition: GeometryCore.h:130
bool shouldDumpGeometry(geo::GeometryCore const &geom) const
Returns whether the specified geometry should be dumped.
void dumpGeometry(Stream &&out, geo::GeometryCore const *geom, geo::WireReadoutGeom const *wireGeom, geo::AuxDetGeometryCore const *auxGeom) const
Dumps the specified geometry into the specified output stream.
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Definition: GeometryCore.h:140
ROOT libraries.
Algorithm dumping the full detector geometry down to wires.
Interface to geometry for wire readouts .
art framework interface to geometry description