LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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/Name.h"
14 #include "fhiclcpp/types/Comment.h"
15 
16 // art libraries
22 
23 // ... plus see below ...
24 
25 namespace hit {
26 
46  class DumpHits: public art::EDAnalyzer {
47  public:
48 
49  struct Config {
50  using Name = fhicl::Name;
52 
54  Name("HitModuleLabel"),
55  Comment("tag of the producer used to create the recob::Hit collection")
56  };
57 
59  Name("OutputCategory"),
60  Comment("the messagefacility category used for the output"),
61  "DumpHits"
62  };
63 
65  Name("CheckRawDigitAssociation"),
66  Comment("verify the associated raw digits are on the same channel as the hit"),
67  false
68  }; // CheckRawDigitAssociation
69 
71  Name("CheckWireAssociation"),
72  Comment("verify the associated wire is on the same channel as the hit"),
73  false
74  }; // CheckWireAssociation
75 
76  }; // Config
77 
79 
80 
82  explicit DumpHits(Parameters const& config);
83 
85  void analyze (const art::Event& evt);
86 
87  private:
88 
90  std::string fOutputCategory;
92  bool bCheckWires;
93 
94  }; // class DumpHits
95 
96 } // namespace hit
97 
98 
99 //------------------------------------------------------------------------------
100 //--- module implementation
101 //---
102 // C//C++ standard libraries
103 #include <vector>
104 #include <memory> // std::unique_ptr<>
105 
106 // support libraries
108 
109 // art libraries
111 
112 // LArSoft includes
113 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
114 #include "lardataobj/RecoBase/Hit.h"
117 
118 
119 namespace hit {
120 
121  //-------------------------------------------------
123  : EDAnalyzer (config)
124  , fHitsModuleLabel (config().HitModuleLabel())
125  , fOutputCategory (config().OutputCategory())
127  , bCheckWires (config().CheckWireAssociation())
128  {}
129 
130 
131  //-------------------------------------------------
132  void DumpHits::analyze(const art::Event& evt) {
133 
134  // fetch the data to be dumped on screen
135  auto Hits = evt.getValidHandle<std::vector<recob::Hit>>(fHitsModuleLabel);
136 
138  << "The event contains " << Hits->size() << " '"
139  << fHitsModuleLabel.encode() << "' hits";
140 
141  std::unique_ptr<art::FindOne<raw::RawDigit>> HitToRawDigit;
142  if (bCheckRawDigits) {
143  HitToRawDigit.reset
145  if (!HitToRawDigit->isValid()) {
147  << "DumpHits: can't find associations between raw digits and hits from '"
148  << fHitsModuleLabel << "'";
149  }
150  } // if check raw digits
151 
152  std::unique_ptr<art::FindOne<recob::Wire>> HitToWire;
153  if (bCheckWires) {
154  HitToWire.reset(new art::FindOne<recob::Wire>(Hits, evt, fHitsModuleLabel));
155  if (!HitToWire->isValid()) {
157  << "DumpHits: can't find associations between wires and hits from '"
158  << fHitsModuleLabel << "'";
159  }
160  } // if check wires
161 
162  unsigned int iHit = 0;
163  for (const recob::Hit& hit: *Hits) {
164 
165  // print a header for the cluster
167  << "Hit #" << iHit << ": " << hit;
168 
169  if (HitToRawDigit) {
170  raw::ChannelID_t assChannelID = HitToRawDigit->at(iHit).ref().Channel();
171  if (assChannelID != hit.Channel()) {
173  << "Hit #" << iHit << " on channel " << hit.Channel()
174  << " is associated with raw digit on channel " << assChannelID
175  << "!!";
176  } // mismatch
177  } // raw digit check
178 
179  if (HitToWire) {
180  raw::ChannelID_t assChannelID = HitToWire->at(iHit).ref().Channel();
181  if (assChannelID != hit.Channel()) {
183  << "Hit #" << iHit << " on channel " << hit.Channel()
184  << " is associated with wire on channel " << assChannelID
185  << "!!";
186  } // mismatch
187  } // wire check
188 
189  ++iHit;
190  } // for hits
191 
192  } // DumpHits::analyze()
193 
195 
196 } // 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.
fhicl::Atom< std::string > OutputCategory
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
std::string encode() const
Definition: InputTag.cc:36
details::FindAllP< recob::Hit, recob::Wire > HitToWire
Query object connecting a hit to a wire.
Definition: HitUtils.h:56
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
size_type size() const
Definition: PtrVector.h:308
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
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:49
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
ValidHandle< PROD > getValidHandle(InputTag const &tag) const