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

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 NuShowerEff (fhicl::ParameterSet const &p)
 
 NuShowerEff (NuShowerEff const &)=delete
 
 NuShowerEff (NuShowerEff &&)=delete
 
NuShowerEffoperator= (NuShowerEff const &)=delete
 
NuShowerEffoperator= (NuShowerEff &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
void beginRun (art::Run const &run) override
 
void doEfficiencies ()
 
bool insideFV (double vertex[4])
 
void reset ()
 
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

std::string fMCTruthModuleLabel
 
std::string fHitModuleLabel
 
std::string fShowerModuleLabel
 
std::string fTruthMatchDataModuleLabel
 
int fNeutrinoPDGcode
 
int fLeptonPDGcode
 
bool fSaveMCTree
 
bool fHitShowerThroughPFParticle
 
double fMinPurity
 
double fMinCompleteness
 
float fFidVolCutX
 
float fFidVolCutY
 
float fFidVolCutZ
 
float fFidVolXmin
 
float fFidVolXmax
 
float fFidVolYmin
 
float fFidVolYmax
 
float fFidVolZmin
 
float fFidVolZmax
 
int Event
 
int Run
 
int SubRun
 
int MC_incoming_PDG
 
int MC_lepton_PDG
 
int MC_isCC
 
int MC_channel
 
int MC_target
 
double MC_Q2
 
double MC_W
 
double MC_vertex [4]
 
double MC_incoming_P [4]
 
double MC_lepton_startMomentum [4]
 
double MC_lepton_endMomentum [40]
 
double MC_lepton_startXYZT [4]
 
double MC_lepton_endXYZT [4]
 
double MC_lepton_theta
 
int MC_leptonID
 
int MC_LeptonTrack
 
double MC_incoming_E
 
double MC_lepton_startEnergy
 
int n_recoShowers
 
double sh_direction_X [MAX_SHOWERS]
 
double sh_direction_Y [MAX_SHOWERS]
 
double sh_direction_Z [MAX_SHOWERS]
 
double sh_start_X [MAX_SHOWERS]
 
double sh_start_Y [MAX_SHOWERS]
 
double sh_start_Z [MAX_SHOWERS]
 
double sh_length [MAX_SHOWERS]
 
double sh_ehit_Q [MAX_SHOWERS]
 
int sh_TrackId [MAX_SHOWERS]
 
int sh_hasPrimary_e [MAX_SHOWERS]
 
double sh_allhit_Q [MAX_SHOWERS]
 
double sh_purity [MAX_SHOWERS]
 
double sh_completeness [MAX_SHOWERS]
 
double esh_1_purity
 
double esh_1_completeness
 
double esh_each_purity [MAX_SHOWERS]
 
double esh_each_completeness [MAX_SHOWERS]
 
double esh_purity
 
double esh_completeness
 
int count_primary_e_in_Event
 
TTree * fEventTree
 
TH1D * h_Ev_den
 
TH1D * h_Ev_num
 
TH1D * h_Ee_den
 
TH1D * h_Ee_num
 
TEfficiency * h_Eff_Ev = 0
 
TEfficiency * h_Eff_Ee = 0
 

Detailed Description

Definition at line 65 of file NuShowerEff_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

NuShowerEff::NuShowerEff ( fhicl::ParameterSet const &  p)
explicit

Definition at line 182 of file NuShowerEff_module.cc.

References std::get().

183  :
184  EDAnalyzer(p), // ,
185  // More initializers here.
186  //fMCTruthModuleLabel (p.get< std::string >("MCTruthModuleLabel", "generator")),
187  fMCTruthModuleLabel (p.get< std::string >("MCTruthModuleLabel")),// get parameter from fcl file
188  fHitModuleLabel (p.get< std::string >("HitModuleLabel")),
189  fShowerModuleLabel (p.get< std::string >("ShowerModuleLabel")),
190  fTruthMatchDataModuleLabel (p.get< std::string >("TruthMatchDataModuleLabel")),
191  fNeutrinoPDGcode (p.get<int>("NeutrinoPDGcode")),
192  fLeptonPDGcode (p.get<int>("LeptonPDGcode")),
193  fSaveMCTree (p.get<bool>("SaveMCTree")),
194  fHitShowerThroughPFParticle (p.get<bool>("HitShowerThroughPFParticle")),
195  fMinPurity (p.get<double>("MinPurity")),
196  fMinCompleteness (p.get<double>("MinCompleteness")),
197  fFidVolCutX (p.get<float>("FidVolCutX")),
198  fFidVolCutY (p.get<float>("FidVolCutY")),
199  fFidVolCutZ (p.get<float>("FidVolCutZ"))
200 {
201  //cout << "\n===== Please refer the fchicl for the values of preset parameters ====\n" << endl;
202 }
std::string fMCTruthModuleLabel
bool fHitShowerThroughPFParticle
std::string fShowerModuleLabel
std::string fHitModuleLabel
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::string fTruthMatchDataModuleLabel
NuShowerEff::NuShowerEff ( NuShowerEff const &  )
delete
NuShowerEff::NuShowerEff ( NuShowerEff &&  )
delete

Member Function Documentation

void NuShowerEff::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 301 of file NuShowerEff_module.cc.

References sim::ParticleList::begin(), simb::MCNeutrino::CCNC(), count_primary_e_in_Event, art::FindManyP< ProdB, Data >::data(), recob::Shower::Direction(), sim::ParticleList::end(), simb::MCParticle::EndMomentum(), simb::MCParticle::EndPosition(), energy, esh_1_completeness, esh_1_purity, esh_completeness, esh_each_completeness, esh_each_purity, esh_purity, art::EventID::event(), Event, fEventTree, fHitModuleLabel, fHitShowerThroughPFParticle, art::fill_ptr_vector(), fLeptonPDGcode, fMCTruthModuleLabel, fMinCompleteness, fMinPurity, fNeutrinoPDGcode, fSaveMCTree, fShowerModuleLabel, fTruthMatchDataModuleLabel, art::DataViewImpl::getByLabel(), simb::MCTruth::GetNeutrino(), h_Ee_den, h_Ee_num, h_Ev_den, h_Ev_num, hits(), art::Event::id(), insideFV(), recob::Hit::Integral(), simb::MCNeutrino::InteractionType(), simb::kBeamNeutrino, art::Ptr< T >::key(), recob::Shower::Length(), simb::MCNeutrino::Lepton(), MC_channel, MC_incoming_E, MC_incoming_P, MC_incoming_PDG, MC_isCC, MC_lepton_endMomentum, MC_lepton_endXYZT, MC_lepton_PDG, MC_lepton_startEnergy, MC_lepton_startMomentum, MC_lepton_startXYZT, MC_leptonID, MC_Q2, MC_target, MC_vertex, MC_W, simb::MCParticle::Momentum(), simb::MCParticle::Mother(), n_recoShowers, simb::MCTruth::NeutrinoSet(), simb::MCNeutrino::Nu(), cheat::ParticleInventoryService::ParticleList(), cheat::ParticleInventoryService::ParticleToMCTruth_P(), simb::MCParticle::PdgCode(), util::pi(), simb::MCParticle::Position(), simb::MCNeutrino::QSqr(), reset(), art::Event::run(), Run, sh_allhit_Q, sh_completeness, sh_direction_X, sh_direction_Y, sh_direction_Z, sh_ehit_Q, sh_hasPrimary_e, sh_length, sh_purity, sh_start_X, sh_start_Y, sh_start_Z, sh_TrackId, recob::Shower::ShowerStart(), art::Event::subRun(), SubRun, simb::MCNeutrino::Target(), simb::MCParticle::TrackId(), cheat::ParticleInventoryService::TrackIdToMotherParticle_P(), cheat::ParticleInventoryService::TrackIdToParticle_P(), and simb::MCNeutrino::W().

302 {
303  // Implementation of required member function here.
304  //cout << "\n===== function: analyze() =====\n" << endl;
305 
306  reset(); // for some variables
307 
308  Event = e.id().event();
309  Run = e.run();
310  SubRun = e.subRun();
311  //cout << "Event information:" << endl;
312  //cout << "\tEvent: " << Event << endl;
313  //cout << "\tRun: " << Run << endl;
314  //cout << "\tSubRun: " << SubRun << endl;
315 
316 
317  // -------- find Geant4 TrackId that corresponds to e+/e- from neutrino interaction ----------
318  // MCTruth: Generator
320  e.getByLabel(fMCTruthModuleLabel, MCtruthHandle);
321  std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
322  art::fill_ptr_vector(MCtruthlist, MCtruthHandle);
323  art::Ptr<simb::MCTruth> MCtruth;
324  // MC (neutrino) interaction
325  int MCinteractions = MCtruthlist.size();
326  //cout << "\nMCinteractions: " << MCinteractions << endl;
327  for (int i=0; i<MCinteractions; i++){
328  MCtruth = MCtruthlist[i];
329  if ( MCtruth->NeutrinoSet() ) { // NeutrinoSet(): whether the neutrino information has been set
330  simb::MCNeutrino nu = MCtruth->GetNeutrino();// GetNeutrino(): reference to neutrino info
331  if( nu.CCNC()==0 ) MC_isCC = 1;
332  else if (nu.CCNC()==1) MC_isCC = 0;
333  simb::MCParticle neutrino = nu.Nu(); // Nu(): the incoming neutrino
334  MC_target = nu.Target(); // Target(): nuclear target, as PDG code
335  MC_incoming_PDG = std::abs(nu.Nu().PdgCode());// here not use std::abs()
336  MC_Q2 = nu.QSqr();// QSqr(): momentum transfer Q^2, in GeV^2
337  MC_channel = nu.InteractionType();// 1001: CCQE
338  MC_W = nu.W(); // W(): hadronic invariant mass
339  const TLorentzVector& nu_momentum = nu.Nu().Momentum(0);
340  nu_momentum.GetXYZT(MC_incoming_P);
341  const TLorentzVector& vertex =neutrino.Position(0);
342  vertex.GetXYZT(MC_vertex);
343  simb::MCParticle lepton = nu.Lepton();// Lepton(): the outgoing lepton
344  MC_lepton_PDG = lepton.PdgCode();
345 
347 
348  //cout << "\tMCinteraction: " << i << "\n\t"
349  // << "neutrino PDG: " << MC_incoming_PDG << "\n\t"
350  // << "MC_lepton_PDG: " << MC_lepton_PDG << "\n\t"
351  // << "MC_channel: " << MC_channel << "\n\t"
352  // << "incoming E: " << MC_incoming_P[3] << "\n\t"
353  // << "MC_vertex: " << MC_vertex[0] << " , " << MC_vertex[1] << " , " <<MC_vertex[2] << " , " <<MC_vertex[3] << endl;
354  }
355  // MCTruth Generator Particles
356  int nParticles = MCtruthlist[0]->NParticles();
357  //cout << "\n\tNparticles: " << MCtruth->NParticles() <<endl;
358  for (int i=0; i<nParticles; i++){
359  simb::MCParticle pi = MCtruthlist[0]->GetParticle(i);
360  //cout << "\tparticle: " << i << "\n\t\t"
361  //<< "Pdgcode: " << pi.PdgCode() << "; Mother: " << pi.Mother() << "; TrackId: " << pi.TrackId() << endl;
362  // Mother(): mother = -1 means that this particle has no mother
363  // TrackId(): same as the index in the MCParticleList
364  }
365  }
366 
367  // Geant4: MCParticle -> lepton (e)
368  // Note: generator level MCPartilceList is different from Geant4 level MCParticleList. MCParticleList(Geant4) contains all particles in MCParticleList(generator) but their the indexes (TrackIds) are different.
369  simb::MCParticle *MClepton = NULL; //Geant4 level
371  const sim::ParticleList& plist = pi_serv->ParticleList();
372  simb::MCParticle *particle=0;
373 
374  for (sim::ParticleList::const_iterator ipar = plist.begin(); ipar!=plist.end();++ipar){
375  particle = ipar->second; // first is index(TrackId), second is value (point address)
376 
377  auto & truth = pi_serv->ParticleToMCTruth_P(particle);// beam neutrino only
378  if ( truth->Origin()==simb::kBeamNeutrino && std::abs(particle->PdgCode()) == fLeptonPDGcode && particle->Mother()==0){ // primary lepton; Mother() = 0 means e^{-} for v+n=e^{-}+p
379  const TLorentzVector& lepton_momentum =particle->Momentum(0);
380  const TLorentzVector& lepton_position =particle->Position(0);
381  const TLorentzVector& lepton_positionEnd = particle->EndPosition();
382  const TLorentzVector& lepton_momentumEnd = particle->EndMomentum();
383  lepton_momentum.GetXYZT(MC_lepton_startMomentum);
384  lepton_position.GetXYZT(MC_lepton_startXYZT);
385  lepton_positionEnd.GetXYZT(MC_lepton_endXYZT);
386  lepton_momentumEnd.GetXYZT(MC_lepton_endMomentum);
387  MC_leptonID = particle->TrackId();
388 
390  //cout << "\nGeant Track ID for electron/positron: " << endl;
391  //cout << "\tMClepton PDG: " << particle->PdgCode() << " ; MC_leptonID: " << MC_leptonID << endl;
392  MClepton = particle;
393  //cout << "\tMClepton PDG:" << MClepton->PdgCode() <<endl;
394  //cout << "\tipar->first (TrackId): " << ipar->first << endl;
395  }
396  }
397 
398  // check if the interaction is inside the Fiducial Volume
399  bool isFiducial = false;
400  isFiducial = insideFV( MC_vertex);
401  if (isFiducial) {
402  //cout <<"\nInfo: Interaction is inside the Fiducial Volume.\n" << endl;
403  }
404  else {
405  //cout << "\n********Interaction is NOT inside the Fiducial Volume. RETURN**********" << endl;
406  return;
407  }
408 
409  if (MC_isCC && (fNeutrinoPDGcode == std::abs(MC_incoming_PDG))) {
410  if (MClepton){
411  h_Ev_den->Fill(MC_incoming_P[3]);
413  }
414  }
415 
416  //if (MC_isCC && (fNeutrinoPDGcode == std::abs(MC_incoming_PDG)) && MC_incoming_E < 0.5) {
417  // cout << "\n------output CC event info for neutrino energy less than 0.5 GeV ------\n" << endl;
418  // cout << "\tEvent : " << Event << "\n"
419  // << "\tRun : " << Run << "\n"
420  // << "\tSubRun : " << SubRun << "\n"
421  // << "\tMC_incoming_E: " << MC_incoming_E << endl;
422  // }
423 
424  // recob::Hit
425  // ---- build a map for total hit charges corresponding to MC_leptonID (Geant4) ----
426 
428  std::vector<art::Ptr<recob::Hit>> all_hits;
429  if(e.getByLabel(fHitModuleLabel,hitHandle)){
430  art::fill_ptr_vector(all_hits, hitHandle);
431  }
432  //cout << "\nTotal hits:" << endl;
433  //cout << "\tall_hits.size(): " << all_hits.size() << endl;
434 
435  double ehit_total =0.0;
436 
437  art::FindManyP<simb::MCParticle,anab::BackTrackerHitMatchingData> fmhitmc(hitHandle, e, fTruthMatchDataModuleLabel);// need #include "lardataobj/AnalysisBase/BackTrackerMatchingData.h"
438 
439  std::map<int,double> all_hits_trk_Q;//Q for charge: Integral()
440  for (size_t i=0; i < all_hits.size(); ++i) {
441  art::Ptr<recob::Hit> hit = all_hits[i];
442  auto particles = fmhitmc.at(hit.key());// particles here is a pointer. A hit may come from multiple particles.
443  auto hitmatch = fmhitmc.data(hit.key());// metadata
444  double maxenergy = -1e9;
445  int hit_TrackId = 0;
446  for (size_t j = 0; j < particles.size(); ++j){
447  if (!particles[j]) continue;
448  if (!pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId())) continue;
449  size_t trkid = (pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))->TrackId();
450 
451  if ( (hitmatch[j]->energy) > maxenergy ){
452  maxenergy = hitmatch[j]->energy;
453  hit_TrackId = trkid;
454  }
455  }
456  if (hit_TrackId == MC_leptonID) ehit_total += hit->Integral();
457  all_hits_trk_Q[hit_TrackId] += hit->Integral(); // Integral(): the integral under the calibrated signal waveform of the hit, in tick x ADC units
458  }
459  //cout << "....ehit_total: " << ehit_total << endl;
460  //cout << "\tall_hits_trk_Q.size(): " << all_hits_trk_Q.size() << endl;
461 
462 
463  //--------- Loop over all showers: find the associated hits for each shower ------------
464  const simb::MCParticle *MClepton_reco = NULL;
465 
466  double temp_sh_ehit_Q = 0.0;
467  double temp_sh_allHit_Q = 0.0;
468  int temp_sh_TrackId = -999;
470 
472  std::vector<art::Ptr<recob::Shower>> showerlist;
473  if(e.getByLabel(fShowerModuleLabel,showerHandle)){
474  art::fill_ptr_vector(showerlist, showerHandle);
475  }
476  n_recoShowers= showerlist.size();
477  //cout << "\nRecon Showers: " << endl;
478  //cout << "\tn_recoShowers: " << n_recoShowers << endl;
479  art::FindManyP<recob::Hit> sh_hitsAll(showerHandle, e, fShowerModuleLabel);
480 
481  //std::vector<std::map<int,double>> showers_hits_trk_Q;
482  std::map<int,double> showers_trk_Q;
483  for (int i=0; i<n_recoShowers;i++){ // loop over showers
484  //const simb::MCParticle *particle;
485  sh_hasPrimary_e[i] = 0;
486 
487  std::map<int,double> sh_hits_trk_Q;//Q for charge: Integral()
488  sh_hits_trk_Q.clear();
489 
490  art::Ptr<recob::Shower> shower = showerlist[i];
491  sh_direction_X[i] = shower->Direction().X(); // Direction(): direction cosines at start of the shower
492  sh_direction_Y[i] = shower->Direction().Y();
493  sh_direction_Z[i] = shower->Direction().Z();
494  sh_start_X[i] = shower->ShowerStart().X();
495  sh_start_Y[i] = shower->ShowerStart().Y();
496  sh_start_Z[i] = shower->ShowerStart().Z();
497  sh_length[i] = shower->Length(); // shower length in [cm]
498  //cout << "\tInfo of shower " << i << "\n\t\t"
499  //<< "direction (cosines): " << sh_direction_X[i] << ", " << sh_direction_Y[i] << ", " << sh_start_Z[i] << "\n\t\t"
500  //<< "start position: " << sh_start_X[i] << ", " << sh_start_Y[i] << ", " << sh_start_Z[i] << "\n\t\t"
501  //<< "shower length: " << sh_length[i] << endl;
502 
503 
504  std::vector<art::Ptr<recob::Hit>> sh_hits;// associated hits for ith shower
505  //In mcc8, if we get hits associated with the shower through shower->hits association directly for pandora, the hit list is incomplete. The recommended way of getting hits is through association with pfparticle:
506  //shower->pfparticle->clusters->hits
507  //----------getting hits through PFParticle (an option here)-------------------
509  //cout << "\n==== Getting Hits associated with shower THROUGH PFParticle ====\n" << endl;
510  //cout << "\nHits in a shower through PFParticle:\n" << endl;
511 
512  // PFParticle
514  std::vector<art::Ptr<recob::PFParticle> > pfps;
515  if (e.getByLabel(fShowerModuleLabel, pfpHandle)) art::fill_ptr_vector(pfps, pfpHandle);
516  // Clusters
518  std::vector<art::Ptr<recob::Cluster> > clusters;
519  if (e.getByLabel(fShowerModuleLabel, clusterHandle)) art::fill_ptr_vector(clusters, clusterHandle);
520  art::FindManyP<recob::PFParticle> fmps(showerHandle, e, fShowerModuleLabel);// PFParticle in Shower
521  art::FindManyP<recob::Cluster> fmcp(pfpHandle, e, fShowerModuleLabel); // Cluster vs. PFParticle
522  art::FindManyP<recob::Hit> fmhc(clusterHandle, e, fShowerModuleLabel); // Hit in Shower
523  if (fmps.isValid()){
524  std::vector<art::Ptr<recob::PFParticle>> pfs = fmps.at(i);
525  for (size_t ipf = 0; ipf<pfs.size(); ++ipf){
526  if (fmcp.isValid()){
527  std::vector<art::Ptr<recob::Cluster>> clus = fmcp.at(pfs[ipf].key());
528  for (size_t iclu = 0; iclu<clus.size(); ++iclu){
529  if (fmhc.isValid()){
530  std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(clus[iclu].key());
531  for (size_t ihit = 0; ihit<hits.size(); ++ihit){
532  sh_hits.push_back(hits[ihit]);
533  }
534  }
535  }
536  }
537  }
538  }
539 
540  // cout << "\tsh_hits.size(): " << sh_hits.size() << endl;
541 
542  // for (size_t k=0;k<sh_hits.size();k++){
543  // art::Ptr<recob::Hit> hit = sh_hits[k];
544  // cout << k << "\thit.key(): " << hit.key() << endl;
545  // cout << k << "\thit->Integral(): " << hit->Integral() << endl;
546  // }
547  } else {
548 
549  // ----- using shower->hit association for getting hits associated with shower-----
550  sh_hits = sh_hitsAll.at(i);// associated hits for ith shower (using association of hits and shower)
551  //cout << "\t\tsh_hits.size(): " << sh_hits.size() << endl;
552  } // we only choose one method for hits associated with shower here.
553 
554 
555  for (size_t k=0; k < sh_hits.size(); ++k) {
556  art::Ptr<recob::Hit> hit = sh_hits[k];
557  auto particles = fmhitmc.at(hit.key());
558  auto hitmatch = fmhitmc.data(hit.key());
559  double maxenergy = -1e9;
560  int hit_TrackId = 0;
561  for (size_t j = 0; j < particles.size(); ++j){
562  if (!particles[j]) continue;
563  if (!pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId())) continue;
564  size_t trkid = (pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))->TrackId();
565 
566  if ( (hitmatch[j]->energy) > maxenergy ){
567  maxenergy = hitmatch[j]->energy;
568  hit_TrackId = trkid;
569  }
570  }
571  if (hit_TrackId == MC_leptonID) {
572  sh_ehit_Q[i] += hit->Integral();
573  }
574  sh_allhit_Q[i] += hit->Integral();
575  sh_hits_trk_Q[hit_TrackId] += hit->Integral();// Q from the same hit_TrackId
576  }
577  //cout << "\tsh_hits_trk_Q.size(): " << sh_hits_trk_Q.size() << endl;
578  //showers_hits_trk_Q.push_back(sh_hits_trk_Q);
579 
580  // get TrackId for a shower
581  double maxshowerQ = -1.0e9;
582  //sh_TrackId[i] = 0;
583  for(std::map<int,double>::iterator k = sh_hits_trk_Q.begin(); k != sh_hits_trk_Q.end(); k++) {
584  //cout << k->first << "\t;\t" << k->second << endl;
585  if (k->second > maxshowerQ) {
586  maxshowerQ = k->second;
587  sh_TrackId[i] = k->first;//assign a sh_TrackId with TrackId from hit(particle) that contributing largest to the shower.
588  }
589  }
590 
591  //---------------------------------------------------------------------------------
592  //cout << "\nRecon Shower: " << i << endl;
593  //cout << "\t*****shower primary TrackId: " << sh_TrackId[i] << endl;
594 
595  if (sh_TrackId[i] == MC_leptonID && sh_ehit_Q[i] >0) {
596  temp_sh_TrackId = sh_TrackId[i];
597  sh_hasPrimary_e[i] = 1;
599  MClepton_reco = pi_serv->TrackIdToParticle_P(sh_TrackId[i]);
600 
601  if (sh_allhit_Q[i] >0 && sh_ehit_Q[i] <= sh_allhit_Q[i]){
602  sh_purity[i] = sh_ehit_Q[i]/sh_allhit_Q[i];
603  //cout << "\t*****shower purity: " << sh_purity[i] << endl;
604  } else {
605  sh_purity[i] = 0;
606  }
607  if(ehit_total >0 && sh_ehit_Q[i] <= sh_allhit_Q[i]){
608  sh_completeness[i] = sh_ehit_Q[i] / ehit_total;
609  //cout << "\t*****shower completeness: " << sh_completeness[i] << endl;
610  } else {
611  sh_completeness[i] = 0;
612  }
613  temp_sh_ehit_Q += sh_ehit_Q[i];
614  temp_sh_allHit_Q += sh_allhit_Q[i];
615  }
616 
617  showers_trk_Q[sh_TrackId[i]] += maxshowerQ;
618  //cout << "\tsh_TrackId: " << sh_TrackId[i] <<" ; maxshowerQ: " << maxshowerQ << endl;
619 
620  } // end: for loop over showers
621 
622  // ---------------------------------------------------------------
623  if (MClepton_reco && MClepton) {
624  if ((temp_sh_TrackId == MC_leptonID) && MC_isCC && (fNeutrinoPDGcode == std::abs(MC_incoming_PDG))) {
625  if ((temp_sh_allHit_Q >= temp_sh_ehit_Q) && (temp_sh_ehit_Q > 0.0)) {
626  esh_purity = temp_sh_ehit_Q/temp_sh_allHit_Q;
627  esh_completeness = temp_sh_ehit_Q/ehit_total;
628 
629  if (esh_purity > fMinPurity &&
631  //cout << "\nInfo: fill h_Ev_num ........\n" << endl;
632  h_Ev_num->Fill(MC_incoming_P[3]);
634  }
635  }
636  }
637  }
638  // --------------------------------------------------------------
639 
640  if ( (MClepton_reco && MClepton) && MC_isCC && (fNeutrinoPDGcode == std::abs(MC_incoming_PDG))){
641  //cout << "\n count_primary_e_in_Event: " << count_primary_e_in_Event << endl;
642  for (int j=0; j<count_primary_e_in_Event; j++){
643  esh_each_purity[j] = 0.0;
644  }
645 
646  double temp_esh_1_allhit = -1.0e9;
647  int temp_shower_index = -999;
648  int temp_esh_index = 0;
649  for (int i=0; i<n_recoShowers; i++) {
650  if (sh_TrackId[i] == MC_leptonID) {
651 
652  // for each electron shower
653  if (sh_ehit_Q[i] >0){
654  esh_each_purity[temp_esh_index] = sh_purity[i];
655  esh_each_completeness[temp_esh_index] = sh_completeness[i];
656  temp_esh_index += 1;
657  }
658 
659  // find largest shower
660  if ((sh_allhit_Q[i] > temp_esh_1_allhit) && (sh_ehit_Q[i] > 0.0) ) {
661  temp_esh_1_allhit = sh_allhit_Q[i];
662  temp_shower_index = i;
663  }
664  }
665  }
666  //if (temp_esh_index != count_primary_e_in_Event){
667  // cout << "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" << endl;
668  //}
669  // largest shower with electron contribution
670  esh_1_purity = sh_purity[temp_shower_index];
671  esh_1_completeness = sh_completeness[temp_shower_index];
672  }
673 
674  if (count_primary_e_in_Event>0 && MC_isCC && fSaveMCTree) { fEventTree->Fill();}// so far, only save CC event
675 }
key_type key() const
Definition: Ptr.h:356
double esh_each_purity[MAX_SHOWERS]
double sh_direction_X[MAX_SHOWERS]
const simb::MCParticle * TrackIdToParticle_P(int const &id)
const TVector3 & ShowerStart() const
Definition: Shower.h:192
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:223
int PdgCode() const
Definition: MCParticle.h:216
int CCNC() const
Definition: MCNeutrino.h:152
double QSqr() const
Definition: MCNeutrino.h:161
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:74
double MC_lepton_startEnergy
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:229
double Length() const
Definition: Shower.h:201
intermediate_table::iterator iterator
double sh_start_Y[MAX_SHOWERS]
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
double sh_direction_Y[MAX_SHOWERS]
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p)
std::string fMCTruthModuleLabel
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:225
double MC_lepton_startMomentum[4]
int TrackId() const
Definition: MCParticle.h:214
bool fHitShowerThroughPFParticle
int sh_TrackId[MAX_SHOWERS]
std::string fShowerModuleLabel
int InteractionType() const
Definition: MCNeutrino.h:154
void hits()
Definition: readHits.C:15
const simb::MCParticle & Lepton() const
Definition: MCNeutrino.h:151
double W() const
Definition: MCNeutrino.h:158
std::string fHitModuleLabel
double esh_each_completeness[MAX_SHOWERS]
int sh_hasPrimary_e[MAX_SHOWERS]
bool insideFV(double vertex[4])
double energy
Definition: plottest35.C:25
iterator begin()
Definition: ParticleList.h:305
const TVector3 & Direction() const
Definition: Shower.h:189
double sh_start_Z[MAX_SHOWERS]
double sh_purity[MAX_SHOWERS]
Detector simulation of raw signals on wires.
double sh_ehit_Q[MAX_SHOWERS]
double MC_lepton_startXYZT[4]
double MC_lepton_endXYZT[4]
double sh_direction_Z[MAX_SHOWERS]
int Target() const
Definition: MCNeutrino.h:155
double sh_completeness[MAX_SHOWERS]
double MC_lepton_endMomentum[40]
double sh_allhit_Q[MAX_SHOWERS]
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:224
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
std::string fTruthMatchDataModuleLabel
bool NeutrinoSet() const
Definition: MCTruth.h:75
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
const simb::MCParticle * TrackIdToMotherParticle_P(int const &id)
Float_t e
Definition: plot.C:34
Event generator information.
Definition: MCNeutrino.h:18
double sh_start_X[MAX_SHOWERS]
const TLorentzVector & EndMomentum() const
Definition: MCParticle.h:244
double MC_incoming_P[4]
double sh_length[MAX_SHOWERS]
Beam neutrinos.
Definition: MCTruth.h:21
vertex reconstruction
void NuShowerEff::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 205 of file NuShowerEff_module.cc.

References count_primary_e_in_Event, esh_1_completeness, esh_1_purity, esh_completeness, esh_each_completeness, esh_each_purity, esh_purity, Event, fEventTree, fFidVolCutX, fFidVolCutY, fFidVolCutZ, fFidVolXmax, fFidVolXmin, fFidVolYmax, fFidVolYmin, fFidVolZmax, fFidVolZmin, fSaveMCTree, h_Ee_den, h_Ee_num, h_Ev_den, h_Ev_num, geo::TPCGeo::LocalToWorld(), art::TFileDirectory::make(), MC_incoming_E, MC_lepton_startEnergy, n_recoShowers, Run, sh_hasPrimary_e, and SubRun.

205  {
206  //cout << "\n===== function: beginJob() ====\n" << endl;
207 
208  // Get geometry: Fiducial Volume
209  auto const* geo = lar::providerFrom<geo::Geometry>();
210  double minx = 1e9; // [cm]
211  double maxx = -1e9;
212  double miny = 1e9;
213  double maxy = -1e9;
214  double minz = 1e9;
215  double maxz = -1e9;
216  //cout << "\nGeometry:\n\tgeo->NTPC(): " << geo->NTPC() << endl;
217  for (size_t i = 0; i<geo->NTPC(); ++i){
218  double local[3] = {0.,0.,0.};
219  double world[3] = {0.,0.,0.};
220  const geo::TPCGeo &tpc = geo->TPC(i);
221  tpc.LocalToWorld(local,world);
222  //cout << "\tlocal: " << local[0] << " ; " << local[1] << " ; " << local[2] << endl;
223  //cout << "\tworld: " << world[0] << " ; " << world[1] << " ; " << world[2] << endl;
224  //cout << "\tgeo->DetHalfWidth(" << i << "): " << geo->DetHalfWidth(i) << endl;
225  //cout << "\tgeo->DetHalfHeight(" << i << "): " << geo->DetHalfHeight(i) << endl;
226  //cout << "\tgeo->DetLength(" << i << "): " << geo->DetLength(i) << endl;
227 
228  if (minx > world[0] - geo->DetHalfWidth(i)) minx = world[0]-geo->DetHalfWidth(i);
229  if (maxx < world[0] + geo->DetHalfWidth(i)) maxx = world[0]+geo->DetHalfWidth(i);
230  if (miny > world[1] - geo->DetHalfHeight(i)) miny = world[1]-geo->DetHalfHeight(i);
231  if (maxy < world[1] + geo->DetHalfHeight(i)) maxy = world[1]+geo->DetHalfHeight(i);
232  if (minz > world[2] - geo->DetLength(i)/2.) minz = world[2]-geo->DetLength(i)/2.;
233  if (maxz < world[2] + geo->DetLength(i)/2.) maxz = world[2]+geo->DetLength(i)/2.;
234  }
235 
236  fFidVolXmin = minx + fFidVolCutX;
237  fFidVolXmax = maxx - fFidVolCutX;
238  fFidVolYmin = miny + fFidVolCutY;
239  fFidVolYmax = maxy - fFidVolCutY;
240  fFidVolZmin = minz + fFidVolCutZ;
241  fFidVolZmax = maxz - fFidVolCutZ;
242 
243  //cout << "\nFiducial Volume (length unit: cm):\n"
244  //<< "\t" << fFidVolXmin<<"\t< x <\t"<<fFidVolXmax<<"\n"
245  //<< "\t" << fFidVolYmin<<"\t< y <\t"<<fFidVolYmax<<"\n"
246  //<< "\t" << fFidVolZmin<<"\t< z <\t"<<fFidVolZmax<<"\n";
247 
249 
250  double E_bins[21] = {0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4,4.5,5.0,5.5,6.0,7.0,8.0,10.0,12.0,14.0,17.0,20.0,25.0};
251 // double theta_bins[44]= { 0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,22.,24.,26.,28.,30.,32.,34.,36.,38.,40.,42.,44.,46.,48.,50.,55.,60.,65.,70.,75.,80.,85.,90.};
252  // double Pbins[18] ={0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.8,2.0,2.5,3.0};
253 
254  h_Ev_den = tfs->make<TH1D>("h_Ev_den", "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency", 20, E_bins);
255  h_Ev_den->Sumw2();
256  h_Ev_num = tfs->make<TH1D>("h_Ev_num","Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",20,E_bins);
257  h_Ev_num->Sumw2();
258 
259  h_Ee_den = tfs->make<TH1D>("h_Ee_den","Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",20,E_bins);
260  h_Ee_den->Sumw2();
261  h_Ee_num = tfs->make<TH1D>("h_Ee_num","Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",20,E_bins);
262  h_Ee_num->Sumw2();
263 
264  if (fSaveMCTree) {
265  fEventTree = new TTree("Event", "Event Tree from Sim & Reco");
266  fEventTree->Branch("eventNo", &Event); // only select event in FV
267  fEventTree->Branch("runNo", &Run);
268  fEventTree->Branch("subRunNo", &SubRun);
269 
270  fEventTree->Branch("MC_incoming_E", &MC_incoming_E);
271  fEventTree->Branch("MC_lepton_startEnergy", &MC_lepton_startEnergy);
272 
273  fEventTree->Branch("n_showers", &n_recoShowers);
274  fEventTree->Branch("sh_hasPrimary_e", &sh_hasPrimary_e, "sh_hasPrimary_e[n_showers]/I");
275  //fEventTree->Branch("sh_purity", &sh_purity, "sh_purity[n_showers]/D");
276  //fEventTree->Branch("sh_completeness", &sh_completeness, "sh_completeness[n_showers]/D");
277  fEventTree->Branch("count_primary_e_in_Event", &count_primary_e_in_Event);
278  fEventTree->Branch("esh_1_purity", &esh_1_purity);
279  fEventTree->Branch("esh_1_completeness", &esh_1_completeness);
280  fEventTree->Branch("esh_each_purity", &esh_each_purity, "esh_each_purity[count_primary_e_in_Event]/D");
281  fEventTree->Branch("esh_each_completeness", &esh_each_completeness, "esh_each_completeness[count_primary_e_in_Event]/D");
282  fEventTree->Branch("esh_purity", &esh_purity);
283  fEventTree->Branch("esh_completeness", &esh_completeness);
284  }
285 
286 }
double esh_each_purity[MAX_SHOWERS]
double MC_lepton_startEnergy
Geometry information for a single TPC.
Definition: TPCGeo.h:37
double esh_each_completeness[MAX_SHOWERS]
int sh_hasPrimary_e[MAX_SHOWERS]
T * make(ARGS...args) const
Namespace collecting geometry-related classes utilities.
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
Definition: TPCGeo.h:490
void NuShowerEff::beginRun ( art::Run const &  run)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 295 of file NuShowerEff_module.cc.

