17 #include "art/Framework/Services/Registry/ServiceHandle.h"
18 #include "art/Framework/Core/EDAnalyzer.h"
19 #include "art/Framework/Core/ModuleMacros.h"
20 #include "canvas/Utilities/Exception.h"
21 #include "messagefacility/MessageLogger/MessageLogger.h"
22 #include "fhiclcpp/types/Atom.h"
23 #include "fhiclcpp/types/Comment.h"
24 #include "fhiclcpp/types/Name.h"
67 Name(
"OutputCategory"),
69 "output category used by the message facility to output information (INFO level)"
75 Name(
"ChannelToWires"),
76 Comment(
"print all the wires corresponding to each channel"),
81 Name(
"WireToChannel"),
82 Comment(
"print which channel covers each wire"),
87 Name(
"OpDetChannels"),
89 "print for each optical detector channel ID the optical detector ID and its center"
96 Comment(
"ID of the lowest channel to be printed (default: no limit)"),
102 Comment(
"ID of the highest channel to be printed (default: no limit)"),
123 void beginRun(art::Run
const&)
override;
145 class DumpChannelToWires {
161 { FirstChannel = first_channel; LastChannel = last_channel; }
164 void Dump(std::string OutputCategory)
const;
174 void CheckConfig()
const;
180 class DumpWireToChannel {
184 DumpWireToChannel() {}
191 void Dump(std::string OutputCategory)
const;
198 void CheckConfig()
const;
204 class DumpOpticalDetectorChannels {
208 DumpOpticalDetectorChannels() {}
215 void Dump(std::string OutputCategory)
const;
222 void CheckConfig()
const;
226 geo::OpDetGeo const* getOpticalDetector(
unsigned int channelID)
const;
240 : art::EDAnalyzer(config)
241 , OutputCategory (config().OutputCategory())
242 , DoChannelToWires(config().ChannelToWires())
243 , DoWireToChannel (config().WireToChannel())
244 , DoOpDetChannels (config().OpDetChannels())
245 , FirstChannel (config().FirstChannel())
246 , LastChannel (config().LastChannel())
256 if (DoChannelToWires) {
257 DumpChannelToWires dumper;
259 dumper.SetLimits(FirstChannel, LastChannel);
260 dumper.Dump(OutputCategory);
263 if (DoWireToChannel) {
264 DumpWireToChannel dumper;
267 dumper.Dump(OutputCategory);
270 if (DoOpDetChannels) {
271 DumpOpticalDetectorChannels dumper;
273 dumper.Dump(OutputCategory);
286 void DumpChannelToWires::CheckConfig()
const {
290 throw art::Exception(art::errors::LogicError)
291 <<
"DumpChannelToWires: no valid geometry available!";
296 void DumpChannelToWires::Dump(std::string OutputCategory)
const {
302 unsigned int const NChannels = pGeom->Nchannels();
304 if (NChannels == 0) {
305 mf::LogError(OutputCategory)
306 <<
"Nice detector we have here, with no channels.";
316 unsigned int const NPrintedChannels = (PrintLast - PrintFirst) + 1;
317 if (NPrintedChannels == NChannels) {
318 mf::LogInfo(OutputCategory) <<
"Printing all " << NChannels <<
" channels";
321 mf::LogInfo(OutputCategory) <<
"Printing channels from " << PrintFirst
322 <<
" to " << LastChannel <<
" (" << NPrintedChannels
323 <<
" channels out of " << NChannels <<
")";
327 mf::LogVerbatim log(OutputCategory);
328 for (
raw::ChannelID_t channel = PrintFirst; channel <= PrintLast; ++channel) {
329 std::vector<geo::WireID>
const Wires = pGeom->ChannelToWire(channel);
331 log <<
"\n " << ((int) channel) <<
" ->";
332 switch (Wires.size()) {
333 case 0: log <<
" no wires";
break;
335 default: log <<
" [" << Wires.size() <<
" wires]";
break;
339 log <<
" { " << std::string(wireID) <<
" };";
348 void DumpWireToChannel::CheckConfig()
const {
352 throw art::Exception(art::errors::LogicError)
353 <<
"DumpWireToChannel: no valid geometry available!";
358 void DumpWireToChannel::Dump(std::string OutputCategory)
const {
364 unsigned int const NChannels = pGeom->Nchannels();
366 if (NChannels == 0) {
367 mf::LogError(OutputCategory)
368 <<
"Nice detector we have here, with no channels.";
373 mf::LogInfo(OutputCategory)
374 <<
"Printing wire channels for up to " << NChannels <<
" channels";
377 mf::LogVerbatim log(OutputCategory);
378 for (
geo::WireID const& wireID: pGeom->IterateWireIDs()) {
380 log <<
"\n { " << std::string(wireID) <<
" } => ";
382 else log <<
"invalid!";
391 void DumpOpticalDetectorChannels::CheckConfig()
const {
395 throw art::Exception(art::errors::LogicError)
396 <<
"DumpOpticalDetectorChannels: no valid geometry available!";
402 geo::OpDetGeo const* DumpOpticalDetectorChannels::getOpticalDetector
403 (
unsigned int channelID)
const
406 return &(pGeom->OpDetGeoFromOpChannel(channelID));
408 catch (cet::exception
const&) {
415 void DumpOpticalDetectorChannels::Dump(std::string OutputCategory)
const {
422 unsigned int const NChannels = pGeom->NOpChannels();
424 if (NChannels == 0) {
425 mf::LogError(OutputCategory)
426 <<
"Nice detector we have here, with no optical channels.";
431 mf::LogInfo(OutputCategory)
432 <<
"Printing optical detectors for up to " << NChannels <<
" channels";
435 mf::LogVerbatim log(OutputCategory);
436 for (
unsigned int channelID = 0; channelID <
NChannels; ++channelID) {
437 log <<
"\nChannel " << channelID <<
" => ";
443 log << opDet->
ID() <<
" at " << opDet->
GetCenter() <<
" cm";
bool DoOpDetChannels
Dump optical detector channel -> optical detector.
const geo::GeometryCore * geometry
std::string OutputCategory
Name of the category for output.
fhicl::Atom< std::string > OutputCategory
void GetCenter(double *xyz, double localz=0.0) const
fhicl::Atom< bool > OpDetChannels
DumpChannelMap & operator=(DumpChannelMap const &)=delete
Access the description of detector geometry.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
void beginRun(art::Run const &) override
Drives the dumping.
constexpr bool isValidChannelID(raw::ChannelID_t channel)
BEGIN_PROLOG vertical distance to the surface Name
bool DoWireToChannel
Dump wire -> channel mapping.
Description of geometry of one entire detector.
Definition of data types for geometry description.
art::EDAnalyzer::Table< Config > Parameters
bool DoChannelToWires
Dump channel -> wires mapping.
raw::ChannelID_t LastChannel
Last channel to be printed.
Encapsulate the geometry of an optical detector.
fhicl::Atom< raw::ChannelID_t > FirstChannel
fhicl::Atom< raw::ChannelID_t > LastChannel
fhicl::Atom< bool > ChannelToWires
Prints on screen the current channel-wire and optical detector maps.
geo::OpDetID const & ID() const
Returns the geometry ID of this optical detector.
fhicl::Atom< bool > WireToChannel
raw::ChannelID_t FirstChannel
First channel to be printed.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
DumpChannelMap(Parameters const &config)
void analyze(art::Event const &) override
art framework interface to geometry description