38 return pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoW(position1, position2);
43 return pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoW(position2, position1);
48 return pandora.GetPlugins()->GetLArTransformationPlugin()->WUtoV(position1, position2);
53 return pandora.GetPlugins()->GetLArTransformationPlugin()->WUtoV(position2, position1);
58 return pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoU(position1, position2);
63 return pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoU(position2, position1);
75 if (direction1.
GetX() * direction2.
GetX() < 0.f)
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);
82 float pX(s1 * direction1.
GetX()), pU(0.f), pV(0.f), pW(0.f);
87 pU = s1 * direction1.
GetZ();
88 pV = s2 * direction2.
GetZ();
94 pV = s1 * direction1.
GetZ();
95 pU = s2 * direction2.
GetZ();
101 pW = s1 * direction1.
GetZ();
102 pU = s2 * direction2.
GetZ();
108 pU = s1 * direction1.
GetZ();
109 pW = s2 * direction2.
GetZ();
115 pV = s1 * direction1.
GetZ();
116 pW = s2 * direction2.
GetZ();
122 pW = s1 * direction1.
GetZ();
123 pV = s2 * direction2.
GetZ();
147 const float X3((position1.
GetX() + position2.
GetX()) / 2.f);
148 const float Z1(position1.
GetZ());
149 const float Z2(position2.
GetZ());
154 chiSquared = ((X3 - position1.
GetX()) * (X3 - position1.
GetX()) + (X3 - position2.
GetX()) * (X3 - position2.
GetX())) / (sigmaUVW * sigmaUVW);
168 float aveU(0.f), aveV(0.f), aveW(0.f);
169 const float Z1(position1.
GetZ()), Z2(position2.
GetZ()), Z3(position3.
GetZ()), aveX(position3.
GetX());
224 if ((view1 == view2) || (view2 == view3) || (view3 == view1))
265 const float YfromUV(
pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoY(positionU.
GetZ(), positionV.
GetZ()));
266 const float YfromUW(
pandora.GetPlugins()->GetLArTransformationPlugin()->UWtoY(positionU.
GetZ(), positionW.
GetZ()));
267 const float YfromVW(
pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoY(positionV.
GetZ(), positionW.
GetZ()));
269 const float ZfromUV(
pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoZ(positionU.
GetZ(), positionV.
GetZ()));
270 const float ZfromUW(
pandora.GetPlugins()->GetLArTransformationPlugin()->UWtoZ(positionU.
GetZ(), positionW.
GetZ()));
271 const float ZfromVW(
pandora.GetPlugins()->GetLArTransformationPlugin()->VWtoZ(positionV.
GetZ(), positionW.
GetZ()));
274 const bool useOldWZEquivalentTreatment(std::fabs(ZfromUW - ZfromVW) < std::numeric_limits<float>::epsilon());
275 const float aveX((positionU.
GetX() + positionV.
GetX() + positionW.
GetX()) / 3.f);
276 const float aveY(useOldWZEquivalentTreatment ? YfromUV : (YfromUV + YfromUW + YfromVW) / 3.f);
277 const float aveZ(useOldWZEquivalentTreatment ? (positionW.
GetZ() + 2.f * ZfromUV) / 3.f : (ZfromUV + ZfromUW + ZfromVW) / 3.f);
279 const float aveU(
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(aveY, aveZ));
280 const float aveV(
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(aveY, aveZ));
281 const float aveW(
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(aveY, aveZ));
288 chiSquared = ((outputU.
GetX() - positionU.
GetX()) * (outputU.
GetX() - positionU.
GetX()) +
293 (outputW.
GetZ() - positionW.
GetZ()) * (outputW.
GetZ() - positionW.
GetZ())) /
294 (sigmaUVW * sigmaUVW);
302 CartesianVector positionU(0.f, 0.f, 0.f), positionV(0.f, 0.f, 0.f), positionW(0.f, 0.f, 0.f);
305 position3D.
SetValues(positionW.
GetX(),
pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoY(positionU.GetZ(), positionV.GetZ()),
306 pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoZ(positionU.GetZ(), positionV.GetZ()));
314 CartesianVector positionU(0.f, 0.f, 0.f), positionV(0.f, 0.f, 0.f), positionW(0.f, 0.f, 0.f);
315 LArGeometryHelper::MergeThreePositions(
pandora, view1, view2, view3, position1, position2, position3, positionU, positionV, positionW, chiSquared);
317 position3D.
SetValues(positionW.
GetX(),
pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoY(positionU.GetZ(), positionV.GetZ()),
318 pandora.GetPlugins()->GetLArTransformationPlugin()->UVtoZ(positionU.GetZ(), positionV.GetZ()));
328 position3D.
GetX(), 0.f,
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(position3D.
GetY(), position3D.
GetZ()));
334 position3D.
GetX(), 0.f,
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(position3D.
GetY(), position3D.
GetZ()));
340 position3D.
GetX(), 0.f,
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(position3D.
GetY(), position3D.
GetZ()));
353 direction3D.
GetX(), 0.f,
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(direction3D.
GetY(), direction3D.
GetZ()))
360 direction3D.
GetX(), 0.f,
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(direction3D.
GetY(), direction3D.
GetZ()))
367 direction3D.
GetX(), 0.f,
pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(direction3D.
GetY(), direction3D.
GetZ()))
383 if (larTPCMap.empty())
385 std::cout <<
"LArGeometryHelper::GetWirePitch - LArTPC description not registered with Pandora as required " << std::endl;
389 const LArTPC *
const pFirstLArTPC(larTPCMap.begin()->second);
393 for (
const LArTPCMap::value_type &mapEntry : larTPCMap)
395 const LArTPC *
const pLArTPC(mapEntry.second);
396 const float alternateWirePitch(
399 if (std::fabs(wirePitch - alternateWirePitch) > maxWirePitchDiscrepancy)
401 std::cout <<
"LArGeometryHelper::GetWirePitch - LArTPC configuration not supported" << std::endl;
416 pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoU(0.f, 1.f));
422 pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoV(0.f, 1.f));
428 pandora.GetPlugins()->GetLArTransformationPlugin()->YZtoW(0.f, 1.f));
438 UIntSet daughterVolumeIds1, daughterVolumeIds2;
443 std::set_intersection(daughterVolumeIds1.begin(), daughterVolumeIds1.end(), daughterVolumeIds2.begin(), daughterVolumeIds2.end(),
444 std::inserter(intersect, intersect.begin()));
452 for (
const DetectorGap *
const pDetectorGap :
pandora.GetGeometry()->GetDetectorGapList())
454 if (pDetectorGap->IsInGap(testPoint2D, hitType, gapTolerance))
477 const bool minLayerIsAtLowX(minLayerPosition.
GetX() < maxLayerPosition.
GetX());
478 const CartesianVector &lowXCoordinate(minLayerIsAtLowX ? minLayerPosition : maxLayerPosition);
479 const CartesianVector &highXCoordinate(minLayerIsAtLowX ? maxLayerPosition : minLayerPosition);
481 if ((xSample > lowXCoordinate.
GetX()) && (xSample < highXCoordinate.GetX()))
494 const bool sampleIsNearerToLowX(std::fabs(xSample - lowXCoordinate.
GetX()) < std::fabs(xSample - highXCoordinate.GetX()));
495 const CartesianVector &startPosition(sampleIsNearerToLowX ? lowXCoordinate : highXCoordinate);
496 const CartesianVector &startDirection(sampleIsNearerToLowX ? lowXDirection : highXDirection);
498 if (std::fabs(startDirection.GetX()) < std::numeric_limits<float>::epsilon())
501 const float pathLength((xSample - startPosition.
GetX()) / startDirection.GetX());
502 const CartesianVector samplingPoint(startPosition + startDirection * pathLength);
511 if (maxZ - minZ < std::numeric_limits<float>::epsilon())
514 float gapDeltaZ(0.f);
516 for (
const DetectorGap *
const pDetectorGap :
pandora.GetGeometry()->GetDetectorGapList())
518 const LineGap *
const pLineGap =
dynamic_cast<const LineGap *
>(pDetectorGap);
534 const float gapMinZ(std::max(minZ, pLineGap->
GetLineStartZ()));
535 const float gapMaxZ(std::min(maxZ, pLineGap->
GetLineEndZ()));
537 if ((gapMaxZ - gapMinZ) > std::numeric_limits<float>::epsilon())
538 gapDeltaZ += (gapMaxZ - gapMinZ);
550 if (larTPCMap.empty())
552 std::cout <<
"LArGeometryHelper::GetSigmaUVW - LArTPC description not registered with Pandora as required " << std::endl;
556 const LArTPC *
const pFirstLArTPC(larTPCMap.begin()->second);
559 for (
const LArTPCMap::value_type &mapEntry : larTPCMap)
561 const LArTPC *
const pLArTPC(mapEntry.second);
563 if (std::fabs(sigmaUVW - pLArTPC->
GetSigmaUVW()) > maxSigmaDiscrepancy)
565 std::cout <<
"LArGeometryHelper::GetSigmaUVW - Plugin does not support provided LArTPC configurations " << std::endl;
Header file for the cartesian vector class.
Header file for the detector gap class.
Header file for the geometry manager class.
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the lar tpc class.
Header file for the lar two dimensional sliding fit result class.
Header file for the pandora class.
Header file for the pandora plugin manager class.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static void GetDaughterVolumeIDs(const pandora::Cluster *const pCluster, UIntSet &daughterVolumeIds)
Get the set of the daughter volumes that contains the cluster.
static float GetSigmaUVW(const pandora::Pandora &pandora, const float maxSigmaDiscrepancy=0.01)
Find the sigmaUVW value for the detector geometry.
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 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).
std::set< unsigned int > UIntSet
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 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 pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
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 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 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 ...
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 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.
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 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.
TwoDSlidingFitResult class.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
pandora::StatusCode GetGlobalFitPositionAtX(const float x, pandora::CartesianVector &position) const
Get global fit position for a given input x coordinate.
void SetValues(float x, float y, float z)
Set the values of cartesian vector components.
float GetX() const
Get the cartesian x coordinate.
CartesianVector GetUnitVector() const
Get a unit vector in the direction of the cartesian vector.
float GetZ() const
Get the cartesian z coordinate.
float GetY() const
Get the cartesian y coordinate.
float GetWirePitchU() const
Get the u wire pitch, units mm.
float GetWirePitchV() const
Get the v wire pitch, units mm.
float GetWirePitchW() const
Get the w wire pitch, units mm.
float GetSigmaUVW() const
Get the u, v, w resolution, units mm.
LineGap class, associated only with 2D TPC hit types and applied only to the z coordinate when sampli...
float GetLineEndZ() const
Get the line end z coordinate.
LineGapType GetLineGapType() const
Get the line gap type.
float GetLineStartZ() const
Get the line start z coordinate.
StatusCodeException class.
HitType
Calorimeter hit type enum.
std::map< unsigned int, const LArTPC * > LArTPCMap
LineGapType
Line gap type.