295  {
296  //cout << "\n===== function: beginRun() =====\n" << endl;
297  mf::LogInfo("ShowerEff") << "==== begin run ... ====" << endl;
298 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
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 NuShowerEff::doEfficiencies ( )

Definition at line 678 of file NuShowerEff_module.cc.

References h_Ee_den, h_Ee_num, h_Eff_Ee, h_Eff_Ev, h_Ev_den, h_Ev_num, and art::TFileDirectory::make().

Referenced by endJob().

678  {
679  //cout << "\n==== function: doEfficiencies() ====" << endl;
680 
682 
683  if(TEfficiency::CheckConsistency(*h_Ev_num,*h_Ev_den)){
684  h_Eff_Ev = tfs->make<TEfficiency>(*h_Ev_num,*h_Ev_den);
685  TGraphAsymmErrors *grEff_Ev = h_Eff_Ev->CreateGraph();
686  grEff_Ev->Write("grEff_Ev");
687  h_Eff_Ev->Write("h_Eff_Ev");
688  }
689 
690  if(TEfficiency::CheckConsistency(*h_Ee_num,*h_Ee_den)){
691  h_Eff_Ee = tfs->make<TEfficiency>(*h_Ee_num,*h_Ee_den);
692  TGraphAsymmErrors *grEff_Ee = h_Eff_Ee->CreateGraph();
693  grEff_Ee->Write("grEff_Ee");
694  h_Eff_Ee->Write("h_Eff_Ee");
695  }
696 
697 }
TEfficiency * h_Eff_Ee
TEfficiency * h_Eff_Ev
T * make(ARGS...args) const
void NuShowerEff::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 289 of file NuShowerEff_module.cc.

References doEfficiencies().

289  {
290  //cout << "\n===== function: endJob() =====\n" << endl;
291  doEfficiencies();
292 }
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
bool NuShowerEff::insideFV ( double  vertex[4])

Definition at line 700 of file NuShowerEff_module.cc.

References fFidVolXmax, fFidVolXmin, fFidVolYmax, fFidVolYmin, fFidVolZmax, fFidVolZmin, x, y, and z.

Referenced by analyze().

700  {
701  //cout << "\n==== function: insideFV() ====" << endl;
702  double x = vertex[0];
703  double y = vertex[1];
704  double z = vertex[2];
705 
706  if (x>fFidVolXmin && x<fFidVolXmax&&
707  y>fFidVolYmin && y<fFidVolYmax&&
708  z>fFidVolZmin && z<fFidVolZmax)
709  {return true;}
710  else
711  {return false;}
712 }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
vertex reconstruction
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  }
NuShowerEff& NuShowerEff::operator= ( NuShowerEff const &  )
delete
NuShowerEff& NuShowerEff::operator= ( NuShowerEff &&  )
delete
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  {}
void NuShowerEff::reset ( void  )

