LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::DeltaRaySplittingAlgorithm Class Reference

DeltaRaySplittingAlgorithm class. More...

#include "DeltaRaySplittingAlgorithm.h"

Inheritance diagram for lar_content::DeltaRaySplittingAlgorithm:
lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm

Public Member Functions

 DeltaRaySplittingAlgorithm ()
 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_stepSize
 
float m_maxTransverseDisplacement
 
float m_maxLongitudinalDisplacement
 
float m_minCosRelativeAngle
 

Detailed Description

DeltaRaySplittingAlgorithm class.

Definition at line 19 of file DeltaRaySplittingAlgorithm.h.

Member Typedef Documentation

Constructor & Destructor Documentation

lar_content::DeltaRaySplittingAlgorithm::DeltaRaySplittingAlgorithm ( )

Member Function Documentation

void lar_content::DeltaRaySplittingAlgorithm::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 30 of file DeltaRaySplittingAlgorithm.cc.

References f, lar_content::LArClusterHelper::GetClosestDistance(), lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::TwoDSlidingFitResult::GetGlobalFitDirection(), lar_content::TwoDSlidingFitResult::GetGlobalFitPosition(), 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(), m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, m_minCosRelativeAngle, m_stepSize, max, and min.

32 {
33  // Conventions:
34  // (1) Delta ray is split from the branch cluster
35  // (2) Delta ray occurs where the vertex of the principal cluster meets the vertex of the branch cluster
36  // Method loops over the inner and outer positions of the principal and branch clusters, trying all
37  // possible assignments of vertex and end position until a split is found
38 
39  for (unsigned int principalForward = 0; principalForward < 2; ++principalForward)
40  {
41  const CartesianVector principalVertex(1==principalForward ? principalSlidingFit.GetGlobalMinLayerPosition() : principalSlidingFit.GetGlobalMaxLayerPosition());
42  const CartesianVector principalEnd(1==principalForward ? principalSlidingFit.GetGlobalMaxLayerPosition() : principalSlidingFit.GetGlobalMinLayerPosition());
43  const CartesianVector principalDirection(1==principalForward ? principalSlidingFit.GetGlobalMinLayerDirection() : principalSlidingFit.GetGlobalMaxLayerDirection() * -1.f);
44 
45  if (LArClusterHelper::GetClosestDistance(principalVertex, branchSlidingFit.GetCluster()) > m_maxLongitudinalDisplacement)
46  continue;
47 
48  for (unsigned int branchForward = 0; branchForward < 2; ++branchForward)
49  {
50  const CartesianVector branchVertex(1==branchForward ? branchSlidingFit.GetGlobalMinLayerPosition() : branchSlidingFit.GetGlobalMaxLayerPosition());
51  const CartesianVector branchEnd(1==branchForward ? branchSlidingFit.GetGlobalMaxLayerPosition() : branchSlidingFit.GetGlobalMinLayerPosition());
52  const CartesianVector branchDirection(1==branchForward ? branchSlidingFit.GetGlobalMinLayerDirection() : branchSlidingFit.GetGlobalMaxLayerDirection() * -1.f);
53 
54  // Require vertices to be closest two ends
55  const float vertex_to_vertex((principalVertex - branchVertex).GetMagnitudeSquared());
56  const float vertex_to_end((principalVertex - branchEnd).GetMagnitudeSquared());
57  const float end_to_vertex((principalEnd - branchVertex).GetMagnitudeSquared());
58  const float end_to_end((principalEnd - branchEnd).GetMagnitudeSquared());
59 
60  // (sign convention for vertexProjection: positive means that clusters overlap)
61  const float vertexProjection(+branchDirection.GetDotProduct(principalVertex - branchVertex));
62  const float cosRelativeAngle(-branchDirection.GetDotProduct(principalDirection));
63 
64  if (vertex_to_vertex > std::min(end_to_end, std::min(vertex_to_end, end_to_vertex)))
65  continue;
66 
67  if (end_to_end < std::max(vertex_to_vertex, std::max(vertex_to_end, end_to_vertex)))
68  continue;
69 
70  if (vertexProjection < 0.f && cosRelativeAngle > m_minCosRelativeAngle)
71  continue;
72 
73  if (cosRelativeAngle < 0.f)
74  continue;
75 
76  // Serach for a split by winding back the branch cluster sliding fit
77  bool foundSplit(false);
78 
79  const float halfWindowLength(branchSlidingFit.GetLayerFitHalfWindowLength());
80  const float deltaL(1==branchForward ? +halfWindowLength : -halfWindowLength);
81 
82  float branchDistance(std::max(0.f,vertexProjection) + 0.5f * m_stepSize);
83 
84  while (!foundSplit)
85  {
86  branchDistance += m_stepSize;
87 
88  const CartesianVector linearProjection(branchVertex + branchDirection * branchDistance);
89 
90  if (principalDirection.GetDotProduct(linearProjection - principalVertex) < -m_maxLongitudinalDisplacement)
91  break;
92 
93  if ((linearProjection - branchVertex).GetMagnitudeSquared() > (linearProjection - branchEnd).GetMagnitudeSquared())
94  break;
95 
96  float localL(0.f), localT(0.f);
97  CartesianVector truncatedPosition(0.f,0.f,0.f);
98  CartesianVector forwardDirection(0.f,0.f,0.f);
99  branchSlidingFit.GetLocalPosition(linearProjection, localL, localT);
100 
101  if ((STATUS_CODE_SUCCESS != branchSlidingFit.GetGlobalFitPosition(localL, truncatedPosition)) ||
102  (STATUS_CODE_SUCCESS != branchSlidingFit.GetGlobalFitDirection(localL + deltaL, forwardDirection)))
103  {
104  continue;
105  }
106 
107  CartesianVector truncatedDirection(1==branchForward ? forwardDirection : forwardDirection * -1.f);
108  const float cosTheta(-truncatedDirection.GetDotProduct(principalDirection));
109 
110  float rT1(0.f), rL1(0.f), rT2(0.f), rL2(0.f);
111  LArPointingClusterHelper::GetImpactParameters(truncatedPosition, truncatedDirection, principalVertex, rL1, rT1);
112  LArPointingClusterHelper::GetImpactParameters(principalVertex, principalDirection, truncatedPosition, rL2, rT2);
113 
114  if ((cosTheta > m_minCosRelativeAngle) && (rT1 < m_maxTransverseDisplacement) && (rT2 < m_maxTransverseDisplacement))
115  {
116  foundSplit = true;
117  principalStartPosition = principalVertex;
118  branchSplitPosition = truncatedPosition;
119  branchSplitDirection = truncatedDirection * -1.f;
120  }
121  }
122 
123  if (foundSplit)
124  return;
125  }
126  }
127 
128  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
129 }
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
Int_t max
Definition: plot.C:27
Int_t min
Definition: plot.C:26
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
StatusCode lar_content::DeltaRaySplittingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::TwoDSlidingFitSplittingAndSplicingAlgorithm.

Definition at line 133 of file DeltaRaySplittingAlgorithm.cc.

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

134 {
135  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
136  "StepSize", m_stepSize));
137 
138  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
139  "MaxTransverseDisplacement", m_maxTransverseDisplacement));
140 
141  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
142  "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
143 
144  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
145  "MinCosRelativeAngle", m_minCosRelativeAngle));
146 
148 }
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::DeltaRaySplittingAlgorithm::m_maxLongitudinalDisplacement
private

Definition at line 36 of file DeltaRaySplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::DeltaRaySplittingAlgorithm::m_maxTransverseDisplacement
private

Definition at line 35 of file DeltaRaySplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::DeltaRaySplittingAlgorithm::m_minCosRelativeAngle
private

Definition at line 37 of file DeltaRaySplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::DeltaRaySplittingAlgorithm::m_stepSize
private

Definition at line 34 of file DeltaRaySplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().


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