9 #include "Pandora/Algorithm.h" 10 #include "Pandora/Pandora.h" 11 #include "Pandora/PandoraInternal.h" 29 bool LArConnectionPathwayHelper::SortByDistanceToPoint::operator()(
const CartesianVector &lhs,
const CartesianVector &rhs)
31 return (m_referencePoint.GetDistanceSquared(lhs) < m_referencePoint.GetDistanceSquared(rhs));
36 bool LArConnectionPathwayHelper::SortByDistanceToPoint::operator()(
const CaloHit *
const lhs,
const CaloHit *
const rhs)
38 return (m_referencePoint.GetDistanceSquared(lhs->GetPositionVector()) < m_referencePoint.GetDistanceSquared(rhs->GetPositionVector()));
45 bool LArConnectionPathwayHelper::FindShowerStarts3D(
const Algorithm *
const pAlgorithm,
const ParticleFlowObject *
const pShowerPfo,
46 const ProtoShowerMatch &protoShowerMatch,
const CartesianVector &nuVertexPosition,
const float maxSeparationFromHit,
47 const float maxProjectionSeparation,
const float maxXSeparation, CartesianPointVector &showerStarts3D)
54 bool uFound(
false), vFound(
false), wFound(
false);
55 CartesianVector uShowerStart3D(0.
f, 0.
f, 0.
f), vShowerStart3D(0.
f, 0.
f, 0.
f), wShowerStart3D(0.
f, 0.
f, 0.
f);
57 CaloHitList caloHitList3D;
58 LArPfoHelper::GetCaloHits(pShowerPfo, TPC_3D, caloHitList3D);
62 LArConnectionPathwayHelper::FindShowerStartFromPosition(pAlgorithm, protoShowerU, protoShowerV, protoShowerW, uShowerStart3D);
63 vShowerStart3D = uShowerStart3D;
64 wShowerStart3D = uShowerStart3D;
66 if (LArClusterHelper::GetClosestDistance(uShowerStart3D, caloHitList3D) < maxSeparationFromHit)
75 if (LArConnectionPathwayHelper::FindShowerStartFromDirection(
76 pAlgorithm, protoShowerU, protoShowerV, protoShowerW, uShowerStart3D, vShowerStart3D, wShowerStart3D))
78 if (LArClusterHelper::GetClosestDistance(uShowerStart3D, caloHitList3D) < maxSeparationFromHit)
81 if (LArClusterHelper::GetClosestDistance(vShowerStart3D, caloHitList3D) < maxSeparationFromHit)
84 if (LArClusterHelper::GetClosestDistance(wShowerStart3D, caloHitList3D) < maxSeparationFromHit)
91 if (LArConnectionPathwayHelper::FindShowerStartFromXProjection(
92 pAlgorithm, protoShowerU, protoShowerV, protoShowerW, maxProjectionSeparation, maxXSeparation, uShowerStart3D) ||
93 LArConnectionPathwayHelper::FindShowerStartFromXProjectionRelaxed(
94 pAlgorithm, protoShowerU, protoShowerV, protoShowerW, maxProjectionSeparation, maxXSeparation, uShowerStart3D) ||
95 LArConnectionPathwayHelper::FindShowerStartFromXProjectionRelaxed(
96 pAlgorithm, protoShowerU, protoShowerW, protoShowerV, maxProjectionSeparation, maxXSeparation, uShowerStart3D))
101 if (LArConnectionPathwayHelper::FindShowerStartFromXProjection(
102 pAlgorithm, protoShowerV, protoShowerW, protoShowerU, maxProjectionSeparation, maxXSeparation, vShowerStart3D) ||
103 LArConnectionPathwayHelper::FindShowerStartFromXProjectionRelaxed(
104 pAlgorithm, protoShowerV, protoShowerW, protoShowerU, maxProjectionSeparation, maxXSeparation, vShowerStart3D) ||
105 LArConnectionPathwayHelper::FindShowerStartFromXProjectionRelaxed(
106 pAlgorithm, protoShowerV, protoShowerU, protoShowerW, maxProjectionSeparation, maxXSeparation, vShowerStart3D))
111 if (LArConnectionPathwayHelper::FindShowerStartFromXProjection(
112 pAlgorithm, protoShowerW, protoShowerU, protoShowerV, maxProjectionSeparation, maxXSeparation, wShowerStart3D) ||
113 LArConnectionPathwayHelper::FindShowerStartFromXProjectionRelaxed(
114 pAlgorithm, protoShowerW, protoShowerU, protoShowerV, maxProjectionSeparation, maxXSeparation, wShowerStart3D) ||
115 LArConnectionPathwayHelper::FindShowerStartFromXProjectionRelaxed(
116 pAlgorithm, protoShowerW, protoShowerV, protoShowerU, maxProjectionSeparation, maxXSeparation, wShowerStart3D))
122 CartesianPointVector foundShowerStarts3D;
125 foundShowerStarts3D.push_back(uShowerStart3D);
128 foundShowerStarts3D.push_back(vShowerStart3D);
131 foundShowerStarts3D.push_back(wShowerStart3D);
133 if (foundShowerStarts3D.empty())
139 showerStarts3D.push_back(foundShowerStarts3D.front());
140 showerStarts3D.push_back((foundShowerStarts3D.size() == 3) ? foundShowerStarts3D[1] : foundShowerStarts3D[0]);
141 showerStarts3D.push_back(foundShowerStarts3D.back());
148 void LArConnectionPathwayHelper::FindShowerStartFromPosition(
const Algorithm *
const pAlgorithm,
const ProtoShower &protoShowerU,
156 LArGeometryHelper::MergeThreePositions3D(
157 pAlgorithm->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W, showerStartU, showerStartV, showerStartW, showerStart3D, chi2);
162 bool LArConnectionPathwayHelper::FindShowerStartFromDirection(
const Algorithm *
const pAlgorithm,
const ProtoShower &protoShowerU,
163 const ProtoShower &protoShowerV,
const ProtoShower &protoShowerW, CartesianVector &uShowerStart3D, CartesianVector &vShowerStart3D,
164 CartesianVector &wShowerStart3D)
167 if (!LArConnectionPathwayHelper::FindShowerStartFromDirection(pAlgorithm, protoShowerU, protoShowerV, protoShowerW, uShowerStart3D))
170 if (!LArConnectionPathwayHelper::FindShowerStartFromDirection(pAlgorithm, protoShowerV, protoShowerW, protoShowerU, vShowerStart3D))
173 if (!LArConnectionPathwayHelper::FindShowerStartFromDirection(pAlgorithm, protoShowerW, protoShowerU, protoShowerV, wShowerStart3D))
181 bool LArConnectionPathwayHelper::FindShowerStartFromDirection(
const Algorithm *
const pAlgorithm,
const ProtoShower &protoShower,
185 const float x(showerStart.GetX());
186 CartesianVector showerStartA(0.
f, 0.
f, 0.
f), showerStartB(0.
f, 0.
f, 0.
f);
188 if (!LArConnectionPathwayHelper::ProjectShowerStartByDirection(protoShowerA,
x, showerStartA))
191 if (!LArConnectionPathwayHelper::ProjectShowerStartByDirection(protoShowerB,
x, showerStartB))
199 LArGeometryHelper::MergeThreePositions3D(
200 pAlgorithm->GetPandora(), hitType, hitTypeA, hitTypeB, showerStart, showerStartA, showerStartB, showerStart3D, chi2);
207 bool LArConnectionPathwayHelper::ProjectShowerStartByDirection(
const ProtoShower &protoShower,
const float x, CartesianVector &showerStart2D)
212 const CartesianVector &displacement(viewShowerStart - viewNuVertex);
213 const float transverse(viewPeakDirection.GetCrossProduct(displacement).GetMagnitude());
215 if (transverse > 1.
f)
218 const CartesianVector xAxis(1.
f, 0.
f, 0.
f);
219 const float cosTheta(std::fabs(viewPeakDirection.GetCosOpeningAngle(xAxis)));
221 showerStart2D = viewNuVertex + (viewPeakDirection * (std::fabs(x - viewNuVertex.GetX()) * cosTheta));
228 bool LArConnectionPathwayHelper::FindShowerStartFromXProjection(
const Algorithm *
const pAlgorithm,
const ProtoShower &protoShower,
229 const ProtoShower &protoShower1,
const ProtoShower &protoShower2,
const float maxSeparation,
const float maxXSeparation, CartesianVector &showerStart3D)
232 CartesianVector showerStart1(0.
f, 0.
f, 0.
f), showerStart2(0.
f, 0.
f, 0.
f);
238 if (!LArConnectionPathwayHelper::FindClosestSpinePosition(protoShower1, showerStart, maxXSeparation, showerStart1))
241 if (!LArConnectionPathwayHelper::FindClosestSpinePosition(protoShower2, showerStart, maxXSeparation, showerStart2))
245 CartesianVector projection(0.
f, 0.
f, 0.
f), projection1(0.
f, 0.
f, 0.
f), projection2(0.
f, 0.
f, 0.
f);
247 LArGeometryHelper::MergeTwoPositions(pAlgorithm->GetPandora(), hitType1, hitType2, showerStart1, showerStart2, projection, chi2);
248 const float separationSquared((projection - showerStart).GetMagnitudeSquared());
250 LArGeometryHelper::MergeTwoPositions(pAlgorithm->GetPandora(), hitType, hitType2, showerStart, showerStart2, projection1, chi2);
251 const float separationSquared1((projection1 - showerStart1).GetMagnitudeSquared());
253 LArGeometryHelper::MergeTwoPositions(pAlgorithm->GetPandora(), hitType, hitType1, showerStart, showerStart1, projection2, chi2);
254 const float separationSquared2((projection2 - showerStart2).GetMagnitudeSquared());
256 if ((separationSquared > maxSeparation * maxSeparation) || (separationSquared1 > maxSeparation * maxSeparation) ||
257 (separationSquared2 > maxSeparation * maxSeparation))
262 LArGeometryHelper::MergeThreePositions3D(
263 pAlgorithm->GetPandora(), hitType, hitType1, hitType2, showerStart, showerStart1, showerStart2, showerStart3D, chi2);
270 bool LArConnectionPathwayHelper::FindClosestSpinePosition(
271 const ProtoShower &protoShower,
const CartesianVector &showerStart3D,
const float maxXSeparation, CartesianVector &foundShowerStart)
274 float lowestL(std::numeric_limits<float>::max());
278 if (std::fabs(pCaloHit->GetPositionVector().GetX() - showerStart3D.GetX()) > maxXSeparation)
284 if ((lVertex > 0.
f) && (lVertex < lowestL))
287 foundShowerStart = pCaloHit->GetPositionVector();
297 bool LArConnectionPathwayHelper::FindShowerStartFromXProjectionRelaxed(
const Algorithm *
const pAlgorithm,
const ProtoShower &protoShower,
298 const ProtoShower &protoShower1,
const ProtoShower &protoShower2,
const float maxSeparation,
const float maxXSeparation, CartesianVector &showerStart3D)
301 CartesianVector showerStart1(0.
f, 0.
f, 0.
f);
306 if (!LArConnectionPathwayHelper::FindClosestSpinePosition(protoShower1, showerStart, maxXSeparation, showerStart1))
310 CartesianVector projection2(0.
f, 0.
f, 0.
f);
312 LArGeometryHelper::MergeTwoPositions(pAlgorithm->GetPandora(), hitType, hitType1, showerStart, showerStart1, projection2, chi2);
316 const float separation(LArClusterHelper::GetClosestDistance(projection2, caloHitList2));
318 if (separation > maxSeparation)
321 LArGeometryHelper::MergeTwoPositions3D(pAlgorithm->GetPandora(), hitType, hitType1, showerStart, showerStart1, showerStart3D, chi2);
330 void LArConnectionPathwayHelper::GetMinMiddleMax(
331 const float value1,
const float value2,
const float value3,
float &minValue,
float &middleValue,
float &maxValue)
333 FloatVector
values({value1, value2, value3});
338 middleValue =
values.at(1);
const ProtoShower & GetProtoShowerU() const
Get the U view ProtoShower.
const ProtoShower & GetProtoShowerV() const
Get the V view ProtoShower.
Header file for the pfo helper class.
Header file for the ProtoShower class.
Header file for the connection pathway helper class.
Consistency
Consistency enumeration.
const ConnectionPathway & GetConnectionPathway() const
Get the connection pathway.
const pandora::CaloHitList & GetSpineHitList() const
Get the spine hit list.
const pandora::CartesianVector & GetStartPosition() const
Get the start position of the connection pathway.
Header file for the geometry helper class.
const pandora::CartesianVector & GetStartPosition() const
Get the start position of the shower core.
Header file for the cluster helper class.
const Consistency & GetConsistencyType() const
Get the consistency type.
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
SortByDistanceToPoint class.
const ShowerCore & GetShowerCore() const
Get the shower core.
const ProtoShower & GetProtoShowerW() const
Get the W view ProtoShower.
const pandora::CartesianVector & GetStartDirection() const
Get the start direction of the connection pathway.