LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
cluster::ClusterTrackAna Class Reference
Inheritance diagram for cluster::ClusterTrackAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Types

using ModuleType = EDAnalyzer
 

Public Member Functions

 ClusterTrackAna (fhicl::ParameterSet const &p)
 
 ClusterTrackAna (ClusterTrackAna const &)=delete
 
 ClusterTrackAna (ClusterTrackAna &&)=delete
 
ClusterTrackAnaoperator= (ClusterTrackAna const &)=delete
 
ClusterTrackAnaoperator= (ClusterTrackAna &&)=delete
 
void analyze (art::Event const &e) override
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResults > getTriggerResults (Event const &e) const
 
ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void endJob () override
 
void FirstLastHitInPlane (unsigned int tpc, unsigned int plane, unsigned int mcpi, unsigned int &firstHitIndex, unsigned int &lastHitIndex)
 
std::string HitLocation (unsigned int iht)
 packs hit WireID and PeakTime into a compact format More...
 

Private Attributes

art::InputTag fHitModuleLabel
 
art::InputTag fClusterModuleLabel
 
art::InputTag fTrackModuleLabel
 
simb::Origin_t fTruthOrigin
 
std::vector< int > fSkipPDGCodes
 
short fPrintLevel
 
unsigned int fInTPC
 
float fBadEP
 
unsigned int fEventCnt {0}
 
unsigned int fNBadEP {0}
 
std::array< float, 5 > Cnts {{0}}
 
std::array< float, 5 > EPSums {{0}}
 
std::array< float, 5 > ESums {{0}}
 
std::array< float, 5 > PSums {{0}}
 
art::Handle< std::vector< recob::Hit > > fHitHandle
 
std::vector< unsigned int > fHitMCPIndex
 
bool fCompareProductIDs
 compare Hit and Cluster-> Hit art product IDs on the first event More...
 
bool fFirstPrint {true}
 
unsigned int fCurrentRun {0}
 

Detailed Description

Definition at line 46 of file ClusterTrackAna_module.cc.

Member Typedef Documentation

Definition at line 22 of file EDAnalyzer.h.

Constructor & Destructor Documentation

cluster::ClusterTrackAna::ClusterTrackAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 99 of file ClusterTrackAna_module.cc.

References Cnts, EPSums, ESums, fBadEP, fClusterModuleLabel, fHitModuleLabel, fInTPC, fPrintLevel, fSkipPDGCodes, fTrackModuleLabel, fTruthOrigin, PSums, and tmp.

99  : EDAnalyzer{pset}
100 {
101  fHitModuleLabel = pset.get<art::InputTag>("HitModuleLabel");
102  bool validModuleLabel = false;
103  fClusterModuleLabel = "NA";
104  fTrackModuleLabel = "NA";
105  fClusterModuleLabel = pset.get<art::InputTag>("ClusterModuleLabel", "NA");
106  if (fClusterModuleLabel != "NA") validModuleLabel = true;
107  fTrackModuleLabel = pset.get<art::InputTag>("TrackModuleLabel", "NA");
108  if (validModuleLabel && fTrackModuleLabel != "NA")
109  throw cet::exception("ClusterTrackAna")
110  << "You must specify either a ClusterModuleLabel OR a TrackModuleLabel\n";
111  if (!validModuleLabel && fTrackModuleLabel != "NA") validModuleLabel = true;
112  // origin = 0 (anything), 1(nu), 2(cosmics), 3(SN nu), 4(SingleParticle)
113  int tmp = pset.get<int>("TruthOrigin", 0);
115  fPrintLevel = pset.get<short>("PrintLevel", 0);
116  if (pset.has_key("SkipPDGCodes")) fSkipPDGCodes = pset.get<std::vector<int>>("SkipPDGCodes");
117  fBadEP = pset.get<float>("BadEP", 0.);
118  fInTPC = UINT_MAX;
119  int intpc = pset.get<int>("InTPC", -1);
120  if (intpc >= 0) fInTPC = intpc;
121  // do some initialization
122  Cnts.fill(0.);
123  EPSums.fill(0.);
124  ESums.fill(0.);
125  PSums.fill(0.);
126 } // ClusterTrackAna constructor
std::array< float, 5 > PSums
enum simb::_ev_origin Origin_t
event origin types
Float_t tmp
Definition: plot.C:35
std::array< float, 5 > Cnts
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
std::array< float, 5 > EPSums
std::array< float, 5 > ESums
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
cluster::ClusterTrackAna::ClusterTrackAna ( ClusterTrackAna const &  )
delete
cluster::ClusterTrackAna::ClusterTrackAna ( ClusterTrackAna &&  )
delete

Member Function Documentation

void cluster::ClusterTrackAna::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 129 of file ClusterTrackAna_module.cc.

References util::abs(), sim::ParticleList::begin(), Cnts, simb::MCParticle::E(), util::empty(), sim::ParticleList::end(), EPSums, ESums, art::Event::event(), fBadEP, fClusterModuleLabel, fCompareProductIDs, fCurrentRun, fEventCnt, fFirstPrint, fHitHandle, fHitMCPIndex, fHitModuleLabel, fInTPC, FirstLastHitInPlane(), fNBadEP, fPrintLevel, fSkipPDGCodes, fTrackModuleLabel, fTruthOrigin, Get, art::ProductRetriever::getByLabel(), HitLocation(), cheat::BackTrackerService::HitToTrackIDEs(), art::Handle< T >::id(), ipart, art::Handle< T >::isValid(), simb::kUnknown, art::InputTag::label(), simb::MCParticle::Mass(), simb::MCTruth::Origin(), part, cheat::ParticleInventoryService::ParticleList(), simb::MCParticle::PdgCode(), PSums, art::Event::run(), util::size(), util::to_string(), simb::MCParticle::TrackId(), and cheat::ParticleInventoryService::TrackIdToMCTruth_P().

130 {
131  // Match hits to MCParticles, then consider reconstructed hits in each TPC and plane
132  // to calculate Efficiency, Purity and Efficiency * Purity (aka EP).
133 
134  ++fEventCnt;
135  auto const* geom = lar::providerFrom<geo::Geometry>();
136  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
137  // auto hitsHandle = art::Handle<std::vector<recob::Hit>>();
138  if (!evt.getByLabel(fHitModuleLabel, fHitHandle))
139  throw cet::exception("ClusterTrackAna")
140  << "Failed to get a handle to hit collection '" << fHitModuleLabel.label() << "'\n";
141  // get a reference to the MCParticles
142  auto mcpHandle = art::Handle<std::vector<simb::MCParticle>>();
143  if (!evt.getByLabel("largeant", mcpHandle))
144  throw cet::exception("ClusterTrackAna")
145  << "Failed to get a handle to MCParticles using largeant\n";
146 
147  // decide whether to consider cluster -> hit -> MCParticle for any MCParticle origin or for
148  // a specific user-specified origin
149  bool anySource = (fTruthOrigin == simb::kUnknown);
150 
151  if (fPrintLevel > 0 && evt.run() != fCurrentRun) {
152  mf::LogVerbatim("ClusterTrackAna") << "Run: " << evt.run();
153  fCurrentRun = evt.run();
154  }
155 
158  sim::ParticleList const& plist = pi_serv->ParticleList();
159  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
160 
161  // make a list of Hit -> MCParticle assns in all TPCs. The first step is
162  // to make a list of Geant TrackIDs whose origin was requested by the user.
163  std::vector<int> trkIDs;
164  // and a vector of MCParticle indices into the mcpHandle vector indexed by trkIDs
165  std::vector<unsigned int> MCPIs;
166  for (sim::ParticleList::const_iterator ipart = plist.begin(); ipart != plist.end(); ++ipart) {
167  const simb::MCParticle* part = (*ipart).second;
168  int trackID = part->TrackId();
169  art::Ptr<simb::MCTruth> theTruth = pi_serv->TrackIdToMCTruth_P(trackID);
170  if (!anySource && theTruth->Origin() != fTruthOrigin) continue;
171  int pdg = abs(part->PdgCode());
172  bool isCharged = (pdg == 11) || (pdg == 13) || (pdg == 211) || (pdg == 321) || (pdg == 2212);
173  if (!isCharged) continue;
174  if (std::find(fSkipPDGCodes.begin(), fSkipPDGCodes.end(), pdg) != fSkipPDGCodes.end()) continue;
175  float TMeV = 1000 * (part->E() - part->Mass());
176  // ignore low energy particles
177  if (TMeV < 1) continue;
178  // find the MCParticle index and stash it in trkMCP
179  unsigned int mcpi = UINT_MAX;
180  for (mcpi = 0; mcpi < (*mcpHandle).size(); ++mcpi)
181  if ((*mcpHandle)[mcpi].TrackId() == trackID) break;
182  if (mcpi == UINT_MAX) {
183  std::cout << "Failed to find a MCParticle from ParticleList\n";
184  return;
185  }
186  trkIDs.push_back(trackID);
187  MCPIs.push_back(mcpi);
188  } // ipart
189  if (trkIDs.empty()) return;
190 
191  // next construct a companion vector of MCParticle indices indexed to the full hit collection
192  fHitMCPIndex.resize((*fHitHandle).size(), UINT_MAX);
193  // Make a list of the <first, last> MC-matched hit in each TPC. This will be used
194  // to only iterate through the range of hits that are interesting
195  std::vector<std::pair<unsigned int, unsigned int>> hitRange(geom->NTPC() + 1);
196  size_t noMatch = 0;
197  size_t nMatch = 0;
198  size_t nInTPC = 0;
199  for (auto& hr : hitRange)
200  hr = std::make_pair(UINT_MAX, UINT_MAX);
201  for (size_t iht = 0; iht < (*fHitHandle).size(); ++iht) {
202  auto& hit = (*fHitHandle)[iht];
203  // only consider hits in a single TPC?
204  unsigned int tpc = hit.WireID().TPC;
205  if (fInTPC != UINT_MAX && tpc != fInTPC) continue;
206  ++nInTPC;
207  auto tides = bt_serv->HitToTrackIDEs(clockData, hit);
208  if (tides.empty()) {
209  ++noMatch;
210  continue;
211  }
212  for (auto& tide : tides) {
213  // declare a match to a MCParticle if > 50% of energy is from it
214  if (tide.energyFrac < 0.5) continue;
215  int trackID = tide.trackID;
216  // find the MCParticle index and define the Hit -> MCParticle assn
217  for (size_t indx = 0; indx < trkIDs.size(); ++indx) {
218  if (trkIDs[indx] == trackID) {
219  fHitMCPIndex[iht] = MCPIs[indx];
220  break;
221  }
222  } // indx
223  break;
224  } // tide
225  if (fHitMCPIndex[iht] == UINT_MAX) continue;
226  ++nMatch;
227  // populate hitRange
228  if (hitRange[tpc].first == UINT_MAX) hitRange[tpc].first = iht;
229  hitRange[tpc].second = iht;
230  } // iht
231 
232  if (nMatch == 0) {
233  fHitMCPIndex.resize(0);
234  return;
235  }
236 
237  if (fPrintLevel > 3) {
238  // Print the gory details
239  mf::LogVerbatim myprt("ClusterTrackAna");
240  myprt << "Checking " << trkIDs.size() << " selected MCParticles with the requested TruthOrigin";
241  if (fInTPC == UINT_MAX) { myprt << " in all TPCs\n"; }
242  else {
243  myprt << " in TPC " << fInTPC;
244  }
245  myprt << " in Run " << evt.run() << " Event " << evt.event();
246  myprt << "\n";
247  myprt << "Found " << nMatch << " MC-matched hits with the requested TruthOrigin";
248  myprt << " out of " << nInTPC << " total hits.\n";
249  myprt << "Found " << noMatch << " hits not matched to ANY MCParticle.\n";
250  // count the number of hits matched to each MCParticle in the list
251  // mcpi count
252  std::vector<std::pair<unsigned int, unsigned int>> mcpCnt;
253  for (auto mcpi : fHitMCPIndex) {
254  if (mcpi == UINT_MAX) continue;
255  unsigned short mIndx = 0;
256  for (mIndx = 0; mIndx < mcpCnt.size(); ++mIndx)
257  if (mcpCnt[mIndx].first == mcpi) break;
258  if (mIndx == mcpCnt.size()) mcpCnt.push_back(std::make_pair(mcpi, 0));
259  // increment the count of MC-matched hits
260  ++mcpCnt[mIndx].second;
261  } // mcpi
262  myprt << " MCPI TrackID PDGCode T(MeV) nHits Process";
263  for (auto mcpcnt : mcpCnt) {
264  myprt << "\n";
265  unsigned int mcpi = mcpcnt.first;
266  auto& mcp = (*mcpHandle)[mcpi];
267  myprt << std::setw(5) << mcpi;
268  myprt << std::setw(8) << mcp.TrackId();
269  myprt << std::setw(8) << abs(mcp.PdgCode());
270  int TMeV = 1000 * (mcp.E() - mcp.Mass());
271  myprt << std::setw(9) << TMeV;
272  myprt << std::setw(8) << mcpcnt.second;
273  myprt << " " << mcp.Process();
274  } // mcpcnt
275  } // fPrintLevel > 3
276 
277  // fill a vector of hits indices from all clusters or all tracks
278  std::vector<std::vector<unsigned int>> recoHits;
279  // and a companion vector of indices into the cluster or track collection
280  std::vector<unsigned int> recoIndex;
281  // handles to these collections to enable printing the cluster or track ID. The
282  // handle will be valid for either clusters or tracks
285  if (fClusterModuleLabel.label() != "NA") {
286  // get MC-matched hits from clusters
287  if (!evt.getByLabel(fClusterModuleLabel, inputClusters))
288  throw cet::exception("ClusterTrackAna")
289  << "Failed to get a handle to the cluster collection '" << fClusterModuleLabel.label()
290  << "'\n";
291  art::FindManyP<recob::Hit> hitsFromCls(inputClusters, evt, fClusterModuleLabel);
292  if (!hitsFromCls.isValid())
293  throw cet::exception("ClusterTrackAna") << "Failed to get a handle to Cluster -> Hit assns\n";
294  for (unsigned int icl = 0; icl < (*inputClusters).size(); ++icl) {
295  std::vector<art::Ptr<recob::Hit>> cluhits = hitsFromCls.at(icl);
296  if (cluhits.empty()) continue;
297  if (fCompareProductIDs) {
298  if (cluhits[0].id() != fHitHandle.id())
299  throw cet::exception("ClusterTrackAna")
300  << "Hits associated with ClusterModuleLabel are in a different collection than "
301  "HitModuleLabel.\n";
302  fCompareProductIDs = false;
303  } // fCompareProductIDs
304  // only load MC-matched hits. Hits that are not MC-matched were either matched to a
305  // MCParticle that was not selected or were mis-reconstructed by the hit finder. Neither
306  // of these conditions warrant penalizing the reconstruction module performance
307  std::vector<unsigned int> hitsIndex;
308  for (auto& cluhit : cluhits) {
309  if (fHitMCPIndex[cluhit.key()] != UINT_MAX) hitsIndex.push_back(cluhit.key());
310  }
311  if (hitsIndex.empty()) continue;
312  recoIndex.push_back(icl);
313  recoHits.push_back(hitsIndex);
314  } // icl
315  }
316  else {
317  // get MC-matched hits from tracks
318  if (!evt.getByLabel(fTrackModuleLabel, inputTracks))
319  throw cet::exception("ClusterTrackAna")
320  << "Failed to get a handle to the track collection '" << fTrackModuleLabel.label() << "'\n";
321  art::FindManyP<recob::Hit> hitsFromTrk(inputTracks, evt, fTrackModuleLabel);
322  if (!hitsFromTrk.isValid())
323  throw cet::exception("ClusterTrackAna") << "Failed to get a handle to Track -> Hit assns\n";
324  for (unsigned int itk = 0; itk < (*inputTracks).size(); ++itk) {
325  std::vector<art::Ptr<recob::Hit>> trkhits = hitsFromTrk.at(itk);
326  if (trkhits.empty()) continue;
327  if (fCompareProductIDs) {
328  if (trkhits[0].id() != fHitHandle.id())
329  throw cet::exception("ClusterTrackAna")
330  << "Hits associated with TrackModuleLabel are in a different collection than "
331  "HitModuleLabel.\n";
332  fCompareProductIDs = false;
333  } // fCompareProductIDs
334  std::vector<unsigned int> hitsIndex;
335  for (auto& trkhit : trkhits) {
336  if (fHitMCPIndex[trkhit.key()] != UINT_MAX) hitsIndex.push_back(trkhit.key());
337  }
338  if (hitsIndex.empty()) continue;
339  recoIndex.push_back(itk);
340  recoHits.push_back(hitsIndex);
341  } // itk
342  } // get hits from tracks
343 
344  for (const auto& tpcid : geom->Iterate<geo::TPCID>()) {
345  unsigned int tpc = tpcid.TPC;
346  if (hitRange[tpc].first == UINT_MAX) continue;
347  // iterate over planes
348  for (unsigned short plane = 0; plane < wireReadoutGeom.Nplanes(); ++plane) {
349  unsigned int tpcMatHitCnt = 0;
350  unsigned int tpcTotHitCnt = 0;
351  // create a list of (MCParticle index, matched hit count> pairs
352  // mcParticle plane
353  std::vector<std::pair<unsigned int, float>> mcpCnt;
354  // count MCParticle, Cluster/Track hit counts - size matched to mcpCnt
355  std::vector<std::vector<std::pair<unsigned int, float>>> mcpClsCnt;
356  for (unsigned int iht = hitRange[tpc].first; iht <= hitRange[tpc].second; ++iht) {
357  auto& hit = (*fHitHandle)[iht];
358  if (hit.WireID().TPC != tpc) continue;
359  if (hit.WireID().Plane != plane) continue;
360  ++tpcTotHitCnt;
361  // ignore hits that were either unmatched to the selected set of PDGCodes
362  // or have a not-requested origin
363  if (fHitMCPIndex[iht] == UINT_MAX) continue;
364  ++tpcMatHitCnt;
365  unsigned int mcpi = fHitMCPIndex[iht];
366  unsigned short mIndx = 0;
367  for (mIndx = 0; mIndx < mcpCnt.size(); ++mIndx)
368  if (mcpCnt[mIndx].first == mcpi) break;
369  if (mIndx == mcpCnt.size()) {
370  // found a MCParticle not in the list yet, so add it
371  mcpCnt.push_back(std::make_pair(mcpi, 0));
372  mcpClsCnt.resize(mcpCnt.size());
373  }
374  // increment the number of MC-matched hits
375  ++mcpCnt[mIndx].second;
376  } // iht
377  // ignore TPCs/planes with few MC-matched hits
378  if (fPrintLevel > 2) {
379  mf::LogVerbatim myprt("ClusterTrackAna");
380  myprt << "TPC:" << tpc << " Plane:" << plane << " has " << tpcMatHitCnt << "/"
381  << tpcTotHitCnt;
382  myprt << " (MC-matched hits) / (all hits)";
383  }
384  if (tpcMatHitCnt < 3) continue;
385  // next iterate over all clusters/tracks and count mc-matched hits that are in this TPC/plane
386  for (unsigned int ii = 0; ii < recoHits.size(); ++ii) {
387  float nRecoHitsInPlane = 0;
388  float nRecoMatHitsInPlane = 0;
389  for (auto iht : recoHits[ii]) {
390  auto& hit = (*fHitHandle)[iht];
391  if (hit.WireID().TPC != tpc) continue;
392  if (hit.WireID().Plane != plane) continue;
393  ++nRecoHitsInPlane;
394  if (fHitMCPIndex[iht] == UINT_MAX) continue;
395  ++nRecoMatHitsInPlane;
396  unsigned int mcpi = fHitMCPIndex[iht];
397  // find the MCParticle index in mcpCnt and use it to count the match entry
398  // in mcpClsCnt
399  unsigned short mIndx = 0;
400  for (mIndx = 0; mIndx < mcpCnt.size(); ++mIndx)
401  if (mcpCnt[mIndx].first == mcpi) break;
402  if (mIndx == mcpCnt.size()) {
403  std::cout << "Logic error: fHitMCPIndex = " << fHitMCPIndex[iht]
404  << " is valid but isn't in the list of MCParticles to use. Please send email "
405  "to baller@fnal.gov.\n";
406  continue;
407  }
408  unsigned short cIndx = 0;
409  for (cIndx = 0; cIndx < mcpClsCnt[mIndx].size(); ++cIndx)
410  if (mcpClsCnt[mIndx][cIndx].first == ii) break;
411  if (cIndx == mcpClsCnt[mIndx].size()) mcpClsCnt[mIndx].push_back(std::make_pair(ii, 0));
412  ++mcpClsCnt[mIndx][cIndx].second;
413  } // cluhit
414  if (nRecoMatHitsInPlane == 0) continue;
415  } // ii
416  // find the cluster that has the most hits matched to each MC Particle
417  for (unsigned short mIndx = 0; mIndx < mcpCnt.size(); ++mIndx) {
418  // require at least 3 MC-matched hits
419  if (mcpCnt[mIndx].second < 3) continue;
420  unsigned int mcpi = mcpCnt[mIndx].first;
421  auto& mcp = (*mcpHandle)[mcpi];
422  unsigned int pdgCode = abs(mcp.PdgCode());
423  unsigned short pIndx = USHRT_MAX;
424  if (pdgCode == 11) pIndx = 0;
425  if (pdgCode == 13) pIndx = 1;
426  if (pdgCode == 211) pIndx = 2;
427  if (pdgCode == 321) pIndx = 3;
428  if (pdgCode == 2212) pIndx = 4;
429  if (mcpClsCnt[mIndx].empty()) {
430  // Un-reconstructed MCParticle hits
431  ++Cnts[pIndx];
432  ++fNBadEP;
433  if (fPrintLevel > 0) {
434  mf::LogVerbatim myprt("ClusterTrackAna");
435  myprt << " MCPI " << mcpi;
436  int TMeV = 1000 * (mcp.E() - mcp.Mass());
437  myprt << " " << TMeV << " MeV";
438  std::string partName = std::to_string(pdgCode);
439  if (pdgCode == 11) partName = "El";
440  if (pdgCode == 13) partName = "Mu";
441  if (pdgCode == 211) partName = "Pi";
442  if (pdgCode == 311) partName = "Ka";
443  if (pdgCode == 2212) partName = "Pr";
444  myprt << std::setw(5) << partName;
445  // print out the range of truth-matched hits
446  unsigned int firstHitIndex = UINT_MAX;
447  unsigned int lastHitIndex = UINT_MAX;
448  FirstLastHitInPlane(tpc, plane, mcpi, firstHitIndex, lastHitIndex);
449  myprt << " Failed to reconstruct. Truth-matched hit range from ";
450  myprt << HitLocation(firstHitIndex);
451  myprt << " to ";
452  myprt << HitLocation(lastHitIndex);
453  myprt << " <- EP = 0!";
454  } // fPrintLevel > 0
455  continue;
456  } // (mcpClsCnt[mIndx].empty()
457  std::pair<unsigned int, float> big = std::make_pair(UINT_MAX, 0);
458  for (unsigned short cIndx = 0; cIndx < mcpClsCnt[mIndx].size(); ++cIndx) {
459  auto& mcc = mcpClsCnt[mIndx][cIndx];
460  if (mcc.second > big.second) big = mcc;
461  } // cIndx
462  if (big.first == UINT_MAX) {
463  if (fPrintLevel > 2) {
464  mf::LogVerbatim myprt("ClusterTrackAna");
465  unsigned int mcpi = mcpCnt[mIndx].first;
466  auto& mcp = (*mcpHandle)[mcpi];
467  myprt << "Match failed: mcpi " << mcpi << " pdg " << mcp.PdgCode();
468  }
469  std::cout << "match failed mIndx " << mIndx << "\n";
470  continue;
471  } // big.first == UINT_MAX
472  unsigned int ii = big.first;
473  float eff = big.second / mcpCnt[mIndx].second;
474  float nRecoHitsInPlane = 0;
475  // define some variables to print the range of the cluster/track
476  unsigned int firstRecoHitIndex = UINT_MAX;
477  unsigned int lastRecoHitIndex = UINT_MAX;
478  for (auto iht : recoHits[ii]) {
479  auto& hit = (*fHitHandle)[iht];
480  if (hit.WireID().TPC != tpc) continue;
481  if (hit.WireID().Plane != plane) continue;
482  ++nRecoHitsInPlane;
483  if (firstRecoHitIndex == UINT_MAX) {
484  firstRecoHitIndex = iht;
485  lastRecoHitIndex = iht;
486  }
487  unsigned int wire = (*fHitHandle)[iht].WireID().Wire;
488  if (wire < (*fHitHandle)[firstRecoHitIndex].WireID().Wire) firstRecoHitIndex = iht;
489  if (wire > (*fHitHandle)[lastRecoHitIndex].WireID().Wire) lastRecoHitIndex = iht;
490  } // iht
491  float pur = big.second / nRecoHitsInPlane;
492  ++Cnts[pIndx];
493  float ep = eff * pur;
494  EPSums[pIndx] += ep;
495  ESums[pIndx] += eff;
496  PSums[pIndx] += pur;
497  bool hasBadEP = (ep < fBadEP);
498  if (hasBadEP) ++fNBadEP;
499  bool prt = fPrintLevel > 1 || (fPrintLevel == 1 && hasBadEP);
500  if (prt) {
501  mf::LogVerbatim myprt("ClusterTrackAna");
502  if (fFirstPrint) {
503  myprt << "Hit location format is TPC:Plane:Wire:Tick\n";
504  myprt << " MCPI Ptcl T(MeV) nMCPHits ____From____ _____To_____";
505  if (inputClusters.isValid()) { myprt << " clsID"; }
506  else {
507  myprt << " trkID";
508  }
509  myprt
510  << " ____From____ _____To_____ nRecoHits nMCPRecoHits Eff Pur EP\n";
511  fFirstPrint = false;
512  } // fFirstPrint
513  myprt << std::setw(5) << mcpi;
514  // convert the PDG code into nicer format
515  std::string partName = std::to_string(pdgCode);
516  if (pdgCode == 11) partName = " Electron";
517  if (pdgCode == 13) partName = " Muon";
518  if (pdgCode == 211) partName = " Pion";
519  if (pdgCode == 311) partName = " Kaon";
520  if (pdgCode == 2212) partName = " Proton";
521  myprt << partName;
522  int TMeV = 1000 * (mcp.E() - mcp.Mass());
523  myprt << std::setw(7) << TMeV;
524  // nMCPHits
525  myprt << std::setw(10) << mcpCnt[mIndx].second;
526  unsigned int firstTruHitIndex = UINT_MAX;
527  unsigned int lastTruHitIndex = UINT_MAX;
528  FirstLastHitInPlane(tpc, plane, mcpi, firstTruHitIndex, lastTruHitIndex);
529  myprt << std::setw(14) << HitLocation(firstTruHitIndex);
530  myprt << std::setw(14) << HitLocation(lastTruHitIndex);
531  int id = -1;
532  if (inputClusters.isValid()) {
533  // print cluster info
534  auto& cls = (*inputClusters)[recoIndex[ii]];
535  id = cls.ID();
536  }
537  else if (inputTracks.isValid()) {
538  // print track info
539  auto& trk = (*inputTracks)[recoIndex[ii]];
540  id = trk.ID();
541  }
542  myprt << std::setw(6) << id;
543  myprt << std::setw(14) << HitLocation(firstRecoHitIndex);
544  myprt << std::setw(14) << HitLocation(lastRecoHitIndex);
545  myprt << std::setw(12) << (int)nRecoHitsInPlane;
546  myprt << std::setw(13) << (int)big.second;
547  myprt << std::fixed << std::setprecision(2);
548  myprt << std::setw(8) << eff;
549  myprt << std::setw(8) << pur;
550  myprt << std::setw(8) << ep;
551  if (hasBadEP) myprt << " <- BadEP";
552  myprt << " Evt: " << evt.event();
553  myprt << " Evt Cnt " << fEventCnt;
554  } // prt
555  } // mIndx
556  } // plane
557  } // tpcid
558 
559  fHitMCPIndex.resize(0);
560 
561 } // analyze
double E(const int i=0) const
Definition: MCParticle.h:234
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
int PdgCode() const
Definition: MCParticle.h:213
unsigned int event
Definition: DataStructs.h:626
Int_t ipart
Definition: Style.C:10
unsigned int run
Definition: DataStructs.h:627
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
std::array< float, 5 > PSums
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
simb::Origin_t Origin() const
Definition: MCTruth.h:74
double Mass() const
Definition: MCParticle.h:240
constexpr auto abs(T v)
Returns the absolute value of the argument.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
std::string HitLocation(unsigned int iht)
packs hit WireID and PeakTime into a compact format
std::array< float, 5 > Cnts
int TrackId() const
Definition: MCParticle.h:211
bool isValid() const noexcept
Definition: Handle.h:203
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
std::string const & label() const noexcept
Definition: InputTag.cc:79
TString part[npart]
Definition: Style.C:32
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
std::array< float, 5 > EPSums
iterator begin()
Definition: ParticleList.h:305
void FirstLastHitInPlane(unsigned int tpc, unsigned int plane, unsigned int mcpi, unsigned int &firstHitIndex, unsigned int &lastHitIndex)
The data type to uniquely identify a TPC.
Definition: geo_types.h:306
Detector simulation of raw signals on wires.
const sim::ParticleList & ParticleList() const
bool fCompareProductIDs
compare Hit and Cluster-> Hit art product IDs on the first event
art::Handle< std::vector< recob::Hit > > fHitHandle
TCEvent evt
Definition: DataStructs.cxx:8
std::array< float, 5 > ESums
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
ProductID id() const
Definition: Handle.h:224
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
std::vector< unsigned int > fHitMCPIndex
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Analyzer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 25 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

