ProtoDUNEPFParticleUtils.h
Go to the documentation of this file.
1 #ifndef PROTODUNE_PFPARTICLE_UTILS_H
2 #define PROTODUNE_PFPARTICLE_UTILS_H
3 
4 ///////////////////////////////////////////////////////////////////
5 // ProtoDUNEPFParticleUtils
6 // - Class to help analysers access useful PFParticle information
7 //
8 // Leigh Whitehead - leigh.howard.whitehead@cern.ch
9 ///////////////////////////////////////////////////////////////////
10 
11 #include <map>
12 #include <string>
13 
25 
26 #include "TVector3.h"
27 
28 namespace protoana {
29 
31 
32  public:
33 
36 
37  /// Get the number of primary PFParticles
38  unsigned int GetNumberPrimaryPFParticle(art::Event const &evt, const std::string particleLabel) const;
39 
40  /// Get a map of slice index to the primary PFParticles within it
41  const std::map<unsigned int,std::vector<const recob::PFParticle*>> GetPFParticleSliceMap(art::Event const &evt, const std::string particleLabel) const;
42 
43  /// Get a map of slice index to all of the PFParticles within it
44  const std::map<unsigned int,std::vector<const recob::PFParticle*>> GetAllPFParticleSliceMap(art::Event const &evt, const std::string particleLabel) const;
45 
46  /// Get the Primary PFParticles from a given slice. Returns an empty vector if the slice number is not valid
47  const std::vector<const recob::PFParticle*> GetPFParticlesFromSlice(const unsigned short slice, art::Event const &evt, const std::string particleLabel) const;
48 
49  /// Get all of the PFParticles from a given slice. Returns an empty vector if the slice number is not valid
50  const std::vector<const recob::PFParticle*> GetAllPFParticlesFromSlice(const unsigned short slice, art::Event const &evt, const std::string particleLabel) const;
51 
52  /// Try to get the slice tagged as beam. Returns 9999 if no beam slice was found
53  unsigned short GetBeamSlice(art::Event const &evt, const std::string particleLabel) const;
54 
55  /// Return the pointers for the PFParticles in the beam slice. Returns an empty vector is no beam slice was found
56  const std::vector<const recob::PFParticle*> GetPFParticlesFromBeamSlice(art::Event const &evt, const std::string particleLabel) const;
57 
58  /// Get the reconstructed slice associated with a particle
59  const recob::Slice* GetPFParticleSlice(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
60 
61  /// Get the reconstructed slice number associated with a particle
62  unsigned short GetPFParticleSliceIndex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
63 
64  /// For a given PFParticle, return all hits from the slice it comes from
65  const std::vector<const recob::Hit*> GetPFParticleSliceHits(const recob::PFParticle &particlei, art::Event const &evt, const std::string particleLabel) const;
66 
67  /// For a given PFParticle find its slice and return all those hits not associated to any PFParticle
68  const std::vector<const recob::Hit*> GetPFParticleSliceUnassociatedHits(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
69 
70  /// Get the cosmic tag(s) from a given PFParticle
71  std::vector<anab::CosmicTag> GetPFParticleCosmicTag(const recob::PFParticle &particle, art::Event const &evt, std::string particleLabel) const;
72 
73  /// Get the T0(s) from a given PFParticle
74  std::vector<anab::T0> GetPFParticleT0(const recob::PFParticle &particle, art::Event const &evt, std::string particleLabel) const;
75  std::vector<anab::T0> GetPFParticleT0(const recob::PFParticle &particle, art::Event const &evt, std::string particleLabel, std::string t0Label) const;
76 
77  /// Access the BDT output used to decide if a slice is beam-like or cosmic-like
78  float GetBeamCosmicScore(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
79 
80  /// Use the pandora metadata to tell us if this is a beam particle or not
81  bool IsBeamParticle(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
82 
83  /// Pandora tags and removes clear cosmics before slicing, so check if this particle is a clear cosmic
84  bool IsClearCosmic(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
85 
86  /// Get all of the clear cosmic ray particles
87  const std::vector<const recob::PFParticle*> GetClearCosmicPFParticles(art::Event const &evt, const std::string particleLabel) const;
88 
89  /// Get the metadata associated to a PFParticle from pandora
90  const std::map<std::string,float> GetPFParticleMetaData(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
91 
92  /// Function to find the interaction vertex of a primary PFParticle
93  const TVector3 GetPFParticleVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const;
94 
95  /// Function to find the secondary interaction vertex of a primary PFParticle
96  const TVector3 GetPFParticleSecondaryVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const;
97 
98  /// Is the particle track-like?
99  bool IsPFParticleTracklike(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const;
100  // Old deprecated version
101  bool IsPFParticleTracklike(const recob::PFParticle &particle) const;
102 
103  /// Is the particle track-like?
104  bool IsPFParticleShowerlike(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const;
105  // Old deprecated version
106  bool IsPFParticleShowerlike(const recob::PFParticle &particle) const;
107 
108  /// Get the track associated to this particle. Returns a null pointer if not found.
109  const recob::Track* GetPFParticleTrack(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const;
110 
111  /// Get the shower associated to this particle. Returns a null pointer if not found.
112  const recob::Shower* GetPFParticleShower(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const;
113 
114  // Get the SpacePoints associated to the PFParticle
115  const std::vector<const recob::SpacePoint*> GetPFParticleSpacePoints(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
116 
117  /// Get the number of space points
118  unsigned int GetNumberPFParticleSpacePoints(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
119 
120  /// Get the clusters associated to the PFParticle
121  const std::vector<const recob::Cluster*> GetPFParticleClusters(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
122 
123  /// Get the number of clusters associated to the PFParticle
124  unsigned int GetNumberPFParticleClusters(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
125 
126  /// Get the hits associated to the PFParticle
127  const std::vector<const recob::Hit*> GetPFParticleHits(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
128  const std::vector<const recob::Hit*> GetPFParticleHitsFromPlane(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, unsigned int planeID ) const;
129  const std::vector< art::Ptr< recob::Hit > > GetPFParticleHits_Ptrs(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
130  const std::vector< art::Ptr< recob::Hit > > GetPFParticleHitsFromPlane_Ptrs(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, size_t planeID) const;
131 
132  /// Get the number of hits
133  unsigned int GetNumberPFParticleHits(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
134 
135  /// Get the total hit charge for each view
136  const std::vector<double> GetPFParticleHitsCharge(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
137 
138  /// Get the earliest hit peak time
139  const double GetPFParticleEarliestHitPeakTime(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const;
140 
141  /// Get the daughter tracks from the PFParticle
142  const std::vector<const recob::Track*> GetPFParticleDaughterTracks(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const;
143 
144  /// Get the daughter showers from the PFParticle
145  const std::vector<const recob::Shower*> GetPFParticleDaughterShowers(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const;
146 
147  private:
148 
149  // Some functions that don't need to be exposed to the outside
150 
151  /// Helper to get the slice map and avoid code repetition
152  const std::map<unsigned int,std::vector<const recob::PFParticle*>> SliceMapHelper(art::Event const &evt, const std::string particleLabel, bool primaryOnly) const;
153 
154  /// Look for entries in the meta data
155  bool FindBoolInMetaData(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string entry) const;
156  float FindFloatInMetaData(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string entry) const;
157 
158  };
159 
160 }
161 
162 #endif
163 
bool IsBeamParticle(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Use the pandora metadata to tell us if this is a beam particle or not.
QList< Entry > entry
const std::vector< const recob::PFParticle * > GetAllPFParticlesFromSlice(const unsigned short slice, art::Event const &evt, const std::string particleLabel) const
Get all of the PFParticles from a given slice. Returns an empty vector if the slice number is not val...
std::vector< anab::T0 > GetPFParticleT0(const recob::PFParticle &particle, art::Event const &evt, std::string particleLabel) const
Get the T0(s) from a given PFParticle.
const recob::Shower * GetPFParticleShower(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the shower associated to this particle. Returns a null pointer if not found.
std::string string
Definition: nybbler.cc:12
const std::vector< const recob::Hit * > GetPFParticleSliceUnassociatedHits(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
For a given PFParticle find its slice and return all those hits not associated to any PFParticle...
bool FindBoolInMetaData(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string entry) const
Look for entries in the meta data.
const std::vector< const recob::Hit * > GetPFParticleHits(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the hits associated to the PFParticle.
const TVector3 GetPFParticleVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Function to find the interaction vertex of a primary PFParticle.
bool IsClearCosmic(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Pandora tags and removes clear cosmics before slicing, so check if this particle is a clear cosmic...
unsigned short GetPFParticleSliceIndex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the reconstructed slice number associated with a particle.
const double GetPFParticleEarliestHitPeakTime(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the earliest hit peak time.
bool IsPFParticleTracklike(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Is the particle track-like?
bool IsPFParticleShowerlike(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Is the particle track-like?
const std::vector< art::Ptr< recob::Hit > > GetPFParticleHitsFromPlane_Ptrs(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, size_t planeID) const
float FindFloatInMetaData(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string entry) const
const std::map< std::string, float > GetPFParticleMetaData(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the metadata associated to a PFParticle from pandora.
const std::vector< const recob::Cluster * > GetPFParticleClusters(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the clusters associated to the PFParticle.
unsigned short GetBeamSlice(art::Event const &evt, const std::string particleLabel) const
Try to get the slice tagged as beam. Returns 9999 if no beam slice was found.
const std::map< unsigned int, std::vector< const recob::PFParticle * > > GetAllPFParticleSliceMap(art::Event const &evt, const std::string particleLabel) const
Get a map of slice index to all of the PFParticles within it.
const recob::Track * GetPFParticleTrack(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the track associated to this particle. Returns a null pointer if not found.
const recob::Slice * GetPFParticleSlice(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the reconstructed slice associated with a particle.
const std::map< unsigned int, std::vector< const recob::PFParticle * > > GetPFParticleSliceMap(art::Event const &evt, const std::string particleLabel) const
Get a map of slice index to the primary PFParticles within it.
const std::vector< const recob::PFParticle * > GetPFParticlesFromBeamSlice(art::Event const &evt, const std::string particleLabel) const
Return the pointers for the PFParticles in the beam slice. Returns an empty vector is no beam slice w...
const std::vector< const recob::SpacePoint * > GetPFParticleSpacePoints(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
unsigned int GetNumberPFParticleSpacePoints(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the number of space points.
const std::vector< double > GetPFParticleHitsCharge(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the total hit charge for each view.
Declaration of signal hit object.
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
unsigned int GetNumberPFParticleClusters(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the number of clusters associated to the PFParticle.
const std::vector< const recob::PFParticle * > GetClearCosmicPFParticles(art::Event const &evt, const std::string particleLabel) const
Get all of the clear cosmic ray particles.
std::vector< anab::CosmicTag > GetPFParticleCosmicTag(const recob::PFParticle &particle, art::Event const &evt, std::string particleLabel) const
Get the cosmic tag(s) from a given PFParticle.
const std::vector< const recob::Shower * > GetPFParticleDaughterShowers(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the daughter showers from the PFParticle.
const std::vector< const recob::PFParticle * > GetPFParticlesFromSlice(const unsigned short slice, art::Event const &evt, const std::string particleLabel) const
Get the Primary PFParticles from a given slice. Returns an empty vector if the slice number is not va...
Provides recob::Track data product.
const std::vector< art::Ptr< recob::Hit > > GetPFParticleHits_Ptrs(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
const TVector3 GetPFParticleSecondaryVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Function to find the secondary interaction vertex of a primary PFParticle.
const std::vector< const recob::Hit * > GetPFParticleHitsFromPlane(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, unsigned int planeID) const
const std::map< unsigned int, std::vector< const recob::PFParticle * > > SliceMapHelper(art::Event const &evt, const std::string particleLabel, bool primaryOnly) const
Helper to get the slice map and avoid code repetition.
TCEvent evt
Definition: DataStructs.cxx:7
unsigned int GetNumberPrimaryPFParticle(art::Event const &evt, const std::string particleLabel) const
Get the number of primary PFParticles.
const std::vector< const recob::Hit * > GetPFParticleSliceHits(const recob::PFParticle &particlei, art::Event const &evt, const std::string particleLabel) const
For a given PFParticle, return all hits from the slice it comes from.
const std::vector< const recob::Track * > GetPFParticleDaughterTracks(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the daughter tracks from the PFParticle.
float GetBeamCosmicScore(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Access the BDT output used to decide if a slice is beam-like or cosmic-like.
unsigned int GetNumberPFParticleHits(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the number of hits.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49