9 #include "Pandora/PandoraInputTypes.h" 11 #include "Pandora/PandoraInputTypes.h" 12 #include "Pandora/PandoraInternal.h" 13 #include "Pandora/StatusCodes.h" 15 #include "Objects/Cluster.h" 35 ClusterList clusterList1, clusterList2;
36 this->GetConnectedElements(iter1->first, ignoreUnavailable, tempElementList, clusterList1, clusterList2);
38 const Cluster *pCluster1(
nullptr), *pCluster2(
nullptr);
39 if (!this->DefaultAmbiguityFunction(clusterList1, clusterList2, pCluster1, pCluster2))
43 if (iter1->first != pCluster1)
46 if (!pCluster1 || !pCluster2)
50 if (iter1->second.end() == iter2)
51 throw StatusCodeException(STATUS_CODE_FAILURE);
53 Element element(pCluster1, pCluster2, iter2->second);
54 elementList.push_back(element);
57 std::sort(elementList.begin(), elementList.end());
64 const ClusterList &clusterList1,
const ClusterList &clusterList2,
const Cluster *&pCluster1,
const Cluster *&pCluster2)
const 66 if ((1 != clusterList1.size()) || (1 != clusterList2.size()))
69 pCluster1 = *(clusterList1.begin());
70 pCluster2 = *(clusterList2.begin());
79 const pandora::Cluster *
const pCluster,
const bool ignoreUnavailable,
ElementList &elementList,
unsigned int &n1,
unsigned int &n2)
const 81 ClusterList clusterList1, clusterList2;
82 this->GetConnectedElements(pCluster, ignoreUnavailable, elementList, clusterList1, clusterList2);
83 n1 = clusterList1.size();
84 n2 = clusterList2.size();
93 sortedKeyClusters.push_back(iter1->first);
95 std::sort(sortedKeyClusters.begin(), sortedKeyClusters.end(), LArClusterHelper::SortByNHits);
100 template <
typename T>
103 OverlapList &overlapList = m_overlapMatrix[pCluster1];
106 if (overlapList.end() != iter)
107 throw pandora::StatusCodeException(pandora::STATUS_CODE_ALREADY_PRESENT);
109 if (!overlapList.insert(
typename OverlapList::value_type(pCluster2, overlapResult)).second)
110 throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
112 ClusterList &navigation12(m_clusterNavigationMap12[pCluster1]);
113 ClusterList &navigation21(m_clusterNavigationMap21[pCluster2]);
115 if (navigation12.end() == std::find(navigation12.begin(), navigation12.end(), pCluster2))
116 navigation12.push_back(pCluster2);
117 if (navigation21.end() == std::find(navigation21.begin(), navigation21.end(), pCluster1))
118 navigation21.push_back(pCluster1);
123 template <
typename T>
128 if (m_overlapMatrix.end() == iter1)
129 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
133 if (iter1->second.end() == iter2)
134 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
136 iter2->second = overlapResult;
141 template <
typename T>
144 ClusterList additionalRemovals;
146 if (m_clusterNavigationMap12.erase(pCluster) > 0)
150 if (m_overlapMatrix.end() != iter)
151 m_overlapMatrix.erase(iter);
156 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
158 if (thisIter->second.end() != listIter)
159 thisIter->second.erase(listIter);
161 if (thisIter->second.empty())
162 additionalRemovals.push_back(thisIter->first);
166 if (m_clusterNavigationMap21.erase(pCluster) > 0)
168 for (
typename TheMatrix::iterator iter1 = m_overlapMatrix.begin(), iter1End = m_overlapMatrix.end(); iter1 != iter1End; ++iter1)
172 if (iter1->second.end() != iter)
173 iter1->second.erase(iter);
179 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
181 if (thisIter->second.end() != listIter)
182 thisIter->second.erase(listIter);
184 if (thisIter->second.empty())
185 additionalRemovals.push_back(thisIter->first);
189 additionalRemovals.sort(LArClusterHelper::SortByNHits);
192 this->RemoveCluster(*iter);
197 template <
typename T>
199 ClusterList &clusterList1, ClusterList &clusterList2)
const 201 ClusterList localClusterList1, localClusterList2;
202 this->ExploreConnections(pCluster, ignoreUnavailable, localClusterList1, localClusterList2);
206 clusterList1.clear();
207 clusterList2.clear();
211 if (localClusterList1.end() == std::find(localClusterList1.begin(), localClusterList1.end(), iter1->first))
214 for (
typename OverlapList::const_iterator iter2 = iter1->second.begin(), iter2End = iter1->second.end(); iter2 != iter2End; ++iter2)
216 if (ignoreUnavailable && (!iter1->first->IsAvailable() || !iter2->first->IsAvailable()))
219 Element element(iter1->first, iter2->first, iter2->second);
220 elementList.push_back(element);
222 if (clusterList1.end() == std::find(clusterList1.begin(), clusterList1.end(), iter1->first))
223 clusterList1.push_back(iter1->first);
224 if (clusterList2.end() == std::find(clusterList2.begin(), clusterList2.end(), iter2->first))
225 clusterList2.push_back(iter2->first);
229 std::sort(elementList.begin(), elementList.end());
234 template <
typename T>
236 const Cluster *
const pCluster,
const bool ignoreUnavailable, ClusterList &clusterList1, ClusterList &clusterList2)
const 238 if (ignoreUnavailable && !pCluster->IsAvailable())
241 const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
242 const bool clusterFromView1(
243 !m_clusterNavigationMap12.empty() && (LArClusterHelper::GetClusterHitType(m_clusterNavigationMap12.begin()->first) == hitType));
244 const bool clusterFromView2(
245 !m_clusterNavigationMap21.empty() && (LArClusterHelper::GetClusterHitType(m_clusterNavigationMap21.begin()->first) == hitType));
247 if (clusterFromView1 == clusterFromView2)
248 throw StatusCodeException(STATUS_CODE_FAILURE);
250 ClusterList &clusterList(clusterFromView1 ? clusterList1 : clusterList2);
251 const ClusterNavigationMap &navigationMap(clusterFromView1 ? m_clusterNavigationMap12 : m_clusterNavigationMap21);
253 if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pCluster))
256 clusterList.push_back(pCluster);
259 if (navigationMap.end() == iter)
260 throw StatusCodeException(STATUS_CODE_FAILURE);
263 this->ExploreConnections(*cIter, ignoreUnavailable, clusterList1, clusterList2);
std::vector< Element > ElementList
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Header file for the lar overlap matrix class.
Header file for the cluster helper class.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterNavigationMap
std::unordered_map< const pandora::Cluster *, OverlapResult > OverlapList
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Header file for the lar track two view overlap result class.