Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::BranchSplittingAlgorithm Class Reference

BranchSplittingAlgorithm class. More...

#include <BranchSplittingAlgorithm.h>

Inheritance diagram for lar_content::BranchSplittingAlgorithm:
lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm

Public Member Functions

 BranchSplittingAlgorithm ()
 Default constructor. More...
 
- Public Member Functions inherited from lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm
 TwoDSlidingFitSplittingAndSplicingAlgorithm ()
 Default constructor. More...
 

Private Member Functions

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. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_maxTransverseDisplacement
 
float m_maxLongitudinalDisplacement
 
float m_minLongitudinalExtension
 
float m_minCosRelativeAngle
 
float m_projectionAngularAllowance
 

Additional Inherited Members

- Protected Types inherited from lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm
typedef std::vector< ClusterExtensionClusterExtensionList
 
- Protected Member Functions inherited from lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm
virtual pandora::StatusCode Run ()
 

Detailed Description

BranchSplittingAlgorithm class.

Definition at line 19 of file BranchSplittingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::BranchSplittingAlgorithm::BranchSplittingAlgorithm ( )

Member Function Documentation

void lar_content::BranchSplittingAlgorithm::FindBestSplitPosition ( const TwoDSlidingFitResult branchSlidingFit,
const TwoDSlidingFitResult replacementSlidingFit,
pandora::CartesianVector &  replacementStartPosition,
pandora::CartesianVector &  branchSplitPosition,
pandora::CartesianVector &  branchSplitDirection 
) const
privatevirtual

Output the best split positions in branch and replacement clusters.

Parameters
branchSlidingFitthe inputted sliding fit result for possible branch cluster
pReplacementClusterthe inputted sliding fit result for possible replacement cluster
replacementStartPositionthe outputted start position of the replacement
branchSplitPositionthe outputted start position of the branch
branchSplitDirectionthe outputted start direction of the branch

Implements lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm.

Definition at line 31 of file BranchSplittingAlgorithm.cc.

