26 m_minCaloHitsPerCluster(5),
27 m_nearbyClusterDistance(2.5f),
28 m_remoteClusterDistance(10.f),
29 m_directionTanAngle(1.732f),
30 m_directionApexShift(0.333f),
31 m_minVertexLongitudinalDistance(-2.5f),
32 m_maxVertexLongitudinalDistance(20.f),
33 m_maxVertexTransverseDistance(1.5f),
34 m_vertexAngularAllowance(3.f)
54 CartesianVector innerCoordinateLhs(0.f, 0.f, 0.f), outerCoordinateLhs(0.f, 0.f, 0.f);
56 const float dLhs2((outerCoordinateLhs - innerCoordinateLhs).GetMagnitudeSquared());
58 CartesianVector innerCoordinateRhs(0.f, 0.f, 0.f), outerCoordinateRhs(0.f, 0.f, 0.f);
60 const float dRhs2((outerCoordinateRhs - innerCoordinateRhs).GetMagnitudeSquared());
62 return (dLhs2 > dRhs2);
77 if (!pClusterList || pClusterList->empty())
80 std::cout <<
"ShowerGrowingAlgorithm: unable to find cluster list " << clusterListName << std::endl;
91 throw statusCodeException;
95 return STATUS_CODE_SUCCESS;
104 const Vertex *
const pVertex(
105 ((pVertexList->size() == 1) && (
VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) :
nullptr);
121 const Cluster *pSeedCluster(
nullptr);
135 pSeedCluster =
nullptr;
138 clusterVector.insert(clusterVector.end(), pClusterList->begin(), pClusterList->end());
141 for (
const Cluster *
const pCluster : clusterVector)
143 if (!pCluster->IsAvailable())
146 if (MU_MINUS == std::abs(pCluster->GetParticleId()))
152 if (usedClusters.count(pCluster))
155 pSeedCluster = pCluster;
167 clusterVector.insert(clusterVector.end(), pClusterList->begin(), pClusterList->end());
169 if (clusterVector.empty())
175 for (
const Cluster *
const pCluster : clusterVector)
177 if (!pCluster->IsAvailable())
180 if (MU_MINUS == std::abs(pCluster->GetParticleId()))
189 seedClusters.push_back(pCluster);
204 if (particleSeedVector.empty())
210 for (
const Cluster *
const pCandidateCluster : clusterList)
212 if (!pCandidateCluster->IsAvailable())
215 if (MU_MINUS == std::abs(pCandidateCluster->GetParticleId()))
221 if (particleSeedVector.end() == std::find(particleSeedVector.begin(), particleSeedVector.end(), pCandidateCluster))
222 candidateClusters.push_back(pCandidateCluster);
228 for (
const Cluster *
const pSeedCluster : particleSeedVector)
242 for (
const auto &mapEntry : seedAssociationList)
243 clusterList.push_back(mapEntry.first);
246 for (
const Cluster *
const pParentCluster : clusterList)
248 const ClusterVector &branchClusters(seedAssociationList.at(pParentCluster));
251 usedClusters.insert(pParentCluster);
252 usedClusters.insert(branchClusters.begin(), branchClusters.end());
262 for (
const Cluster *
const pBranchCluster : branchClusters)
264 if (pBranchCluster->IsAvailable())
280 const Vertex *
const pVertex(
281 ((pVertexList->size() == 1) && (
VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) :
nullptr);
291 seedIter =
m_clusterDirectionMap.insert(ClusterDirectionMap::value_type(pClusterSeed, direction)).first;
327 if ((checkSeedForward == checkCandidateForward) && (checkSeedBackward == checkCandidateBackward))
362 const Vertex *
const pVertex(
363 ((pVertexList->size() == 1) && (
VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) :
nullptr);
369 unsigned int nVertexAssociatedSeeds(0), nVertexAssociatedNonSeeds(0);
372 for (
const auto &mapEntry : seedAssociationList)
373 clusterList.push_back(mapEntry.first);
376 for (
const Cluster *
const pSeedCluster : clusterList)
378 const ClusterVector &associatedClusters(seedAssociationList.at(pSeedCluster));
392 for (
const Cluster *
const pAssociatedCluster : associatedClusters)
407 const float figureOfMerit(
static_cast<float>(nVertexAssociatedSeeds) -
static_cast<float>(nVertexAssociatedNonSeeds));
408 return figureOfMerit;
415 unsigned int nConnections(0);
417 for (LArPointingClusterList::const_iterator cIter = pointingClusterList.begin(), cIterEnd = pointingClusterList.end(); cIter != cIterEnd; ++cIter)
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the lar pointing cluster class.
Header file for the shower growing algorithm class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static pandora::StatusCode GetCurrentList(const pandora::Algorithm &algorithm, const T *&pT)
Get the current list.
static pandora::StatusCode MergeAndDeleteClusters(const pandora::Algorithm &algorithm, const pandora::Cluster *const pClusterToEnlarge, const pandora::Cluster *const pClusterToDelete)
Merge two clusters in the current list, enlarging one cluster and deleting the second.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
std::unordered_map< const pandora::Cluster *, pandora::ClusterVector > SeedAssociationList
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void FindAssociatedClusters(const pandora::Cluster *const pParticleSeed, pandora::ClusterVector &candidateClusters, ClusterUsageMap &forwardUsageMap, ClusterUsageMap &backwardUsageMap) const
Find clusters associated with a particle seed.
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterUsageMap
AssociationType
AssociationType enum.
void IdentifyClusterMerges(const pandora::ClusterVector &particleSeedVector, const ClusterUsageMap &backwardUsageMap, SeedAssociationList &seedAssociationList) const
Identify cluster merges.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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,...
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)
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
static bool IsNode(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxTransverseDistance)
Whether pointing vertex is adjacent to a given position.
static bool IsEmission(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance)
Whether pointing vertex is emitted from a given position.
LArPointingCluster class.
const Vertex & GetInnerVertex() const
Get the inner vertex.
const Vertex & GetOuterVertex() const
Get the outer vertex.
static ClusterDirection GetClusterDirectionInZ(const pandora::Pandora &pandora, const pandora::Vertex *const pVertex, const pandora::Cluster *const pCluster, const float tanAngle, const float apexShift)
Get the direction of the cluster in z, using a projection of the provided vertex.
@ DIRECTION_BACKWARD_IN_Z
AssociationType AreClustersAssociated(const pandora::Cluster *const pClusterSeed, const pandora::Cluster *const pCluster) const
Determine whether two clusters are associated.
void ProcessBranchClusters(const pandora::Cluster *const pParentCluster, const pandora::ClusterVector &branchClusters, const std::string &listName) const
Process the list of branch clusters, merging with specified parent cluster, dealing with any existing...
float m_vertexAngularAllowance
Vertex association check: pointing angular allowance in degrees.
pandora::StringVector m_inputClusterListNames
The names of the input cluster lists.
unsigned int GetNVertexConnections(const pandora::CartesianVector &vertexPosition2D, const LArPointingClusterList &pointingClusterList) const
Get the number of clusters associated with the vertex.
void ProcessSeedAssociationDetails(const SeedAssociationList &seedAssociationList, const std::string &clusterListName, pandora::ClusterSet &usedClusters) const
Process the details stored in a specified seed association list.
ShowerGrowingAlgorithm()
Default constructor.
static bool SortClusters(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sorting for clusters to determine order in which seeds are considered.
void GetSeedAssociationList(const pandora::ClusterVector &particleSeedVector, const pandora::ClusterList *const pClusterList, SeedAssociationList &seedAssociationList) const
Get the seed association list for a given vector of particle seed candidates.
float m_nearbyClusterDistance
The nearby cluster distance, used for determining cluster associations.
bool IsVertexAssociated(const LArPointingCluster &pointingCluster, const pandora::CartesianVector &vertexPosition2D) const
Whether a pointing cluster is assciated with a provided 2D vertex projection.
void SimpleModeShowerGrowing(const pandora::ClusterList *const pClusterList, const std::string &clusterListName) const
Simple single-pass shower growing mode.
float m_directionApexShift
Direction determination, look for vertex inside triangle with apex shifted along the cluster length.
ClusterDirectionMap m_clusterDirectionMap
The cluster direction map.
unsigned int m_minCaloHitsPerCluster
The minimum number of calo hits per (seed or branch) cluster.
pandora::StatusCode Run()
Run the algorithm.
bool GetNextSeedCandidate(const pandora::ClusterList *const pClusterList, const pandora::ClusterSet &usedClusters, const pandora::Cluster *&pSeedCluster) const
Get the next seed candidate, using a list of available candidates and a list of those already used.
void GetAllVertexSeedCandidates(const pandora::ClusterList *const pClusterList, const pandora::Vertex *const pVertex, pandora::ClusterVector &seedClusters) const
Get all seed candidates associated with a provided vertex.
float GetFigureOfMerit(const SeedAssociationList &seedAssociationList) const
Get a figure of merit representing the consistency of the provided seed associated list.
float m_directionTanAngle
Direction determination, look for vertex inside triangle with apex shifted along the cluster length.
float m_remoteClusterDistance
The remote cluster distance, used for determining cluster associations.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
float m_maxVertexLongitudinalDistance
Vertex association check: max longitudinal distance cut.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
unsigned int GetOuterPseudoLayer() const
Get the outermost pseudo layer in the cluster.
unsigned int GetInnerPseudoLayer() const
Get the innermost pseudo layer in the cluster.
const CartesianVector GetCentroid(const unsigned int pseudoLayer) const
Get unweighted centroid for cluster at a particular pseudo layer, calculated using cached values of h...
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
const CartesianVector & GetPosition() const
Get the vertex position.
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::vector< LArPointingCluster > LArPointingClusterList
HitType
Calorimeter hit type enum.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::unordered_set< const Cluster * > ClusterSet
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.