Find the best split position and direction for a pair of clusters.
94 return STATUS_CODE_NOT_FOUND;
98 const CartesianVector &minPosition1(slidingFitResult1.GetGlobalMinLayerPosition());
99 const CartesianVector &maxPosition1(slidingFitResult1.GetGlobalMaxLayerPosition());
101 const CartesianVector &minPosition2(slidingFitResult2.GetGlobalMinLayerPosition());
102 const CartesianVector &maxPosition2(slidingFitResult2.GetGlobalMaxLayerPosition());
109 return STATUS_CODE_NOT_FOUND;
113 return STATUS_CODE_NOT_FOUND;
115 CartesianPointVector candidateVector;
118 if (candidateVector.empty())
119 return STATUS_CODE_NOT_FOUND;
122 bool foundSplit(
false);
125 const float halfWindowLength1(slidingFitResult1.GetLayerFitHalfWindowLength());
126 const float halfWindowLength2(slidingFitResult2.GetLayerFitHalfWindowLength());
130 const CartesianVector &candidatePosition(*iter);
133 float rL1(0.
f), rT1(0.
f);
134 CartesianVector R1(0.
f, 0.
f, 0.
f);
135 CartesianVector
F1(0.
f, 0.
f, 0.
f);
136 CartesianVector B1(0.
f, 0.
f, 0.
f);
138 if (STATUS_CODE_SUCCESS != slidingFitResult1.GetGlobalFitProjection(candidatePosition, R1))
141 slidingFitResult1.GetLocalPosition(R1, rL1, rT1);
142 if ((STATUS_CODE_SUCCESS != slidingFitResult1.GetGlobalFitPosition(rL1 + halfWindowLength1,
F1)) ||
143 (STATUS_CODE_SUCCESS != slidingFitResult1.GetGlobalFitPosition(rL1 - halfWindowLength1, B1)))
149 float rL2(0.
f), rT2(0.
f);
150 CartesianVector R2(0.
f, 0.
f, 0.
f);
151 CartesianVector
F2(0.
f, 0.
f, 0.
f);
152 CartesianVector B2(0.
f, 0.
f, 0.
f);
154 if (STATUS_CODE_SUCCESS != slidingFitResult2.GetGlobalFitProjection(candidatePosition, R2))
157 slidingFitResult2.GetLocalPosition(R2, rL2, rT2);
158 if ((STATUS_CODE_SUCCESS != slidingFitResult2.GetGlobalFitPosition(rL2 + halfWindowLength2,
F2)) ||
159 (STATUS_CODE_SUCCESS != slidingFitResult2.GetGlobalFitPosition(rL2 - halfWindowLength2, B2)))
165 const CartesianVector C0((R1 + R2) * 0.5);
185 const CartesianVector
a1(B1);
186 const CartesianVector
a2(
F1);
188 for (
unsigned int iForward = 0; iForward < 2; ++iForward)
190 const CartesianVector b1((0 == iForward) ?
F2 : B2);
191 const CartesianVector b2((0 == iForward) ? B2 :
F2);
193 const CartesianVector s1((b1 - R2).GetUnitVector());
194 const CartesianVector
t1((R1 -
a1).GetUnitVector());
195 const CartesianVector s2((b2 - R2).GetUnitVector());
196 const CartesianVector t2((R1 -
a2).GetUnitVector());
202 const CartesianVector p1((b1 -
a1).GetUnitVector());
203 const CartesianVector p2((b2 -
a2).GetUnitVector());
205 float mu1(0.
f), mu2(0.
f);
206 CartesianVector
C1(0.
f, 0.
f, 0.
f);
212 catch (
const StatusCodeException &)
217 if (mu1 < 0.
f || mu2 < 0.f || mu1 > (b1 -
a1).GetMagnitude() || mu2 > (b2 -
a2).GetMagnitude())
220 const float thisSeparationSquared((C0 -
C1).GetMagnitudeSquared());
222 if (thisSeparationSquared < closestSeparationSquared)
224 closestSeparationSquared = thisSeparationSquared;
225 splitPosition = (C0 +
C1) * 0.5;
226 firstDirection = t2 * -1.f;
227 secondDirection =
t1;
234 return STATUS_CODE_NOT_FOUND;
236 return STATUS_CODE_SUCCESS;
static void GetIntersection(const LArPointingCluster::Vertex &firstVertex, const LArPointingCluster::Vertex &secondVertex, pandora::CartesianVector &intersectPosition, float &firstDisplacement, float &secondDisplacement)
Get intersection of two vertices.
float m_minCosRelativeAngle
maximum relative angle between tracks after un-crossing
static int max(int a, int b)
void FindCandidateSplitPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianPointVector &candidateVector) const
Find average positions of pairs of hits within a maximum separation.
float m_maxClusterSeparation
maximum separation of two clusters
ClusterToClustersMap m_nearbyClusters
The nearby clusters map.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.