All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArPointingClusterHelper.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_POINTING_CLUSTER_HELPER_H
9 #define LAR_POINTING_CLUSTER_HELPER_H 1
10 
11 #include "Objects/Cluster.h"
12 
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief LArPointingClusterHelper class
20  */
22 {
23 public:
24  /**
25  * @brief Calculate distance squared between inner and outer vertices of pointing cluster
26  *
27  * @param pointingCluster the input pointing cluster
28  *
29  * @return float the distance squared
30  */
31  static float GetLengthSquared(const LArPointingCluster &pointingCluster);
32 
33  /**
34  * @brief Calculate distance squared between inner and outer vertices of pointing cluster
35  *
36  * @param pointingCluster the input pointing cluster
37  *
38  * @return float the distance
39  */
40  static float GetLength(const LArPointingCluster &pointingCluster);
41 
42  /**
43  * @brief Whether pointing vertex is adjacent to a given position
44  *
45  * @param parentVertex the parent vertex position
46  * @param daughtervertex the daughter pointing vertex
47  * @param minLongitudinalDistance the min longitudinal distance cut
48  * @param maxTransverseDistance the max transverse distance cut
49  *
50  * @return boolean
51  */
52  static bool IsNode(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex,
53  const float minLongitudinalDistance, const float maxTransverseDistance);
54 
55  /**
56  * @brief Whether pointing vertex is emitted from a given position
57  *
58  * @param parentVertex the parent vertex position
59  * @param daughtervertex the daughter pointing vertex
60  * @param minLongitudinalDistance the min longitudinal distance cut
61  * @param maxLongitudinalDistance the max longitudinal distance cut
62  * @param maxTransverseDistance the max transverse distance cut
63  * @param angularAllowance the pointing angular allowance in degrees
64  *
65  * @return boolean
66  */
67  static bool IsEmission(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex,
68  const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance);
69 
70  /**
71  * @brief Get projected position on a cluster from a specified position and direction
72  *
73  * @param initialPosition the initial position of the cluster
74  * @param initialDirection the initial direction of the cluster
75  * @param pCluster address of the cluster
76  * @param projectionAngularAllowance the projection angular allowance
77  *
78  * @return the projected position
79  */
80  static pandora::CartesianVector GetProjectedPosition(const pandora::CartesianVector &initialPosition,
81  const pandora::CartesianVector &initialDirection, const pandora::Cluster *const pCluster, const float projectionAngularAllowance);
82 
83  /**
84  * @brief Given a pair of pointing clusters, receive the closest or farthest pair of vertices
85  * @param useX use relative X coordinates in the calculation
86  * @param useY use relative Y coordinates in the calculation
87  * @param useZ use relative Z coordinates in the calculation
88  * @param pointingClusterI the first pointing cluster
89  * @param pointingClusterJ the second pointing cluster
90  * @param closestVertexI to receive the relevant vertex from the first pointing cluster
91  * @param closestVertexJ to receive the relevant vertex from the second pointing cluster
92  */
93  static void GetClosestVertices(const bool useX, const bool useY, const bool useZ, const LArPointingCluster &pointingClusterI,
94  const LArPointingCluster &pointingClusterJ, LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ);
95 
96  /**
97  * @brief Given a pair of pointing clusters, find the closest pair of vertices
98  *
99  * @param pointingClusterI the first pointing cluster
100  * @param pointingClusterJ the second pointing cluster
101  * @param closestVertexI to receive the relevant vertex from the first pointing cluster
102  * @param closestVertexJ to receive the relevant vertex from the second pointing cluster
103  */
104  static void GetClosestVertices(const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ,
105  LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ);
106 
107  /**
108  * @brief Given a pair of pointing clusters, find the pair of vertices with smallest x-separation
109  *
110  * @param pointingClusterI the first pointing cluster
111  * @param pointingClusterJ the second pointing cluster
112  * @param closestVertexI to receive the relevant vertex from the first pointing cluster
113  * @param closestVertexJ to receive the relevant vertex from the second pointing cluster
114  */
115  static void GetClosestVerticesInX(const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ,
116  LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ);
117 
118  /**
119  * @brief Given a pair of pointing clusters, find the pair of vertices with smallest yz-separation
120  *
121  * @param pointingClusterI the first pointing cluster
122  * @param pointingClusterJ the second pointing cluster
123  * @param closestVertexI to receive the relevant vertex from the first pointing cluster
124  * @param closestVertexJ to receive the relevant vertex from the second pointing cluster
125  */
126  static void GetClosestVerticesInYZ(const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ,
127  LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ);
128 
129  /**
130  * @brief Calculate impact parameters between a pair of pointing vertices using yz-coordinates
131  *
132  * @param pointingVertex the pointing vertex
133  * @param targetPosition the target position
134  * @param longitidinal the longitudinal displacement
135  * @param transverse the transverse displacement
136  */
137  static void GetImpactParametersInYZ(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex,
138  float &longitudinal, float &transverse);
139 
140  /**
141  * @brief Calculate impact parameters between a pair of pointing vertices
142  *
143  * @param pointingVertex the pointing vertex
144  * @param targetPosition the target position
145  * @param longitidinal the longitudinal displacement
146  * @param transverse the transverse displacement
147  */
148  static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex,
149  float &longitudinal, float &transverse);
150 
151  /**
152  * @brief Calculate impact parameters between a pointing cluster vertex and a target position
153  *
154  * @param pointingVertex the pointing vertex
155  * @param targetPosition the target position
156  * @param longitidinal the longitudinal displacement
157  * @param transverse the transverse displacement
158  */
159  static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const pandora::CartesianVector &targetPosition,
160  float &longitudinal, float &transverse);
161 
162  /**
163  * @brief Calculate impact parameters of a specified position and direction to a target position
164  *
165  * @param initialPosition the initial position of the cluster
166  * @param initialDirection the initial direction of the cluster
167  * @param targetPosition the target position
168  * @param longitidinal the longitudinal displacement
169  * @param transverse the transverse displacement
170  */
171  static void GetImpactParameters(const pandora::CartesianVector &initialPosition, const pandora::CartesianVector &initialDirection,
172  const pandora::CartesianVector &targetPosition, float &longitudinal, float &transverse);
173 
174  /**
175  * @brief Get intersection of two vertices
176  *
177  * @param firstVertex the first vertex
178  * @param secondVertex the second vertex
179  * @param intersectPosition the position of the intersection
180  * @param firstDisplacement the displacement from first vertex to intersection
181  * @param secondDisplacement the displacement from second vertex to intersection
182  */
183  static void GetIntersection(const LArPointingCluster::Vertex &firstVertex, const LArPointingCluster::Vertex &secondVertex,
184  pandora::CartesianVector &intersectPosition, float &firstDisplacement, float &secondDisplacement);
185 
186  /**
187  * @brief Get average direction of two vertices
188  *
189  * @param firstVertex the first vertex
190  * @param secondVertex the second vertex
191  * @param averageDirection the average direction
192  */
193  static void GetAverageDirection(const LArPointingCluster::Vertex &firstVertex, const LArPointingCluster::Vertex &secondVertex,
194  pandora::CartesianVector &averageDirection);
195 
196  /**
197  * @brief Get intersection of two vertices
198  *
199  * @param firstPosition the position of the first vertex
200  * @param firstDirection the direction of the first vertex
201  * @param secondPosition the position of the second vertex
202  * @param secondDirection the direction of the second vertex
203  * @param intersectPosition the position of the intersection
204  * @param firstDisplacement the displacement from first vertex to intersection
205  * @param secondDisplacement the displacement from second vertex to intersection
206  */
207  static void GetIntersection(const pandora::CartesianVector &firstPosition, const pandora::CartesianVector &firstDirection,
208  const pandora::CartesianVector &secondPosition, const pandora::CartesianVector &secondDirection,
209  pandora::CartesianVector &intersectPosition, float &firstDisplacement, float &secondDisplacement);
210 
211  /**
212  * @brief Get intersection of vertex with target cluster
213  *
214  * @param vertexCluster the vertex
215  * @param pTargetCluster the target cluster
216  * @param intersectPosition the position of the intersection
217  * @param displacementL the longitudinal displacement
218  * @param displacementT the transverse displacement
219  */
220  static void GetIntersection(const LArPointingCluster::Vertex &vertexCluster, const pandora::Cluster *const pTargetCluster,
221  pandora::CartesianVector &intersectPosition, float &displacementL, float &displacementT);
222 
223  /**
224  * @brief Simple and fast vertex selection, choosing best vertex from a specified list to represent a set of pointing clusters
225  *
226  * @param vertexList the candidate vertex list
227  * @param pointingClusterList the pointing cluster list
228  * @param minLongitudinalDistance the min longitudinal distance cut
229  * @param maxLongitudinalDistance the max longitudinal distance cut
230  * @param maxTransverseDistance the max transverse distance cut
231  * @param angularAllowance the pointing angular allowance in degrees
232  *
233  * @return the best vertex estimate
234  */
236  const LArPointingClusterList &pointingClusterList, const float minLongitudinalDistance, const float maxLongitudinalDistance,
237  const float maxTransverseDistance, const float angularAllowance);
238 
239 private:
240  /**
241  * @brief Collect cluster vertices, from a provided input list, associated with a specified vertex
242  *
243  * @param vertex the vertex
244  * @param inputList the input list of pointing clusters
245  * @param minLongitudinalDistance the min longitudinal distance cut
246  * @param maxLongitudinalDistance the max longitudinal distance cut
247  * @param maxTransverseDistance the max transverse distance cut
248  * @param angularAllowance the pointing angular allowance in degrees
249  * @param outputList to receive the output list of cluster vertices associated with the specified vertex
250  */
252  const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance,
253  const float angularAllowance, LArPointingClusterVertexList &outputList);
254 
255  /**
256  * @brief Get an estimate of the energy associated with a specified vertex
257  *
258  * @param vertex the vertex
259  * @param clusterVertices the list of cluster vertices associated with the specified vertex
260  *
261  * @return the energy associated with a specified vertex
262  */
263  static float GetAssociatedEnergy(const LArPointingCluster::Vertex &vertex, const LArPointingClusterVertexList &clusterVertices);
264 };
265 
266 } // namespace lar_content
267 
268 #endif // #ifndef LAR_POINTING_CLUSTER_HELPER_H
process_name vertex
Definition: cheaterreco.fcl:51
Header file for the lar pointing cluster class.
static bool IsEmission(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance)
Whether pointing vertex is emitted from a given position.
static void GetClosestVerticesInYZ(const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ, LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ)
Given a pair of pointing clusters, find the pair of vertices with smallest yz-separation.
static void GetIntersection(const LArPointingCluster::Vertex &firstVertex, const LArPointingCluster::Vertex &secondVertex, pandora::CartesianVector &intersectPosition, float &firstDisplacement, float &secondDisplacement)
Get intersection of two vertices.
std::vector< LArPointingCluster > LArPointingClusterList
static void GetImpactParametersInYZ(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices using yz-coordinates.
static pandora::CartesianVector GetProjectedPosition(const pandora::CartesianVector &initialPosition, const pandora::CartesianVector &initialDirection, const pandora::Cluster *const pCluster, const float projectionAngularAllowance)
Get projected position on a cluster from a specified position and direction.
static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices.
static float GetLength(const LArPointingCluster &pointingCluster)
Calculate distance squared between inner and outer vertices of pointing cluster.
LArPointingCluster class.
LArPointingClusterHelper class.
static void GetClosestVertices(const bool useX, const bool useY, const bool useZ, const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ, LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ)
Given a pair of pointing clusters, receive the closest or farthest pair of vertices.
std::vector< LArPointingCluster::Vertex > LArPointingClusterVertexList
static void CollectAssociatedClusters(const LArPointingCluster::Vertex &vertex, const LArPointingClusterList &inputList, const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance, LArPointingClusterVertexList &outputList)
Collect cluster vertices, from a provided input list, associated with a specified vertex...
static float GetAssociatedEnergy(const LArPointingCluster::Vertex &vertex, const LArPointingClusterVertexList &clusterVertices)
Get an estimate of the energy associated with a specified vertex.
static void GetAverageDirection(const LArPointingCluster::Vertex &firstVertex, const LArPointingCluster::Vertex &secondVertex, pandora::CartesianVector &averageDirection)
Get average direction of two vertices.
static LArPointingCluster::Vertex GetBestVertexEstimate(const LArPointingClusterVertexList &vertexList, const LArPointingClusterList &pointingClusterList, const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance)
Simple and fast vertex selection, choosing best vertex from a specified list to represent a set of po...
static void GetClosestVerticesInX(const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ, LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ)
Given a pair of pointing clusters, find the pair of vertices with smallest x-separation.
static float GetLengthSquared(const LArPointingCluster &pointingCluster)
Calculate distance squared between inner and outer vertices of pointing cluster.
static bool IsNode(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxTransverseDistance)
Whether pointing vertex is adjacent to a given position.