All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArPfoHelper.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArHelpers/LArPfoHelper.h
3  *
4  * @brief Header file for the pfo helper class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_PFO_HELPER_H
9 #define LAR_PFO_HELPER_H 1
10 
11 #include "Objects/Cluster.h"
12 #include "Objects/ParticleFlowObject.h"
13 #include "Objects/Vertex.h"
14 
16 
17 namespace lar_content
18 {
19 
20 /**
21  * @brief LArPfoHelper class
22  */
24 {
25 public:
26  /**
27  * @brief Get a list of coordinates of a particular hit type from an input pfos
28  *
29  * @param pPfo the address of the input Pfo
30  * @param hitType the cluster hit type
31  * @param coordinateVector the output list of coordinates
32  */
33  static void GetCoordinateVector(
34  const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CartesianPointVector &coordinateVector);
35 
36  /**
37  * @brief Get a list of calo hits of a particular hit type from a list of pfos
38  *
39  * @param pfoList the input list of Pfos
40  * @param hitType the cluster hit type
41  * @param caloHitList the output list of calo hits
42  */
43  static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList);
44 
45  /**
46  * @brief Get a list of calo hits of a particular hit type from a given pfo
47  *
48  * @param pPfo the input Pfo
49  * @param hitType the cluster hit type
50  * @param caloHitList the output list of calo hits
51  */
52  static void GetCaloHits(const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList);
53 
54  /**
55  * @brief Get a list of isolated calo hits of a particular hit type from a list of pfos
56  *
57  * @param pfoList the input list of Pfos
58  * @param hitType the cluster hit type
59  * @param caloHitList the output list of calo hits
60  */
61  static void GetIsolatedCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList);
62 
63  /**
64  * @brief Get a list of isolated calo hits of a particular hit type from a given pfo
65  *
66  * @param pPfo the input Pfo
67  * @param hitType the cluster hit type
68  * @param caloHitList the output list of isolated calo hits
69  */
70  static void GetIsolatedCaloHits(const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList);
71 
72  /**
73  * @brief Get a list of all calo hits (including isolated) of all types from a given pfo
74  *
75  * @param pPfo the input Pfo
76  * @param caloHitList the output list of calo hits
77  */
78  static void GetAllCaloHits(const pandora::ParticleFlowObject *pPfo, pandora::CaloHitList &caloHitList);
79 
80  /**
81  * @brief Get a list of clusters of a particular hit type from a list of pfos
82  *
83  * @param pfoList the input list of Pfos
84  * @param hitType the cluster hit type
85  * @param clusterList the output list of clusters
86  */
87  static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList);
88 
89  /**
90  * @brief Get a list of clusters of a particular hit type from a given pfo
91  *
92  * @param pPfo the input Pfo
93  * @param hitType the cluster hit type
94  * @param clusterList the output list of clusters
95  */
96  static void GetClusters(const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::ClusterList &clusterList);
97 
98  /**
99  * @brief Get the number of 2D hits of a PFO
100  *
101  * @param pPfo the pfo to check
102  * @return int of number of 2D hits
103  */
104  static unsigned int GetNumberOfTwoDHits(const pandora::ParticleFlowObject *const pPfo);
105 
106  /**
107  * @brief Get the list of 2D clusters from an input pfo
108  *
109  * @param pPfo the input Pfo
110  * @param clusterList the output list of clusters
111  */
112  static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList);
113 
114  /**
115  * @brief Get the list of 3D clusters from an input pfo
116  *
117  * @param pPfo the input Pfo
118  * @param clusterList the output list of clusters
119  */
120  static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList);
121 
122  /**
123  * @brief Get a flat list of all pfos, recursively including all daughters and parents associated with those pfos in an input list
124  *
125  * @param inputPfoList the input pfo list
126  * @param outputPfoList to receive the output pfo list
127  */
128  static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList);
129 
130  /**
131  * @brief Get a flat list of all pfos, recursively including all daughters and parents associated with an input pfo
132  *
133  * @param pPfo the input Pfo
134  * @param outputPfoList to receive the output pfo list
135  */
136  static void GetAllConnectedPfos(const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &outputPfoList);
137 
138  /**
139  * @brief Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input list
140  *
141  * @param inputPfoList the input pfo list
142  * @param outputPfoList to receive the output pfo list
143  */
144  static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList);
145 
146  /**
147  * @brief Get a flat list of all pfos, recursively, of all daughters and parents associated with an input pfo
148  *
149  * @param pPfo the input Pfo
150  * @param outputPfoList to receive the output pfo list
151  */
152  static void GetAllDownstreamPfos(const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &outputPfoList);
153 
154  /**
155  * @brief Get flat lists of all downstream track pfos and also shower-like pfos.
156  * This method collects together all track-like particles downstream of the root particle, stopping at a leading shower and
157  * then storing that leading shower in a separate list.
158  *
159  * @param pPfo the input pfo
160  * @param outputTrackPfoList the output list of descendent track-like particles
161  * @param outputLeadingShowerParticles the output list of leading shower particles
162  */
163  static void GetAllDownstreamPfos(
164  const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &outputTrackPfoList, pandora::PfoList &outputLeadingShowerPfoList);
165 
166  /**
167  * @brief Determine the position in the hierarchy for the MCParticle
168  *
169  * @param pPfo the input Pfo
170  *
171  * @return integer
172  */
173  static int GetHierarchyTier(const pandora::ParticleFlowObject *const pPfo);
174 
175  /**
176  * @brief Calculate length of Pfo using 2D clusters
177  *
178  * @param pPfo the input Pfo
179  *
180  * @return length variable
181  */
182  static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo);
183 
184  /**
185  * @brief Calculate length of Pfo using 3D clusters
186  *
187  * @param pPfo the input Pfo
188  *
189  * @return length variable
190  */
191  static float GetThreeDLengthSquared(const pandora::ParticleFlowObject *const pPfo);
192 
193  /**
194  * @brief Get closest distance between Pfo and cluster
195  *
196  * @param pPfo the address of the input Pfo
197  * @param pCluster the address of the input cluster
198  */
199  static float GetClosestDistance(const pandora::ParticleFlowObject *const pPfo, const pandora::Cluster *const pCluster);
200 
201  /**
202  * @brief Get distance between two Pfos using 3D clusters
203  *
204  * @param pPfo the address of the first Pfo
205  * @param pPfo the address of the second Pfo
206  */
207  static float GetThreeDSeparation(const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2);
208 
209  /**
210  * @brief Does Pfo contain 2D clusters
211  *
212  * @param pPfo the address of the Pfo
213  */
214  static bool IsTwoD(const pandora::ParticleFlowObject *const pPfo);
215 
216  /**
217  * @brief Does Pfo contain 3D clusters
218  *
219  * @param pPfo the address of the Pfo
220  */
221  static bool IsThreeD(const pandora::ParticleFlowObject *const pPfo);
222 
223  /**
224  * @brief Return track flag based on Pfo Particle ID
225  *
226  * @param pPfo the address of the Pfo
227  */
228  static bool IsTrack(const pandora::ParticleFlowObject *const pPfo);
229 
230  /**
231  * @brief Return shower flag based on Pfo Particle ID
232  *
233  * @param pPfo the address of the Pfo
234  */
235  static bool IsShower(const pandora::ParticleFlowObject *const pPfo);
236 
237  /**
238  * @brief Get primary neutrino or antineutrino
239  *
240  * @param pPfo the address of the Pfo
241  *
242  * @return pdg code of neutrino (or zero, otherwise)
243  */
244  static int GetPrimaryNeutrino(const pandora::ParticleFlowObject *const pPfo);
245 
246  /**
247  * @brief Whether a pfo is a primary parent particle
248  *
249  * @param pPfo the address of the Pfo
250  *
251  * @return boolean
252  */
253  static bool IsFinalState(const pandora::ParticleFlowObject *const pPfo);
254 
255  /**
256  * @brief Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction
257  *
258  * @param pPfo the address of the Pfo
259  *
260  * @return boolean
261  */
262  static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo);
263 
264  /**
265  * @brief Whether a pfo is a neutrino or (antineutrino)
266  *
267  * @param pPfo the address of the Pfo
268  *
269  * @return boolean
270  */
271  static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo);
272 
273  /**
274  * @brief Whether a pfo is a final-state particle from a test beam particle interaction
275  *
276  * @param pPfo the address of the Pfo
277  *
278  * @return boolean
279  */
280  static bool IsTestBeamFinalState(const pandora::ParticleFlowObject *const pPfo);
281 
282  /**
283  * @brief Whether a pfo is a test beam particle
284  *
285  * @param pPfo the address of the Pfo
286  *
287  * @return boolean
288  */
289  static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo);
290 
291  /**
292  * @brief Get neutrino pfos from an input pfo list
293  *
294  * @param pPfoList the input pfo list
295  * @param recoNeutrinos to receive the list of neutrino pfos
296  */
297  static void GetRecoNeutrinos(const pandora::PfoList *const pPfoList, pandora::PfoList &recoNeutrinos);
298 
299  /**
300  * @brief Get the primary parent pfo
301  *
302  * @param pPfo the address of the Pfo
303  *
304  * @return address of the primary parent pfo
305  */
306  static const pandora::ParticleFlowObject *GetParentPfo(const pandora::ParticleFlowObject *const pPfo);
307 
308  /**
309  * @brief Get primary neutrino or antineutrino
310  *
311  * @param pPfo the address of the Pfo
312  *
313  * @return address of primary neutrino pfo
314  */
315  static const pandora::ParticleFlowObject *GetParentNeutrino(const pandora::ParticleFlowObject *const pPfo);
316 
317  /**
318  * @brief Get the pfo vertex
319  *
320  * @param pPfo the address of the Pfo
321  *
322  * @return address of pfo vertex
323  */
324  static const pandora::Vertex *GetVertex(const pandora::ParticleFlowObject *const pPfo);
325 
326  /**
327  * @brief Get the pfo test beam interaction vertex
328  *
329  * @param pPfo the address of the Pfo
330  *
331  * @return address of pfo vertex
332  */
333  static const pandora::Vertex *GetTestBeamInteractionVertex(const pandora::ParticleFlowObject *const pPfo);
334 
335  /**
336  * @brief Get the vertex with a specific vertex label in a given vertex list
337  *
338  * @param vertexList vertex list
339  * @param vertexLabel target vertex label type
340  *
341  * @return address of the desired vertex
342  */
343  static const pandora::Vertex *GetVertexWithLabel(const pandora::VertexList &vertexList, const pandora::VertexLabel vertexLabel);
344 
345  /**
346  * @brief Apply 3D sliding fit to a set of 3D points and return track trajectory
347  *
348  * @param pointVector the input list of 3D positions
349  * @param vertexPosition the input vertex position
350  * @param slidingFitHalfWindow size of half window for sliding linear fit
351  * @param layerPitch size of pitch for sliding linear fit
352  * @param trackStateVector the output track trajectory
353  * @param pIndexVector lookup vector of spacepoint indices to store trajectory point sorting
354  */
355  static void GetSlidingFitTrajectory(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition,
356  const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector = nullptr);
357 
358  /**
359  * @brief Apply 3D sliding fit to Pfo and return track trajectory
360  *
361  * @param pPfo the address of the input Pfo
362  * @param pVertex the address of the input vertex
363  * @param slidingFitHalfWindow size of half window for sliding linear fit
364  * @param layerPitch size of pitch for sliding linear fit
365  * @param trackStateVector the output track trajectory
366  */
367  static void GetSlidingFitTrajectory(const pandora::ParticleFlowObject *const pPfo, const pandora::Vertex *const pVertex,
368  const unsigned int slidingFitHalfWindow, const float layerPitch, LArTrackStateVector &trackStateVector);
369 
370  /**
371  * @brief Perform PCA analysis on a set of 3D points and return results
372  *
373  * @param pointVector the input list of 3D positions
374  * @param vertexPosition the input vertex position
375  */
376  static LArShowerPCA GetPrincipalComponents(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition);
377 
378  /**
379  * @brief Perform PCA analysis on Pfo and return results
380  *
381  * @param pPfo the address of the input Pfo
382  * @param pVertex the address of the input vertex
383  */
384  static LArShowerPCA GetPrincipalComponents(const pandora::ParticleFlowObject *const pPfo, const pandora::Vertex *const pVertex);
385 
386  /**
387  * @brief Sort pfos by number of constituent hits
388  *
389  * @param pLhs address of first pfo
390  * @param pRhs address of second pfo
391  */
392  static bool SortByHitProjection(const LArTrackTrajectoryPoint &lhs, const LArTrackTrajectoryPoint &rhs);
393 
394  /**
395  * @brief Sort pfos by number of constituent hits
396  *
397  * @param pLhs address of first pfo
398  * @param pRhs address of second pfo
399  */
400  static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs);
401 
402  /**
403  * @brief Retrieve a linearised representation of the PFO hierarchy in breadth first order. This iterates over the PFO hierarchy in a
404  * manor that sees primaries at the front of the list, with progressively deeper tiers later in the list. This is useful for
405  * some visualisation cases.
406  *
407  * @param pPfo a PFO in the hierarchy - can be any PFO
408  * @param pfoList the output PFO list
409  */
410  static void GetBreadthFirstHierarchyRepresentation(const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &pfoList);
411 
412 private:
413  /**
414  * @brief Implementation of sliding fit trajectory extraction
415  *
416  * @param t the input information
417  * @param pVertex the address of the input vertex
418  * @param slidingFitHalfWindow size of half window for sliding linear fit
419  * @param layerPitch size of pitch for sliding linear fit
420  * @param trackStateVector the output track trajectory
421  * @param pIndexVector lookup vector of spacepoint indices to store trajectory point sorting
422  */
423  template <typename T>
424  static void SlidingFitTrajectoryImpl(const T *const pT, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow,
425  const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector = nullptr);
426 };
427 
428 } // namespace lar_content
429 
430 #endif // #ifndef LAR_PFO_HELPER_H
static LArShowerPCA GetPrincipalComponents(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition)
Perform PCA analysis on a set of 3D points and return results.
static float GetThreeDSeparation(const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2)
Get distance between two Pfos using 3D clusters.
static unsigned int GetNumberOfTwoDHits(const pandora::ParticleFlowObject *const pPfo)
Get the number of 2D hits of a PFO.
static bool IsThreeD(const pandora::ParticleFlowObject *const pPfo)
Does Pfo contain 3D clusters.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static const pandora::Vertex * GetVertexWithLabel(const pandora::VertexList &vertexList, const pandora::VertexLabel vertexLabel)
Get the vertex with a specific vertex label in a given vertex list.
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
static void GetRecoNeutrinos(const pandora::PfoList *const pPfoList, pandora::PfoList &recoNeutrinos)
Get neutrino pfos from an input pfo list.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
Header file for lar pfo objects.
static float GetThreeDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 3D clusters.
static float GetClosestDistance(const pandora::ParticleFlowObject *const pPfo, const pandora::Cluster *const pCluster)
Get closest distance between Pfo and cluster.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
static void GetSlidingFitTrajectory(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector=nullptr)
Apply 3D sliding fit to a set of 3D points and return track trajectory.
static bool IsTwoD(const pandora::ParticleFlowObject *const pPfo)
Does Pfo contain 2D clusters.
static const pandora::Vertex * GetTestBeamInteractionVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo test beam interaction vertex.
std::vector< int > IntVector
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 2D clusters.
static void GetAllCaloHits(const pandora::ParticleFlowObject *pPfo, pandora::CaloHitList &caloHitList)
Get a list of all calo hits (including isolated) of all types from a given pfo.
Definition: LArPfoHelper.cc:76
static void SlidingFitTrajectoryImpl(const T *const pT, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector=nullptr)
Implementation of sliding fit trajectory extraction.
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
static int GetHierarchyTier(const pandora::ParticleFlowObject *const pPfo)
Determine the position in the hierarchy for the MCParticle.
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
static int GetPrimaryNeutrino(const pandora::ParticleFlowObject *const pPfo)
Get primary neutrino or antineutrino.
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
static void GetCoordinateVector(const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CartesianPointVector &coordinateVector)
Get a list of coordinates of a particular hit type from an input pfos.
Definition: LArPfoHelper.cc:27
static const pandora::ParticleFlowObject * GetParentNeutrino(const pandora::ParticleFlowObject *const pPfo)
Get primary neutrino or antineutrino.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
static bool SortByHitProjection(const LArTrackTrajectoryPoint &lhs, const LArTrackTrajectoryPoint &rhs)
Sort pfos by number of constituent hits.
static void GetBreadthFirstHierarchyRepresentation(const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &pfoList)
Retrieve a linearised representation of the PFO hierarchy in breadth first order. This iterates over ...
static bool IsFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a primary parent particle.
static void GetIsolatedCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of isolated calo hits of a particular hit type from a list of pfos.
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
LArPfoHelper class.
Definition: LArPfoHelper.h:23
std::vector< LArTrackState > LArTrackStateVector
Definition: LArPfoObjects.h:67
LArTrackTrajectoryPoint class.
Definition: LArPfoObjects.h:74
LArShowerPCA class.
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
std::list< Vertex > VertexList
Definition: DCEL.h:182
static bool IsTestBeamFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a test beam particle interaction.