Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ThreeViewRemnantsAlgorithm.cc
Go to the documentation of this file.
1
10
12
15
16using namespace pandora;
17
18namespace lar_content
19{
20
22 m_nMaxTensorToolRepeats(1000),
23 m_minClusterCaloHits(5),
24 m_xOverlapWindow(2.f),
25 m_pseudoChi2Cut(10.f)
26{
27}
28
29//------------------------------------------------------------------------------------------------------------------------------------------
30
31void ThreeViewRemnantsAlgorithm::SelectInputClusters(const ClusterList *const pInputClusterList, ClusterList &selectedClusterList) const
32{
33 for (ClusterList::const_iterator iter = pInputClusterList->begin(), iterEnd = pInputClusterList->end(); iter != iterEnd; ++iter)
34 {
35 const Cluster *const pCluster = *iter;
36
37 if (!pCluster->IsAvailable())
38 continue;
39
40 if (pCluster->GetNCaloHits() < m_minClusterCaloHits)
41 continue;
42
43 selectedClusterList.push_back(pCluster);
44 }
45}
46
47//------------------------------------------------------------------------------------------------------------------------------------------
48
49void ThreeViewRemnantsAlgorithm::CalculateOverlapResult(const Cluster *const pClusterU, const Cluster *const pClusterV, const Cluster *const pClusterW)
50{
51 // Requirements on X matching
52 float xMinU(0.f), xMinV(0.f), xMinW(0.f), xMaxU(0.f), xMaxV(0.f), xMaxW(0.f);
53 pClusterU->GetClusterSpanX(xMinU, xMaxU);
54 pClusterV->GetClusterSpanX(xMinV, xMaxV);
55 pClusterW->GetClusterSpanX(xMinW, xMaxW);
56
57 const float xMin(std::max(xMinU, std::max(xMinV, xMinW)) - m_xOverlapWindow);
58 const float xMax(std::min(xMaxU, std::min(xMaxV, xMaxW)) + m_xOverlapWindow);
59 const float xOverlap(xMax - xMin);
60
61 if (xOverlap < std::numeric_limits<float>::epsilon())
62 return;
63
64 // Requirements on 3D matching
65 float u(std::numeric_limits<float>::max()), v(std::numeric_limits<float>::max()), w(std::numeric_limits<float>::max());
66
67 if ((STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterU, xMin, xMax, u)) ||
68 (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterV, xMin, xMax, v)) ||
69 (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterW, xMin, xMax, w)))
70 {
71 return;
72 }
73
77
78 const float pseudoChi2(((u - vw2u) * (u - vw2u) + (v - wu2v) * (v - wu2v) + (w - uv2w) * (w - uv2w)) / 3.f);
79
80 if (pseudoChi2 > m_pseudoChi2Cut)
81 return;
82
83 // ATTN Essentially a boolean result; actual value matters only so as to ensure that overlap results can be sorted
84 const float hackValue(
85 pseudoChi2 + pClusterU->GetElectromagneticEnergy() + pClusterV->GetElectromagneticEnergy() + pClusterW->GetElectromagneticEnergy());
86 this->GetMatchingControl().GetOverlapTensor().SetOverlapResult(pClusterU, pClusterV, pClusterW, hackValue);
87}
88
89//------------------------------------------------------------------------------------------------------------------------------------------
90
92{
93 unsigned int repeatCounter(0);
94
95 for (RemnantTensorToolVector::const_iterator iter = m_algorithmToolVector.begin(), iterEnd = m_algorithmToolVector.end(); iter != iterEnd;)
96 {
97 if ((*iter)->Run(this, this->GetMatchingControl().GetOverlapTensor()))
98 {
99 iter = m_algorithmToolVector.begin();
100
101 if (++repeatCounter > m_nMaxTensorToolRepeats)
102 break;
103 }
104 else
105 {
106 ++iter;
107 }
108 }
109}
110
111//------------------------------------------------------------------------------------------------------------------------------------------
112
114{
115 AlgorithmToolVector algorithmToolVector;
116 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "TrackTools", algorithmToolVector));
117
118 for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
119 {
120 RemnantTensorTool *const pRemnantTensorTool(dynamic_cast<RemnantTensorTool *>(*iter));
121
122 if (!pRemnantTensorTool)
123 return STATUS_CODE_INVALID_PARAMETER;
124
125 m_algorithmToolVector.push_back(pRemnantTensorTool);
126 }
127
129 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NMaxTensorToolRepeats", m_nMaxTensorToolRepeats));
130
132 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterCaloHits", m_minClusterCaloHits));
133
134 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OverlapWindow", m_xOverlapWindow));
135
136 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PseudoChi2Cut", m_pseudoChi2Cut));
137
138 return BaseAlgorithm::ReadSettings(xmlHandle);
139}
140
141} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cluster helper class.
Header file for the geometry helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
Header file for the three view remnants algorithm class.
static pandora::StatusCode GetAverageZ(const pandora::Cluster *const pCluster, const float xmin, const float xmax, float &averageZ)
Get average Z positions of the calo hits in a cluster in range xmin to xmax.
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void SetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Set overlap result.
TensorType & GetOverlapTensor()
Get the overlap tensor.
void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
unsigned int m_minClusterCaloHits
The selection cut on the number of cluster calo hits.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void ExamineOverlapContainer()
Examine contents of overlap container, collect together best-matching 2D particles and modify cluster...
float m_pseudoChi2Cut
The selection cut on the matched chi2.
RemnantTensorToolVector m_algorithmToolVector
The algorithm tool list.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in container.
float m_xOverlapWindow
The sampling pitch in the x coordinate.
Cluster class.
Definition Cluster.h:31
bool IsAvailable() const
Whether the cluster is available to be added to a particle flow object.
Definition Cluster.h:582
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
Definition Cluster.h:484
float GetElectromagneticEnergy() const
Get the sum of electromagnetic energy measures of all constituent calo hits, units GeV.
Definition Cluster.h:519
void GetClusterSpanX(float &xmin, float &xmax) const
Get minimum and maximum X positions of the calo hits in this cluster.
Definition Cluster.cc:169
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
static StatusCode ProcessAlgorithmToolList(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &listName, AlgorithmToolVector &algorithmToolVector)
Process a list of algorithms tools in an xml file.
Definition XmlHelper.cc:101
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< AlgorithmTool * > AlgorithmToolVector
StatusCode
The StatusCode enum.