LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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...
 

Protected Types

typedef std::vector< ClusterExtensionClusterExtensionList
 

Protected Member Functions

virtual pandora::StatusCode Run ()
 

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
 

Detailed Description

BranchSplittingAlgorithm class.

Definition at line 19 of file BranchSplittingAlgorithm.h.

Member Typedef Documentation

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.

References f, lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::TwoDSlidingFitResult::GetCosScatteringAngle(), lar_content::TwoDSlidingFitResult::GetGlobalFitDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition(), lar_content::LArPointingClusterHelper::GetImpactParameters(), lar_content::TwoDSlidingFitResult::GetLayerFitHalfWindowLength(), lar_content::TwoDSlidingFitResult::GetLocalPosition(), lar_content::LArPointingClusterHelper::GetProjectedPosition(), m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, m_minCosRelativeAngle, m_minLongitudinalExtension, and m_projectionAngularAllowance.

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(1==principalForward ? principalSlidingFit.GetGlobalMinLayerPosition() : principalSlidingFit.GetGlobalMaxLayerPosition());
42  const CartesianVector principalEndPosition(1!=principalForward ? principalSlidingFit.GetGlobalMinLayerPosition() : principalSlidingFit.GetGlobalMaxLayerPosition());
43  const CartesianVector principalVertexDirection(1==principalForward ? principalSlidingFit.GetGlobalMinLayerDirection() : principalSlidingFit.GetGlobalMaxLayerDirection() * -1.f);
44 
45  CartesianVector projectedBranchPosition(0.f,0.f,0.f);
46  bool projectedPositionFound(false), projectedPositionFail(false);
47 
48  for (unsigned int branchForward = 0; branchForward < 2; ++branchForward)
49  {
50  const CartesianVector branchVertexPosition(1==branchForward ? branchSlidingFit.GetGlobalMinLayerPosition() : branchSlidingFit.GetGlobalMaxLayerPosition());
51  const CartesianVector branchEndPosition(1!=branchForward ? branchSlidingFit.GetGlobalMinLayerPosition() : branchSlidingFit.GetGlobalMaxLayerPosition());
52  const CartesianVector branchEndDirection(1!=branchForward ? branchSlidingFit.GetGlobalMinLayerDirection() : branchSlidingFit.GetGlobalMaxLayerDirection() * -1.f);
53 
54  if (principalVertexDirection.GetDotProduct(branchEndDirection) < 0.5f)
55  continue;
56 
57  if ((principalEndPosition - branchEndPosition).GetMagnitudeSquared() < (principalVertexPosition - branchVertexPosition).GetMagnitudeSquared())
58  continue;
59 
60  // Project the principal vertex onto the branch cluster
61  try
62  {
63  if (!projectedPositionFound && !projectedPositionFail)
64  {
65  projectedBranchPosition = LArPointingClusterHelper::GetProjectedPosition(principalVertexPosition, principalVertexDirection, branchSlidingFit.GetCluster(), m_projectionAngularAllowance);
66  projectedPositionFound = true;
67  }
68  }
69  catch (StatusCodeException &)
70  {
71  projectedPositionFail = true;
72  }
73 
74  if (!projectedPositionFound || projectedPositionFail)
75  continue;
76 
77  const float projectedDistanceSquared((projectedBranchPosition - principalVertexPosition).GetMagnitudeSquared());
78 
79  if (projectedDistanceSquared > m_maxLongitudinalDisplacement * m_maxLongitudinalDisplacement)
80  continue;
81 
82  const float commonDistanceSquared((projectedBranchPosition - branchEndPosition).GetMagnitudeSquared());
83 
84  if (projectedDistanceSquared > commonDistanceSquared)
85  continue;
86 
87  const float replacementDistanceSquared((projectedBranchPosition - principalEndPosition).GetMagnitudeSquared());
88 
89  if (replacementDistanceSquared < m_minLongitudinalExtension * m_minLongitudinalExtension)
90  continue;
91 
92  const float branchDistanceSquared((projectedBranchPosition - branchVertexPosition).GetMagnitudeSquared());
93 
94  if (branchDistanceSquared > 4.f * replacementDistanceSquared)
95  continue;
96 
97  // Require that principal vertex and branch projection have good (and improved) pointing
98  bool foundSplit(false);
99 
100  const float halfWindowLength(branchSlidingFit.GetLayerFitHalfWindowLength());
101  const float deltaL(1==branchForward ? +halfWindowLength : -halfWindowLength);
102 
103  float localL(0.f), localT(0.f);
104  CartesianVector forwardDirection(0.f,0.f,0.f);
105  branchSlidingFit.GetLocalPosition(projectedBranchPosition, localL, localT);
106 
107  if (STATUS_CODE_SUCCESS != branchSlidingFit.GetGlobalFitDirection(localL + deltaL, forwardDirection))
108  continue;
109 
110  CartesianVector projectedBranchDirection(1==branchForward ? forwardDirection : forwardDirection * -1.f);
111  const float cosTheta(-projectedBranchDirection.GetDotProduct(principalVertexDirection));
112 
113  try
114  {
115  const float currentCosTheta(branchSlidingFit.GetCosScatteringAngle(localL));
116 
117  if (cosTheta < currentCosTheta)
118  continue;
119  }
120  catch (StatusCodeException &)
121  {
122  }
123 
124  float rT1(0.f), rL1(0.f), rT2(0.f), rL2(0.f);
125  LArPointingClusterHelper::GetImpactParameters(projectedBranchPosition, projectedBranchDirection, principalVertexPosition, rL1, rT1);
126  LArPointingClusterHelper::GetImpactParameters(principalVertexPosition, principalVertexDirection, projectedBranchPosition, rL2, rT2);
127 
129  {
130  foundSplit = true;
131  principalStartPosition = principalVertexPosition;
132  branchSplitPosition = projectedBranchPosition;
133  branchSplitDirection = projectedBranchDirection * -1.f;
134  }
135 
136  if (foundSplit)
137  return;
138  }
139  }
140 
141  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
142 }
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.
TFile f
Definition: plotHisto.C:6
StatusCode lar_content::BranchSplittingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm.

