9 #include "Pandora/AlgorithmHeaders.h"
26 m_pInputClusterList1(nullptr),
27 m_pInputClusterList2(nullptr)
43 return m_overlapMatrix;
51 HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
53 if ((iter != m_hitTypeToIndexMap.end()) && (iter->second != 1) && (iter->second != 2))
54 throw StatusCodeException(STATUS_CODE_FAILURE);
56 return iter == m_hitTypeToIndexMap.end() ? 0 : iter->second;
65 HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
67 if ((m_hitTypeToIndexMap.end() == iter) || ((1 != iter->second) && (2 != iter->second)))
68 throw StatusCodeException(STATUS_CODE_FAILURE);
70 ClusterList &clusterList((1 == iter->second) ? m_clusterList1 : m_clusterList2);
72 if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pNewCluster))
73 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
75 clusterList.push_back(pNewCluster);
77 const ClusterList &clusterList2((1 == iter->second) ? m_clusterList2 : m_clusterList1);
79 ClusterVector clusterVector2(clusterList2.begin(), clusterList2.end());
82 for (
const Cluster *
const pCluster2 : clusterVector2)
84 if (1 == iter->second)
86 m_pAlgorithm->CalculateOverlapResult(pNewCluster, pCluster2);
90 m_pAlgorithm->CalculateOverlapResult(pCluster2, pNewCluster);
100 ClusterList::iterator iter1 = std::find(m_clusterList1.begin(), m_clusterList1.end(), pDeletedCluster);
101 ClusterList::iterator iter2 = std::find(m_clusterList2.begin(), m_clusterList2.end(), pDeletedCluster);
103 if (m_clusterList1.end() != iter1)
104 m_clusterList1.erase(iter1);
106 if (m_clusterList2.end() != iter2)
107 m_clusterList2.erase(iter2);
109 m_overlapMatrix.RemoveCluster(pDeletedCluster);
114 template <
typename T>
117 HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
118 if (m_hitTypeToIndexMap.end() == iter)
119 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
121 if ((1 != iter->second) && (2 != iter->second))
122 throw StatusCodeException(STATUS_CODE_FAILURE);
124 return ((1 == iter->second) ? m_inputClusterListName1 : m_inputClusterListName2);
129 template <
typename T>
132 HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
133 if (m_hitTypeToIndexMap.end() == iter)
134 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
136 if ((1 == iter->second) && m_pInputClusterList1)
137 return (*m_pInputClusterList1);
139 if ((2 == iter->second) && m_pInputClusterList2)
140 return (*m_pInputClusterList2);
142 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
147 template <
typename T>
150 HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
151 if (m_hitTypeToIndexMap.end() == iter)
152 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
154 if ((1 != iter->second) && (2 != iter->second))
155 throw StatusCodeException(STATUS_CODE_FAILURE);
157 return ((1 == iter->second) ? m_clusterList1 : m_clusterList2);
162 template <
typename T>
165 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
166 PandoraContentApi::GetList(*m_pAlgorithm, m_inputClusterListName1, m_pInputClusterList1));
167 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
168 PandoraContentApi::GetList(*m_pAlgorithm, m_inputClusterListName2, m_pInputClusterList2));
170 if (!m_pInputClusterList1 || !m_pInputClusterList2)
172 if (PandoraContentApi::GetSettings(*m_pAlgorithm)->ShouldDisplayAlgorithmInfo())
173 std::cout <<
"TwoViewMatchingControl: one or more input cluster lists unavailable." << std::endl;
175 throw StatusCodeException(STATUS_CODE_SUCCESS);
178 if (!m_pInputClusterList1->empty())
181 if (!m_pInputClusterList2->empty())
184 m_pAlgorithm->SelectInputClusters(m_pInputClusterList1, m_clusterList1);
185 m_pAlgorithm->SelectInputClusters(m_pInputClusterList2, m_clusterList2);
190 template <
typename T>
193 m_pAlgorithm->PrepareInputClusters(m_clusterList1);
194 m_pAlgorithm->PrepareInputClusters(m_clusterList2);
199 template <
typename T>
202 m_overlapMatrix.Clear();
203 m_hitTypeToIndexMap.clear();
205 m_pInputClusterList1 =
nullptr;
206 m_pInputClusterList2 =
nullptr;
208 m_clusterList1.clear();
209 m_clusterList2.clear();
214 template <
typename T>
217 ClusterVector clusterVector1(m_clusterList1.begin(), m_clusterList1.end());
218 ClusterVector clusterVector2(m_clusterList2.begin(), m_clusterList2.end());
222 for (
const Cluster *
const pCluster1 : clusterVector1)
224 for (
const Cluster *
const pCluster2 : clusterVector2)
225 m_pAlgorithm->CalculateOverlapResult(pCluster1, pCluster2);
231 template <
typename T>
234 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"InputClusterListName1", m_inputClusterListName1));
235 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"InputClusterListName2", m_inputClusterListName2));
237 return STATUS_CODE_SUCCESS;
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.
void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
TwoViewMatchingControl class.
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
NViewMatchingControl class.
void TidyUp()
Tidy member variables.
MatrixType & GetOverlapMatrix()
Get the overlap matrix.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
MatchingBaseAlgorithm class.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void SelectAllInputClusters()
Select a subset of input clusters for processing in this algorithm.
const pandora::ClusterList & GetInputClusterList(const pandora::HitType hitType) const
Get the input cluster list corresponding to a specified hit type.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read settings from xml.
Header file for the cluster helper class.
void PrepareAllInputClusters()
Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results...
virtual ~TwoViewMatchingControl()
Destructor.
unsigned int GetHitTypeIndex(const pandora::HitType hitType)
Get the index of an input hit type returning 0 if not found in map.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
const pandora::ClusterList & GetSelectedClusterList(const pandora::HitType hitType) const
Get the selected cluster list corresponding to a specified hit type.
void PerformMainLoop()
Main loop over cluster combinations in order to populate the overlap container. Responsible for calli...
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Header file for the two view matching control class.
Header file for the lar track two view overlap result class.
BEGIN_PROLOG could also be cout
Header file for the three dimension algorithm base class.