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)
83 const Cluster *
const pParentCluster(pointingCluster.
GetCluster());
85 if (pParentCluster == pDaughterCluster)
88 for (
unsigned int useInner = 0; useInner < 2; ++useInner)
93 if (pointingVertex.GetRms() > 0.5f)
102 float figureOfMerit(projectedDisplacement);
104 CartesianVector firstCoordinate(0.
f, 0.
f, 0.
f);
105 CartesianVector secondCoordinate(0.
f, 0.
f, 0.
f);
108 float firstL(0.
f), firstT(0.
f), secondT(0.
f), secondL(0.
f);
112 const float innerL(firstL < secondL ? firstL : secondL);
113 const float innerT(firstL < secondL ? firstT : secondT);
114 const float outerL(firstL > secondL ? firstL : secondL);
115 const float outerT(firstL > secondL ? firstT : secondT);
121 figureOfMerit = outerL;
124 (void)clusterAssociationMatrix[pParentCluster].insert(
125 ClusterAssociationMap::value_type(pDaughterCluster,
ClusterAssociation(vertexType, vertexType, associationType, figureOfMerit)));
137 for (
const auto &mapEntry : parentToDaughterMatrix)
138 sortedParentClusters.push_back(mapEntry.first);
141 for (
const Cluster *
const pParentCluster : sortedParentClusters)
150 for (
const auto &mapEntry : daughterToAssociationMap)
151 sortedLocalDaughterClusters.push_back(mapEntry.first);
154 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
156 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
160 if (clusterAssociation.GetParent() ==
ClusterAssociation::INNER && clusterAssociation.GetFigureOfMerit() < maxDisplacementInner)
163 if (clusterAssociation.GetParent() ==
ClusterAssociation::OUTER && clusterAssociation.GetFigureOfMerit() < maxDisplacementOuter)
164 maxDisplacementOuter = clusterAssociation.GetFigureOfMerit();
169 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
171 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
175 if (clusterAssociation.GetParent() ==
ClusterAssociation::INNER && clusterAssociation.GetFigureOfMerit() < maxDisplacementInner)
176 (
void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
178 if (clusterAssociation.GetParent() ==
ClusterAssociation::OUTER && clusterAssociation.GetFigureOfMerit() < maxDisplacementOuter)
179 (
void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
186 for (
const auto &mapEntry : daughterToParentMatrix)
187 sortedDaughterClusters.push_back(mapEntry.first);
191 for (
const Cluster *
const pDaughterCluster : sortedDaughterClusters)
195 const Cluster *pParentCluster(
nullptr);
199 for (
const auto &mapEntry : parentToAssociationMap)
200 sortedLocalParentClusters.push_back(mapEntry.first);
203 for (
const Cluster *
const pCandidateParentCluster : sortedLocalParentClusters)
205 const ClusterAssociation &clusterAssociation(parentToAssociationMap.at(pCandidateParentCluster));
207 if (clusterAssociation.GetFigureOfMerit() < minDisplacement)
210 pParentCluster = pCandidateParentCluster;
216 ClusterList &parentList(clusterMergeMap[pParentCluster]);
218 if (parentList.end() == std::find(parentList.begin(), parentList.end(), pDaughterCluster))
219 parentList.push_back(pDaughterCluster);
221 ClusterList &daughterList(clusterMergeMap[pDaughterCluster]);
223 if (daughterList.end() == std::find(daughterList.begin(), daughterList.end(), pParentCluster))
224 daughterList.push_back(pParentCluster);
233 PANDORA_RETURN_RESULT_IF_AND_IF(
234 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinClusterLength",
m_minClusterLength));
236 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
239 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
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::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.
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
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...
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
static int max(int a, int b)
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
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.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
std::vector< art::Ptr< recob::Cluster > > ClusterVector
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
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.