23 m_maxDRSeparationFromTrack(1.5f),
24 m_maxClusterSeparation(3.f),
25 m_maxVertexSeparation(10.f),
26 m_maxGoodMatchReducedChiSquared(1.f)
37 std::cout <<
"----> Running Algorithm Tool: " << this->
GetInstanceName() <<
", " << this->
GetType() << std::endl;
46 bool mergeMade(
false), mergesMade(
false), finishedTwoViewMerges(
false);
53 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
56 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
58 if (usedKeyClusters.count(pKeyCluster))
61 TensorType::ElementList elementList;
62 overlapTensor.GetConnectedElements(pKeyCluster,
true, elementList);
64 for (
const TensorType::Element &element : elementList)
65 usedKeyClusters.insert(element.GetClusterU());
67 if (elementList.size() < 2)
77 finishedTwoViewMerges =
true;
95 for (
auto iter1 = elementList.begin(); iter1 != elementList.end(); ++iter1)
97 const TensorType::Element &element1(*iter1);
99 for (
auto iter2 = std::next(iter1); iter2 != elementList.end(); ++iter2)
101 const TensorType::Element &element2(*iter2);
105 if ((element1.GetCluster(hitType1) == element2.GetCluster(hitType1)))
109 if (hitType1 == hitType2)
112 if ((element1.GetCluster(hitType2) == element2.GetCluster(hitType2)))
115 const Cluster *pClusterToEnlarge(element1.GetCluster(mergeHitType)), *pClusterToDelete(element2.GetCluster(mergeHitType));
147 const PfoList &commonMuonPfoList1(element1.GetOverlapResult().GetCommonMuonPfoList());
148 const PfoList &commonMuonPfoList2(element2.GetOverlapResult().GetCommonMuonPfoList());
154 if (commonMuonPfoList.empty())
157 const Cluster *
const pCluster1(element1.GetCluster(mergeHitType)), *
const pCluster2(element2.GetCluster(mergeHitType));
159 PfoList connectedMuonPfoList1, connectedMuonPfoList2;
163 if (connectedMuonPfoList1.empty() || connectedMuonPfoList2.empty())
170 if ((pConnectedMuon1 == pConnectedMuon2) && (this->
IsHiddenByTrack(pConnectedMuon1, pCluster1, pCluster2)))
186 if (pCommonMuonPfo1 == pCommonMuonPfo2)
187 commonMuonPfoList.push_back(pCommonMuonPfo1);
198 if (this->
IsConnected(pDeltaRayCluster, pCommonMuonPfo))
199 connectedMuonPfoList.push_back(pCommonMuonPfo);
212 if (muonClusterList.size() != 1)
237 if (vertices1.empty() || vertices2.empty())
240 for (
const CaloHit *
const pCaloHit : vertices1)
260 if (muonClusterList.size() != 1)
264 muonClusterList.front()->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
266 for (
const CaloHit *
const pCaloHit : caloHitList)
269 vertexList.push_back(pCaloHit);
277 for (
auto iter1 = elementList.begin(); iter1 != elementList.end(); ++iter1)
279 const TensorType::Element &element1(*iter1);
281 for (
auto iter2 = std::next(iter1); iter2 != elementList.end(); ++iter2)
283 const TensorType::Element &element2(*iter2);
287 if (element1.GetCluster(hitType) == element2.GetCluster(hitType))
292 const Cluster *pClusterToEnlarge1 = element1.GetCluster(mergeHitType1), *pClusterToDelete1 = element2.GetCluster(mergeHitType1);
293 const Cluster *pClusterToEnlarge2 = element1.GetCluster(mergeHitType2), *pClusterToDelete2 = element2.GetCluster(mergeHitType2);
295 if ((pClusterToEnlarge1 == pClusterToDelete1) || (pClusterToEnlarge2 == pClusterToDelete2))
304 CaloHitList caloHitList1, caloHitList2, caloHitList3;
306 pClusterToDelete1->GetOrderedCaloHitList().FillCaloHitList(caloHitList1);
308 pClusterToDelete2->GetOrderedCaloHitList().FillCaloHitList(caloHitList2);
309 element1.GetCluster(hitType)->GetOrderedCaloHitList().FillCaloHitList(caloHitList3);
311 float reducedChiSquared(std::numeric_limits<float>::max());
314 if (status == STATUS_CODE_NOT_FOUND)
367 return STATUS_CODE_SUCCESS;
Header file for the cluster helper class.
Header file for the muon leading helper class.
Header file for the pfo helper class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, 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 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 const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
bool AreAssociated(const TensorType::Element &element1, const TensorType::Element &element2, const pandora::HitType &mergeHitType) const
Determine, from a topological point of view, whether two delta ray clusters should be merged together...
bool IsConnected(const pandora::Cluster *const pCluster, const pandora::Pfo *const pCommonMuonPfo) const
Determine whether a given cluster is connected to a cosmic ray pfo.
void GetConnectedMuons(const pandora::Cluster *const pDeltaRayCluster, const pandora::PfoList &commonMuonPfoList, pandora::PfoList &connectedMuonPfoList) const
Return the list of muon pfos that a specified delta ray cluster is directly connected to.
bool MakeTwoCommonViewMerges(const TensorType::ElementList &elementList) const
Search for two matches with two common clusters and attempt to merge the clusters in the third view t...
float m_maxVertexSeparation
The maximum separation of the connection points of two delta ray clusters that are hidden by a CR tra...
void FindVertices(const pandora::Pfo *const pCommonMuonPfo, const pandora::Cluster *const pCluster, pandora::CaloHitList &vertexList) const
Find all connection points of a delta ray cluster and a cosmic ray pfo.
bool IsHiddenByTrack(const pandora::ParticleFlowObject *const pMuonPfo, const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const
Determine whether two delta ray clusters are actually a single cluster that is hidden behind a cosmic...
bool MakeOneCommonViewMerges(const TensorType::ElementList &elementList) const
Search for two matches with a single common cluster and attempt to merge the clusters in the other tw...
bool ExamineConnectedElements(TensorType &overlapTensor) const
Identify ambiguous matches (e.g. 3:2:1) and attempt to merge clusters together.
float m_maxGoodMatchReducedChiSquared
The threshold reduced chi squared value for a potential two view merge to go ahead.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
bool IsBrokenCluster(const pandora::Cluster *const pClusterToEnlarge, const pandora::Cluster *const pClusterToDelete) const
Determine whether two delta ray clusters have been split.
DeltaRayMergeTool()
Default constructor.
void CombineCommonMuonPfoLists(const pandora::PfoList &commonMuonPfoList1, const pandora::PfoList &commonMuonPfoList2, pandora::PfoList &commonMuonPfoList) const
Create a list of the shared common muon pfos of two elements.
float m_maxClusterSeparation
The maximum separation of two broken clusters that should be merged.
float m_maxDRSeparationFromTrack
The maximum distance of a connected delta ray from a cosmic ray track.
bool Run(ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
ThreeViewDeltaRayMatchingAlgorithm::MatchingType::TensorType TensorType
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
void UpdateForNewClusters(const pandora::ClusterVector &newClusterVector, const pandora::PfoVector &pfoVector)
Add a new cluster to algorithm ownership maps and, if it a delta ray cluster, to the underlying match...
pandora::StatusCode PerformThreeViewMatching(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3, float &reducedChiSquared) const
To determine how well three clusters (one in each view) map onto one another expressing this in terms...
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
ThreeViewDeltaRayMatchingAlgorithm class.
const OrderedCaloHitList & GetOrderedCaloHitList() const
Get the ordered calo hit list.
void FillCaloHitList(CaloHitList &caloHitList) const
Fill a provided calo hit list with all the calo hits in the ordered calo hit list.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const std::string & GetType() const
Get the type.
const std::string & GetInstanceName() const
Get the instance name.
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::unordered_set< const Cluster * > ClusterSet
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList