9 #include "Pandora/PandoraEnumeratedTypes.h" 11 #include "Objects/Cluster.h" 23 DeltaRayMatchingContainers::DeltaRayMatchingContainers() :
31 const ClusterList &inputClusterList2,
const ClusterList &inputClusterList3)
48 for (
const Cluster *
const pCluster : inputClusterList)
61 CaloHitList caloHitList;
62 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
64 for (
const CaloHit *
const pCaloHit : caloHitList)
65 hitToClusterMap[pCaloHit] = pCluster;
72 if (inputClusterList.empty())
79 for (
const Cluster *
const pCluster : inputClusterList)
92 CaloHitList allCaloHits;
94 for (
auto &entry : hitToClusterMap)
95 allCaloHits.push_back(entry.first);
100 kdTree.
build(hitKDNode2DList, hitsBoundingRegion2D);
116 CaloHitList caloHitList;
117 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
119 for (
const CaloHit *
const pCaloHit : caloHitList)
124 kdTree.
search(searchRegionHits, found);
126 for (
const auto &
hit : found)
128 const Cluster *
const pNearbyCluster(hitToClusterMap.at(
hit.data));
130 if (pNearbyCluster == pCluster)
133 ClusterList &nearbyClusterList(clusterProximityMap[pCluster]);
135 if (std::find(nearbyClusterList.begin(), nearbyClusterList.end(), pNearbyCluster) == nearbyClusterList.end())
136 nearbyClusterList.push_back(pNearbyCluster);
138 ClusterList &invertedNearbyClusterList(clusterProximityMap[pNearbyCluster]);
140 if (std::find(invertedNearbyClusterList.begin(), invertedNearbyClusterList.end(), pCluster) == invertedNearbyClusterList.end())
141 invertedNearbyClusterList.push_back(pCluster);
150 for (
const ParticleFlowObject *
const pPfo : inputPfoList)
158 for (
const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
160 ClusterList pfoClusters;
167 for (
const Cluster *
const pCluster : pfoClusters)
169 if (clusterToPfoMap.find(pCluster) != clusterToPfoMap.end())
172 clusterToPfoMap[pCluster] = pPfo;
181 for (
const Cluster *
const pNewCluster : newClusterVector)
184 for (
unsigned int i = 0; i < newClusterVector.size(); i++)
186 const Cluster *
const pNewCluster(newClusterVector.at(i));
187 const ParticleFlowObject *
const pMuonPfo(pfoVector.at(i));
211 CaloHitList caloHitList;
212 pDeletedCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
214 for (
const CaloHit *
const pCaloHit : caloHitList)
218 if (iter == hitToClusterMap.end())
219 throw StatusCodeException(STATUS_CODE_FAILURE);
221 hitToClusterMap.erase(iter);
226 if (clusterProximityIter != clusterProximityMap.end())
228 const ClusterList &nearbyClusterList(clusterProximityIter->second);
230 for (
const Cluster *
const pNearbyCluster : nearbyClusterList)
234 if (iter == clusterProximityMap.end())
237 ClusterList &invertedCloseClusters(iter->second);
239 ClusterList::iterator invertedIter(std::find(invertedCloseClusters.begin(), invertedCloseClusters.end(), pDeletedCluster));
240 invertedCloseClusters.erase(invertedIter);
243 clusterProximityMap.erase(clusterProximityIter);
248 if (clusterToPfoIter != clusterToPfoMap.end())
249 clusterToPfoMap.erase(clusterToPfoIter);
std::map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
HitKDTree2D m_kdTreeW
The KD tree (in the W view)
void FillHitToClusterMap(const pandora::ClusterList &inputClusterList)
Populate the hit to cluster map from a list of clusters.
std::map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
Header file for the pfo helper class.
HitKDTree2D m_kdTreeV
The KD tree (in the V view)
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.
HitToClusterMap m_hitToClusterMapW
The mapping of hits to the clusters to which they belong (in the W view)
Box structure used to define 2D field. It's used in KDTree building step to divide the detector space...
void AddClustersToPfoMaps(const pandora::ParticleFlowObject *const pPfo)
Add the clusters of a cosmic ray/delta ray pfo to the cluster to pfo maps.
Header file for the delta ray matching containers class.
void clear()
Clear all allocated structures.
HitToClusterMap m_hitToClusterMapU
The mapping of hits to the clusters to which they belong (in the U view)
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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...
ClusterProximityMap m_clusterProximityMapU
The mapping of clusters to their neighbouring clusters (in the U view)
void FillClusterProximityMap(const pandora::ClusterList &inputClusterList)
Populate the cluster proximity map from a list of clusters.
Header file for the cluster helper class.
ClusterProximityMap m_clusterProximityMapV
The mapping of clusters to their neighbouring clusters (in the V view)
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, to the cluster to pfo map.
ClusterToPfoMap m_clusterToPfoMapU
The mapping of cosmic ray U clusters to the cosmic ray pfos to which they belong. ...
void build(std::vector< KDTreeNodeInfoT< DATA, DIM >> &eltList, const KDTreeBoxT< DIM > ®ion)
Build the KD tree from the "eltList" in the space define by "region".
void FillClusterToPfoMaps(const pandora::PfoList &pfoList)
Populate all cluster to pfo maps from a list of particle flow objects.
void AddToClusterMap(const pandora::Cluster *const pCluster)
Add the hits of a given cluster to the hit to cluster map.
void AddToClusterProximityMap(const pandora::Cluster *const pCluster)
Add a cluster to the cluster proximity map.
Detector simulation of raw signals on wires.
void BuildKDTree(const pandora::HitType hitType)
Build the KD tree.
ClusterToPfoMap m_clusterToPfoMapW
The mapping of cosmic ray W clusters to the cosmic ray pfos to which they belong. ...
HitKDTree2D m_kdTreeU
The KD tree (in the U view)
std::map< const pandora::Cluster *, pandora::ClusterList > ClusterProximityMap
HitToClusterMap m_hitToClusterMapV
The mapping of hits to the clusters to which they belong (in the V view)
ClusterProximityMap m_clusterProximityMapW
The mapping of clusters to their neighbouring clusters (in the W view)
KDTreeBox fill_and_bound_2d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 2 >> &nodes)
fill_and_bound_2d_kd_tree
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void ClearContainers()
Empty all algorithm containers.
KDTreeBox build_2d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float z_span)
build_2d_kd_search_region
void search(const KDTreeBoxT< DIM > &searchBox, std::vector< KDTreeNodeInfoT< DATA, DIM >> &resRecHitList)
Search in the KDTree for all points that would be contained in the given searchbox The founded points...
void RemoveClusterFromContainers(const pandora::Cluster *const pDeletedCluster)
Remove an input cluster's hits from the hit to cluster and cluster proximity maps and...
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-tree.
std::vector< HitKDNode2D > HitKDNode2DList
ClusterToPfoMap m_clusterToPfoMapV
The mapping of cosmic ray V clusters to the cosmic ray pfos to which they belong. ...