LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DumpHits_module.cc
Go to the documentation of this file.
1 
8 // C//C++ standard libraries
9 #include <string>
10 
11 // support libraries
12 #include "fhiclcpp/types/Atom.h"
13 #include "fhiclcpp/types/Comment.h"
14 #include "fhiclcpp/types/Name.h"
15 
16 // art libraries
22 
23 // ... plus see below ...
24 
25 namespace hit {
26 
46  class DumpHits : public art::EDAnalyzer {
47  public:
48  struct Config {
49  using Name = fhicl::Name;
51 
53  Name("HitModuleLabel"),
54  Comment("tag of the producer used to create the recob::Hit collection")};
55 
57  Name("OutputCategory"),
58  Comment("the messagefacility category used for the output"),
59  "DumpHits"};
60 
62  Name("CheckRawDigitAssociation"),
63  Comment("verify the associated raw digits are on the same channel as the hit"),
64  false}; // CheckRawDigitAssociation
65 
67  Name("CheckWireAssociation"),
68  Comment("verify the associated wire is on the same channel as the hit"),
69  false}; // CheckWireAssociation
70 
71  }; // Config
72 
74 
76  explicit DumpHits(Parameters const& config);
77 
79  void analyze(const art::Event& evt);
80 
81  private:
83  std::string fOutputCategory;
85  bool bCheckWires;
86 
87  }; // class DumpHits
88 
89 } // namespace hit
90 
91 //------------------------------------------------------------------------------
92 //--- module implementation
93 //---
94 // C//C++ standard libraries
95 #include <memory> // std::unique_ptr<>
96 
97 // support libraries
99 
100 // art libraries
102 
103 // LArSoft includes
104 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
106 #include "lardataobj/RecoBase/Hit.h"
108 
109 namespace hit {
110 
111  //-------------------------------------------------
113  : EDAnalyzer(config)
114  , fHitsModuleLabel(config().HitModuleLabel())
115  , fOutputCategory(config().OutputCategory())
117  , bCheckWires(config().CheckWireAssociation())
118  {}
119 
120  //-------------------------------------------------
122  {
123 
124  // fetch the data to be dumped on screen
125  auto Hits = evt.getValidHandle<std::vector<recob::Hit>>(fHitsModuleLabel);
126 
127  mf::LogInfo(fOutputCategory) << "The event contains " << Hits->size() << " '"
128  << fHitsModuleLabel.encode() << "' hits";
129 
130  std::unique_ptr<art::FindOne<raw::RawDigit>> HitToRawDigit;
131  if (bCheckRawDigits) {
132  HitToRawDigit.reset(new art::FindOne<raw::RawDigit>(Hits, evt, fHitsModuleLabel));
133  if (!HitToRawDigit->isValid()) {
135  << "DumpHits: can't find associations between raw digits and hits from '"
136  << fHitsModuleLabel << "'";
137  }
138  } // if check raw digits
139 
140  std::unique_ptr<art::FindOne<recob::Wire>> HitToWire;
141  if (bCheckWires) {
142  HitToWire.reset(new art::FindOne<recob::Wire>(Hits, evt, fHitsModuleLabel));
143  if (!HitToWire->isValid()) {
145  << "DumpHits: can't find associations between wires and hits from '" << fHitsModuleLabel
146  << "'";
147  }
148  } // if check wires
149 
150  unsigned int iHit = 0;
151  for (const recob::Hit& hit : *Hits) {
152 
153  // print a header for the cluster
154  mf::LogVerbatim(fOutputCategory) << "Hit #" << iHit << ": " << hit;
155 
156  if (HitToRawDigit) {
157  raw::ChannelID_t assChannelID = HitToRawDigit->at(iHit).ref().Channel();
158  if (assChannelID != hit.Channel()) {
160  << "Hit #" << iHit << " on channel " << hit.Channel()
161  << " is associated with raw digit on channel " << assChannelID << "!!";
162  } // mismatch
163  } // raw digit check
164 
165  if (HitToWire) {
166  raw::ChannelID_t assChannelID = HitToWire->at(iHit).ref().Channel();
167  if (assChannelID != hit.Channel()) {
169  << "Hit #" << iHit << " on channel " << hit.Channel()
170  << " is associated with wire on channel " << assChannelID << "!!";
171  } // mismatch
172  } // wire check
173 
174  ++iHit;
175  } // for hits
176 
177  } // DumpHits::analyze()
178 
180 
181 } // namespace hit
fhicl::Atom< bool > CheckWireAssociation
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
art::InputTag fHitsModuleLabel
name of module that produced the hits
fhicl::Atom< bool > CheckRawDigitAssociation
Prints the content of all the hits on screen.
fhicl::Atom< art::InputTag > HitModuleLabel
fhicl::Comment Comment
void analyze(const art::Event &evt)
Does the printing.
std::string fOutputCategory
category for LogInfo output
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
Definition of basic raw digits.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
fhicl::Atom< std::string > OutputCategory
std::string encode() const
Definition: InputTag.cc:97
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
details::FindAllP< recob::Hit, recob::Wire > HitToWire
Query object connecting a hit to a wire.
Definition: HitUtils.h:54
size_type size() const
Definition: PtrVector.h:302
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::PtrVector< recob::Hit > Hits
bool bCheckWires
check associations with wires
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool bCheckRawDigits
check associations with raw digits
DumpHits(Parameters const &config)
Default constructor.
Declaration of basic channel signal object.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
TCEvent evt
Definition: DataStructs.cxx:8
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28