LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cluster::ClusterAna Class Reference
Inheritance diagram for cluster::ClusterAna:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 ClusterAna (fhicl::ParameterSet const &pset)
 
virtual ~ClusterAna ()
 
void analyze (const art::Event &evt)
 read access to event More...
 
void beginJob ()
 
void endJob ()
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

TH1F * fNClusters
 
TH1F * fNHitInCluster
 
TH1F * fCREP2
 
TH1F * fCRE
 
TH1F * fCRP
 
TH1F * fNuKE_elec
 
TH1F * fNuKE_muon
 
TH1F * fNuKE_pion
 
TH1F * fNuKE_kaon
 
TH1F * fNuKE_prot
 
TH1F * fNuEP2_elec
 
TH1F * fNuEP2_muon
 
TH1F * fNuEP2_pion
 
TH1F * fNuEP2_kaon
 
TH1F * fNuEP2_prot
 
TH1F * fNuE_elec
 
TH1F * fNuE_muon
 
TH1F * fNuE_pion
 
TH1F * fNuE_kaon
 
TH1F * fNuE_prot
 
TH1F * fNuP_elec
 
TH1F * fNuP_muon
 
TH1F * fNuP_pion
 
TH1F * fNuP_kaon
 
TH1F * fNuP_prot
 
TH1F * fNuVtx_dx
 
TH1F * fNuVtx_dy
 
TH1F * fNuVtx_dz
 
TProfile * fNuEP2_KE_elec
 
TProfile * fNuEP2_KE_muon
 
TProfile * fNuEP2_KE_pion
 
TProfile * fNuEP2_KE_kaon
 
TProfile * fNuEP2_KE_prot
 
std::string fHitsModuleLabel
 
std::string fClusterModuleLabel
 
std::string fVertexModuleLabel
 
std::vector< float > fElecKERange
 
std::vector< float > fMuonKERange
 
std::vector< float > fPionKERange
 
std::vector< float > fKaonKERange
 
std::vector< float > fProtKERange
 
short fTrackWeightOption
 
bool fMergeDaughters
 
bool fSkipCosmics
 
short fPrintLevel
 
short moduleID
 
std::ofstream outFile
 

Detailed Description

Definition at line 58 of file ClusterAna_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

cluster::ClusterAna::ClusterAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 136 of file ClusterAna_module.cc.

References fClusterModuleLabel, fPrintLevel, moduleID, and outFile.

137  : EDAnalyzer(pset)
138  , fHitsModuleLabel (pset.get< std::string > ("HitsModuleLabel") )
139  , fClusterModuleLabel (pset.get< std::string > ("ClusterModuleLabel"))
140  , fVertexModuleLabel (pset.get< std::string > ("VertexModuleLabel") )
141  , fElecKERange (pset.get< std::vector<float>> ("ElecKERange"))
142  , fMuonKERange (pset.get< std::vector<float>> ("MuonKERange"))
143  , fPionKERange (pset.get< std::vector<float>> ("PionKERange"))
144  , fKaonKERange (pset.get< std::vector<float>> ("KaonKERange"))
145  , fProtKERange (pset.get< std::vector<float>> ("ProtKERange"))
146  , fTrackWeightOption (pset.get< short > ("TrackWeightOption"))
147  , fMergeDaughters (pset.get< bool > ("MergeDaughters"))
148  , fSkipCosmics (pset.get< bool > ("SkipCosmics"))
149  , fPrintLevel (pset.get< short > ("PrintLevel"))
150  {
151 
152  if(fPrintLevel == -1) {
153  // encode the clustermodule label into an integer
154  moduleID = 0;
155  size_t found = fClusterModuleLabel.find("traj"); if(found != std::string::npos) moduleID = 1;
156  found = fClusterModuleLabel.find("line"); if(found != std::string::npos) moduleID = 2;
157  found = fClusterModuleLabel.find("fuzz"); if(found != std::string::npos) moduleID = 3;
158  found = fClusterModuleLabel.find("pand"); if(found != std::string::npos) moduleID = 4;
159  std::cout<<"fClusterModuleLabel "<<fClusterModuleLabel<<" ID "<<moduleID<<"\n";
160 
161  std::string fileName = fClusterModuleLabel + ".tru";
162  outFile.open(fileName);
163  }
164 
165  }
std::vector< float > fElecKERange
std::vector< float > fProtKERange
std::vector< float > fKaonKERange
std::string fVertexModuleLabel
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::string fClusterModuleLabel
std::vector< float > fPionKERange
std::vector< float > fMuonKERange
cluster::ClusterAna::~ClusterAna ( )
virtual

Definition at line 168 of file ClusterAna_module.cc.

169  {
170 
171  }

Member Function Documentation

void cluster::ClusterAna::analyze ( const art::Event evt)

read access to event

Definition at line 232 of file ClusterAna_module.cc.

References sim::ParticleList::begin(), simb::MCNeutrino::CCNC(), DEFINE_ART_MODULE, simb::MCParticle::E(), sim::ParticleList::end(), art::EventID::event(), fClusterModuleLabel, fCRE, fCREP2, fCRP, fElecKERange, fHitsModuleLabel, art::fill_ptr_vector(), fKaonKERange, fMergeDaughters, fMuonKERange, fNClusters, fNHitInCluster, fNuE_elec, fNuE_kaon, fNuE_muon, fNuE_pion, fNuE_prot, fNuEP2_elec, fNuEP2_kaon, fNuEP2_KE_elec, fNuEP2_KE_kaon, fNuEP2_KE_muon, fNuEP2_KE_pion, fNuEP2_KE_prot, fNuEP2_muon, fNuEP2_pion, fNuEP2_prot, fNuKE_elec, fNuKE_kaon, fNuKE_muon, fNuKE_pion, fNuKE_prot, fNuP_elec, fNuP_kaon, fNuP_muon, fNuP_pion, fNuP_prot, fNuVtx_dx, fNuVtx_dy, fNuVtx_dz, fPionKERange, fPrintLevel, fProtKERange, fSkipCosmics, fTrackWeightOption, fVertexModuleLabel, art::DataViewImpl::getByLabel(), simb::MCTruth::GetNeutrino(), art::Event::id(), simb::MCNeutrino::InteractionType(), ipart, art::Handle< T >::isValid(), simb::kBeamNeutrino, simb::kCC, simb::kCosmicRay, simb::kNC, simb::kSingleParticle, simb::MCParticle::Mass(), moduleID, simb::MCParticle::Mother(), geo::GeometryCore::Nplanes(), simb::MCNeutrino::Nu(), simb::MCTruth::Origin(), outFile, part, cheat::ParticleInventoryService::ParticleList(), simb::MCParticle::PdgCode(), recob::Hit::PeakTime(), geo::GeometryCore::Plane(), simb::MCParticle::Process(), art::PtrVector< T >::push_back(), art::right(), art::PtrVector< T >::size(), simb::MCParticle::TrackId(), cheat::BackTrackerService::TrackIdsToHits_Ps(), cheat::ParticleInventoryService::TrackIdToMCTruth_P(), geo::PlaneGeo::View(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), simb::MCParticle::Vz(), geo::WireID::Wire, recob::Hit::WireID(), and recob::Vertex::XYZ().

233  {
234 
235  // code stolen from TrackAna_module.cc
237  if(geom->Nplanes() > 3) {
238  mf::LogError("ClusterAna")<<"Too many planes for this code...";
239  return;
240  }
241 
242  // get all hits in the event
243  art::Handle< std::vector<recob::Hit> > hitListHandle;
244  evt.getByLabel(fHitsModuleLabel, hitListHandle);
245  std::vector< art::Ptr<recob::Hit> > allhits;
246  art::fill_ptr_vector(allhits, hitListHandle);
247  if(allhits.size() == 0) return;
248 
249  // get clusters and cluster-hit associations
250  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
251  evt.getByLabel(fClusterModuleLabel,clusterListHandle);
252  art::FindManyP<recob::Hit> fmh(clusterListHandle, evt, fClusterModuleLabel);
253  if(clusterListHandle->size() == 0) {
254  std::cout<<"No clusters in event. Hits size "<<allhits.size()<<"\n";
255  // don't return or the statistics will be off
256 // return;
257  }
258 
259  // get 3D vertices
260  art::Handle< std::vector<recob::Vertex> > vertexListHandle;
261  double xyz[3] = {0,0,0};
262  art::PtrVector<recob::Vertex> recoVtxList;
263  if(vertexListHandle.isValid()) {
264  evt.getByLabel(fVertexModuleLabel,vertexListHandle);
265  for(unsigned int ii = 0; ii < vertexListHandle->size(); ++ii){
266  art::Ptr<recob::Vertex> vertex(vertexListHandle, ii);
267  recoVtxList.push_back(vertex);
268  vertex->XYZ(xyz);
269  } // ii
270  } // vertexListHandle
271 
272  // list of all true particles
275  sim::ParticleList const& plist = pi_serv->ParticleList();
276  // list of all true particles that will be considered
277  std::vector<const simb::MCParticle*> plist2;
278  // true (reconstructed) hits for each particle in plist2
279  std::vector<std::vector<art::Ptr<recob::Hit>>> hlist2;
280  // index of cluster matched to each particle in plist2 in each plane
281  std::vector<std::vector<short>> truToCl;
282  // number of true hits in each plane and cluster
283  std::vector<std::vector<unsigned short>> nTruHitInCl;
284  //number of reconstructed hits in all clusters
285  std::vector<unsigned short> nRecHitInCl;
286 
287  // calculate average EP2 for every event to facilitate code development
288  // Beam Neutrinos - muons and not-muons
289 
290  float aveNuEP2mu = 0.;
291  float numNuEP2mu = 0.;
292  float aveNuEP2nm = 0.;
293  float numNuEP2nm = 0.;
294  // Cosmic Rays
295  float aveCREP2 = 0.;
296  float numCREP2 = 0.;
297 
298  // track ID of the neutrino (or single particle)
299  int neutTrackID = -1;
300  std::vector<int> tidlist;
301  float neutEnergy = -1.;
302  int neutIntType = -1;
303  int neutCCNC = -1;
304  bool isNeutrino = false;
305  bool isSingleParticle = false;
306  for(sim::ParticleList::const_iterator ipart = plist.begin(); ipart != plist.end(); ++ipart) {
307  const simb::MCParticle* part = (*ipart).second;
308  assert(part != 0);
309  int pdg = abs(part->PdgCode());
310  int trackID = part->TrackId();
311  art::Ptr<simb::MCTruth> theTruth = pi_serv->TrackIdToMCTruth_P(trackID);
312  if(fSkipCosmics && theTruth->Origin() == simb::kCosmicRay) continue;
313  if(theTruth->Origin() == simb::kBeamNeutrino) isNeutrino = true;
314  if(theTruth->Origin() == simb::kSingleParticle) isSingleParticle = true;
315  float KE = 1000 * (part->E() - part->Mass());
316 
317  // Get the neutrino track ID. Assume that there is only one neutrino
318  // interaction and it is first in the list of BeamNeutrino particles
319  if((isNeutrino || isSingleParticle) && neutTrackID < 0) {
320  neutTrackID = trackID;
321  if(isNeutrino) {
322  simb::MCNeutrino theNeutrino = theTruth->GetNeutrino();
323  neutEnergy = 1000. * theNeutrino.Nu().E();
324  neutIntType = theNeutrino.InteractionType();
325  neutCCNC = theNeutrino.CCNC();
326  }
327 // mf::LogVerbatim("ClusterAna")
328 // <<"True Vtx "<<part->Vx()<<" "<<part->Vy()<<" "<<part->Vz();
329  for(unsigned short iv = 0; iv < recoVtxList.size(); ++iv) {
330  recoVtxList[iv]->XYZ(xyz);
331  fNuVtx_dx->Fill(part->Vx() - xyz[0]);
332  fNuVtx_dy->Fill(part->Vy() - xyz[1]);
333  fNuVtx_dz->Fill(part->Vz() - xyz[2]);
334  } // iv
335  } // theTruth->Origin() == simb::kBeamNeutrino && neutTrackID <
336 
337  if(fPrintLevel > 3) mf::LogVerbatim("ClusterAna")
338  <<"Origin "<<theTruth->Origin()<<" trackID "<<trackID
339  <<" PDG "<<part->PdgCode()
340  <<" KE "<<(int)KE<<" MeV "
341  <<" neutTrackID "<<neutTrackID
342  <<" Mother "<<part->Mother()
343  <<" Proc "<<part->Process();
344 
345  bool isCharged = (pdg == 11) || (pdg == 13) || (pdg == 211)
346  || (pdg == 321) || (pdg == 2212);
347 
348 
349  if(!isCharged) continue;
350 
351  // KE (MeV) cuts
352  if(pdg == 11) {
353  if(fElecKERange[0] < 0) continue;
354  // only allow primary electrons
355  if(part->Process() != "primary") continue;
356  if(KE < fElecKERange[0] || KE > fElecKERange[1]) continue;
357  }
358  if(pdg == 13) {
359  if(fMuonKERange[0] < 0) continue;
360  if(KE < fMuonKERange[0] || KE > fMuonKERange[1]) continue;
361  }
362  if(pdg == 211) {
363  if(fPionKERange[0] < 0) continue;
364  if(KE < fPionKERange[0] || KE > fPionKERange[1]) continue;
365  }
366  if(pdg == 321) {
367  if(fKaonKERange[0] < 0) continue;
368  if(KE < fKaonKERange[0] || KE > fKaonKERange[1]) continue;
369  }
370  if(pdg == 2212) {
371  if(fProtKERange[0] < 0) continue;
372  if(KE < fProtKERange[0] || KE > fProtKERange[1]) continue;
373  }
374  // ignore secondaries from neutron interactions
375  if(part->Process() == "NeutronInelastic") continue;
376  plist2.push_back(part);
377  tidlist.push_back(trackID);
378  // initialize the true->(cluster,plane) association
379  std::vector<short> temp {-1, -1, -1};
380  truToCl.push_back(temp);
381  // initialize the true hit count
382  std::vector<unsigned short> temp2(3);
383  nTruHitInCl.push_back(temp2);
384 
385  if(fPrintLevel > 2) mf::LogVerbatim("ClusterAna")
386  <<"plist2["<<plist2.size() - 1<<"]"
387  <<" Origin "<<theTruth->Origin()<<" trackID "<<trackID
388  <<" PDG "<<part->PdgCode()
389  <<" KE "<<(int)KE
390  <<" Mother "<<part->Mother() + neutTrackID - 1
391  <<" Proc "<<part->Process();
392  }
393 
394  if(plist2.size() == 0) return;
395 
396  // get the hits (in all planes) that are matched to the true tracks
397  hlist2 = bt_serv->TrackIdsToHits_Ps( tidlist,allhits);
398  if(hlist2.size() != plist2.size()) {
399  mf::LogError("ClusterAna")
400  <<"MC particle list size "<<plist2.size()
401  <<" != size of MC particle true hits lists "<<hlist2.size();
402  return;
403  }
404  tidlist.clear();
405 
406  // vector of (mother, daughter) pairs
407  std::vector<std::pair<unsigned short, unsigned short>> moda;
408  // Deal with mother-daughter tracks
409  if(fMergeDaughters && neutTrackID >= 0) {
410  // Assume that daughters appear later in the list. Step backwards
411  // to accumulate all generations of daughters
412  unsigned short ii, dpl, jj, jpl, kpl;
413  for(ii = 0; ii < plist2.size(); ++ii) {
414  dpl = plist2.size() - 1 - ii;
415  // no mother
416  if(plist2[dpl]->Mother() == 0) continue;
417  // electron
418  if(abs(plist2[dpl]->PdgCode()) == 11) continue;
419  // the actual mother trackID is offset from the neutrino trackID
420  int motherID = neutTrackID + plist2[dpl]->Mother() - 1;
421  // ensure that we are only looking at BeamNeutrino or single particle daughters
422  if(motherID != neutTrackID) continue;
423  // count the number of daughters
424  int ndtr = 0;
425  for(kpl = 0; kpl < plist2.size(); ++kpl) {
426  if(plist2[kpl]->Mother() == motherID) ++ndtr;
427  }
428  // require only one daughter
429  if(ndtr > 1) continue;
430  // find the mother in the list
431  int mpl = -1;
432  for(jj = 0; jj < plist2.size(); ++jj) {
433  jpl = plist2.size() - 1 - jj;
434  if(plist2[jpl]->TrackId() == motherID) {
435  mpl = jpl;
436  break;
437  }
438  } // jpl
439  // mother not found for some reason
440  if(mpl < 0) {
441  mf::LogVerbatim("ClusterAna")<<" mother of daughter "<<dpl<<" not found. mpl = "<<mpl;
442  continue;
443  }
444  // ensure that PDG code for mother and daughter are the same
445  if(plist2[dpl]->PdgCode() != plist2[mpl]->PdgCode()) continue;
446  moda.push_back(std::make_pair(mpl, dpl));
447  } // dpl
448  } // MergeDaughters
449 
450  // Now match reconstructed clusters to true particles.
452  for (unsigned int ii = 0; ii < clusterListHandle->size(); ++ii){
453  art::Ptr<recob::Cluster> clusterHolder(clusterListHandle,ii);
454  clusters.push_back(clusterHolder);
455  }
456 
457  fNClusters->Fill(clusterListHandle->size());
458  nRecHitInCl.resize(clusters.size());
459 
460  // get the plane from the view. Perhaps there is a method that does
461  // this somewhere...
462  std::map< geo::View_t, unsigned int > ViewToPlane;
463  for(unsigned int plane=0; plane < geom->Nplanes(); ++plane){
464  geo::View_t view = geom->Plane(plane).View();
465  ViewToPlane[view] = plane;
466  }
467  for(size_t icl = 0; icl < clusters.size(); ++icl){
468  unsigned int plane = ViewToPlane[clusters[icl]->View()];
469  std::vector< art::Ptr<recob::Hit> > cluhits = fmh.at(icl);
470  fNHitInCluster->Fill(cluhits.size());
471  nRecHitInCl[icl] = cluhits.size();
472  // count the number of hits matched to each true particle in plist2
473  std::vector<unsigned short> nHitInPl2(plist2.size());
474  for(size_t iht = 0; iht < cluhits.size(); ++iht){
475 
476 // mf::LogVerbatim("ClusterAna")<<"Clus Hit "<<cluhits[iht]->View()<<":"<<cluhits[iht]->WireID().Wire<<":"<<(int)cluhits[iht]->PeakTime();
477 
478  // look for this hit in all of the truth hit lists
479  short hitInPl2 = -1;
480  for(unsigned short ipl = 0; ipl < plist2.size(); ++ipl) {
481  unsigned short imat = 0;
482  for(imat = 0; imat < hlist2[ipl].size(); ++imat) {
483  if(cluhits[iht] == hlist2[ipl][imat]) break;
484  } // imat
485  if(imat < hlist2[ipl].size()) {
486  hitInPl2 = ipl;
487  break;
488  }
489  } // ipl
490  if(hitInPl2 < 0) continue;
491  // Assign the hit count to the mother if this is a daughter.
492  // Mother-daughter pairs are entered in the moda vector in reverse
493  // order, so assign daughter hits to the highest generation mother.
494  for(unsigned short imd = 0; imd < moda.size(); ++imd) {
495  if(moda[imd].second == hitInPl2) hitInPl2 = moda[imd].first;
496  }
497  // count
498  ++nHitInPl2[hitInPl2];
499  } // iht
500  // Associate the cluster with the truth particle that has the highest
501  // number of cluster hits
502  unsigned short nhit = 0;
503  short imtru = -1;
504  for(unsigned int ipl = 0; ipl < nHitInPl2.size(); ++ipl) {
505  if(nHitInPl2[ipl] > nhit) {
506  nhit = nHitInPl2[ipl];
507  imtru = ipl;
508  }
509  } // ipl
510  // make the cluster->(true,plane) association and save the
511  // number of true hits in the cluster
512  if(imtru != -1) {
513  // clobber a previously made association?
514  if(nhit > nTruHitInCl[imtru][plane]) {
515  truToCl[imtru][plane] = icl;
516  nTruHitInCl[imtru][plane] = nhit;
517  }
518  } // imtru != 1
519  } // icl
520 
521  // ready to calculate Efficiency, Purity in each plane and EP2
522  for(unsigned short ipl = 0; ipl < plist2.size(); ++ipl) {
523  // ignore daughters
524  bool skipit = false;
525  for(unsigned short ii = 0; ii < moda.size(); ++ii) {
526  if(moda[ii].second == ipl) {
527  skipit = true;
528  break;
529  }
530  } // ii
531  if(skipit) continue;
532  // ignore true particles with few true hits. Outside the detector
533  // or not reconstructable?
534  if(hlist2[ipl].size() < 3) continue;
535 
536  int trackID = plist2[ipl]->TrackId();
537  art::Ptr<simb::MCTruth> theTruth = pi_serv->TrackIdToMCTruth_P(trackID);
538  bool isCosmic = (theTruth->Origin() == simb::kCosmicRay);
539  float KE = 1000 * (plist2[ipl]->E() - plist2[ipl]->Mass());
540  int PDG = abs(plist2[ipl]->PdgCode());
541 
542  std::vector<short> nTru(geom->Nplanes());
543  std::vector<short> nRec(geom->Nplanes());
544  std::vector<short> nTruRec(geom->Nplanes());
545  std::vector<float> eff(geom->Nplanes());
546  std::vector<float> pur(geom->Nplanes());
547  std::vector<float> ep(geom->Nplanes());
548  for(unsigned int plane = 0; plane < geom->Nplanes(); ++plane) {
549  // count the number of true hits in this plane for the true particle.
550  // First count the mother hits
551  for(unsigned short ii = 0; ii < hlist2[ipl].size(); ++ii){
552  if(ViewToPlane[hlist2[ipl][ii]->View()] == plane) ++nTru[plane];
553  } // ii
554 // mf::LogVerbatim("ClusterAna")<<"Chk mom "<<ipl<<" plane "<<plane<<" nTru hits "<<nTru[plane];
555  // next look for daughters and count those hits in all generations
556  unsigned short mom = ipl;
557  std::vector<std::pair<unsigned short, unsigned short>>::reverse_iterator
558  rit = moda.rbegin();
559  while(rit != moda.rend()) {
560  if((*rit).first == mom) {
561  unsigned short dau = (*rit).second;
562  for(unsigned short jj = 0; jj < hlist2[dau].size(); ++jj) {
563  if(ViewToPlane[hlist2[dau][jj]->View()] == plane) ++nTru[plane];
564  } // jj
565  // It is likely that one hit appears in the mother list
566  // as well as the daughter list, so subtract one from the count
567 // --nTru[plane];
568  mom = (*rit).second;
569 // mf::LogVerbatim("ClusterAna")<<"new mom "<<mom<<" nTru "<<nTru[plane];
570  } // (*rit).first == mom
571  ++rit;
572  } // rit
573 // mf::LogVerbatim("ClusterAna")<<"Chk dau "<<nTru[plane];
574  if(nTru[plane] == 0) continue;
575  // Ignore short truth clusters
576  if(nTru[plane] < 3) continue;
577  short icl = truToCl[ipl][plane];
578  if(icl < 0) {
579  nRec[plane] = 0;
580  } else {
581  nRec[plane] = nRecHitInCl[icl];
582  }
583  nTruRec[plane] = nTruHitInCl[ipl][plane];
584  eff[plane] = 0;
585  pur[plane] = 0;
586  if(nTru[plane] > 0) eff[plane] = (float)nTruRec[plane] / (float)nTru[plane];
587  if(nRec[plane] > 0) pur[plane] = (float)nTruRec[plane] / (float)nRec[plane];
588  // do this to prevent histogram under/over flow
589  if(eff[plane] == 0) { eff[plane] = 0.001; }
590  if(pur[plane] == 0) { pur[plane] = 0.001; }
591  if(eff[plane] >= 1) { eff[plane] = 0.999; }
592  if(pur[plane] >= 1) { pur[plane] = 0.999; }
593  ep[plane] = eff[plane] * pur[plane];
594  if(fPrintLevel == -1) outFile<<moduleID<<" "<<evt.id().event()<<" "<<trackID<<" "<<PDG<<" "<<(int)KE<<" "<<plane<<" "<<nTru[plane]<<" "<<std::setprecision(3)<<eff[plane]<<" "<<pur[plane]<<"\n";
595 // mf::LogVerbatim("ClusterAna")<<"Cluster "<<icl<<" nRec hits "<<nRec[plane]<<" nTruRec hits "<<nTruRec[plane]<<" eff "<<eff[plane]<<" pur "<<pur[plane];
596  } // plane
597  // sort the ep values in ascending order
598  std::vector<float> temp;
599  temp = ep;
600  std::sort(temp.begin(), temp.end());
601  // EP2 is the second highest value
602  unsigned short ii = temp.size() - 2;
603  float ep2 = temp[ii];
604  // find the plane that defined EP2
605  short ep2Plane = 0;
606  short ep2Cluster = 0;
607  for(unsigned short jj = 0; jj < temp.size(); ++jj) {
608  if(ep[jj] == ep2) {
609  ep2Plane = jj;
610  ep2Cluster = truToCl[ipl][ep2Plane];
611  break;
612  }
613  } // jj
614  // find the US and DS ends of the cluster for printing
615  std::array<double, 2> clBeg, clEnd;
616  if(ep2Cluster >= 0) {
617  clBeg[0] = clusters[ep2Cluster]->StartWire();
618  clBeg[1] = clusters[ep2Cluster]->StartTick();
619  clEnd[0] = clusters[ep2Cluster]->EndWire();
620  clEnd[1] = clusters[ep2Cluster]->EndTick();
621  }
622  else {
623  clBeg.fill(0.);
624  clEnd.fill(0.);
625  }
626  // fill histograms
627  if(isCosmic) {
628  fCREP2->Fill(ep2);
629  fCRE->Fill(eff[ep2Plane]);
630  fCRP->Fill(pur[ep2Plane]);
631  aveCREP2 += ep2;
632  numCREP2 += 1.;
633  if(fPrintLevel > 1) mf::LogVerbatim("ClusterAna")
634  <<">>>CREP2 "<<std::fixed<<std::setprecision(2)<<ep2
635  <<" E "<<eff[ep2Plane]<<std::setprecision(2)<<" P "<<pur[ep2Plane]
636  <<" P:W:T "<<ep2Plane<<":"<<(int)clBeg[0]<<":"<<(int)clBeg[1]
637  <<"-"<<ep2Plane<<":"<<(int)clEnd[0]<<":"<<(int)clEnd[1]
638  <<" PDG "<<PDG<<" KE "<<(int)KE<<" MeV";
639  } // isCosmic
640  else {
641  float wght = 1.;
642  if(fTrackWeightOption == 1) wght = KE;
643  // accumulate statistics for muons and not-muons
644  if(PDG == 13) {
645  aveNuEP2mu += ep2 * wght;
646  numNuEP2mu += wght;
647  } else {
648  aveNuEP2nm += ep2 * wght;
649  numNuEP2nm += wght;
650  }
651  if(PDG == 11) {
652  fNuKE_elec->Fill(KE, wght);
653  fNuE_elec->Fill(eff[ep2Plane], wght);
654  fNuP_elec->Fill(pur[ep2Plane], wght);
655  fNuEP2_elec->Fill(ep2, wght);
656  fNuEP2_KE_elec->Fill(KE, ep2, wght);
657  } else if(PDG == 13) {
658  fNuKE_muon->Fill(KE, wght);
659  fNuE_muon->Fill(eff[ep2Plane], wght);
660  fNuP_muon->Fill(pur[ep2Plane], wght);
661  fNuEP2_muon->Fill(ep2, wght);
662  fNuEP2_KE_muon->Fill(KE, ep2, wght);
663  } else if(PDG == 211) {
664  fNuKE_pion->Fill(KE, wght);
665  fNuE_pion->Fill(eff[ep2Plane], wght);
666  fNuP_pion->Fill(pur[ep2Plane], wght);
667  fNuEP2_pion->Fill(ep2, wght);
668  fNuEP2_KE_pion->Fill(KE, ep2, wght);
669  } else if(PDG == 321) {
670  fNuKE_kaon->Fill(KE, wght);
671  fNuE_kaon->Fill(eff[ep2Plane], wght);
672  fNuP_kaon->Fill(pur[ep2Plane], wght);
673  fNuEP2_kaon->Fill(ep2, wght);
674  fNuEP2_KE_kaon->Fill(KE, ep2, wght);
675  } else if(PDG == 2212) {
676  fNuKE_prot->Fill(KE, wght);
677  fNuE_prot->Fill(eff[ep2Plane], wght);
678  fNuP_prot->Fill(pur[ep2Plane], wght);
679  fNuEP2_prot->Fill(ep2, wght);
680  fNuEP2_KE_prot->Fill(KE, ep2, wght);
681  }
682  if(fPrintLevel > 1) mf::LogVerbatim("ClusterAna")
683  <<">>>NuEP2 "<<std::fixed<<std::setprecision(2)<<ep2
684  <<" E "<<eff[ep2Plane]<<std::setprecision(2)<<" P "<<pur[ep2Plane]
685  <<" P:W:T "<<ep2Plane<<":"<<(int)clBeg[0]<<":"<<(int)clBeg[1]
686  <<"-"<<ep2Plane<<":"<<(int)clEnd[0]<<":"<<(int)clEnd[1]
687  <<" PDG "<<PDG<<" KE "<<(int)KE<<" MeV ";
688  if(fPrintLevel > 2) {
689  // print out the begin/end true hits
690  mf::LogVerbatim mfp("ClusterAna");
691  mfp<<" Truth P:W:T ";
692  for(unsigned int plane = 0; plane < geom->Nplanes(); ++plane) {
693  unsigned short loW = 9999;
694  unsigned short loT = 0;
695  unsigned short hiW = 0;
696  unsigned short hiT = 0;
697  for(unsigned short ii = 0; ii < hlist2[ipl].size(); ++ii){
698  if(ViewToPlane[hlist2[ipl][ii]->View()] == plane) {
699  art::Ptr<recob::Hit> theHit = hlist2[ipl][ii];
700  if(theHit->WireID().Wire < loW) {
701  loW = theHit->WireID().Wire;
702  loT = theHit->PeakTime();
703  }
704  if(theHit->WireID().Wire > hiW) {
705  hiW = theHit->WireID().Wire;
706  hiT = theHit->PeakTime();
707  }
708  } // correct view
709  } // ii
710  mfp<<plane<<":"<<loW<<":"<<loT<<"-"<<plane<<":"<<hiW<<":"<<hiT<<" ";
711  } // plane
712  } // fPrintLevel > 2
713  } // !isCosmic
714  } // ipl
715 
716  float ave1 = -1.;
717  if(numNuEP2mu > 0.) ave1 = aveNuEP2mu/numNuEP2mu;
718 
719  float ave2 = -1.;
720  if(numNuEP2nm > 0.) ave2 = aveNuEP2nm/numNuEP2nm;
721 
722  float ave3 = -1.;
723  if(numCREP2 > 0.) ave3 = aveCREP2/numCREP2;
724 
725 
726 
727  if(fPrintLevel > 0) {
728  std::string nuType = "Other";
729  if(neutCCNC == simb::kCC) {
730  if(neutIntType == 1001) nuType = "CCQE";
731  if(neutIntType == 1091) nuType = "DIS";
732  if(neutIntType == 1097) nuType = "COH";
733  if(neutIntType > 1002 && neutIntType < 1091) nuType = "RES";
734  } else if(neutCCNC == simb::kNC) {
735  nuType = "NC";
736  } else {
737  nuType = "Unknown";
738  }
739  mf::LogVerbatim("ClusterAna")
740  <<"EvtEP2 "<<evt.id().event()
741  <<" NuType "<<nuType
742  <<" Enu "<<std::fixed<<std::setprecision(0)<<neutEnergy
743  <<std::right<<std::fixed<<std::setprecision(2)
744  <<" NuMuons "<<ave1
745  <<" NuPiKp "<<ave2
746  <<" CosmicRays "<<ave3
747  <<" CCNC "<<neutCCNC<<" IntType "<<neutIntType;
748  }
749  } // analyze
double E(const int i=0) const
Definition: MCParticle.h:237
const std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIdsToHits_Ps(std::vector< int > const &tkIds, std::vector< art::Ptr< recob::Hit > > const &hitsIn)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
int PdgCode() const
Definition: MCParticle.h:216
int CCNC() const
Definition: MCNeutrino.h:152
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:74
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
int Mother() const
Definition: MCParticle.h:217
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:150
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
simb::Origin_t Origin() const
Definition: MCTruth.h:71
double Mass() const
Definition: MCParticle.h:243
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::string Process() const
Definition: MCParticle.h:219
int TrackId() const
Definition: MCParticle.h:214
std::vector< float > fElecKERange
else
Definition: plot.C:35
bool isValid() const
Definition: Handle.h:190
int InteractionType() const
Definition: MCNeutrino.h:154
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:171
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
if(nlines<=0)
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
single particles thrown at the detector
Definition: MCTruth.h:24
TString part[npart]
Definition: Style.C:32
std::vector< float > fProtKERange
std::vector< float > fKaonKERange
iterator begin()
Definition: ParticleList.h:305
std::string fVertexModuleLabel
size_type size() const
Definition: PtrVector.h:308
double Vx(const int i=0) const
Definition: MCParticle.h:225
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Int_t ipart
Definition: Style.C:10
double Vz(const int i=0) const
Definition: MCParticle.h:227
EventNumber_t event() const
Definition: EventID.h:117
std::string fClusterModuleLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Event generator information.
Definition: MCNeutrino.h:18
std::vector< float > fPionKERange
std::vector< float > fMuonKERange
EventID id() const
Definition: Event.h:56
double Vy(const int i=0) const
Definition: MCParticle.h:226
Cosmic rays.
Definition: MCTruth.h:22
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int const &id)
Beam neutrinos.
Definition: MCTruth.h:21
vertex reconstruction
void cluster::ClusterAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 173 of file ClusterAna_module.cc.