26  {
27  setupQueues(resources);
28  ProcessingFrame const frame{ScheduleID{}};
29  beginJobWithFrame(frame);
30  }
virtual void beginJobWithFrame(ProcessingFrame const &)=0
virtual void setupQueues(SharedResources const &)=0
bool art::detail::Analyzer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 68 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

69  {
70  ProcessingFrame const frame{mc.scheduleID()};
71  beginRunWithFrame(std::as_const(rp).makeRun(mc), frame);
72  return true;
73  }
virtual void beginRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 84 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

85  {
86  ProcessingFrame const frame{mc.scheduleID()};
87  beginSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
88  return true;
89  }
virtual void beginSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doEndJob ( )
inherited

Definition at line 33 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

34  {
35  ProcessingFrame const frame{ScheduleID{}};
36  endJobWithFrame(frame);
37  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 76 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

77  {
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(std::as_const(rp).makeRun(mc), frame);
80  return true;
81  }
virtual void endRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 92 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

93  {
94  ProcessingFrame const frame{mc.scheduleID()};
95  endSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
96  return true;
97  }
virtual void endSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 100 of file Analyzer.cc.

References e, and art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

105  {
106  auto const e = std::as_const(ep).makeEvent(mc);
107  if (wantEvent(mc.scheduleID(), e)) {
108  ++counts_run;
109  ProcessingFrame const frame{mc.scheduleID()};
110  analyzeWithFrame(e, frame);
111  ++counts_passed;
112  }
113  return true;
114  }
bool wantEvent(ScheduleID id, Event const &e) const
Definition: Observer.cc:63
Float_t e
Definition: plot.C:35
virtual void analyzeWithFrame(Event const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 47 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

48  {
49  ProcessingFrame const frame{ScheduleID{}};
51  }
TFile fb("Li6.root")
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 61 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

62  {
63  ProcessingFrame const frame{ScheduleID{}};
65  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Analyzer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 40 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

41  {
42  ProcessingFrame const frame{ScheduleID{}};
44  }
TFile fb("Li6.root")
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 54 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

55  {
56  ProcessingFrame const frame{ScheduleID{}};
58  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void cluster::ClusterTrackAna::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 600 of file ClusterTrackAna_module.cc.

References Cnts, DEFINE_ART_MODULE, EPSums, ESums, fBadEP, fClusterModuleLabel, fEventCnt, fInTPC, fNBadEP, fTrackModuleLabel, fTruthOrigin, art::InputTag::label(), and PSums.

601 {
602  // output results
603  mf::LogVerbatim myprt("ClusterTrackAna");
604  myprt << "ClusterTrackAna summary results for " << fEventCnt;
605  if (fClusterModuleLabel.label() != "NA") {
606  myprt << " events using ClusterModuleLabel: " << fClusterModuleLabel.label();
607  }
608  else {
609  myprt << " events using TrackModuleLabel: " << fTrackModuleLabel.label();
610  }
611  myprt << " Origin: " << fTruthOrigin;
612  if (fInTPC != UINT_MAX) { myprt << " in TPC " << fInTPC; }
613  else {
614  myprt << " in all TPCs";
615  }
616  myprt << "\n";
617  float cnts = 0;
618  for (unsigned short pIndx = 0; pIndx < 5; ++pIndx)
619  cnts += Cnts[pIndx];
620  if (cnts == 0) {
621  myprt << "No ClusterTrackAna results";
622  return;
623  }
624  float sumEP = 0;
625  float sumE = 0;
626  float sumP = 0;
627  myprt << "Efficiency (Eff), Purity (Pur) and Eff * Pur (EP) by selected truth particle types\n";
628  std::array<std::string, 5> pName = {{"El", "Mu", "Pi", "K ", "P "}};
629  myprt << "particle Eff Pur EP\n";
630  myprt << "-------------------------------";
631  for (unsigned short pIndx = 0; pIndx < 5; ++pIndx) {
632  if (Cnts[pIndx] == 0) continue;
633  float ave;
634  myprt << "\n " << pName[pIndx] << " ";
635  myprt << std::fixed << std::setprecision(3);
636  ave = ESums[pIndx] / Cnts[pIndx];
637  myprt << std::setw(8) << ave;
638  ave = PSums[pIndx] / Cnts[pIndx];
639  myprt << std::setw(8) << ave;
640  ave = EPSums[pIndx] / Cnts[pIndx];
641  myprt << std::setw(8) << ave;
642  if (pIndx == 0) continue;
643  sumEP += EPSums[pIndx];
644  sumE += ESums[pIndx];
645  sumP += PSums[pIndx];
646  } // pIndx
647  if (cnts == 0) return;
648  myprt << "\n";
649  myprt << "Averages for all selected truth particles\n";
650  myprt << "Ave Eff " << sumE / cnts;
651  myprt << " Ave Pur " << sumP / cnts;
652  myprt << " Ave EP " << sumEP / cnts;
653  myprt << " nBadEP " << fNBadEP;
654  myprt << " (EP < " << std::fixed << std::setprecision(2) << fBadEP << ")";
655  myprt << "\n";
656  myprt << "MCParticle counts in all TPCs and Planes:";
657  for (unsigned short pIndx = 0; pIndx < 5; ++pIndx) {
658  if (Cnts[pIndx] == 0) continue;
659  myprt << " " << pName[pIndx] << " " << (int)Cnts[pIndx];
660  } // pIndx
661 } // endJob
std::array< float, 5 > PSums
std::array< float, 5 > Cnts
std::string const & label() const noexcept
Definition: InputTag.cc:79
std::array< float, 5 > EPSums
std::array< float, 5 > ESums
void cluster::ClusterTrackAna::FirstLastHitInPlane ( unsigned int  tpc,
unsigned int  plane,
unsigned int  mcpi,
unsigned int &  firstHitIndex,
unsigned int &  lastHitIndex 
)
private

Definition at line 574 of file ClusterTrackAna_module.cc.

References fHitHandle, and fHitMCPIndex.

Referenced by analyze().

579 {
580  // Returns the index of the first hit (lowest wire number) and last hit (highest wire number)
581  // matched to the MCParticle indexed by mcpi in the requested tpc, plane
582  firstHitIndex = UINT_MAX;
583  lastHitIndex = UINT_MAX;
584  for (unsigned int iht = 0; iht < (*fHitHandle).size(); ++iht) {
585  if (fHitMCPIndex[iht] != mcpi) continue;
586  auto& hit = (*fHitHandle)[iht];
587  if (hit.WireID().TPC != tpc) continue;
588  if (hit.WireID().Plane != plane) continue;
589  if (firstHitIndex == UINT_MAX) {
590  firstHitIndex = iht;
591  lastHitIndex = iht;
592  }
593  unsigned int wire = (*fHitHandle)[iht].WireID().Wire;
594  if (wire < (*fHitHandle)[firstHitIndex].WireID().Wire) firstHitIndex = iht;
595  if (wire > (*fHitHandle)[lastHitIndex].WireID().Wire) lastHitIndex = iht;
596  } // iht
597 } // FirstLastHitInPlane
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
Detector simulation of raw signals on wires.
art::Handle< std::vector< recob::Hit > > fHitHandle
std::vector< unsigned int > fHitMCPIndex
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
Handle< TriggerResults > art::Observer::getTriggerResults ( Event const &  e) const
protectedinherited

Definition at line 75 of file Observer.cc.

References art::ProductRetriever::get(), and art::Observer::selectors_.

Referenced by art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

76  {
77  if (selectors_) {
78  return selectors_->getOneTriggerResults(e);
79  }
80 
81  // The following applies for cases where no SelectEvents entries
82  // exist.
83  Handle<TriggerResults> h;
84  if (e.get(empty_process_name, h)) {
85  return h;
86  }
87  return Handle<TriggerResults>{};
88  }
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79
std::string cluster::ClusterTrackAna::HitLocation ( unsigned int  iht)
private

packs hit WireID and PeakTime into a compact format

Definition at line 564 of file ClusterTrackAna_module.cc.

References util::to_string().

Referenced by analyze().

565 {
566  // Put the hit location into a compact human-readable format
567  if (iht >= (*fHitHandle).size()) return "NA";
568  auto& hit = (*fHitHandle)[iht];
569  return std::to_string(hit.WireID().TPC) + ":" + std::to_string(hit.WireID().Plane) + ":" +
570  std::to_string(hit.WireID().Wire) + ":" + std::to_string((int)hit.PeakTime());
571 } // HitLocation
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
Detector simulation of raw signals on wires.
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
ClusterTrackAna& cluster::ClusterTrackAna::operator= ( ClusterTrackAna const &  )
delete
ClusterTrackAna& cluster::ClusterTrackAna::operator= ( ClusterTrackAna &&  )
delete
string const & art::Observer::processName ( ) const
protectedinherited

Definition at line 57 of file Observer.cc.

References art::Observer::process_name_.

Referenced by art::FileDumperOutput::printPrincipal().

58  {
59  return process_name_;
60  }
std::string process_name_
Definition: Observer.h:76
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
bool art::Observer::wantAllEvents ( ) const
inlineprotectednoexceptinherited

Definition at line 31 of file Observer.h.

References e, art::Observer::getTriggerResults(), art::Observer::wantAllEvents_, and art::Observer::wantEvent().

32  {
33  return wantAllEvents_;
34  }
bool wantAllEvents_
Definition: Observer.h:75
bool art::Observer::wantEvent ( ScheduleID  id,
Event const &  e 
) const
protectedinherited

Definition at line 63 of file Observer.cc.

References art::Observer::rejectors_, art::Observer::selectors_, and art::Observer::wantAllEvents_.

Referenced by art::OutputModule::doEvent(), art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

64  {
65  if (wantAllEvents_) {
66  return true;
67  }
68  bool const select_event = selectors_ ? selectors_->matchEvent(id, e) : true;
69  bool const reject_event =
70  rejectors_ ? rejectors_->matchEvent(id, e) : false;
71  return select_event and not reject_event;
72  }
bool wantAllEvents_
Definition: Observer.h:75
std::optional< detail::ProcessAndEventSelectors > rejectors_
Definition: Observer.h:80
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79

Member Data Documentation

std::array<float, 5> cluster::ClusterTrackAna::Cnts {{0}}
private

Definition at line 75 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

std::array<float, 5> cluster::ClusterTrackAna::EPSums {{0}}
private

Definition at line 76 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

std::array<float, 5> cluster::ClusterTrackAna::ESums {{0}}
private

Definition at line 78 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

float cluster::ClusterTrackAna::fBadEP
private

Definition at line 68 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

art::InputTag cluster::ClusterTrackAna::fClusterModuleLabel
private

Definition at line 62 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

bool cluster::ClusterTrackAna::fCompareProductIDs
private
Initial value:
{
true}

compare Hit and Cluster-> Hit art product IDs on the first event

Definition at line 85 of file ClusterTrackAna_module.cc.

Referenced by analyze().

unsigned int cluster::ClusterTrackAna::fCurrentRun {0}
private

Definition at line 88 of file ClusterTrackAna_module.cc.

Referenced by analyze().

unsigned int cluster::ClusterTrackAna::fEventCnt {0}
private

Definition at line 71 of file ClusterTrackAna_module.cc.

Referenced by analyze(), and endJob().

bool cluster::ClusterTrackAna::fFirstPrint {true}
private

Definition at line 87 of file ClusterTrackAna_module.cc.

Referenced by analyze().

art::Handle<std::vector<recob::Hit> > cluster::ClusterTrackAna::fHitHandle
private

Definition at line 82 of file ClusterTrackAna_module.cc.

Referenced by analyze(), and FirstLastHitInPlane().

std::vector<unsigned int> cluster::ClusterTrackAna::fHitMCPIndex
private

Definition at line 83 of file ClusterTrackAna_module.cc.

Referenced by analyze(), and FirstLastHitInPlane().

art::InputTag cluster::ClusterTrackAna::fHitModuleLabel
private

Definition at line 61 of file ClusterTrackAna_module.cc.

Referenced by analyze(), and ClusterTrackAna().

unsigned int cluster::ClusterTrackAna::fInTPC
private

Definition at line 67 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

unsigned int cluster::ClusterTrackAna::fNBadEP {0}
private

Definition at line 73 of file ClusterTrackAna_module.cc.

Referenced by analyze(), and endJob().

short cluster::ClusterTrackAna::fPrintLevel
private

Definition at line 66 of file ClusterTrackAna_module.cc.

Referenced by analyze(), and ClusterTrackAna().

std::vector<int> cluster::ClusterTrackAna::fSkipPDGCodes
private

Definition at line 65 of file ClusterTrackAna_module.cc.

Referenced by analyze(), and ClusterTrackAna().

art::InputTag cluster::ClusterTrackAna::fTrackModuleLabel
private

Definition at line 63 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

simb::Origin_t cluster::ClusterTrackAna::fTruthOrigin
private

Definition at line 64 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().

std::array<float, 5> cluster::ClusterTrackAna::PSums {{0}}
private

Definition at line 80 of file ClusterTrackAna_module.cc.

Referenced by analyze(), ClusterTrackAna(), and endJob().


The documentation for this class was generated from the following file: