9 #include "Pandora/PandoraInputTypes.h" 11 #include "Pandora/PandoraInternal.h" 12 #include "Pandora/PandoraInputTypes.h" 13 #include "Pandora/StatusCodes.h" 15 #include "Objects/Cluster.h" 36 ClusterList clusterListU, clusterListV, clusterListW;
37 this->GetConnectedElements(iterU->first, ignoreUnavailable, tempElementList, clusterListU, clusterListV, clusterListW);
39 const Cluster *pClusterU(NULL), *pClusterV(NULL), *pClusterW(NULL);
40 if (!this->DefaultAmbiguityFunction(clusterListU, clusterListV, clusterListW, pClusterU, pClusterV, pClusterW))
44 if (iterU->first != pClusterU)
47 if ((NULL == pClusterU) || (NULL == pClusterV) || (NULL == pClusterW))
51 if (iterU->second.end() == iterV)
52 throw StatusCodeException(STATUS_CODE_FAILURE);
55 if (iterV->second.end() == iterW)
56 throw StatusCodeException(STATUS_CODE_FAILURE);
58 Element element(pClusterU, pClusterV, pClusterW, iterW->second);
59 elementList.push_back(element);
62 std::sort(elementList.begin(), elementList.end());
69 const Cluster *&pClusterU,
const Cluster *&pClusterV,
const Cluster *&pClusterW)
const 71 if ((1 != clusterListU.size()) || (1 != clusterListV.size()) || (1 != clusterListW.size()))
74 pClusterU = *(clusterListU.begin());
75 pClusterV = *(clusterListV.begin());
76 pClusterW = *(clusterListW.begin());
85 unsigned int &nU,
unsigned int &nV,
unsigned int &nW)
const 87 ClusterList clusterListU, clusterListV, clusterListW;
88 this->GetConnectedElements(pCluster, ignoreUnavailable, elementList, clusterListU, clusterListV, clusterListW);
89 nU = clusterListU.size(); nV = clusterListV.size(); nW = clusterListW.size();
98 sortedKeyClusters.push_back(iterU->first);
100 std::sort(sortedKeyClusters.begin(), sortedKeyClusters.end(), LArClusterHelper::SortByNHits);
105 template <
typename T>
107 const pandora::Cluster *
const pClusterW,
const OverlapResult &overlapResult)
109 OverlapList &overlapList = m_overlapTensor[pClusterU][pClusterV];
112 if (overlapList.end() != iter)
113 throw pandora::StatusCodeException(pandora::STATUS_CODE_ALREADY_PRESENT);
115 if (!overlapList.insert(
typename OverlapList::value_type(pClusterW, overlapResult)).second)
116 throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
118 ClusterList &navigationUV(m_clusterNavigationMapUV[pClusterU]);
119 ClusterList &navigationVW(m_clusterNavigationMapVW[pClusterV]);
120 ClusterList &navigationWU(m_clusterNavigationMapWU[pClusterW]);
122 if (navigationUV.end() == std::find(navigationUV.begin(), navigationUV.end(), pClusterV)) navigationUV.push_back(pClusterV);
123 if (navigationVW.end() == std::find(navigationVW.begin(), navigationVW.end(), pClusterW)) navigationVW.push_back(pClusterW);
124 if (navigationWU.end() == std::find(navigationWU.begin(), navigationWU.end(), pClusterU)) navigationWU.push_back(pClusterU);
129 template <
typename T>
131 const pandora::Cluster *
const pClusterW,
const OverlapResult &overlapResult)
135 if (m_overlapTensor.end() == iterU)
136 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
140 if (iterU->second.end() == iterV)
141 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
145 if (iterV->second.end() == iterW)
146 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
148 iterW->second = overlapResult;
153 template <
typename T>
156 ClusterList additionalRemovals;
158 if (m_clusterNavigationMapUV.erase(pCluster) > 0)
162 if (m_overlapTensor.end() != iter)
163 m_overlapTensor.erase(iter);
168 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
170 if (thisIter->second.end() != listIter)
171 thisIter->second.erase(listIter);
173 if (thisIter->second.empty())
174 additionalRemovals.push_back(thisIter->first);
178 if (m_clusterNavigationMapVW.erase(pCluster) > 0)
180 for (
typename TheTensor::iterator iterU = m_overlapTensor.begin(), iterUEnd = m_overlapTensor.end(); iterU != iterUEnd; ++iterU)
184 if (iterU->second.end() != iter)
185 iterU->second.erase(iter);
191 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
193 if (thisIter->second.end() != listIter)
194 thisIter->second.erase(listIter);
196 if (thisIter->second.empty())
197 additionalRemovals.push_back(thisIter->first);
201 if (m_clusterNavigationMapWU.erase(pCluster) > 0)
203 for (
typename TheTensor::iterator iterU = m_overlapTensor.begin(), iterUEnd = m_overlapTensor.end(); iterU != iterUEnd; ++iterU)
205 for (
typename OverlapMatrix::iterator iterV = iterU->second.begin(), iterVEnd = iterU->second.end(); iterV != iterVEnd; ++iterV)
209 if (iterV->second.end() != iter)
210 iterV->second.erase(iter);
217 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
219 if (thisIter->second.end() != listIter)
220 thisIter->second.erase(listIter);
222 if (thisIter->second.empty())
223 additionalRemovals.push_back(thisIter->first);
227 additionalRemovals.sort(LArClusterHelper::SortByNHits);
230 this->RemoveCluster(*iter);
235 template <
typename T>
237 ClusterList &clusterListU, ClusterList &clusterListV, ClusterList &clusterListW)
const 239 ClusterList localClusterListU, localClusterListV, localClusterListW;
240 this->ExploreConnections(pCluster, ignoreUnavailable, localClusterListU, localClusterListV, localClusterListW);
243 elementList.clear(); clusterListU.clear(); clusterListV.clear(); clusterListW.clear();
247 if (localClusterListU.end() == std::find(localClusterListU.begin(), localClusterListU.end(), iterU->first))
252 for (
typename OverlapList::const_iterator iterW = iterV->second.begin(), iterWEnd = iterV->second.end(); iterW != iterWEnd; ++iterW)
254 if (ignoreUnavailable && (!iterU->first->IsAvailable() || !iterV->first->IsAvailable() || !iterW->first->IsAvailable()))
257 Element element(iterU->first, iterV->first, iterW->first, iterW->second);
258 elementList.push_back(element);
260 if (clusterListU.end() == std::find(clusterListU.begin(), clusterListU.end(), iterU->first)) clusterListU.push_back(iterU->first);
261 if (clusterListV.end() == std::find(clusterListV.begin(), clusterListV.end(), iterV->first)) clusterListV.push_back(iterV->first);
262 if (clusterListW.end() == std::find(clusterListW.begin(), clusterListW.end(), iterW->first)) clusterListW.push_back(iterW->first);
267 std::sort(elementList.begin(), elementList.end());
272 template <
typename T>
274 ClusterList &clusterListV, ClusterList &clusterListW)
const 276 if (ignoreUnavailable && !pCluster->IsAvailable())
279 const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
281 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
282 throw StatusCodeException(STATUS_CODE_FAILURE);
284 ClusterList &clusterList((TPC_VIEW_U == hitType) ? clusterListU : (TPC_VIEW_V == hitType) ? clusterListV : clusterListW);
285 const ClusterNavigationMap &navigationMap((TPC_VIEW_U == hitType) ? m_clusterNavigationMapUV : (TPC_VIEW_V == hitType) ? m_clusterNavigationMapVW : m_clusterNavigationMapWU);
287 if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pCluster))
290 clusterList.push_back(pCluster);
293 if (navigationMap.end() == iter)
294 throw StatusCodeException(STATUS_CODE_FAILURE);
297 this->ExploreConnections(*cIter, ignoreUnavailable, clusterListU, clusterListV, clusterListW);
Header file for the lar overlap tensor class.
std::unordered_map< const pandora::Cluster *, OverlapResult > OverlapList
std::vector< Element > ElementList
Header file for the cluster helper class.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
Header file for the lar shower overlap result class.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Header file for the lar track overlap result class.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterNavigationMap
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)