References fCRE, fCREP2, fCRP, fNClusters, fNHitInCluster, fNuE_elec, fNuE_kaon, fNuE_muon, fNuE_pion, fNuE_prot, fNuEP2_elec, fNuEP2_kaon, fNuEP2_KE_elec, fNuEP2_KE_kaon, fNuEP2_KE_muon, fNuEP2_KE_pion, fNuEP2_KE_prot, fNuEP2_muon, fNuEP2_pion, fNuEP2_prot, fNuKE_elec, fNuKE_kaon, fNuKE_muon, fNuKE_pion, fNuKE_prot, fNuP_elec, fNuP_kaon, fNuP_muon, fNuP_pion, fNuP_prot, fNuVtx_dx, fNuVtx_dy, fNuVtx_dz, fSkipCosmics, and art::TFileDirectory::make().

174  {
175 
176  // get access to the TFile service
178 
179  fNClusters=tfs->make<TH1F>("fNoClustersInEvent","Number of Clusters", 40,0 ,400);
180  fNHitInCluster = tfs->make<TH1F>("fNHitInCluster","NHitInCluster",100,0,100);
181 
182  if(!fSkipCosmics) {
183  // Cosmic ray histos
184  fCREP2 = tfs->make<TH1F>("CREP2","CREP2",50,0,1);
185  fCRE = tfs->make<TH1F>("CRE","CR Efficiency",50,0,1);
186  fCRP = tfs->make<TH1F>("CRP","CR Purity",50,0,1);
187  }
188  // Neutrino Int histos
189  fNuKE_elec = tfs->make<TH1F>("NuKE_elec","NuKE electron",100,0,4000);
190  fNuKE_muon = tfs->make<TH1F>("NuKE_muon","NuKE muon",100,0,4000);
191  fNuKE_pion = tfs->make<TH1F>("NuKE_pion","NuKE pion",100,0,4000);
192  fNuKE_kaon = tfs->make<TH1F>("NuKE_kaon","NuKE kaon",100,0,4000);
193  fNuKE_prot = tfs->make<TH1F>("NuKE_prot","NuKE proton",100,0,4000);
194 
195  fNuEP2_elec = tfs->make<TH1F>("NuEP2_elec","NuEP2 electron",50,0,1);
196  fNuEP2_muon = tfs->make<TH1F>("NuEP2_muon","NuEP2 muon",50,0,1);
197  fNuEP2_pion = tfs->make<TH1F>("NuEP2_pion","NuEP2 pion",50,0,1);
198  fNuEP2_kaon = tfs->make<TH1F>("NuEP2_kaon","NuEP2 kaon",50,0,1);
199  fNuEP2_prot = tfs->make<TH1F>("NuEP2_prot","NuEP2 proton",50,0,1);
200 
201  fNuE_elec = tfs->make<TH1F>("NuE_elec","Nu Efficiency electron",50,0,1);
202  fNuE_muon = tfs->make<TH1F>("NuE_muon","Nu Efficiency muon",50,0,1);
203  fNuE_pion = tfs->make<TH1F>("NuE_pion","Nu Efficiency pion",50,0,1);
204  fNuE_kaon = tfs->make<TH1F>("NuE_kaon","Nu Efficiency kaon",50,0,1);
205  fNuE_prot = tfs->make<TH1F>("NuE_prot","Nu Efficiency proton",50,0,1);
206 
207  fNuP_elec = tfs->make<TH1F>("NuP_elec","Nu Purity electron",50,0,1);
208  fNuP_muon = tfs->make<TH1F>("NuP_muon","Nu Purity muon",50,0,1);
209  fNuP_pion = tfs->make<TH1F>("NuP_pion","Nu Purity pion",50,0,1);
210  fNuP_kaon = tfs->make<TH1F>("NuP_kaon","Nu Purity kaon",50,0,1);
211  fNuP_prot = tfs->make<TH1F>("NuP_prot","Nu Purity proton",50,0,1);
212 
213  // True - Reco vertex difference
214  fNuVtx_dx = tfs->make<TH1F>("Vtx dx","Vtx dx",80,-10,10);
215  fNuVtx_dy = tfs->make<TH1F>("Vtx dy","Vtx dy",80,-10,10);
216  fNuVtx_dz = tfs->make<TH1F>("Vtx dz","Vtx dz",80,-10,10);
217 
218  fNuEP2_KE_elec = tfs->make<TProfile>("NuEP2_KE_elec","NuEP2 electron vs KE",200,0,2000);
219  fNuEP2_KE_muon = tfs->make<TProfile>("NuEP2_KE_muon","NuEP2 muon vs KE",200,0,2000);
220  fNuEP2_KE_pion = tfs->make<TProfile>("NuEP2_KE_pion","NuEP2 pion vs KE",200,0,2000);
221  fNuEP2_KE_kaon = tfs->make<TProfile>("NuEP2_KE_kaon","NuEP2 kaon vs KE",200,0,2000);
222  fNuEP2_KE_prot = tfs->make<TProfile>("NuEP2_KE_prot","NuEP2 proton vs KE",200,0,2000);
223 
224  }
T * make(ARGS...args) const
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

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

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDAnalyzer::currentContext ( ) const
protectedinherited

