34 allPfoList.insert(allPfoList.end(), muonPfoList.begin(), muonPfoList.end());
47 return STATUS_CODE_SUCCESS;
54 const std::string inputClusterListName(
60 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
PandoraContentApi::GetList(*
this, inputClusterListName, pInputClusterList));
62 if (!pInputClusterList)
65 return *pInputClusterList;
72 const PfoList *pMuonPfoList(
nullptr);
87 const PfoList *pDeltaRayPfoList(
nullptr);
92 if (!pDeltaRayPfoList)
95 return *pDeltaRayPfoList;
106 for (
auto &entry : clusterProximityMap)
108 if (entry.first->IsAvailable())
109 availableClusterList.push_back(entry.first);
116 for (
const Cluster *
const pAvailableCluster : availableClusterList)
118 if (modifiedClusters.count(pAvailableCluster))
121 const DeltaRayMatchingContainers::ClusterProximityMap::const_iterator iter(clusterProximityMap.find(pAvailableCluster));
124 if (iter == clusterProximityMap.end())
128 const ClusterList &nearbyClusters(clusterProximityMap.at(pAvailableCluster));
136 float closestDistance(std::numeric_limits<float>::max());
138 for (
const Cluster *
const pNearbyCluster : nearbyClusters)
143 if (std::find(nearbyMuonPfoVector.begin(), nearbyMuonPfoVector.end(), clusterToPfoMap.at(pNearbyCluster)) !=
144 nearbyMuonPfoVector.end())
151 if (separation < closestDistance)
153 closestDistance = separation;
154 pClosestMuonPfo = clusterToPfoMap.at(pNearbyCluster);
159 nearbyMuonPfoVector.push_back(pClosestMuonPfo);
162 if (nearbyMuonPfoVector.empty())
168 this->
CreateDeltaRay(pAvailableCluster, nearbyMuonPfoVector, modifiedClusters);
178 const DeltaRayMatchingContainers::ClusterToPfoMap::const_iterator iter(clusterToPfoMap.find(pCluster));
180 if (iter == clusterToPfoMap.end())
186 return (std::find(muonPfoList.begin(), muonPfoList.end(), pPfo) != muonPfoList.end());
204 if ((!pProjectedCluster1) || (!pProjectedCluster2))
231 if (muonClusterList.size() != 1)
235 auto muonProximityIter(clusterProximityMap.find(muonClusterList.front()));
237 if (muonProximityIter == clusterProximityMap.end())
240 float spanMinX(0.f), spanMaxX(0.f);
243 unsigned int highestHit(0);
244 const Cluster *pProjectedCluster(
nullptr);
246 for (
const Cluster *
const pNearbyCluster : muonProximityIter->second)
248 if (findAvailable && !pNearbyCluster->IsAvailable())
254 float minX(0.f), maxX(0.f);
255 pNearbyCluster->GetClusterSpanX(minX, maxX);
260 if (pNearbyCluster->GetNCaloHits() > highestHit)
262 highestHit = pNearbyCluster->GetNCaloHits();
263 pProjectedCluster = pNearbyCluster;
267 return pProjectedCluster;
277 const DeltaRayMatchingContainers::ClusterToPfoMap::const_iterator iter(clusterToPfoMap.find(pCluster));
279 if (iter == clusterToPfoMap.end())
285 return (std::find(deltaRayPfoList.begin(), deltaRayPfoList.end(), pDeltaRayPfo) != deltaRayPfoList.end());
292 spanMinX = std::numeric_limits<float>::max();
293 spanMaxX = -std::numeric_limits<float>::max();
295 for (
const Cluster *
const pCluster : clusterList)
297 float minX(0.f), maxX(0.f);
298 pCluster->GetClusterSpanX(minX, maxX);
315 for (
const Cluster *
const pModifiedCluster : clusterGroup)
316 modifiedClusters.insert(pModifiedCluster);
321 ClusterList projectedClusters1, projectedClusters2;
328 if ((!pProjectedCluster1) && (!pProjectedCluster2))
332 if (pProjectedCluster1)
336 if (pProjectedCluster2)
344 this->
CreatePfo(pCluster1, pCluster2, pCluster3);
354 consideredClusters.push_back(pCluster);
359 if (std::find(foundClusters.begin(), foundClusters.end(), pCluster) == foundClusters.end())
360 foundClusters.push_back(pCluster);
362 const DeltaRayMatchingContainers::ClusterProximityMap::const_iterator proximityIter(clusterProximityMap.find(pCluster));
364 if (proximityIter == clusterProximityMap.end())
367 for (
const Cluster *
const pNearbyCluster : proximityIter->second)
369 if (!pNearbyCluster->IsAvailable())
372 if (std::find(consideredClusters.begin(), consideredClusters.end(), pNearbyCluster) != consideredClusters.end())
375 if (std::find(foundClusters.begin(), foundClusters.end(), pNearbyCluster) != foundClusters.end())
386 if (clusterGroup.empty())
389 const Cluster *
const pClusterToEnlarge(clusterGroup.front());
391 if (clusterGroup.size() == 1)
392 return pClusterToEnlarge;
395 const std::string inputClusterListName(
398 for (
const Cluster *
const pClusterToDelete : clusterGroup)
402 if (pClusterToDelete != pClusterToEnlarge)
411 return pClusterToEnlarge;
418 const PfoList *pPfoList(
nullptr);
419 std::string pfoListName;
422 PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
423 pfoParameters.m_particleId = E_MINUS;
426 pfoParameters.m_energy = 0.f;
430 pfoParameters.m_clusterList.push_back(pCluster1);
433 pfoParameters.m_clusterList.push_back(pCluster2);
436 pfoParameters.m_clusterList.push_back(pCluster3);
438 if (pfoParameters.m_clusterList.empty())
443 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*
this, pfoParameters, pPfo));
456 for (
const Cluster *
const pCluster : inputClusterList)
458 if (!pCluster->IsAvailable())
464 this->
CreatePfo(pCluster,
nullptr,
nullptr);
492 return STATUS_CODE_SUCCESS;
Header file for the kd tree linker algo template class.
Header file for the cluster helper class.
Header file for the pfo helper class.
Header file for the one viw delta ray matching algorithm.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#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 ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode AddToPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Add a cluster to a particle flow object.
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
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.
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-tree.
void FillContainers(const pandora::PfoList &inputPfoList, const pandora::ClusterList &inputClusterList1, const pandora::ClusterList &inputClusterList2=pandora::ClusterList(), const pandora::ClusterList &inputClusterList3=pandora::ClusterList())
Fill the HitToClusterMap, the ClusterProximityMap and the ClusterToPfoMap in all input views.
void ClearContainers()
Empty all algorithm containers.
std::map< const pandora::Cluster *, pandora::ClusterList > ClusterProximityMap
void AddClustersToPfoMaps(const pandora::ParticleFlowObject *const pPfo)
Add the clusters of a cosmic ray/delta ray pfo to the cluster to pfo maps.
std::map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
const ClusterToPfoMap & GetClusterToPfoMap(const pandora::HitType hitType) const
Get the mapping of clusters to the pfos to which they belong.
const ClusterProximityMap & GetClusterProximityMap(const pandora::HitType hitType) const
Get the mapping of clusters to to their neighbouring clusters.
void AddClustersToContainers(const pandora::ClusterVector &newClusterVector, const pandora::PfoVector &pfoVector)
Add a list of clusters to the hit to cluster and cluster proximity maps and, if appropriate,...
void RemoveClusterFromContainers(const pandora::Cluster *const pDeletedCluster)
Remove an input cluster's hits from the hit to cluster and cluster proximity maps and,...
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 float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
const pandora::Cluster * GetBestProjectedCluster(const pandora::ClusterList &deltaRayClusterGroup, const pandora::ParticleFlowObject *const pNearbyMuonPfo, const pandora::HitType hitType, const bool findAvailable)
Get the best matched available or unavailable cluster of a remaining delta ray cluster group wrt a co...
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
const pandora::ClusterList GetInputClusterList(const pandora::HitType hitType)
Get the input cluster list of a given hit type.
std::string m_outputPfoListName
The list to receive the created delta ray pfos.
void PerformRecovery(const pandora::HitType hitType)
Create a delta ray pfo from any remaining, significant clusters.
pandora::StatusCode Run()
Run the algorithm.
std::string m_inputClusterListNameW
The list of reconstructed W clusters.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
const pandora::PfoList GetDeltaRayPfoList()
Get the input delta ray pfo list.
void CreatePfo(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3)
Create a pfo from the input clusters updating the cluster to pfo map accordingly.
float m_overlapExtension
The extension to each side of the x overlap region in which to search for matched clusters.
const pandora::Cluster * MergeClusterGroup(const pandora::ClusterList &clusterGroup)
Merge a collection of available clusters together updating hit containers accordingly.
unsigned int m_minClusterHits
The minimum number of hits for a cluster to be significant.
void GetNearbyAvailableClusters(const pandora::Cluster *const pCluster, pandora::ClusterList &consideredClusters, pandora::ClusterList &foundClusters)
In the view of the input available cluster, gather nearby available clusters.
bool IsMuonPfo(const pandora::Cluster *const pCluster)
Determine whether an input cluster belongs to a cosmic ray pfo.
OneViewDeltaRayMatchingAlgorithm()
Default constructor.
std::string m_deltaRayPfoListName
The list of reconstructed delta ray pfos.
bool AddIntoExistingDeltaRay(const pandora::Cluster *const pAvailableCluster, const pandora::PfoVector &nearbyMuonPfoVector)
Use nearby muon pfos to project into other views and attempt to add a remaining delta ray cluster int...
const pandora::PfoList GetMuonPfoList()
Get the input cosmic ray pfo list.
std::string m_muonPfoListName
The list of reconstructed cosmic ray pfos.
void PerformOneViewMatching(const pandora::HitType hitType)
Use nearby muon pfos to project into other views and attempt to match the remaining delta ray cluster...
void CreateDeltaRay(const pandora::Cluster *const pAvailableCluster, const pandora::PfoVector &nearbyMuonPfoVector, pandora::ClusterSet &modifiedClusters)
Use nearby muon pfos to project into other views and attempt to match a remaining delta ray cluster t...
std::string m_inputClusterListNameV
The list of reconstructed V clusters.
void GetClusterSpanX(const pandora::ClusterList &clusterList, float &spanMinX, float &spanMaxX)
Determine cluster span (in x) of a group of clusters.
std::string m_inputClusterListNameU
The list of reconstructed U clusters.
bool IsDeltaRayPfo(const pandora::Cluster *const pCluster)
Determine whether an input cluster belongs to a delta ray pfo.
bool IsAvailable() const
Whether the cluster is available to be added to a particle flow object.
ParticleFlowObject class.
static float GetParticleMass(const int pdgCode)
Get the mass of a particle type.
static int GetParticleCharge(const int pdgCode)
Get the charge of a particle type.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
HitType
Calorimeter hit type enum.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< const ParticleFlowObject * > PfoVector
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList