All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArClusterHelper.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArHelpers/LArClusterHelper.h
3  *
4  * @brief Header file for the cluster helper class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_CLUSTER_HELPER_H
9 #define LAR_CLUSTER_HELPER_H 1
10 
11 #include "Objects/Cluster.h"
12 
13 namespace lar_content
14 {
15 
16 /**
17  * @brief LArClusterHelper class
18  */
20 {
21 public:
22  typedef std::set<unsigned int> UIntSet;
23 
24  /**
25  * @brief Get the hit type associated with a two dimensional cluster
26  *
27  * @param pCluster the address of the cluster
28  *
29  * @return the cluster hit type
30  */
31  static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster);
32 
33  /**
34  * @brief Divide an input cluster list into separate u, v and w lists (exception raised if alternative hit type encountered)
35  *
36  * @param inputClusters the input cluster list
37  * @param clusterListU to receive the u clusters
38  * @param clusterListV to receive the v clusters
39  * @param clusterListW to receive the w clusters
40  */
41  static void GetClustersUVW(const pandora::ClusterList &inputClusters, pandora::ClusterList &clusterListU,
42  pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW);
43 
44  /**
45  * @brief Get the subset of clusters, from a provided list, that match the specified hit type
46  *
47  * @param inputClusters the input cluster list
48  * @param hitType the specified hit type
49  * @param clusterList to receive the clusters
50  */
51  static void GetClustersByHitType(const pandora::ClusterList &inputClusters, const pandora::HitType hitType, pandora::ClusterList &clusterList);
52 
53  /**
54  * @brief Get length squared of cluster
55  *
56  * @param pCluster address of the cluster
57  *
58  * @return the length squared
59  */
60  static float GetLengthSquared(const pandora::Cluster *const pCluster);
61 
62  /**
63  * @brief Get length of cluster
64  *
65  * @param pCluster address of the cluster
66  *
67  * @return the length
68  */
69  static float GetLength(const pandora::Cluster *const pCluster);
70 
71  /**
72  * @brief Get energy of cluster, based on length
73  *
74  * @param pCluster address of the cluster
75  *
76  * @return the energy
77  */
78  static float GetEnergyFromLength(const pandora::Cluster *const pCluster);
79 
80  /**
81  * @brief Get number of layers spanned by cluster (1+Last-First)
82  *
83  * @param pCluster address of the cluster
84  *
85  * @return the layer span
86  */
87  static unsigned int GetLayerSpan(const pandora::Cluster *const pCluster);
88 
89  /**
90  * @brief Fraction of occupied layers in cluster
91  *
92  * @param pCluster address of the cluster
93  *
94  * @return float
95  */
96  static float GetLayerOccupancy(const pandora::Cluster *const pCluster);
97 
98  /**
99  * @brief Fraction of occupied layers in a pair of clusters
100  *
101  * @param pCluster1 address of the first cluster
102  * @param pCluster2 address of the second cluster
103  *
104  * @return float
105  */
106  static float GetLayerOccupancy(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2);
107 
108  /**
109  * @brief Get closest distance between clusters in a pair of cluster lists
110  *
111  * @param clusterList1 the first cluster list
112  * @param clusterList2 the second cluster list
113  *
114  * @return the closest distance
115  */
116  static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2);
117 
118  /**
119  * @brief Get closest distance between a specified cluster and list of clusters
120  *
121  * @param pCluster address of the input cluster
122  * @param clusterList list of input clusters
123  *
124  * @return the closest distance
125  */
126  static float GetClosestDistance(const pandora::Cluster *const pCluster, const pandora::ClusterList &clusterList);
127 
128  /**
129  * @brief Get closest distance between a pair of clusters
130  *
131  * @param pCluster1 address of the first cluster
132  * @param pCluster2 address of the second cluster
133  *
134  * @return the closest distance
135  */
136  static float GetClosestDistance(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2);
137 
138  /**
139  * @brief Get closest distance between a specified position and list of clusters
140  *
141  * @param position the position vector
142  * @param clusterList list of input clusters
143  *
144  * @return the closest distance
145  */
146  static float GetClosestDistance(const pandora::CartesianVector &position, const pandora::ClusterList &clusterList);
147 
148  /**
149  * @brief Get closest distance between a specified position vector and the hits in a specified cluster
150  *
151  * @param position the position vector
152  * @param pCluster address of the cluster
153  *
154  * @return the closest distance
155  */
156  static float GetClosestDistance(const pandora::CartesianVector &position, const pandora::Cluster *const pCluster);
157 
158  /**
159  * @brief Get closest distance between a specified position vector and the hits in a specified calo hit list
160  *
161  * @param position the position vector
162  * @param caloHitList the list of calo hits
163  *
164  * @return the closest distance
165  */
166  static float GetClosestDistance(const pandora::CartesianVector &position, const pandora::CaloHitList &caloHitList);
167 
168  /**
169  * @brief Get closest position in a list of clusters to a specified input position vector
170  *
171  * @param position the position vector
172  * @param clusterList list of input clusters
173  *
174  * @return the closest position
175  */
176  static pandora::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::ClusterList &clusterList);
177 
178  /**
179  * @brief Get closest position on a cluster to a specified input position vector
180  *
181  * @param position the position vector
182  * @param pCluster address of the cluster
183  *
184  * @return the closest position
185  */
186  static pandora::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::Cluster *const pCluster);
187 
188  /**
189  * @brief Get closest position of hits in a given calo hit list to a specified input position vector
190  *
191  * @param position the position vector
192  * @param caloHitList the list of calo hits
193  *
194  * @return the closest position
195  */
196  static pandora::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::CaloHitList &caloHitList);
197 
198  /**
199  * @brief Get pair of closest positions for a pair of clusters
200  *
201  * @param pCluster1 the address of the first cluster
202  * @param pCluster2 the address of the second cluster
203  * @param the closest position in the first cluster
204  * @param the closest position in the second cluster
205  */
206  static void GetClosestPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2,
207  pandora::CartesianVector &position1, pandora::CartesianVector &position2);
208 
209  /**
210  * @brief Get positions of the two most distant calo hits in a list of cluster (ordered by Z)
211  *
212  * @param clusterList the input cluster list
213  * @param the inner extremal position
214  * @param the outer extremal position
215  */
216  static void GetExtremalCoordinates(
217  const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate);
218 
219  /**
220  * @brief Get positions of the two most distant calo hits in a cluster (ordered by Z)
221  *
222  * @param pCluster the input cluster
223  * @param the inner extremal position
224  * @param the outer extremal position
225  */
226  static void GetExtremalCoordinates(
227  const pandora::Cluster *const pCluster, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate);
228 
229  /**
230  * @brief Get positions of the two most distant calo hits in an ordered calo hit list (ordered by Z)
231  *
232  * @param orderedCaloHitList the ordered calo hit list
233  * @param the inner extremal position
234  * @param the outer extremal position
235  */
236  static void GetExtremalCoordinates(const pandora::OrderedCaloHitList &orderedCaloHitList, pandora::CartesianVector &innerCoordinate,
237  pandora::CartesianVector &outerCoordinate);
238 
239  /**
240  * @brief Get positions of the two most distant points in a provided list (ordered by Z)
241  *
242  * @param coordinateVector the hit list
243  * @param the inner extremal position
244  * @param the outer extremal position
245  */
246  static void GetExtremalCoordinates(const pandora::CartesianPointVector &coordinateVector, pandora::CartesianVector &innerCoordinate,
247  pandora::CartesianVector &outerCoordinate);
248 
249  /**
250  * @brief Get minimum and maximum X, Y and Z positions of the calo hits in a cluster
251  *
252  * @param pCluster address of the cluster
253  * @param the minimum positions (x,y,z)
254  * @param the maximum positions (x,y,z)
255  */
256  static void GetClusterBoundingBox(
257  const pandora::Cluster *const pCluster, pandora::CartesianVector &minimumCoordinate, pandora::CartesianVector &maximumCoordinate);
258 
259  /**
260  * @brief Get vector of hit coordinates from an input cluster
261  *
262  * @param pCluster address of the cluster
263  * @param coordinateVector
264  */
265  static void GetCoordinateVector(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector);
266 
267  /**
268  * @brief Get list of Calo hits from an input cluster that are contained in a bounding box. The hits are sorted by position
269  *
270  * @param pCluster address of the cluster
271  * @param lowerBound one opposing corner of the bounding box
272  * @param upperBound the other opposing corner of the bounding box
273  * @param caloHitList the CaloHitList to be filled
274  */
275  static void GetCaloHitListInBoundingBox(const pandora::Cluster *const pCluster, const pandora::CartesianVector &lowerBound,
276  const pandora::CartesianVector &upperBound, pandora::CaloHitList &caloHitList);
277 
278  /**
279  * @brief Get the set of the daughter volumes that contains the cluster
280  *
281  * @param pCluster address of the cluster
282  * @param daughterVolumeIds output variable
283  */
284  static void GetDaughterVolumeIDs(const pandora::Cluster *const pCluster, UIntSet &daughterVolumeIds);
285 
286  /**
287  * @brief Get average Z positions of the calo hits in a cluster in range xmin to xmax
288  *
289  * @param pCluster address of the cluster
290  * @param xmin for range in x
291  * @param xmax for range in x
292  * @param averageZ to receive the average Z position
293  *
294  * @return status code, faster than throwing in regular use-cases
295  */
296  static pandora::StatusCode GetAverageZ(const pandora::Cluster *const pCluster, const float xmin, const float xmax, float &averageZ);
297 
298  /**
299  * @brief Sort clusters by number of occupied layers, and by inner layer, then energy in event of a tie
300  *
301  * @param pLhs address of first cluster
302  * @param pRhs address of second cluster
303  */
304  static bool SortByNOccupiedLayers(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs);
305 
306  /**
307  * @brief Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height
308  *
309  * @param pLhs address of first cluster
310  * @param pRhs address of second cluster
311  */
312  static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs);
313 
314  /**
315  * @brief Sort clusters by layer span, then inner layer, then position, then pulse-height
316  *
317  * @param pLhs address of first cluster
318  * @param pRhs address of second cluster
319  */
320  static bool SortByLayerSpan(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs);
321 
322  /**
323  * @brief Sort clusters by inner layer, then position, then pulse-height
324  *
325  * @param pLhs address of first cluster
326  * @param pRhs address of second cluster
327  */
328  static bool SortByInnerLayer(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs);
329 
330  /**
331  * @brief Sort clusters by position, then pulse-height
332  *
333  * @param pLhs address of first cluster
334  * @param pRhs address of second cluster
335  */
336  static bool SortByPosition(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs);
337 
338  /**
339  * @brief Sort clusters by pulse-height
340  *
341  * @param pLhs address of first cluster
342  * @param pRhs address of second cluster
343  */
344  static bool SortByPulseHeight(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs);
345 
346  /**
347  * @brief Sort calo hits by their position (use Z, followed by X, followed by Y)
348  *
349  * @param pLhs address of first calo hit
350  * @param pRhs address of second calo hit
351  */
352  static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs);
353 
354  /**
355  * @brief Sort calo hits by their position (use X, followed by Z, followed by Y)
356  *
357  * @param pLhs address of first calo hit
358  * @param pRhs address of second calo hit
359  */
360  static bool SortHitsByPositionInX(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs);
361 
362  /**
363  * @brief Sort calo hits by their pulse height
364  *
365  * @param pLhs address of first calo hit
366  * @param pRhs address of second calo hit
367  */
368  static bool SortHitsByPulseHeight(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs);
369 
370  /**
371  * @brief Sort cartesian vectors by their position (use Z, followed by X, followed by Y)
372  *
373  * @param lhs first point
374  * @param rhs second point
375  */
376  static bool SortCoordinatesByPosition(const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs);
377 };
378 
379 } // namespace lar_content
380 
381 #endif // #ifndef LAR_CLUSTER_HELPER_H
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
static unsigned int GetLayerSpan(const pandora::Cluster *const pCluster)
Get number of layers spanned by cluster (1+Last-First)
static bool SortHitsByPulseHeight(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their pulse height.
static void GetClustersByHitType(const pandora::ClusterList &inputClusters, const pandora::HitType hitType, pandora::ClusterList &clusterList)
Get the subset of clusters, from a provided list, that match the specified hit type.
static void GetDaughterVolumeIDs(const pandora::Cluster *const pCluster, UIntSet &daughterVolumeIds)
Get the set of the daughter volumes that contains the cluster.
static bool SortHitsByPositionInX(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use X, followed by Z, followed by Y)
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static void GetClosestPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianVector &position1, pandora::CartesianVector &position2)
Get pair of closest positions for a pair of clusters.
static pandora::StatusCode GetAverageZ(const pandora::Cluster *const pCluster, const float xmin, const float xmax, float &averageZ)
Get average Z positions of the calo hits in a cluster in range xmin to xmax.
static bool SortByPulseHeight(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by pulse-height.
static void GetClustersUVW(const pandora::ClusterList &inputClusters, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW)
Divide an input cluster list into separate u, v and w lists (exception raised if alternative hit type...
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
static bool SortCoordinatesByPosition(const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
Sort cartesian vectors by their position (use Z, followed by X, followed by Y)
static bool SortByPosition(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by position, then pulse-height.
static void GetClusterBoundingBox(const pandora::Cluster *const pCluster, pandora::CartesianVector &minimumCoordinate, pandora::CartesianVector &maximumCoordinate)
Get minimum and maximum X, Y and Z positions of the calo hits in a cluster.
static float GetEnergyFromLength(const pandora::Cluster *const pCluster)
Get energy of cluster, based on length.
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
static void GetCaloHitListInBoundingBox(const pandora::Cluster *const pCluster, const pandora::CartesianVector &lowerBound, const pandora::CartesianVector &upperBound, pandora::CaloHitList &caloHitList)
Get list of Calo hits from an input cluster that are contained in a bounding box. The hits are sorted...
static float GetLength(const pandora::Cluster *const pCluster)
Get length of cluster.
static bool SortByLayerSpan(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by layer span, then inner layer, then position, then pulse-height.
std::set< unsigned int > UIntSet
static float GetLayerOccupancy(const pandora::Cluster *const pCluster)
Fraction of occupied layers in cluster.
static void GetExtremalCoordinates(const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
Get positions of the two most distant calo hits in a list of cluster (ordered by Z) ...
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
static void GetCoordinateVector(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector)
Get vector of hit coordinates from an input cluster.
static pandora::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::ClusterList &clusterList)
Get closest position in a list of clusters to a specified input position vector.
LArClusterHelper class.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static bool SortByNOccupiedLayers(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of occupied layers, and by inner layer, then energy in event of a tie...
static bool SortByInnerLayer(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by inner layer, then position, then pulse-height.