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)
45 CartesianVector projectedBranchPosition(0.
f,0.
f,0.
f);
46 bool projectedPositionFound(
false), projectedPositionFail(
false);
48 for (
unsigned int branchForward = 0; branchForward < 2; ++branchForward)
54 if (principalVertexDirection.GetDotProduct(branchEndDirection) < 0.5f)
57 if ((principalEndPosition - branchEndPosition).GetMagnitudeSquared() < (principalVertexPosition - branchVertexPosition).GetMagnitudeSquared())
63 if (!projectedPositionFound && !projectedPositionFail)
66 projectedPositionFound =
true;
69 catch (StatusCodeException &)
71 projectedPositionFail =
true;
74 if (!projectedPositionFound || projectedPositionFail)
77 const float projectedDistanceSquared((projectedBranchPosition - principalVertexPosition).GetMagnitudeSquared());
82 const float commonDistanceSquared((projectedBranchPosition - branchEndPosition).GetMagnitudeSquared());
84 if (projectedDistanceSquared > commonDistanceSquared)
87 const float replacementDistanceSquared((projectedBranchPosition - principalEndPosition).GetMagnitudeSquared());
92 const float branchDistanceSquared((projectedBranchPosition - branchVertexPosition).GetMagnitudeSquared());
94 if (branchDistanceSquared > 4.
f * replacementDistanceSquared)
98 bool foundSplit(
false);
101 const float deltaL(1==branchForward ? +halfWindowLength : -halfWindowLength);
103 float localL(0.
f), localT(0.
f);
104 CartesianVector forwardDirection(0.
f,0.
f,0.
f);
107 if (STATUS_CODE_SUCCESS != branchSlidingFit.
GetGlobalFitDirection(localL + deltaL, forwardDirection))
110 CartesianVector projectedBranchDirection(1==branchForward ? forwardDirection : forwardDirection * -1.
f);
111 const float cosTheta(-projectedBranchDirection.GetDotProduct(principalVertexDirection));
117 if (cosTheta < currentCosTheta)
120 catch (StatusCodeException &)
124 float rT1(0.
f), rL1(0.
f), rT2(0.
f), rL2(0.
f);
131 principalStartPosition = principalVertexPosition;
132 branchSplitPosition = projectedBranchPosition;
133 branchSplitDirection = projectedBranchDirection * -1.f;
141 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
148 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
151 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
154 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
157 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
160 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
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.