Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
MopUpRemnantsTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
21
22//------------------------------------------------------------------------------------------------------------------------------------------
23
24bool MopUpRemnantsTool::Run(ThreeViewRemnantsAlgorithm *const pAlgorithm, TensorType &overlapTensor)
25{
27 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
28
29 ProtoParticleVector protoParticleVector;
30 this->FindBestShowers(overlapTensor, protoParticleVector);
31
32 const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
33 return particlesMade;
34}
35
36//------------------------------------------------------------------------------------------------------------------------------------------
37
38void MopUpRemnantsTool::FindBestShowers(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
39{
40 ClusterSet usedClusters;
41 ClusterVector sortedKeyClusters;
42 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
43
44 for (const Cluster *const pKeyCluster : sortedKeyClusters)
45 {
46 if (!pKeyCluster->IsAvailable())
47 continue;
48
49 TensorType::ElementList connectedElements;
50 overlapTensor.GetConnectedElements(pKeyCluster, true, connectedElements);
51
52 TensorType::ElementList::const_iterator eIter = connectedElements.end();
53 this->SelectBestElement(connectedElements, usedClusters, eIter);
54 this->GetUsedClusters(connectedElements, usedClusters);
55
56 if (connectedElements.end() == eIter)
57 continue;
58
59 ProtoParticle protoParticle;
60 protoParticle.m_clusterList.push_back(eIter->GetClusterU());
61 protoParticle.m_clusterList.push_back(eIter->GetClusterV());
62 protoParticle.m_clusterList.push_back(eIter->GetClusterW());
63 protoParticleVector.push_back(protoParticle);
64 }
65}
66
67//------------------------------------------------------------------------------------------------------------------------------------------
68
69void MopUpRemnantsTool::GetUsedClusters(const TensorType::ElementList &elementList, ClusterSet &usedClusters) const
70{
71 for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
72 {
73 usedClusters.insert(eIter->GetClusterU());
74 usedClusters.insert(eIter->GetClusterV());
75 usedClusters.insert(eIter->GetClusterW());
76 }
77}
78
79//------------------------------------------------------------------------------------------------------------------------------------------
80
82 const TensorType::ElementList &elementList, const ClusterSet &usedClusters, TensorType::ElementList::const_iterator &bestIter) const
83{
84 float bestFigureOfMerit(0.f);
85
86 for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
87 {
88 const Cluster *const pClusterU = eIter->GetClusterU();
89 const Cluster *const pClusterV = eIter->GetClusterV();
90 const Cluster *const pClusterW = eIter->GetClusterW();
91
92 if (usedClusters.count(pClusterU) || usedClusters.count(pClusterV) || usedClusters.count(pClusterW))
93 continue;
94
95 const float figureOfMerit(pClusterU->GetHadronicEnergy() + pClusterV->GetHadronicEnergy() + pClusterW->GetHadronicEnergy());
96
97 if (figureOfMerit > bestFigureOfMerit)
98 {
99 bestFigureOfMerit = figureOfMerit;
100 bestIter = eIter;
101 }
102 }
103}
104
105//------------------------------------------------------------------------------------------------------------------------------------------
106
108{
109 return STATUS_CODE_SUCCESS;
110}
111
112} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the mop-up remnants tool class.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
void SelectBestElement(const TensorType::ElementList &elementList, const pandora::ClusterSet &usedClusters, TensorType::ElementList::const_iterator &bestIter) const
Select the best triplet of clusters.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
MopUpRemnantsTool()
Default constructor.
void FindBestShowers(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
Identify candidate particles.
bool Run(ThreeViewRemnantsAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
void GetUsedClusters(const TensorType::ElementList &elementList, pandora::ClusterSet &usedClusters) const
Copy used clusters into cluster list.
ThreeViewRemnantsAlgorithm::MatchingType::TensorType TensorType
Cluster class.
Definition Cluster.h:31
float GetHadronicEnergy() const
Get the sum of hadronic energy measures of all constituent calo hits, units GeV.
Definition Cluster.h:526
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const std::string & GetType() const
Get the type.
Definition Process.h:102
const std::string & GetInstanceName() const
Get the instance name.
Definition Process.h:109
std::vector< ProtoParticle > ProtoParticleVector
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
std::vector< const Cluster * > ClusterVector
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.