9 #include "Pandora/AlgorithmHeaders.h" 21 TransverseExtensionAlgorithm::TransverseExtensionAlgorithm() :
22 m_minClusterLength(5.
f),
23 m_maxLongitudinalDisplacement(10.
f),
24 m_maxTransverseDisplacement(1.
f)
33 clusterVector.push_back(*iter);
47 const Cluster *
const pCluster(*iter);
56 catch (StatusCodeException &)
68 const Cluster *
const pDaughterCluster(*iter2);
70 if (parentCluster.
GetCluster() == pDaughterCluster)
82 const Cluster *
const pParentCluster(pointingCluster.
GetCluster());
84 if (pParentCluster == pDaughterCluster)
87 for (
unsigned int useInner = 0; useInner < 2; ++useInner)
92 if (pointingVertex.GetRms() > 0.5f)
101 float figureOfMerit(projectedDisplacement);
103 CartesianVector firstCoordinate(0.
f, 0.
f, 0.
f);
104 CartesianVector secondCoordinate(0.
f, 0.
f, 0.
f);
107 float firstL(0.
f), firstT(0.
f), secondT(0.
f), secondL(0.
f);
111 const float innerL(firstL < secondL ? firstL : secondL);
112 const float innerT(firstL < secondL ? firstT : secondT);
113 const float outerL(firstL > secondL ? firstL : secondL);
114 const float outerT(firstL > secondL ? firstT : secondT);
120 figureOfMerit = outerL;
123 (void) clusterAssociationMatrix[pParentCluster].insert(ClusterAssociationMap::value_type(pDaughterCluster,
136 for (
const auto &mapEntry : parentToDaughterMatrix) sortedParentClusters.push_back(mapEntry.first);
139 for (
const Cluster *
const pParentCluster : sortedParentClusters)
148 for (
const auto &mapEntry : daughterToAssociationMap) sortedLocalDaughterClusters.push_back(mapEntry.first);
151 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
153 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
157 if (clusterAssociation.GetParent() ==
ClusterAssociation::INNER && clusterAssociation.GetFigureOfMerit() < maxDisplacementInner)
160 if (clusterAssociation.GetParent() ==
ClusterAssociation::OUTER && clusterAssociation.GetFigureOfMerit() < maxDisplacementOuter)
161 maxDisplacementOuter = clusterAssociation.GetFigureOfMerit();
166 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
168 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
172 if (clusterAssociation.GetParent() ==
ClusterAssociation::INNER && clusterAssociation.GetFigureOfMerit() < maxDisplacementInner)
173 (
void) daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
175 if (clusterAssociation.GetParent() ==
ClusterAssociation::OUTER && clusterAssociation.GetFigureOfMerit() < maxDisplacementOuter)
176 (
void) daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
183 for (
const auto &mapEntry : daughterToParentMatrix) sortedDaughterClusters.push_back(mapEntry.first);
187 for (
const Cluster *
const pDaughterCluster : sortedDaughterClusters)
191 const Cluster *pParentCluster(
nullptr);
195 for (
const auto &mapEntry : parentToAssociationMap) sortedLocalParentClusters.push_back(mapEntry.first);
198 for (
const Cluster *
const pCandidateParentCluster : sortedLocalParentClusters)
200 const ClusterAssociation &clusterAssociation(parentToAssociationMap.at(pCandidateParentCluster));
202 if (clusterAssociation.GetFigureOfMerit() < minDisplacement)
205 pParentCluster = pCandidateParentCluster;
211 ClusterList &parentList(clusterMergeMap[pParentCluster]);
213 if (parentList.end() == std::find(parentList.begin(), parentList.end(), pDaughterCluster))
214 parentList.push_back(pDaughterCluster);
216 ClusterList &daughterList(clusterMergeMap[pDaughterCluster]);
218 if (daughterList.end() == std::find(daughterList.begin(), daughterList.end(), pParentCluster))
219 daughterList.push_back(pParentCluster);
228 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
231 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
234 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
std::vector< LArPointingCluster > LArPointingClusterList
static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices.
ClusterAssociation class.
void FillClusterAssociationMatrix(const pandora::ClusterVector &clusterVector, ClusterAssociationMatrix &clusterAssociationMatrix) const
Fill the cluster association matrix.
LArPointingCluster class.
void FillClusterMergeMap(const ClusterAssociationMatrix &clusterAssociationMatrix, ClusterMergeMap &clusterMergeMap) const
Fill the cluster merge map.
const pandora::Cluster * GetCluster() const
Get the address of the cluster.
float m_maxTransverseDisplacement
Header file for the cluster helper class.
const Vertex & GetOuterVertex() const
Get the outer vertex.
float m_maxLongitudinalDisplacement
const Vertex & GetInnerVertex() const
Get the inner vertex.
AssociationType
Association enumeration.
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 ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
static void GetExtremalCoordinates(const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
Get positions of the two most distant calo hits in a list of cluster (ordered by Z) ...
Header file for the transverse extension algorithm class.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
VertexType
Vertex enumeration.
float GetFigureOfMerit() const
Get figure of merit.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.