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