9 #include "Pandora/AlgorithmHeaders.h" 22 TransverseExtensionAlgorithm::TransverseExtensionAlgorithm() :
23 m_minClusterLength(5.
f),
24 m_maxLongitudinalDisplacement(10.
f),
25 m_maxTransverseDisplacement(1.
f)
34 clusterVector.push_back(*iter);
48 const Cluster *
const pCluster(*iter);
57 catch (StatusCodeException &)
69 const Cluster *
const pDaughterCluster(*iter2);
71 if (parentCluster.
GetCluster() == pDaughterCluster)
84 const Cluster *
const pParentCluster(pointingCluster.
GetCluster());
86 if (pParentCluster == pDaughterCluster)
93 for (
unsigned int useInner = 0; useInner < 2; ++useInner)
98 if (pointingVertex.GetRms() > 0.5f)
103 if (projectedDisplacement > maxLongitudinalDisplacementAdjusted)
107 float figureOfMerit(projectedDisplacement);
109 CartesianVector firstCoordinate(0.
f, 0.
f, 0.
f);
110 CartesianVector secondCoordinate(0.
f, 0.
f, 0.
f);
113 float firstL(0.
f), firstT(0.
f), secondT(0.
f), secondL(0.
f);
117 const float innerL(firstL < secondL ? firstL : secondL);
118 const float innerT(firstL < secondL ? firstT : secondT);
119 const float outerL(firstL > secondL ? firstL : secondL);
120 const float outerT(firstL > secondL ? firstT : secondT);
122 if (innerL > 0.
f && innerL < 2.5
f && outerL < maxLongitudinalDisplacementAdjusted && innerT < maxTransverseDisplacementAdjusted &&
123 outerT < 1.5
f * maxTransverseDisplacementAdjusted)
126 figureOfMerit = outerL;
129 (void)clusterAssociationMatrix[pParentCluster].insert(
130 ClusterAssociationMap::value_type(pDaughterCluster,
ClusterAssociation(vertexType, vertexType, associationType, figureOfMerit)));
142 for (
const auto &mapEntry : parentToDaughterMatrix)
143 sortedParentClusters.push_back(mapEntry.first);
146 for (
const Cluster *
const pParentCluster : sortedParentClusters)
150 float maxDisplacementInner(std::numeric_limits<float>::max());
151 float maxDisplacementOuter(std::numeric_limits<float>::max());
155 for (
const auto &mapEntry : daughterToAssociationMap)
156 sortedLocalDaughterClusters.push_back(mapEntry.first);
159 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
161 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
165 if (clusterAssociation.GetParent() ==
ClusterAssociation::INNER && clusterAssociation.GetFigureOfMerit() < maxDisplacementInner)
168 if (clusterAssociation.GetParent() ==
ClusterAssociation::OUTER && clusterAssociation.GetFigureOfMerit() < maxDisplacementOuter)
169 maxDisplacementOuter = clusterAssociation.GetFigureOfMerit();
174 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
176 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
180 if (clusterAssociation.GetParent() ==
ClusterAssociation::INNER && clusterAssociation.GetFigureOfMerit() < maxDisplacementInner)
181 (
void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
183 if (clusterAssociation.GetParent() ==
ClusterAssociation::OUTER && clusterAssociation.GetFigureOfMerit() < maxDisplacementOuter)
184 (
void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
191 for (
const auto &mapEntry : daughterToParentMatrix)
192 sortedDaughterClusters.push_back(mapEntry.first);
196 for (
const Cluster *
const pDaughterCluster : sortedDaughterClusters)
200 const Cluster *pParentCluster(
nullptr);
201 float minDisplacement(std::numeric_limits<float>::max());
204 for (
const auto &mapEntry : parentToAssociationMap)
205 sortedLocalParentClusters.push_back(mapEntry.first);
208 for (
const Cluster *
const pCandidateParentCluster : sortedLocalParentClusters)
210 const ClusterAssociation &clusterAssociation(parentToAssociationMap.at(pCandidateParentCluster));
212 if (clusterAssociation.GetFigureOfMerit() < minDisplacement)
215 pParentCluster = pCandidateParentCluster;
221 ClusterList &parentList(clusterMergeMap[pParentCluster]);
223 if (parentList.end() == std::find(parentList.begin(), parentList.end(), pDaughterCluster))
224 parentList.push_back(pDaughterCluster);
226 ClusterList &daughterList(clusterMergeMap[pDaughterCluster]);
228 if (daughterList.end() == std::find(daughterList.begin(), daughterList.end(), pParentCluster))
229 daughterList.push_back(pParentCluster);
238 PANDORA_RETURN_RESULT_IF_AND_IF(
239 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinClusterLength",
m_minClusterLength));
241 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
244 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.
static float GetWirePitchRatio(const pandora::Pandora &pandora, const pandora::HitType view)
Return the ratio of the wire pitch of the specified view to the minimum wire pitch for the detector...
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.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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 geometry helper class.
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
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.