Output the best split positions in branch and replacement clusters.
39 for (
unsigned int principalForward = 0; principalForward < 2; ++principalForward)
41 const CartesianVector principalVertexPosition(
42 1 == principalForward ? principalSlidingFit.GetGlobalMinLayerPosition() : principalSlidingFit.GetGlobalMaxLayerPosition());
43 const CartesianVector principalEndPosition(
44 1 != principalForward ? principalSlidingFit.GetGlobalMinLayerPosition() : principalSlidingFit.GetGlobalMaxLayerPosition());
45 const CartesianVector principalVertexDirection(1 == principalForward ? principalSlidingFit.GetGlobalMinLayerDirection()
46 : principalSlidingFit.GetGlobalMaxLayerDirection() * -1.f);
48 CartesianVector projectedBranchPosition(0.f, 0.f, 0.f);
49 bool projectedPositionFound(
false), projectedPositionFail(
false);
51 for (
unsigned int branchForward = 0; branchForward < 2; ++branchForward)
53 const CartesianVector branchVertexPosition(
54 1 == branchForward ? branchSlidingFit.GetGlobalMinLayerPosition() : branchSlidingFit.GetGlobalMaxLayerPosition());
55 const CartesianVector branchEndPosition(
56 1 != branchForward ? branchSlidingFit.GetGlobalMinLayerPosition() : branchSlidingFit.GetGlobalMaxLayerPosition());
57 const CartesianVector branchEndDirection(
58 1 != branchForward ? branchSlidingFit.GetGlobalMinLayerDirection() : branchSlidingFit.GetGlobalMaxLayerDirection() * -1.f);
60 if (principalVertexDirection.GetDotProduct(branchEndDirection) < 0.5f)
63 if ((principalEndPosition - branchEndPosition).GetMagnitudeSquared() < (principalVertexPosition - branchVertexPosition).GetMagnitudeSquared())
69 if (!projectedPositionFound && !projectedPositionFail)
73 projectedPositionFound =
true;
76 catch (StatusCodeException &)
78 projectedPositionFail =
true;
81 if (!projectedPositionFound || projectedPositionFail)
84 const float projectedDistanceSquared((projectedBranchPosition - principalVertexPosition).GetMagnitudeSquared());
89 const float commonDistanceSquared((projectedBranchPosition - branchEndPosition).GetMagnitudeSquared());
91 if (projectedDistanceSquared > commonDistanceSquared)
94 const float replacementDistanceSquared((projectedBranchPosition - principalEndPosition).GetMagnitudeSquared());
99 const float branchDistanceSquared((projectedBranchPosition - branchVertexPosition).GetMagnitudeSquared());
101 if (branchDistanceSquared > 4.f * replacementDistanceSquared)
105 bool foundSplit(
false);
107 const float halfWindowLength(branchSlidingFit.GetLayerFitHalfWindowLength());
108 const float deltaL(1 == branchForward ? +halfWindowLength : -halfWindowLength);
110 float localL(0.f), localT(0.f);
111 CartesianVector forwardDirection(0.f, 0.f, 0.f);
112 branchSlidingFit.GetLocalPosition(projectedBranchPosition, localL, localT);
114 if (STATUS_CODE_SUCCESS != branchSlidingFit.GetGlobalFitDirection(localL + deltaL, forwardDirection))
117 CartesianVector projectedBranchDirection(1 == branchForward ? forwardDirection : forwardDirection * -1.f);
118 const float cosTheta(-projectedBranchDirection.GetDotProduct(principalVertexDirection));
122 const float currentCosTheta(branchSlidingFit.GetCosScatteringAngle(localL));
124 if (cosTheta < currentCosTheta)
127 catch (StatusCodeException &)
131 float rT1(0.f), rL1(0.f), rT2(0.f), rL2(0.f);
138 principalStartPosition = principalVertexPosition;
139 branchSplitPosition = projectedBranchPosition;
140 branchSplitDirection = projectedBranchDirection * -1.f;
148 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
float m_minCosRelativeAngle
static pandora::CartesianVector GetProjectedPosition(const pandora::CartesianVector &initialPosition, const pandora::CartesianVector &initialDirection, const pandora::Cluster *const pCluster, const float projectionAngularAllowance)
Get projected position on a cluster from a specified position and direction.
static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices.
float m_projectionAngularAllowance
float m_maxLongitudinalDisplacement
float m_minLongitudinalExtension
float m_maxTransverseDisplacement