Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ThreeViewMatchingControl.cc
Go to the documentation of this file.
1
10
12
15
18
19using namespace pandora;
20
21namespace lar_content
22{
23
24template <typename T>
26 NViewMatchingControl(pAlgorithm),
27 m_pInputClusterListU(nullptr),
28 m_pInputClusterListV(nullptr),
29 m_pInputClusterListW(nullptr)
30{
31}
33//------------------------------------------------------------------------------------------------------------------------------------------
34
35template <typename T>
39
40//------------------------------------------------------------------------------------------------------------------------------------------
41
42template <typename T>
48//------------------------------------------------------------------------------------------------------------------------------------------
50template <typename T>
53 const HitType hitType(LArClusterHelper::GetClusterHitType(pNewCluster));
55 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
56 throw StatusCodeException(STATUS_CODE_FAILURE);
57
58 ClusterList &clusterList((TPC_VIEW_U == hitType) ? m_clusterListU : (TPC_VIEW_V == hitType) ? m_clusterListV : m_clusterListW);
59
60 if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pNewCluster))
61 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
62
63 clusterList.push_back(pNewCluster);
64
65 const ClusterList &clusterList2((TPC_VIEW_U == hitType) ? m_clusterListV : m_clusterListU);
66 const ClusterList &clusterList3((TPC_VIEW_W == hitType) ? m_clusterListV : m_clusterListW);
67
68 ClusterVector clusterVector2(clusterList2.begin(), clusterList2.end());
69 ClusterVector clusterVector3(clusterList3.begin(), clusterList3.end());
70 std::sort(clusterVector2.begin(), clusterVector2.end(), LArClusterHelper::SortByNHits);
71 std::sort(clusterVector3.begin(), clusterVector3.end(), LArClusterHelper::SortByNHits);
72
73 for (const Cluster *const pCluster2 : clusterVector2)
74 {
75 for (const Cluster *const pCluster3 : clusterVector3)
76 {
77 if (TPC_VIEW_U == hitType)
78 {
79 m_pAlgorithm->CalculateOverlapResult(pNewCluster, pCluster2, pCluster3);
80 }
81 else if (TPC_VIEW_V == hitType)
82 {
83 m_pAlgorithm->CalculateOverlapResult(pCluster2, pNewCluster, pCluster3);
84 }
85 else
86 {
87 m_pAlgorithm->CalculateOverlapResult(pCluster2, pCluster3, pNewCluster);
88 }
89 }
90 }
91}
92
93//------------------------------------------------------------------------------------------------------------------------------------------
94
95template <typename T>
97{
98 ClusterList::iterator iterU = std::find(m_clusterListU.begin(), m_clusterListU.end(), pDeletedCluster);
99 ClusterList::iterator iterV = std::find(m_clusterListV.begin(), m_clusterListV.end(), pDeletedCluster);
100 ClusterList::iterator iterW = std::find(m_clusterListW.begin(), m_clusterListW.end(), pDeletedCluster);
101
102 if (m_clusterListU.end() != iterU)
103 m_clusterListU.erase(iterU);
104
105 if (m_clusterListV.end() != iterV)
106 m_clusterListV.erase(iterV);
107
108 if (m_clusterListW.end() != iterW)
109 m_clusterListW.erase(iterW);
110
111 m_overlapTensor.RemoveCluster(pDeletedCluster);
112}
113
114//------------------------------------------------------------------------------------------------------------------------------------------
115
116template <typename T>
117const std::string &ThreeViewMatchingControl<T>::GetClusterListName(const HitType hitType) const
118{
119 if (TPC_VIEW_U == hitType)
120 return m_inputClusterListNameU;
121
122 if (TPC_VIEW_V == hitType)
123 return m_inputClusterListNameV;
124
125 if (TPC_VIEW_W == hitType)
126 return m_inputClusterListNameW;
127
128 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
129}
130
131//------------------------------------------------------------------------------------------------------------------------------------------
132
133template <typename T>
135{
136 if ((TPC_VIEW_U == hitType) && m_pInputClusterListU)
137 return (*m_pInputClusterListU);
138
139 if ((TPC_VIEW_V == hitType) && m_pInputClusterListV)
140 return (*m_pInputClusterListV);
141
142 if ((TPC_VIEW_W == hitType) && m_pInputClusterListW)
143 return (*m_pInputClusterListW);
144
145 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
146}
147
148//------------------------------------------------------------------------------------------------------------------------------------------
149
150template <typename T>
152{
153 if (TPC_VIEW_U == hitType)
154 return m_clusterListU;
155
156 if (TPC_VIEW_V == hitType)
157 return m_clusterListV;
158
159 if (TPC_VIEW_W == hitType)
160 return m_clusterListW;
161
162 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
163}
164
165//------------------------------------------------------------------------------------------------------------------------------------------
166
167template <typename T>
169{
170 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
171 PandoraContentApi::GetList(*m_pAlgorithm, m_inputClusterListNameU, m_pInputClusterListU));
172 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
173 PandoraContentApi::GetList(*m_pAlgorithm, m_inputClusterListNameV, m_pInputClusterListV));
174 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
175 PandoraContentApi::GetList(*m_pAlgorithm, m_inputClusterListNameW, m_pInputClusterListW));
176
177 if (!m_pInputClusterListU || !m_pInputClusterListV || !m_pInputClusterListW)
178 {
180 std::cout << "ThreeViewMatchingControl: one or more input cluster lists unavailable." << std::endl;
181
182 throw StatusCodeException(STATUS_CODE_SUCCESS);
183 }
184
185 m_pAlgorithm->SelectInputClusters(m_pInputClusterListU, m_clusterListU);
186 m_pAlgorithm->SelectInputClusters(m_pInputClusterListV, m_clusterListV);
187 m_pAlgorithm->SelectInputClusters(m_pInputClusterListW, m_clusterListW);
188}
189
190//------------------------------------------------------------------------------------------------------------------------------------------
191
192template <typename T>
194{
195 m_pAlgorithm->PrepareInputClusters(m_clusterListU);
196 m_pAlgorithm->PrepareInputClusters(m_clusterListV);
197 m_pAlgorithm->PrepareInputClusters(m_clusterListW);
198}
199
200//------------------------------------------------------------------------------------------------------------------------------------------
201
202template <typename T>
204{
205 m_overlapTensor.Clear();
206
207 m_pInputClusterListU = nullptr;
208 m_pInputClusterListV = nullptr;
209 m_pInputClusterListW = nullptr;
210
211 m_clusterListU.clear();
212 m_clusterListV.clear();
213 m_clusterListW.clear();
214}
215
216//------------------------------------------------------------------------------------------------------------------------------------------
217
218template <typename T>
220{
221 ClusterVector clusterVectorU(m_clusterListU.begin(), m_clusterListU.end());
222 ClusterVector clusterVectorV(m_clusterListV.begin(), m_clusterListV.end());
223 ClusterVector clusterVectorW(m_clusterListW.begin(), m_clusterListW.end());
224 std::sort(clusterVectorU.begin(), clusterVectorU.end(), LArClusterHelper::SortByNHits);
225 std::sort(clusterVectorV.begin(), clusterVectorV.end(), LArClusterHelper::SortByNHits);
226 std::sort(clusterVectorW.begin(), clusterVectorW.end(), LArClusterHelper::SortByNHits);
227
228 for (const Cluster *const pClusterU : clusterVectorU)
229 {
230 for (const Cluster *const pClusterV : clusterVectorV)
231 {
232 for (const Cluster *const pClusterW : clusterVectorW)
233 m_pAlgorithm->CalculateOverlapResult(pClusterU, pClusterV, pClusterW);
234 }
235 }
236}
237
238//------------------------------------------------------------------------------------------------------------------------------------------
239
240template <typename T>
242{
243 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameU", m_inputClusterListNameU));
244 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameV", m_inputClusterListNameV));
245 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameW", m_inputClusterListNameW));
246
247 return STATUS_CODE_SUCCESS;
248}
249
256
257} // 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 lar shower overlap result class.
Header file for the lar track overlap result class.
Header file for the three dimension algorithm base class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:55
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
Header file for the three view matching control class.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position,...
void SelectAllInputClusters()
Select a subset of input clusters for processing in this algorithm.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read settings from xml.
void PerformMainLoop()
Main loop over cluster combinations in order to populate the overlap container. Responsible for calli...
ThreeViewMatchingControl(MatchingBaseAlgorithm *const pAlgorithm)
Constructor.
void PrepareAllInputClusters()
Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results.
const pandora::ClusterList & GetSelectedClusterList(const pandora::HitType hitType) const
Get the selected cluster list corresponding to a specified hit type.
void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
TensorType & GetOverlapTensor()
Get the overlap tensor.
const pandora::ClusterList & GetInputClusterList(const pandora::HitType hitType) const
Get the input cluster list corresponding to a specified hit type.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
Cluster class.
Definition Cluster.h:31
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
HitType
Calorimeter hit type enum.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.