Definition at line 715 of file NuShowerEff_module.cc.

References DEFINE_ART_MODULE, MAX_SHOWERS, MC_channel, MC_incoming_PDG, MC_isCC, MC_lepton_PDG, MC_lepton_theta, MC_leptonID, MC_LeptonTrack, MC_Q2, MC_target, MC_W, sh_allhit_Q, sh_completeness, sh_direction_X, sh_direction_Y, sh_direction_Z, sh_ehit_Q, sh_hasPrimary_e, sh_length, sh_purity, sh_start_X, sh_start_Y, and sh_start_Z.

Referenced by analyze().

715  {
716  //cout << "\n===== function: reset() =====\n" << endl;
717 
718  MC_incoming_PDG = -999;
719  MC_lepton_PDG =-999;
720  MC_isCC =-999;
721  MC_channel =-999;
722  MC_target =-999;
723  MC_Q2 =-999.0;
724  MC_W =-999.0;
725  MC_lepton_theta = -999.0;
726  MC_leptonID = -999;
727  MC_LeptonTrack = -999;
728 
729  for(int i=0; i<MAX_SHOWERS; i++){
730  sh_direction_X[i] = -999.0;
731  sh_direction_Y[i] = -999.0;
732  sh_direction_Z[i] = -999.0;
733  sh_start_X[i] = -999.0;
734  sh_start_Y[i] = -999.0;
735  sh_start_Z[i] = -999.0;
736  sh_length[i] = -999.0;
737  sh_hasPrimary_e[i] = -999;
738  sh_ehit_Q[i] = 0.0;
739  sh_allhit_Q[i] = 0.0;
740  sh_purity[i] = 0.0;
741  sh_completeness[i] = 0.0;
742  }
743 
744 }
double sh_direction_X[MAX_SHOWERS]
double sh_start_Y[MAX_SHOWERS]
double sh_direction_Y[MAX_SHOWERS]
#define MAX_SHOWERS
int sh_hasPrimary_e[MAX_SHOWERS]
double sh_start_Z[MAX_SHOWERS]
double sh_purity[MAX_SHOWERS]
double sh_ehit_Q[MAX_SHOWERS]
double sh_direction_Z[MAX_SHOWERS]
double sh_completeness[MAX_SHOWERS]
double sh_allhit_Q[MAX_SHOWERS]
double sh_start_X[MAX_SHOWERS]
double sh_length[MAX_SHOWERS]
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

int NuShowerEff::count_primary_e_in_Event
private

Definition at line 164 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::esh_1_completeness
private

Definition at line 159 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::esh_1_purity
private

Definition at line 158 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::esh_completeness
private

Definition at line 163 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::esh_each_completeness[MAX_SHOWERS]
private

Definition at line 161 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::esh_each_purity[MAX_SHOWERS]
private

Definition at line 160 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::esh_purity
private

Definition at line 162 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

int NuShowerEff::Event
private

Definition at line 118 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

TTree* NuShowerEff::fEventTree
private

Definition at line 167 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

float NuShowerEff::fFidVolCutX
private

Definition at line 105 of file NuShowerEff_module.cc.

Referenced by beginJob().

float NuShowerEff::fFidVolCutY
private

Definition at line 106 of file NuShowerEff_module.cc.

Referenced by beginJob().

float NuShowerEff::fFidVolCutZ
private

Definition at line 107 of file NuShowerEff_module.cc.

Referenced by beginJob().

float NuShowerEff::fFidVolXmax
private

Definition at line 111 of file NuShowerEff_module.cc.

Referenced by beginJob(), and insideFV().

float NuShowerEff::fFidVolXmin
private

Definition at line 110 of file NuShowerEff_module.cc.

Referenced by beginJob(), and insideFV().

float NuShowerEff::fFidVolYmax
private

Definition at line 113 of file NuShowerEff_module.cc.

Referenced by beginJob(), and insideFV().

float NuShowerEff::fFidVolYmin
private

Definition at line 112 of file NuShowerEff_module.cc.

Referenced by beginJob(), and insideFV().

float NuShowerEff::fFidVolZmax
private

Definition at line 115 of file NuShowerEff_module.cc.

Referenced by beginJob(), and insideFV().

float NuShowerEff::fFidVolZmin
private

Definition at line 114 of file NuShowerEff_module.cc.

Referenced by beginJob(), and insideFV().

std::string NuShowerEff::fHitModuleLabel
private

Definition at line 94 of file NuShowerEff_module.cc.

Referenced by analyze().

bool NuShowerEff::fHitShowerThroughPFParticle
private

Definition at line 102 of file NuShowerEff_module.cc.

Referenced by analyze().

int NuShowerEff::fLeptonPDGcode
private

Definition at line 100 of file NuShowerEff_module.cc.

Referenced by analyze().

std::string NuShowerEff::fMCTruthModuleLabel
private

Definition at line 93 of file NuShowerEff_module.cc.

Referenced by analyze().

double NuShowerEff::fMinCompleteness
private

Definition at line 104 of file NuShowerEff_module.cc.

Referenced by analyze().

double NuShowerEff::fMinPurity
private

Definition at line 103 of file NuShowerEff_module.cc.

Referenced by analyze().

int NuShowerEff::fNeutrinoPDGcode
private

Definition at line 99 of file NuShowerEff_module.cc.

Referenced by analyze().

bool NuShowerEff::fSaveMCTree
private

Definition at line 101 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

std::string NuShowerEff::fShowerModuleLabel
private

Definition at line 95 of file NuShowerEff_module.cc.

Referenced by analyze().

std::string NuShowerEff::fTruthMatchDataModuleLabel
private

Definition at line 96 of file NuShowerEff_module.cc.

Referenced by analyze().

TH1D* NuShowerEff::h_Ee_den
private

Definition at line 172 of file NuShowerEff_module.cc.

Referenced by analyze(), beginJob(), and doEfficiencies().

TH1D* NuShowerEff::h_Ee_num
private

Definition at line 173 of file NuShowerEff_module.cc.

Referenced by analyze(), beginJob(), and doEfficiencies().

TEfficiency* NuShowerEff::h_Eff_Ee = 0
private

Definition at line 176 of file NuShowerEff_module.cc.

Referenced by doEfficiencies().

TEfficiency* NuShowerEff::h_Eff_Ev = 0
private

