Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
SimpleShowersTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18SimpleShowersTool::SimpleShowersTool() : m_minMatchedFraction(0.2f), m_minMatchedSamplingPoints(40), m_minXOverlapFraction(0.5f)
19{
20}
21
22//------------------------------------------------------------------------------------------------------------------------------------------
23
24bool SimpleShowersTool::Run(ThreeViewShowersAlgorithm *const pAlgorithm, TensorType &overlapTensor)
25{
27 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
28
29 ProtoParticleVector protoParticleVector;
30 this->FindBestShower(overlapTensor, protoParticleVector);
31
32 const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
33 return particlesMade;
34}
35
36//------------------------------------------------------------------------------------------------------------------------------------------
37
38void SimpleShowersTool::FindBestShower(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
39{
40 ClusterVector sortedKeyClusters;
41 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
42
43 for (const Cluster *const pKeyCluster : sortedKeyClusters)
44 {
45 if (!pKeyCluster->IsAvailable())
46 continue;
47
48 unsigned int nU(0), nV(0), nW(0);
49 TensorType::ElementList elementList;
50 overlapTensor.GetConnectedElements(pKeyCluster, true, elementList, nU, nV, nW);
51
52 if (elementList.empty())
53 continue;
54
55 TensorType::Element bestElement(elementList.back());
56
57 if (!bestElement.GetOverlapResult().IsInitialized())
58 continue;
59
60 if ((NULL == bestElement.GetClusterU()) || (NULL == bestElement.GetClusterV()) || (NULL == bestElement.GetClusterW()))
61 continue;
62
63 ProtoParticle protoParticle;
64 protoParticle.m_clusterList.push_back(bestElement.GetClusterU());
65 protoParticle.m_clusterList.push_back(bestElement.GetClusterV());
66 protoParticle.m_clusterList.push_back(bestElement.GetClusterW());
67 protoParticleVector.push_back(protoParticle);
68
69 return;
70 }
71}
72
73//------------------------------------------------------------------------------------------------------------------------------------------
74
75bool SimpleShowersTool::PassesElementCuts(TensorType::ElementList::const_iterator eIter) const
76{
77 if (eIter->GetOverlapResult().GetMatchedFraction() < m_minMatchedFraction)
78 return false;
79
80 if (eIter->GetOverlapResult().GetNMatchedSamplingPoints() < m_minMatchedSamplingPoints)
81 return false;
82
83 const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
84
85 if ((xOverlap.GetXSpanU() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanU() > m_minXOverlapFraction) &&
86 (xOverlap.GetXSpanV() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanV() > m_minXOverlapFraction) &&
87 (xOverlap.GetXSpanW() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanW() > m_minXOverlapFraction))
88 {
89 return true;
90 }
91
92 return false;
93}
94
95//------------------------------------------------------------------------------------------------------------------------------------------
96
98{
100 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchedFraction", m_minMatchedFraction));
101
102 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
103 XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
104
106 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlapFraction", m_minXOverlapFraction));
107
108 return STATUS_CODE_SUCCESS;
109}
110
111} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the simple showers tool class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
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.
ThreeViewShowersAlgorithm::MatchingType::TensorType TensorType
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
SimpleShowersTool()
Default constructor.
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
bool Run(ThreeViewShowersAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
void FindBestShower(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
Find best shower match as a simple way to (try to) resolve ambiguities in the tensor.
bool PassesElementCuts(TensorType::ElementList::const_iterator eIter) const
Whether a provided (iterator to a) tensor element passes the selection cuts for particle creation.
XOverlap class.
Definition LArXOverlap.h:18
float GetXSpanV() const
Get the x span in the v view.
float GetXOverlapSpan() const
Get the x overlap span.
float GetXSpanW() const
Get the x span in the w view.
float GetXSpanU() const
Get the x span in the u view.
Cluster class.
Definition Cluster.h:31
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
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
std::vector< ProtoParticle > ProtoParticleVector
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
std::vector< const Cluster * > ClusterVector
StatusCode
The StatusCode enum.