All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbnana/sbnanalysis/ana/SBNOscReco/CosmicIDAlgs/PandoraT0CosmicIdAlg.cc
Go to the documentation of this file.
1 #include "PandoraT0CosmicIdAlg.h"
2 
3 namespace ana{
4 
6 
7  this->reconfigure(config);
8 
9 }
10 
11 
13 
14 }
15 
16 
18 
19 }
20 
21 
23 
24  fPandoraLabel = config.PandoraLabel();
26  fBeamTimeMin = config.BeamTimeLimits().BeamTimeMin();
27  fBeamTimeMax = config.BeamTimeLimits().BeamTimeMax();
28 
29  return;
30 }
31 
32 // Finds any t0s associated with track by pandora, tags if outside beam
34 
35  // Get the pfps and associations
36  art::Handle< std::vector<recob::PFParticle> > pfParticleHandle;
37  event.getByLabel(fPandoraLabel, pfParticleHandle);
38  art::FindManyP<recob::Track> pfPartToTrackAssoc(pfParticleHandle, event, fTpcTrackModuleLabel);
39  art::FindManyP<anab::T0> findManyT0(pfParticleHandle, event, fPandoraLabel);
40 
41  // Loop over all the pfps
42  for(auto const pfp : (*pfParticleHandle)){
43  // Get the associated track if there is one
44  const std::vector< art::Ptr<recob::Track> > associatedTracks(pfPartToTrackAssoc.at(pfp.Self()));
45  if(associatedTracks.size() != 1) continue;
46  recob::Track trk = *associatedTracks.front();
47  if(trk.ID() != track.ID()) continue;
48  // Get the associated t0
49  const std::vector< art::Ptr<anab::T0> > associatedT0s(findManyT0.at(pfp.Self()));
50 
51  // If any t0 outside of beam limits then remove
52  for(size_t i = 0; i < associatedT0s.size(); i++){
53  double pandoraTime = associatedT0s[i]->Time()*1e-3; // [us]
54  if(pandoraTime < fBeamTimeMin || pandoraTime > fBeamTimeMax) return true;
55  }
56  }
57 
58  return false;
59 
60 }
61 
62 // Finds any t0s associated with pfparticle by pandora, tags if outside beam
63 bool PandoraT0CosmicIdAlg::PandoraT0CosmicId(recob::PFParticle pfparticle, std::map< size_t, art::Ptr<recob::PFParticle> > pfParticleMap, const art::Event& event){
64 
65  // Get pfp associations to t0s
66  art::Handle< std::vector<recob::PFParticle> > pfParticleHandle;
67  event.getByLabel(fPandoraLabel, pfParticleHandle);
68  art::FindManyP<anab::T0> findManyT0(pfParticleHandle, event, fPandoraLabel);
69 
70  // Loop over daughters
71  for (const size_t daughterId : pfparticle.Daughters()){
72  // Get associated t0s
73  art::Ptr<recob::PFParticle> pParticle = pfParticleMap.at(daughterId);
74  const std::vector< art::Ptr<anab::T0> > associatedT0s(findManyT0.at(pParticle.key()));
75 
76  // If any t0 outside of beam limits then remove
77  for(size_t i = 0; i < associatedT0s.size(); i++){
78  double pandoraTime = associatedT0s[i]->Time()*1e-3; // [us]
79  if(pandoraTime < fBeamTimeMin || pandoraTime > fBeamTimeMax) return true;
80  }
81  }
82 
83  return false;
84 
85 }
86 
87 
88 }
const std::vector< size_t > & Daughters() const
Returns the collection of daughter particles.
Definition: PFParticle.h:114
process_name use argoneut_mc_hitfinder track
process_name opflashCryoW ana
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
bool PandoraT0CosmicId(recob::Track track, const art::Event &event)
do i e
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track: