LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
LArGeometryHelper.cc
Go to the documentation of this file.
1 
9 #include "Managers/PluginManager.h"
10 #include "Managers/GeometryManager.h"
11 
12 #include "Geometry/DetectorGap.h"
13 #include "Geometry/LArTPC.h"
14 
15 #include "Objects/CartesianVector.h"
16 
17 #include "Pandora/Pandora.h"
18 
21 
23 
24 #include "Plugins/LArTransformationPlugin.h"
25 
26 using namespace pandora;
27 
28 namespace lar_content
29 {
30 
31 float LArGeometryHelper::MergeTwoPositions(const Pandora &pandora, const HitType view1, const HitType view2, const float position1, const float position2)
32 {
33  if (view1 == view2)
34  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
35 
36  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_V))
37  {
38  return pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoW(position1, position2);
39  }
40 
41  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_U))
42  {
43  return pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoW(position2, position1);
44  }
45 
46  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_U))
47  {
48  return pandora.GetPlugins()->GetLArTransformationPlugin()->WUtoV(position1, position2);
49  }
50 
51  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_W))
52  {
53  return pandora.GetPlugins()->GetLArTransformationPlugin()->WUtoV(position2, position1);
54  }
55 
56  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_W))
57  {
58  return pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoU(position1, position2);
59  }
60 
61  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_V))
62  {
63  return pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoU(position2, position1);
64  }
65 
66  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
67 }
68 
69 //------------------------------------------------------------------------------------------------------------------------------------------
70 
71 CartesianVector LArGeometryHelper::MergeTwoDirections(const Pandora &pandora, const HitType view1, const HitType view2,
72  const CartesianVector &direction1, const CartesianVector &direction2)
73 {
74  // x components must be consistent
75  if (direction1.GetX() * direction2.GetX() < 0.f)
76  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
77 
78  // scale x components to a common value
79  const float s1((std::fabs(direction1.GetX()) > std::numeric_limits<float>::epsilon()) ? 100.f * std::fabs(direction2.GetX()) : 1.f);
80  const float s2((std::fabs(direction2.GetX()) > std::numeric_limits<float>::epsilon()) ? 100.f * std::fabs(direction1.GetX()) : 1.f);
81 
82  float pX(s1 * direction1.GetX()), pU(0.f), pV(0.f), pW(0.f);
83  HitType newView(HIT_CUSTOM);
84 
85  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_V))
86  {
87  pU = s1 * direction1.GetZ(); pV = s2 * direction2.GetZ(); newView = TPC_VIEW_W;
88  }
89 
90  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_U))
91  {
92  pV = s1 * direction1.GetZ(); pU = s2 * direction2.GetZ(); newView = TPC_VIEW_W;
93  }
94 
95  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_U))
96  {
97  pW = s1 * direction1.GetZ(); pU = s2 * direction2.GetZ(); newView = TPC_VIEW_V;
98  }
99 
100  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_W))
101  {
102  pU = s1 * direction1.GetZ(); pW = s2 * direction2.GetZ(); newView = TPC_VIEW_V;
103  }
104 
105  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_W))
106  {
107  pV = s1 * direction1.GetZ(); pW = s2 * direction2.GetZ(); newView = TPC_VIEW_U;
108  }
109 
110  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_V))
111  {
112  pW = s1 * direction1.GetZ(); pV = s2 * direction2.GetZ(); newView = TPC_VIEW_U;
113  }
114 
115  if (newView == TPC_VIEW_W)
116  return CartesianVector(pX, 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoW(pU, pV)).GetUnitVector();
117 
118  if (newView == TPC_VIEW_U)
119  return CartesianVector(pX, 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoU(pV, pW)).GetUnitVector();
120 
121  if (newView == TPC_VIEW_V)
122  return CartesianVector(pX, 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->WUtoV(pW, pU)).GetUnitVector();
123 
124  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
125 }
126 
127 //------------------------------------------------------------------------------------------------------------------------------------------
128 
129 void LArGeometryHelper::MergeTwoPositions(const Pandora &pandora, const HitType view1, const HitType view2, const CartesianVector &position1,
130  const CartesianVector &position2, CartesianVector &position3, float& chiSquared)
131 {
132  if (view1 == view2)
133  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
134 
135  const float X3((position1.GetX() + position2.GetX() ) / 2.f);
136  const float Z1(position1.GetZ());
137  const float Z2(position2.GetZ());
138  const float Z3(LArGeometryHelper::MergeTwoPositions(pandora, view1, view2, Z1, Z2));
139 
140  position3.SetValues(X3, 0.f, Z3);
141  const float sigmaUVW(LArGeometryHelper::GetSigmaUVW(pandora));
142  chiSquared = ((X3 - position1.GetX()) * (X3 - position1.GetX()) + (X3 - position2.GetX()) * (X3 - position2.GetX())) / (sigmaUVW * sigmaUVW);
143 }
144 
145 //------------------------------------------------------------------------------------------------------------------------------------------
146 
147 void LArGeometryHelper::MergeTwoPositions(const Pandora &pandora, const HitType view1, const HitType view2, const CartesianVector &position1,
148  const CartesianVector &position2, CartesianVector &outputU, CartesianVector &outputV, CartesianVector &outputW, float& chiSquared)
149 {
150  if (view1 == view2)
151  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
152 
153  CartesianVector position3(0.f, 0.f, 0.f);
154  LArGeometryHelper::MergeTwoPositions(pandora, view1, view2, position1, position2, position3, chiSquared);
155 
156  float aveU(0.f), aveV(0.f), aveW(0.f);
157  const float Z1(position1.GetZ()), Z2(position2.GetZ()), Z3(position3.GetZ()), aveX(position3.GetX());
158 
159  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_V))
160  {
161  aveU = Z1; aveV = Z2; aveW = Z3;
162  }
163 
164  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_W))
165  {
166  aveV = Z1; aveW = Z2; aveU = Z3;
167  }
168 
169  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_U))
170  {
171  aveW = Z1; aveU = Z2; aveV = Z3;
172  }
173 
174  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_U))
175  {
176  aveV = Z1; aveU = Z2; aveW = Z3;
177  }
178 
179  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_V))
180  {
181  aveW = Z1; aveV = Z2; aveU = Z3;
182  }
183 
184  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_W))
185  {
186  aveU = Z1; aveW = Z2; aveV = Z3;
187  }
188 
189  outputU.SetValues( aveX, 0.f, aveU );
190  outputV.SetValues( aveX, 0.f, aveV );
191  outputW.SetValues( aveX, 0.f, aveW );
192 }
193 
194 //------------------------------------------------------------------------------------------------------------------------------------------
195 
196 void LArGeometryHelper::MergeThreePositions(const Pandora &pandora, const HitType view1, const HitType view2, const HitType view3,
197  const CartesianVector &position1, const CartesianVector &position2, const CartesianVector &position3, CartesianVector &outputU,
198  CartesianVector &outputV, CartesianVector &outputW, float &chiSquared)
199 {
200  if ((view1 == view2) || (view2 == view3) || (view3 == view1))
201  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
202 
203  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_V))
204  {
205  return LArGeometryHelper::MergeThreePositions(pandora, position1, position2, position3, outputU, outputV, outputW, chiSquared);
206  }
207 
208  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_W))
209  {
210  return LArGeometryHelper::MergeThreePositions(pandora, position3, position1, position2, outputU, outputV, outputW, chiSquared );
211  }
212 
213  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_U))
214  {
215  return LArGeometryHelper::MergeThreePositions(pandora, position2, position3, position1, outputU, outputV, outputW, chiSquared);
216  }
217 
218  if ((view1 == TPC_VIEW_V) && (view2 == TPC_VIEW_U))
219  {
220  return LArGeometryHelper::MergeThreePositions(pandora, position2, position1, position3, outputU, outputV, outputW, chiSquared);
221  }
222 
223  if ((view1 == TPC_VIEW_W) && (view2 == TPC_VIEW_V))
224  {
225  return LArGeometryHelper::MergeThreePositions(pandora, position3, position2, position1, outputU, outputV, outputW, chiSquared);
226  }
227 
228  if ((view1 == TPC_VIEW_U) && (view2 == TPC_VIEW_W))
229  {
230  return LArGeometryHelper::MergeThreePositions(pandora, position1, position3, position2, outputU, outputV, outputW, chiSquared);
231  }
232 
233  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
234 }
235 
236 //------------------------------------------------------------------------------------------------------------------------------------------
237 
238 void LArGeometryHelper::MergeThreePositions(const Pandora &pandora, const CartesianVector &positionU, const CartesianVector &positionV,
239  const CartesianVector &positionW, CartesianVector &outputU, CartesianVector &outputV, CartesianVector &outputW, float &chiSquared)
240 {
241  const float YfromUV(pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoY(positionU.GetZ(), positionV.GetZ()));
242  const float YfromUW(pandora.GetPlugins()->GetLArTransformationPlugin()->UWtoY(positionU.GetZ(), positionW.GetZ()));
243  const float YfromVW(pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoY(positionV.GetZ(), positionW.GetZ()));
244 
245  const float ZfromUV(pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoZ(positionU.GetZ(), positionV.GetZ()));
246  const float ZfromUW(pandora.GetPlugins()->GetLArTransformationPlugin()->UWtoZ(positionU.GetZ(), positionW.GetZ()));
247  const float ZfromVW(pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoZ(positionV.GetZ(), positionW.GetZ()));
248 
249  // ATTN For detectors where w and z are equivalent, remain consistent with original treatment. TODO Use new treatment always.
250  const bool useOldWZEquivalentTreatment(std::fabs(ZfromUW - ZfromVW) < std::numeric_limits<float>::epsilon());
251  const float aveX((positionU.GetX() + positionV.GetX() + positionW.GetX()) / 3.f);
252  const float aveY(useOldWZEquivalentTreatment ? YfromUV : (YfromUV + YfromUW + YfromVW) / 3.f);
253  const float aveZ(useOldWZEquivalentTreatment ? (positionW.GetZ() + 2.f * ZfromUV) / 3.f : (ZfromUV + ZfromUW + ZfromVW) / 3.f);
254 
255  const float aveU(pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(aveY, aveZ));
256  const float aveV(pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(aveY, aveZ));
257  const float aveW(pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(aveY, aveZ));
258 
259  outputU.SetValues(aveX, 0.f, aveU);
260  outputV.SetValues(aveX, 0.f, aveV);
261  outputW.SetValues(aveX, 0.f, aveW);
262 
263  const float sigmaUVW(LArGeometryHelper::GetSigmaUVW(pandora));
264  chiSquared = ((outputU.GetX() - positionU.GetX()) * (outputU.GetX() - positionU.GetX()) +
265  (outputV.GetX() - positionV.GetX()) * (outputV.GetX() - positionV.GetX()) +
266  (outputW.GetX() - positionW.GetX()) * (outputW.GetX() - positionW.GetX()) +
267  (outputU.GetZ() - positionU.GetZ()) * (outputU.GetZ() - positionU.GetZ()) +
268  (outputV.GetZ() - positionV.GetZ()) * (outputV.GetZ() - positionV.GetZ()) +
269  (outputW.GetZ() - positionW.GetZ()) * (outputW.GetZ() - positionW.GetZ())) / (sigmaUVW * sigmaUVW);
270 }
271 
272 //------------------------------------------------------------------------------------------------------------------------------------------
273 
274 void LArGeometryHelper::MergeTwoPositions3D(const Pandora &pandora, const HitType view1, const HitType view2, const CartesianVector &position1,
275  const CartesianVector &position2, CartesianVector &position3D, float &chiSquared)
276 {
277  CartesianVector positionU(0.f, 0.f, 0.f), positionV(0.f, 0.f, 0.f), positionW(0.f, 0.f, 0.f);
278  LArGeometryHelper::MergeTwoPositions(pandora, view1, view2, position1, position2, positionU, positionV, positionW, chiSquared);
279 
280  position3D.SetValues(positionW.GetX(), pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoY(positionU.GetZ(),positionV.GetZ()),
281  pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoZ(positionU.GetZ(),positionV.GetZ()) );
282 }
283 
284 //------------------------------------------------------------------------------------------------------------------------------------------
285 
286 void LArGeometryHelper::MergeThreePositions3D(const Pandora &pandora, const HitType view1, const HitType view2, const HitType view3,
287  const CartesianVector &position1, const CartesianVector &position2, const CartesianVector &position3, CartesianVector &position3D, float &chiSquared)
288 {
289  CartesianVector positionU(0.f, 0.f, 0.f), positionV(0.f, 0.f, 0.f), positionW(0.f, 0.f, 0.f);
290  LArGeometryHelper::MergeThreePositions(pandora, view1, view2, view3, position1, position2, position3, positionU, positionV, positionW, chiSquared);
291 
292  position3D.SetValues(positionW.GetX(), pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoY(positionU.GetZ(),positionV.GetZ()),
293  pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoZ(positionU.GetZ(),positionV.GetZ()));
294 }
295 
296 //------------------------------------------------------------------------------------------------------------------------------------------
297 
298 CartesianVector LArGeometryHelper::ProjectPosition(const Pandora &pandora, const CartesianVector &position3D, const HitType view)
299 {
300  if (view == TPC_VIEW_U)
301  {
302  return CartesianVector(position3D.GetX(), 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(position3D.GetY(), position3D.GetZ()));
303  }
304 
305  else if (view == TPC_VIEW_V)
306  {
307  return CartesianVector(position3D.GetX(), 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(position3D.GetY(), position3D.GetZ()));
308  }
309 
310  else if (view == TPC_VIEW_W)
311  {
312  return CartesianVector(position3D.GetX(), 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(position3D.GetY(), position3D.GetZ()));
313  }
314 
315  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
316 }
317 
318 //------------------------------------------------------------------------------------------------------------------------------------------
319 
320 CartesianVector LArGeometryHelper::ProjectDirection(const Pandora &pandora, const CartesianVector &direction3D, const HitType view)
321 {
322  if (view == TPC_VIEW_U)
323  {
324  return CartesianVector(direction3D.GetX(), 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(direction3D.GetY(), direction3D.GetZ())).GetUnitVector();
325  }
326 
327  else if (view == TPC_VIEW_V)
328  {
329  return CartesianVector(direction3D.GetX(), 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(direction3D.GetY(), direction3D.GetZ())).GetUnitVector();
330  }
331 
332  else if (view == TPC_VIEW_W)
333  {
334  return CartesianVector(direction3D.GetX(), 0.f, pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(direction3D.GetY(), direction3D.GetZ())).GetUnitVector();
335  }
336 
337  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
338 }
339 
340 //------------------------------------------------------------------------------------------------------------------------------------------
341 
342 float LArGeometryHelper::GetWirePitch(const Pandora &pandora, const HitType view, const float maxWirePitchDiscrepancy)
343 {
344  if (view != TPC_VIEW_U && view != TPC_VIEW_V && view != TPC_VIEW_W)
345  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
346 
347  const LArTPCMap &larTPCMap(pandora.GetGeometry()->GetLArTPCMap());
348 
349  if (larTPCMap.empty())
350  {
351  std::cout << "LArGeometryHelper::GetWirePitch - LArTPC description not registered with Pandora as required " << std::endl;
352  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
353  }
354 
355  const LArTPC *const pFirstLArTPC(larTPCMap.begin()->second);
356  const float wirePitch(view == TPC_VIEW_U ? pFirstLArTPC->GetWirePitchU() : (view == TPC_VIEW_V ? pFirstLArTPC->GetWirePitchV() : pFirstLArTPC->GetWirePitchW()));
357 
358  for (const LArTPCMap::value_type &mapEntry : larTPCMap)
359  {
360  const LArTPC *const pLArTPC(mapEntry.second);
361  const float alternateWirePitch(view == TPC_VIEW_U ? pLArTPC->GetWirePitchU() : (view == TPC_VIEW_V ? pLArTPC->GetWirePitchV() : pLArTPC->GetWirePitchW()));
362 
363  if (std::fabs(wirePitch - alternateWirePitch) > maxWirePitchDiscrepancy)
364  {
365  std::cout << "LArGeometryHelper::GetWirePitch - LArTPC configuration not supported" << std::endl;
366  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
367  }
368  }
369 
370  return wirePitch;
371 }
372 
373 //------------------------------------------------------------------------------------------------------------------------------------------
374 
375 CartesianVector LArGeometryHelper::GetWireAxis(const Pandora &pandora, const HitType view)
376 {
377  if (view == TPC_VIEW_U)
378  {
379  return CartesianVector(0.f,
380  pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(1.f, 0.f),
381  pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(0.f, 1.f));
382  }
383 
384  else if (view == TPC_VIEW_V)
385  {
386  return CartesianVector(0.f,
387  pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(1.f, 0.f),
388  pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(0.f, 1.f));
389  }
390 
391  else if (view == TPC_VIEW_W)
392  {
393  return CartesianVector(0.f,
394  pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(1.f, 0.f),
395  pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(0.f, 1.f));
396  }
397 
398  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
399 }
400 
401 //------------------------------------------------------------------------------------------------------------------------------------------
402 
403 bool LArGeometryHelper::IsInGap(const Pandora &pandora, const CartesianVector &testPoint2D, const HitType hitType, const float gapTolerance)
404 {
405  // ATTN: input test point MUST be a 2D position vector
406  for (const DetectorGap *const pDetectorGap : pandora.GetGeometry()->GetDetectorGapList())
407  {
408  if (pDetectorGap->IsInGap(testPoint2D, hitType, gapTolerance))
409  return true;
410  }
411 
412  return false;
413 }
414 
415 //------------------------------------------------------------------------------------------------------------------------------------------
416 
417 bool LArGeometryHelper::IsInGap3D(const Pandora &pandora, const CartesianVector &testPoint3D, const HitType hitType, const float gapTolerance)
418 {
419  const CartesianVector testPoint2D(LArGeometryHelper::ProjectPosition(pandora, testPoint3D, hitType));
420  return LArGeometryHelper::IsInGap(pandora, testPoint2D, hitType, gapTolerance);
421 }
422 
423 //------------------------------------------------------------------------------------------------------------------------------------------
424 
425 bool LArGeometryHelper::IsXSamplingPointInGap(const Pandora &pandora, const float xSample, const TwoDSlidingFitResult &slidingFitResult,
426  const float gapTolerance)
427 {
428  const HitType hitType(LArClusterHelper::GetClusterHitType(slidingFitResult.GetCluster()));
429  const CartesianVector minLayerPosition(slidingFitResult.GetGlobalMinLayerPosition());
430  const CartesianVector maxLayerPosition(slidingFitResult.GetGlobalMaxLayerPosition());
431 
432  const bool minLayerIsAtLowX(minLayerPosition.GetX() < maxLayerPosition.GetX());
433  const CartesianVector &lowXCoordinate(minLayerIsAtLowX ? minLayerPosition : maxLayerPosition);
434  const CartesianVector &highXCoordinate(minLayerIsAtLowX ? maxLayerPosition : minLayerPosition);
435 
436  if ((xSample > lowXCoordinate.GetX()) && (xSample < highXCoordinate.GetX()))
437  {
438  CartesianVector slidingFitPosition(0.f, 0.f, 0.f);
439 
440  if (STATUS_CODE_SUCCESS == slidingFitResult.GetGlobalFitPositionAtX(xSample, slidingFitPosition))
441  return (LArGeometryHelper::IsInGap(pandora, slidingFitPosition, hitType, gapTolerance));
442  }
443 
444  const CartesianVector lowXDirection(minLayerIsAtLowX ? slidingFitResult.GetGlobalMinLayerDirection() : slidingFitResult.GetGlobalMaxLayerDirection());
445  const CartesianVector highXDirection(minLayerIsAtLowX ? slidingFitResult.GetGlobalMaxLayerDirection() : slidingFitResult.GetGlobalMinLayerDirection());
446 
447  const bool sampleIsNearerToLowX(std::fabs(xSample - lowXCoordinate.GetX()) < std::fabs(xSample - highXCoordinate.GetX()));
448  const CartesianVector &startPosition(sampleIsNearerToLowX ? lowXCoordinate : highXCoordinate);
449  const CartesianVector &startDirection(sampleIsNearerToLowX ? lowXDirection : highXDirection);
450 
451  if (std::fabs(startDirection.GetX()) < std::numeric_limits<float>::epsilon())
452  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
453 
454  const float pathLength((xSample - startPosition.GetX()) / startDirection.GetX());
455  const CartesianVector samplingPoint(startPosition + startDirection * pathLength);
456 
457  return (LArGeometryHelper::IsInGap(pandora, samplingPoint, hitType, gapTolerance));
458 }
459 
460 //------------------------------------------------------------------------------------------------------------------------------------------
461 
462 float LArGeometryHelper::CalculateGapDeltaZ(const Pandora &pandora, const float minZ, const float maxZ, const HitType hitType)
463 {
464  if (maxZ - minZ < std::numeric_limits<float>::epsilon())
465  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
466 
467  float gapDeltaZ(0.f);
468 
469  for (const DetectorGap *const pDetectorGap : pandora.GetGeometry()->GetDetectorGapList())
470  {
471  const LineGap *const pLineGap = dynamic_cast<const LineGap*>(pDetectorGap);
472 
473  if (!pLineGap)
474  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
475 
476  const LineGapType lineGapType(pLineGap->GetLineGapType());
477 
478  if (!(((TPC_VIEW_U == hitType) && (TPC_WIRE_GAP_VIEW_U == lineGapType)) ||
479  ((TPC_VIEW_V == hitType) && (TPC_WIRE_GAP_VIEW_V == lineGapType)) ||
480  ((TPC_VIEW_W == hitType) && (TPC_WIRE_GAP_VIEW_W == lineGapType))))
481  {
482  continue;
483  }
484 
485  if ((pLineGap->GetLineStartZ() > maxZ) || (pLineGap->GetLineEndZ() < minZ))
486  continue;
487 
488  const float gapMinZ(std::max(minZ, pLineGap->GetLineStartZ()));
489  const float gapMaxZ(std::min(maxZ, pLineGap->GetLineEndZ()));
490 
491  if ((gapMaxZ - gapMinZ) > std::numeric_limits<float>::epsilon())
492  gapDeltaZ += (gapMaxZ - gapMinZ);
493  }
494 
495  return gapDeltaZ;
496 }
497 
498 //------------------------------------------------------------------------------------------------------------------------------------------
499 
500 float LArGeometryHelper::GetSigmaUVW(const Pandora &pandora, const float maxSigmaDiscrepancy)
501 {
502  const LArTPCMap &larTPCMap(pandora.GetGeometry()->GetLArTPCMap());
503 
504  if (larTPCMap.empty())
505  {
506  std::cout << "LArGeometryHelper::GetSigmaUVW - LArTPC description not registered with Pandora as required " << std::endl;
507  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
508  }
509 
510  const LArTPC *const pFirstLArTPC(larTPCMap.begin()->second);
511  const float sigmaUVW(pFirstLArTPC->GetSigmaUVW());
512 
513  for (const LArTPCMap::value_type &mapEntry : larTPCMap)
514  {
515  const LArTPC *const pLArTPC(mapEntry.second);
516 
517  if (std::fabs(sigmaUVW - pLArTPC->GetSigmaUVW()) > maxSigmaDiscrepancy)
518  {
519  std::cout << "LArGeometryHelper::GetSigmaUVW - Plugin does not support provided LArTPC configurations " << std::endl;
520  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
521  }
522  }
523 
524  return sigmaUVW;
525 }
526 
527 } // namespace lar_content
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
TFile f
Definition: plotHisto.C:6
Header file for the geometry helper class.
Int_t max
Definition: plot.C:27
Header file for the cluster helper class.
Header file for the lar two dimensional sliding fit result class.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
Double_t Z2
Definition: plot.C:266
Double_t Z1
Definition: plot.C:266
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
pandora::StatusCode GetGlobalFitPositionAtX(const float x, pandora::CartesianVector &position) const
Get global fit position for a given input x coordinate.
Int_t min
Definition: plot.C:26
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.