Definition at line 175 of file NuShowerEff_module.cc.

Referenced by doEfficiencies().

TH1D* NuShowerEff::h_Ev_den
private

Definition at line 169 of file NuShowerEff_module.cc.

Referenced by analyze(), beginJob(), and doEfficiencies().

TH1D* NuShowerEff::h_Ev_num
private

Definition at line 170 of file NuShowerEff_module.cc.

Referenced by analyze(), beginJob(), and doEfficiencies().

int NuShowerEff::MC_channel
private

Definition at line 126 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::MC_incoming_E
private

Definition at line 140 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::MC_incoming_P[4]
private

Definition at line 131 of file NuShowerEff_module.cc.

Referenced by analyze().

int NuShowerEff::MC_incoming_PDG
private

Definition at line 123 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

int NuShowerEff::MC_isCC
private

Definition at line 125 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::MC_lepton_endMomentum[40]
private

Definition at line 133 of file NuShowerEff_module.cc.

Referenced by analyze().

double NuShowerEff::MC_lepton_endXYZT[4]
private

Definition at line 135 of file NuShowerEff_module.cc.

Referenced by analyze().

int NuShowerEff::MC_lepton_PDG
private

Definition at line 124 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::MC_lepton_startEnergy
private

Definition at line 141 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::MC_lepton_startMomentum[4]
private

Definition at line 132 of file NuShowerEff_module.cc.

Referenced by analyze().

double NuShowerEff::MC_lepton_startXYZT[4]
private

Definition at line 134 of file NuShowerEff_module.cc.

Referenced by analyze().

double NuShowerEff::MC_lepton_theta
private

Definition at line 136 of file NuShowerEff_module.cc.

Referenced by reset().

int NuShowerEff::MC_leptonID
private

Definition at line 137 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

int NuShowerEff::MC_LeptonTrack
private

Definition at line 138 of file NuShowerEff_module.cc.

Referenced by reset().

double NuShowerEff::MC_Q2
private

Definition at line 128 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

int NuShowerEff::MC_target
private

Definition at line 127 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::MC_vertex[4]
private

Definition at line 130 of file NuShowerEff_module.cc.

Referenced by analyze().

double NuShowerEff::MC_W
private

Definition at line 129 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

int NuShowerEff::n_recoShowers
private

Definition at line 144 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

int NuShowerEff::Run
private

Definition at line 119 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().

double NuShowerEff::sh_allhit_Q[MAX_SHOWERS]
private

Definition at line 155 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_completeness[MAX_SHOWERS]
private

Definition at line 157 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_direction_X[MAX_SHOWERS]
private

Definition at line 145 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_direction_Y[MAX_SHOWERS]
private

Definition at line 146 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_direction_Z[MAX_SHOWERS]
private

Definition at line 147 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_ehit_Q[MAX_SHOWERS]
private

Definition at line 152 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

int NuShowerEff::sh_hasPrimary_e[MAX_SHOWERS]
private

Definition at line 154 of file NuShowerEff_module.cc.

Referenced by analyze(), beginJob(), and reset().

double NuShowerEff::sh_length[MAX_SHOWERS]
private

Definition at line 151 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_purity[MAX_SHOWERS]
private

Definition at line 156 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_start_X[MAX_SHOWERS]
private

Definition at line 148 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_start_Y[MAX_SHOWERS]
private

Definition at line 149 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

double NuShowerEff::sh_start_Z[MAX_SHOWERS]
private

Definition at line 150 of file NuShowerEff_module.cc.

Referenced by analyze(), and reset().

int NuShowerEff::sh_TrackId[MAX_SHOWERS]
private

Definition at line 153 of file NuShowerEff_module.cc.

Referenced by analyze().

int NuShowerEff::SubRun
private

Definition at line 120 of file NuShowerEff_module.cc.

Referenced by analyze(), and beginJob().


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