LArGeometryHelper.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArHelpers/LArGeometryHelper.h
3  *
4  * @brief Header file for the geometry helper class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_GEOMETRY_HELPER_H
9 #define LAR_GEOMETRY_HELPER_H 1
10 
11 #include "Pandora/PandoraEnumeratedTypes.h"
12 #include "Pandora/StatusCodes.h"
13 
14 #include <unordered_map>
15 
16 namespace pandora
17 {
18 class CartesianVector;
19 class Pandora;
20 } // namespace pandora
21 
22 namespace lar_content
23 {
24 
25 class TwoDSlidingFitResult;
26 
27 //------------------------------------------------------------------------------------------------------------------------------------------
28 
29 /**
30  * @brief LArGeometryHelper class
31  */
33 {
34 public:
35  typedef std::set<unsigned int> UIntSet;
36 
37  /**
38  * @brief Merge two views (U,V) to give a third view (Z).
39  *
40  * @param pandora the associated pandora instance
41  * @param view1 the first view
42  * @param view2 the second view
43  * @param position1 the position in the first view
44  * @param position2 the position in the second view
45  */
46  static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2,
47  const float position1, const float position2);
48 
49  /**
50  * @brief Merge two views (U,V) to give a third view (Z).
51  *
52  * @param pandora the associated pandora instance
53  * @param view1 the first view
54  * @param view2 the second view
55  * @param direction1 the direction in the first view
56  * @param direction2 the direction in the second view
57  */
58  static pandora::CartesianVector MergeTwoDirections(const pandora::Pandora &pandora, const pandora::HitType view1,
59  const pandora::HitType view2, const pandora::CartesianVector &direction1, const pandora::CartesianVector &direction2);
60 
61  /**
62  * @brief Merge 2D positions from two views to give 2D position in third view
63  *
64  * @param pandora the associated pandora instance
65  * @param view1 the first view
66  * @param view2 the second view
67  * @param position1 the position in the first view
68  * @param position2 the position in the second view
69  * @param position3 output position in the third view
70  * @param chi-squared
71  */
72  static void MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2,
73  const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &position3, float &chiSquared);
74 
75  /**
76  * @brief Merge 2D positions from two views to give 2D position in third view
77  *
78  * @param view1 the first view
79  * @param view2 the second view
80  * @param position1 the position in the first view
81  * @param position2 the position in the second view
82  *
83  * @param positionU output position in the U view
84  * @param positionV output position in the V view
85  * @param positionW output position in the W view
86  * @param chi-squared
87  */
88  static void MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2,
89  const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &outputU,
90  pandora::CartesianVector &outputV, pandora::CartesianVector &outputW, float &chiSquared);
91 
92  /**
93  * @brief Merge 2D positions from three views to give unified 2D positions for each view
94  *
95  * @param pandora the associated pandora instance
96  * @param view1 the first view
97  * @param view2 the second view
98  * @param view3 the third view
99  * @param position1 the position in the first view
100  * @param position2 the position in the second view
101  * @param position3 the position in the third view
102  * @param positionU output position in the U view
103  * @param positionV output position in the V view
104  * @param positionW output position in the W view
105  * @param chi-squared
106  */
107  static void MergeThreePositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2,
108  const pandora::HitType view3, const pandora::CartesianVector &position1, const pandora::CartesianVector &position2,
109  const pandora::CartesianVector &position3, pandora::CartesianVector &outputU, pandora::CartesianVector &outputV,
110  pandora::CartesianVector &outputW, float &chiSquared);
111 
112  /**
113  * @brief Merge 2D positions from three views to give unified 2D positions for each view
114  *
115  * @param pandora the associated pandora instance
116  * @param positionU input position in the U view
117  * @param positionV input position in the V view
118  * @param positionW input position in the W view
119  * @param positionU output position in the U view
120  * @param positionV output position in the V view
121  * @param positionW output position in the W view
122  * @param chi-squared
123  */
124  static void MergeThreePositions(const pandora::Pandora &pandora, const pandora::CartesianVector &positionU,
125  const pandora::CartesianVector &positionV, const pandora::CartesianVector &positionW, pandora::CartesianVector &outputU,
126  pandora::CartesianVector &outputV, pandora::CartesianVector &outputW, float &chiSquared);
127 
128  /**
129  * @brief Merge 2D positions from two views to give unified 3D position
130  *
131  * @param pandora the associated pandora instance
132  * @param view1 the first view
133  * @param view2 the second view
134  * @param position1 the position in the first view
135  * @param position2 the position in the second view
136  * @param position3D output position in 3D
137  * @param chi-squared
138  */
139  static void MergeTwoPositions3D(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2,
140  const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &position3D, float &chiSquared);
141 
142  /**
143  * @brief Merge 2D positions from three views to give unified 3D position
144  *
145  * @param pandora the associated pandora instance
146  * @param view1 the first view
147  * @param view2 the second view
148  * @param view3 the third view
149  * @param position1 the position in the first view
150  * @param position2 the position in the second view
151  * @param position3 the position in the third view
152  * @param position3D output position in 3D
153  * @param chi-squared
154  */
155  static void MergeThreePositions3D(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2,
156  const pandora::HitType view3, const pandora::CartesianVector &position1, const pandora::CartesianVector &position2,
157  const pandora::CartesianVector &position3, pandora::CartesianVector &position3D, float &chiSquared);
158 
159  /**
160  * @brief Project 3D position into a given 2D view
161  *
162  * @param pandora the associated pandora instance
163  * @param position3D the position in 3D
164  * @param view the 2D projection
165  */
166  static pandora::CartesianVector ProjectPosition(
167  const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view);
168 
169  /**
170  * @brief Project 3D direction into a given 2D view
171  *
172  * @param pandora the associated pandora instance
173  * @param direction3D the direction in 3D
174  * @param view the 2D projection
175  */
176  static pandora::CartesianVector ProjectDirection(
177  const pandora::Pandora &pandora, const pandora::CartesianVector &direction3D, const pandora::HitType view);
178 
179  /**
180  * @brief Return the wire pitch
181  *
182  * @param pandora the associated pandora instance
183  * @param maxWirePitchDiscrepancy maximum allowed discrepancy between lar tpc wire pitch value in the w view
184  */
185  static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy = 0.01);
186 
187  /**
188  * @brief Return the wire pitch
189  *
190  * @param pandora the associated pandora instance
191  * @param view the 2D projection
192  * @param maxWirePitchDiscrepancy maximum allowed discrepancy between lar tpc wire pitch values
193  */
194  static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy = 0.01);
195 
196  /**
197  * @brief Return the wire axis (vector perpendicular to the wire direction and drift direction)
198  *
199  * @param pandora the associated pandora instance
200  * @param view the 2D projection
201  */
202  static pandora::CartesianVector GetWireAxis(const pandora::Pandora &pandora, const pandora::HitType view);
203 
204  /**
205  * @brief Whether a 2D test point lies in a registered gap with the associated hit type
206  *
207  * @param pandora the associated pandora instance
208  * @param testPoint the test point
209  * @param hitType the hit type
210  * @param gapTolerance the gap tolerance
211  *
212  * @return boolean
213  */
214  static bool IsInGap(const pandora::Pandora &pandora, const pandora::CartesianVector &testPoint2D, const pandora::HitType hitType,
215  const float gapTolerance = 0.f);
216 
217  /**
218  * @brief Whether a 3D test point lies in a registered gap with the associated hit type
219  *
220  * @param pandora the associated pandora instance
221  * @param testPoint the test point
222  * @param hitType the hit type
223  * @param gapTolerance the gap tolerance
224  *
225  * @return boolean
226  */
227  static bool IsInGap3D(const pandora::Pandora &pandora, const pandora::CartesianVector &testPoint3D, const pandora::HitType hitType,
228  const float gapTolerance = 0.f);
229 
230  /**
231  * @brief Whether there is a gap in a cluster (described via its sliding fit result) at a specified x sampling position
232  *
233  * @param pandora the associated pandora instance
234  * @param xSample the x sampling position
235  * @param slidingFitResult the sliding fit result for a cluster
236  * @param gapTolerance the gap tolerance
237  *
238  * @return boolean
239  */
240  static bool IsXSamplingPointInGap(
241  const pandora::Pandora &pandora, const float xSample, const TwoDSlidingFitResult &slidingFitResult, const float gapTolerance = 0.f);
242 
243  /**
244  * @brief Calculate the total distance within a given 2D region that is composed of detector gaps
245  *
246  * @param pandora the associated pandora instance
247  * @param minZ the start position in Z
248  * @param maxZ the end position in Z
249  * @param hitType the hit type
250  */
251  static float CalculateGapDeltaZ(const pandora::Pandora &pandora, const float minZ, const float maxZ, const pandora::HitType hitType);
252 
253  /**
254  * @brief Find the sigmaUVW value for the detector geometry
255  *
256  * @param pandora the associated pandora instance
257  * @param maxSigmaDiscrepancy maximum allowed discrepancy between lar tpc sigmaUVW values
258  */
259  static float GetSigmaUVW(const pandora::Pandora &pandora, const float maxSigmaDiscrepancy = 0.01);
260 
261  /**
262  * @brief Return the set of common daughter volumes between two 2D clusters
263  *
264  * @param intersect the set of shared daughter volumes
265  * @param pCluster1 the first cluster
266  * @param pCluster2 the second cluster
267  */
268  static void GetCommonDaughterVolumes(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, UIntSet &intersect);
269 };
270 //------------------------------------------------------------------------------------------------------------------------------------------
271 
272 inline float LArGeometryHelper::GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchWDiscrepancy)
273 {
274  return LArGeometryHelper::GetWirePitch(pandora, pandora::TPC_VIEW_W, maxWirePitchWDiscrepancy);
275 }
276 
277 } // namespace lar_content
278 
279 #endif // #ifndef LAR_GEOMETRY_HELPER_H
enum cvn::HType HitType
LArGeometryHelper class.
std::set< unsigned int > UIntSet