Definition at line 146 of file BranchSplittingAlgorithm.cc.

References m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, m_minCosRelativeAngle, m_minLongitudinalExtension, m_projectionAngularAllowance, and lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::ReadSettings().

147 {
148  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
149  "MaxTransverseDisplacement", m_maxTransverseDisplacement));
150 
151  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
152  "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
153 
154  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
155  "MinLongitudinalExtension", m_minLongitudinalExtension));
156 
157  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
158  "MinCosRelativeAngle", m_minCosRelativeAngle));
159 
160  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
161  "ProjectionAngularAllowance", m_projectionAngularAllowance));
162 
164 }
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
StatusCode lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::Run ( )
protectedvirtualinherited

Definition at line 32 of file TwoDSlidingFitSplittingAndSplicingAlgorithm.cc.

References lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::BuildClusterExtensionList(), lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::BuildSlidingFitResultMap(), lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::GetListOfCleanClusters(), lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::m_longHalfWindowLayers, lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::m_runCosmicMode, lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::m_shortHalfWindowLayers, lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::PruneClusterExtensionList(), and lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm::RunSplitAndExtension().

33 {
34  const ClusterList *pClusterList = NULL;
35  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
36 
37  TwoDSlidingFitResultMap branchSlidingFitResultMap, replacementSlidingFitResultMap;
38 
39  unsigned int nIterations(0);
40 
41  while (++nIterations < 100) // Protect against flip-flopping between two answers
42  {
43  // Get ordered list of candidate clusters
44  ClusterVector clusterVector;
45  this->GetListOfCleanClusters(pClusterList, clusterVector);
46 
47  // Calculate sliding fit results for branch clusters (use a soft sliding fit for these)
48  this->BuildSlidingFitResultMap(clusterVector, m_shortHalfWindowLayers, branchSlidingFitResultMap);
49 
50  // Calculate sliding fit results for replacement clusters (use a hard linear fit for these)
51  this->BuildSlidingFitResultMap(clusterVector, m_longHalfWindowLayers, replacementSlidingFitResultMap);
52 
53  // Compile a list of possible splits
54  ClusterExtensionList splitList;
55 
56  if (m_runCosmicMode)
57  {
58  this->BuildClusterExtensionList(clusterVector, branchSlidingFitResultMap, replacementSlidingFitResultMap, splitList);
59  }
60  else
61  {
62  ClusterExtensionList intermediateList;
63  this->BuildClusterExtensionList(clusterVector, branchSlidingFitResultMap, replacementSlidingFitResultMap, intermediateList);
64  this->PruneClusterExtensionList(intermediateList, branchSlidingFitResultMap, replacementSlidingFitResultMap, splitList);
65  }
66 
67  // Run splitting and extension
68  if (STATUS_CODE_SUCCESS != this->RunSplitAndExtension(splitList, branchSlidingFitResultMap, replacementSlidingFitResultMap))
69  break;
70  }
71 
72  return STATUS_CODE_SUCCESS;
73 }
void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers, TwoDSlidingFitResultMap &slidingFitResultMap) const
Build the map of sliding fit results.
void BuildClusterExtensionList(const pandora::ClusterVector &clusterVector, const TwoDSlidingFitResultMap &branchResultMap, const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &clusterExtensionList) const
Build a list of candidate splits.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const
Populate cluster vector with subset of cluster list, containing clusters judged to be clean...
pandora::StatusCode RunSplitAndExtension(const ClusterExtensionList &splitList, TwoDSlidingFitResultMap &branchResultMap, TwoDSlidingFitResultMap &replacementResultMap) const
Run the machinary that performs the cluster splitting and extending.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void PruneClusterExtensionList(const ClusterExtensionList &inputList, const TwoDSlidingFitResultMap &branchResultMap, const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &outputList) const
Finalize the list of candidate splits.

Member Data Documentation

float lar_content::BranchSplittingAlgorithm::m_maxLongitudinalDisplacement
private

Definition at line 35 of file BranchSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::BranchSplittingAlgorithm::m_maxTransverseDisplacement
private

Definition at line 34 of file BranchSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::BranchSplittingAlgorithm::m_minCosRelativeAngle
private

Definition at line 37 of file BranchSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::BranchSplittingAlgorithm::m_minLongitudinalExtension
private

Definition at line 36 of file BranchSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::BranchSplittingAlgorithm::m_projectionAngularAllowance
private

Definition at line 38 of file BranchSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().


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