9 #include "Pandora/AlgorithmHeaders.h" 20 BranchSplittingAlgorithm::BranchSplittingAlgorithm() :
21 m_maxTransverseDisplacement(1.5
f),
22 m_maxLongitudinalDisplacement(10.
f),
23 m_minLongitudinalExtension(3.
f),
24 m_minCosRelativeAngle(0.966
f),
25 m_projectionAngularAllowance(20.
f)
32 CartesianVector &principalStartPosition, CartesianVector &branchSplitPosition, CartesianVector &branchSplitDirection)
const 39 for (
unsigned int principalForward = 0; principalForward < 2; ++principalForward)
41 const CartesianVector principalVertexPosition(
43 const CartesianVector principalEndPosition(
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(
55 const CartesianVector branchEndPosition(
57 const CartesianVector branchEndDirection(
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);
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);
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));
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);
155 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
158 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
161 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
164 PANDORA_RETURN_RESULT_IF_AND_IF(
165 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinCosRelativeAngle",
m_minCosRelativeAngle));
167 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, 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 GetLayerFitHalfWindowLength() const
Get the layer fit half window length.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
float GetCosScatteringAngle(const float rL) const
Get scattering angle for a given longitudinal coordinate.
float m_projectionAngularAllowance
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_maxLongitudinalDisplacement
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
Header file for the branch splitting algorithm class.
float m_minLongitudinalExtension
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const
Get global fit direction for a given longitudinal coordinate.
void FindBestSplitPosition(const TwoDSlidingFitResult &branchSlidingFit, const TwoDSlidingFitResult &replacementSlidingFit, pandora::CartesianVector &replacementStartPosition, pandora::CartesianVector &branchSplitPosition, pandora::CartesianVector &branchSplitDirection) const
Output the best split positions in branch and replacement clusters.
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.
float m_maxTransverseDisplacement
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
TwoDSlidingFitResult class.