33 {
34  // Conventions:
35  // (1) Delta ray is split from the branch cluster
36  // (2) Delta ray occurs where the vertex of the principal cluster meets the vertex of the branch cluster
37  // Method loops over the inner and outer positions of the principal and branch clusters, trying all
38  // possible assignments of vertex and end position until a split is found
39  for (unsigned int principalForward = 0; principalForward < 2; ++principalForward)
40  {
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);
47 
48  CartesianVector projectedBranchPosition(0.f, 0.f, 0.f);
49  bool projectedPositionFound(false), projectedPositionFail(false);
50 
51  for (unsigned int branchForward = 0; branchForward < 2; ++branchForward)
52  {
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);
59 
60  if (principalVertexDirection.GetDotProduct(branchEndDirection) < 0.5f)
61  continue;
62 
63  if ((principalEndPosition - branchEndPosition).GetMagnitudeSquared() < (principalVertexPosition - branchVertexPosition).GetMagnitudeSquared())
64  continue;
65 
66  // Project the principal vertex onto the branch cluster
67  try
68  {
69  if (!projectedPositionFound && !projectedPositionFail)
70  {
71  projectedBranchPosition = LArPointingClusterHelper::GetProjectedPosition(
72  principalVertexPosition, principalVertexDirection, branchSlidingFit.GetCluster(), m_projectionAngularAllowance);
73  projectedPositionFound = true;
74  }
75  }
76  catch (StatusCodeException &)
77  {
78  projectedPositionFail = true;
79  }
80 
81  if (!projectedPositionFound || projectedPositionFail)
82  continue;
83 
84  const float projectedDistanceSquared((projectedBranchPosition - principalVertexPosition).GetMagnitudeSquared());
85 
86  if (projectedDistanceSquared > m_maxLongitudinalDisplacement * m_maxLongitudinalDisplacement)
87  continue;
88 
89  const float commonDistanceSquared((projectedBranchPosition - branchEndPosition).GetMagnitudeSquared());
90 
91  if (projectedDistanceSquared > commonDistanceSquared)
92  continue;
93 
94  const float replacementDistanceSquared((projectedBranchPosition - principalEndPosition).GetMagnitudeSquared());
95 
96  if (replacementDistanceSquared < m_minLongitudinalExtension * m_minLongitudinalExtension)
97  continue;
98 
99  const float branchDistanceSquared((projectedBranchPosition - branchVertexPosition).GetMagnitudeSquared());
100 
101  if (branchDistanceSquared > 4.f * replacementDistanceSquared)
102  continue;
103 
104  // Require that principal vertex and branch projection have good (and improved) pointing
105  bool foundSplit(false);
106 
107  const float halfWindowLength(branchSlidingFit.GetLayerFitHalfWindowLength());
108  const float deltaL(1 == branchForward ? +halfWindowLength : -halfWindowLength);
109 
110  float localL(0.f), localT(0.f);
111  CartesianVector forwardDirection(0.f, 0.f, 0.f);
112  branchSlidingFit.GetLocalPosition(projectedBranchPosition, localL, localT);
113 
114  if (STATUS_CODE_SUCCESS != branchSlidingFit.GetGlobalFitDirection(localL + deltaL, forwardDirection))
115  continue;
116 
117  CartesianVector projectedBranchDirection(1 == branchForward ? forwardDirection : forwardDirection * -1.f);
118  const float cosTheta(-projectedBranchDirection.GetDotProduct(principalVertexDirection));
119 
120  try
121  {
122  const float currentCosTheta(branchSlidingFit.GetCosScatteringAngle(localL));
123 
124  if (cosTheta < currentCosTheta)
125  continue;
126  }
127  catch (StatusCodeException &)
128  {
129  }
130 
131  float rT1(0.f), rL1(0.f), rT2(0.f), rL2(0.f);
132  LArPointingClusterHelper::GetImpactParameters(projectedBranchPosition, projectedBranchDirection, principalVertexPosition, rL1, rT1);
133  LArPointingClusterHelper::GetImpactParameters(principalVertexPosition, principalVertexDirection, projectedBranchPosition, rL2, rT2);
134 
136  {
137  foundSplit = true;
138  principalStartPosition = principalVertexPosition;
139  branchSplitPosition = projectedBranchPosition;
140  branchSplitDirection = projectedBranchDirection * -1.f;
141  }
142 
143  if (foundSplit)
144  return;
145  }
146  }
147 
148  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
149 }
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.
StatusCode lar_content::BranchSplittingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm.

Definition at line 153 of file BranchSplittingAlgorithm.cc.

154 {
155  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
156  XmlHelper::ReadValue(xmlHandle, "MaxTransverseDisplacement", m_maxTransverseDisplacement));
157 
158  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
159  XmlHelper::ReadValue(xmlHandle, "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
160 
161  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
162  XmlHelper::ReadValue(xmlHandle, "MinLongitudinalExtension", m_minLongitudinalExtension));
163 
164  PANDORA_RETURN_RESULT_IF_AND_IF(
165  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCosRelativeAngle", m_minCosRelativeAngle));
166 
167  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
168  XmlHelper::ReadValue(xmlHandle, "ProjectionAngularAllowance", m_projectionAngularAllowance));
169 
171 }
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)

Member Data Documentation

float lar_content::BranchSplittingAlgorithm::m_maxLongitudinalDisplacement
private

Definition at line 35 of file BranchSplittingAlgorithm.h.

float lar_content::BranchSplittingAlgorithm::m_maxTransverseDisplacement
private

Definition at line 34 of file BranchSplittingAlgorithm.h.

float lar_content::BranchSplittingAlgorithm::m_minCosRelativeAngle
private

Definition at line 37 of file BranchSplittingAlgorithm.h.

float lar_content::BranchSplittingAlgorithm::m_minLongitudinalExtension
private

Definition at line 36 of file BranchSplittingAlgorithm.h.

float lar_content::BranchSplittingAlgorithm::m_projectionAngularAllowance
private

Definition at line 38 of file BranchSplittingAlgorithm.h.


The documentation for this class was generated from the following files: