9 #include "Pandora/AlgorithmHeaders.h"
27 m_pInputClusterListU(nullptr),
28 m_pInputClusterListV(nullptr),
29 m_pInputClusterListW(nullptr)
45 return m_overlapTensor;
55 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
56 throw StatusCodeException(STATUS_CODE_FAILURE);
58 ClusterList &clusterList((TPC_VIEW_U == hitType) ? m_clusterListU : (TPC_VIEW_V == hitType) ? m_clusterListV : m_clusterListW);
60 if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pNewCluster))
61 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
63 clusterList.push_back(pNewCluster);
65 const ClusterList &clusterList2((TPC_VIEW_U == hitType) ? m_clusterListV : m_clusterListU);
66 const ClusterList &clusterList3((TPC_VIEW_W == hitType) ? m_clusterListV : m_clusterListW);
68 ClusterVector clusterVector2(clusterList2.begin(), clusterList2.end());
69 ClusterVector clusterVector3(clusterList3.begin(), clusterList3.end());
73 for (
const Cluster *
const pCluster2 : clusterVector2)
75 for (
const Cluster *
const pCluster3 : clusterVector3)
77 if (TPC_VIEW_U == hitType)
79 m_pAlgorithm->CalculateOverlapResult(pNewCluster, pCluster2, pCluster3);
81 else if (TPC_VIEW_V == hitType)
83 m_pAlgorithm->CalculateOverlapResult(pCluster2, pNewCluster, pCluster3);
87 m_pAlgorithm->CalculateOverlapResult(pCluster2, pCluster3, pNewCluster);
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);
102 if (m_clusterListU.end() != iterU)
103 m_clusterListU.erase(iterU);
105 if (m_clusterListV.end() != iterV)
106 m_clusterListV.erase(iterV);
108 if (m_clusterListW.end() != iterW)
109 m_clusterListW.erase(iterW);
111 m_overlapTensor.RemoveCluster(pDeletedCluster);
116 template <
typename T>
119 if (TPC_VIEW_U == hitType)
120 return m_inputClusterListNameU;
122 if (TPC_VIEW_V == hitType)
123 return m_inputClusterListNameV;
125 if (TPC_VIEW_W == hitType)
126 return m_inputClusterListNameW;
128 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
133 template <
typename T>
136 if ((TPC_VIEW_U == hitType) && m_pInputClusterListU)
137 return (*m_pInputClusterListU);
139 if ((TPC_VIEW_V == hitType) && m_pInputClusterListV)
140 return (*m_pInputClusterListV);
142 if ((TPC_VIEW_W == hitType) && m_pInputClusterListW)
143 return (*m_pInputClusterListW);
145 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
150 template <
typename T>
153 if (TPC_VIEW_U == hitType)
154 return m_clusterListU;
156 if (TPC_VIEW_V == hitType)
157 return m_clusterListV;
159 if (TPC_VIEW_W == hitType)
160 return m_clusterListW;
162 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
167 template <
typename T>
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));
177 if (!m_pInputClusterListU || !m_pInputClusterListV || !m_pInputClusterListW)
179 if (PandoraContentApi::GetSettings(*m_pAlgorithm)->ShouldDisplayAlgorithmInfo())
180 std::cout <<
"ThreeViewMatchingControl: one or more input cluster lists unavailable." << std::endl;
182 throw StatusCodeException(STATUS_CODE_SUCCESS);
185 m_pAlgorithm->SelectInputClusters(m_pInputClusterListU, m_clusterListU);
186 m_pAlgorithm->SelectInputClusters(m_pInputClusterListV, m_clusterListV);
187 m_pAlgorithm->SelectInputClusters(m_pInputClusterListW, m_clusterListW);
192 template <
typename T>
195 m_pAlgorithm->PrepareInputClusters(m_clusterListU);
196 m_pAlgorithm->PrepareInputClusters(m_clusterListV);
197 m_pAlgorithm->PrepareInputClusters(m_clusterListW);
202 template <
typename T>
205 m_overlapTensor.Clear();
207 m_pInputClusterListU =
nullptr;
208 m_pInputClusterListV =
nullptr;
209 m_pInputClusterListW =
nullptr;
211 m_clusterListU.clear();
212 m_clusterListV.clear();
213 m_clusterListW.clear();
218 template <
typename T>
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());
228 for (
const Cluster *
const pClusterU : clusterVectorU)
230 for (
const Cluster *
const pClusterV : clusterVectorV)
232 for (
const Cluster *
const pClusterW : clusterVectorW)
233 m_pAlgorithm->CalculateOverlapResult(pClusterU, pClusterV, pClusterW);
240 template <
typename T>
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));
247 return STATUS_CODE_SUCCESS;
ThreeViewMatchingControl class.
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, then pulse-height.
NViewMatchingControl class.
TensorType & GetOverlapTensor()
Get the overlap tensor.
void PerformMainLoop()
Main loop over cluster combinations in order to populate the overlap container. Responsible for calli...
MatchingBaseAlgorithm class.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read settings from xml.
void PrepareAllInputClusters()
Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results...
Header file for the cluster helper class.
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
Header file for the lar shower overlap result class.
const pandora::ClusterList & GetInputClusterList(const pandora::HitType hitType) const
Get the input cluster list corresponding to a specified hit type.
void TidyUp()
Tidy member variables.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Header file for the lar track overlap result class.
Header file for the three view matching control class.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
const pandora::ClusterList & GetSelectedClusterList(const pandora::HitType hitType) const
Get the selected cluster list corresponding to a specified hit type.
virtual ~ThreeViewMatchingControl()
Destructor.
BEGIN_PROLOG could also be cout
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
void SelectAllInputClusters()
Select a subset of input clusters for processing in this algorithm.
Header file for the three dimension algorithm base class.