Definition at line 114 of file EDAnalyzer.cc.

References art::EDAnalyzer::current_context_.

Referenced by art::EDAnalyzer::workerType().

115  {
116  return current_context_.get();
117  }
CPC_exempt_ptr current_context_
Definition: EDAnalyzer.h:179
void cluster::ClusterAna::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 226 of file ClusterAna_module.cc.

References fPrintLevel, and outFile.

227  {
228  if(fPrintLevel == -1) outFile.close();
229  }
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

Referenced by art::OutputModule::doWriteEvent().

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:34
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

Referenced by art::RootOutputFile::writeOne().

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

std::string cluster::ClusterAna::fClusterModuleLabel
private

Definition at line 111 of file ClusterAna_module.cc.

Referenced by analyze(), and ClusterAna().

TH1F* cluster::ClusterAna::fCRE
private

Definition at line 75 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fCREP2
private

Definition at line 74 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fCRP
private

Definition at line 76 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

std::vector<float> cluster::ClusterAna::fElecKERange
private

Definition at line 113 of file ClusterAna_module.cc.

Referenced by analyze().

std::string cluster::ClusterAna::fHitsModuleLabel
private

Definition at line 110 of file ClusterAna_module.cc.

Referenced by analyze().

std::vector<float> cluster::ClusterAna::fKaonKERange
private

Definition at line 116 of file ClusterAna_module.cc.

Referenced by analyze().

bool cluster::ClusterAna::fMergeDaughters
private

Definition at line 119 of file ClusterAna_module.cc.

Referenced by analyze().

std::vector<float> cluster::ClusterAna::fMuonKERange
private

Definition at line 114 of file ClusterAna_module.cc.

Referenced by analyze().

TH1F* cluster::ClusterAna::fNClusters
private

Definition at line 71 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNHitInCluster
private

Definition at line 72 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuE_elec
private

Definition at line 89 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuE_kaon
private

Definition at line 92 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuE_muon
private

Definition at line 90 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuE_pion
private

Definition at line 91 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuE_prot
private

Definition at line 93 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuEP2_elec
private

Definition at line 84 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuEP2_kaon
private

Definition at line 87 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TProfile* cluster::ClusterAna::fNuEP2_KE_elec
private

Definition at line 104 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TProfile* cluster::ClusterAna::fNuEP2_KE_kaon
private

Definition at line 107 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TProfile* cluster::ClusterAna::fNuEP2_KE_muon
private

Definition at line 105 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TProfile* cluster::ClusterAna::fNuEP2_KE_pion
private

Definition at line 106 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TProfile* cluster::ClusterAna::fNuEP2_KE_prot
private

Definition at line 108 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuEP2_muon
private

Definition at line 85 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuEP2_pion
private

Definition at line 86 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuEP2_prot
private

Definition at line 88 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuKE_elec
private

Definition at line 78 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuKE_kaon
private

Definition at line 81 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuKE_muon
private

Definition at line 79 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuKE_pion
private

Definition at line 80 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuKE_prot
private

Definition at line 82 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuP_elec
private

Definition at line 94 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuP_kaon
private

Definition at line 97 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuP_muon
private

Definition at line 95 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuP_pion
private

Definition at line 96 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuP_prot
private

Definition at line 98 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuVtx_dx
private

Definition at line 100 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuVtx_dy
private

Definition at line 101 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* cluster::ClusterAna::fNuVtx_dz
private

Definition at line 102 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

std::vector<float> cluster::ClusterAna::fPionKERange
private

Definition at line 115 of file ClusterAna_module.cc.

Referenced by analyze().

short cluster::ClusterAna::fPrintLevel
private

Definition at line 122 of file ClusterAna_module.cc.

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

std::vector<float> cluster::ClusterAna::fProtKERange
private

Definition at line 117 of file ClusterAna_module.cc.

Referenced by analyze().

bool cluster::ClusterAna::fSkipCosmics
private

Definition at line 121 of file ClusterAna_module.cc.

Referenced by analyze(), and beginJob().

short cluster::ClusterAna::fTrackWeightOption
private

Definition at line 118 of file ClusterAna_module.cc.

Referenced by analyze().

std::string cluster::ClusterAna::fVertexModuleLabel
private

Definition at line 112 of file ClusterAna_module.cc.

Referenced by analyze().

short cluster::ClusterAna::moduleID
private

Definition at line 123 of file ClusterAna_module.cc.

Referenced by analyze(), and ClusterAna().

std::ofstream cluster::ClusterAna::outFile
private

Definition at line 125 of file ClusterAna_module.cc.

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


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