9 #include "Pandora/AlgorithmHeaders.h"
21 TransverseExtensionAlgorithm::TransverseExtensionAlgorithm() :
22 m_minClusterLength(5.f),
23 m_maxLongitudinalDisplacement(10.f),
24 m_maxTransverseDisplacement(1.f)
32 for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
33 clusterVector.push_back(*iter);
45 for (ClusterVector::const_iterator iter = clusterVector.begin(), iterEnd = clusterVector.end(); iter != iterEnd; ++iter)
47 const Cluster *
const pCluster(*iter);
56 catch (StatusCodeException &)
62 for (LArPointingClusterList::const_iterator iter1 = pointingClusterList.begin(), iterEnd1 = pointingClusterList.end(); iter1 != iterEnd1; ++iter1)
64 const LArPointingCluster &parentCluster = *iter1;
66 for (ClusterVector::const_iterator iter2 = clusterVector.begin(), iterEnd2 = clusterVector.end(); iter2 != iterEnd2; ++iter2)
68 const Cluster *
const pDaughterCluster(*iter2);
70 if (parentCluster.GetCluster() == pDaughterCluster)
81 const Cluster *
const pDaughterCluster, ClusterAssociationMatrix &clusterAssociationMatrix)
const
83 const Cluster *
const pParentCluster(pointingCluster.GetCluster());
85 if (pParentCluster == pDaughterCluster)
88 for (
unsigned int useInner = 0; useInner < 2; ++useInner)
90 const LArPointingCluster::Vertex &pointingVertex(useInner == 1 ? pointingCluster.GetInnerVertex() : pointingCluster.GetOuterVertex());
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)
145 float maxDisplacementInner(std::numeric_limits<float>::max());
146 float maxDisplacementOuter(std::numeric_limits<float>::max());
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);
196 float minDisplacement(std::numeric_limits<float>::max());
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, !=,
240 XmlHelper::ReadValue(xmlHandle,
"MaxTransverseDisplacement", m_maxTransverseDisplacement));
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.
float m_maxTransverseDisplacement
Header file for the cluster helper class.
float m_maxLongitudinalDisplacement
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
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) ...
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
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.