44 for (
typename TheTensor::const_iterator iterU = this->
begin(), iterUEnd = this->
end(); iterU != iterUEnd; ++iterU)
47 ClusterList clusterListU, clusterListV, clusterListW;
48 this->
GetConnectedElements(iterU->first, ignoreUnavailable, tempElementList, clusterListU, clusterListV, clusterListW);
50 const Cluster *pClusterU(
nullptr), *pClusterV(
nullptr), *pClusterW(
nullptr);
55 if (iterU->first != pClusterU)
58 if (!pClusterU || !pClusterV || !pClusterW)
62 if (iterU->second.end() == iterV)
65 typename OverlapList::const_iterator iterW = iterV->second.find(pClusterW);
66 if (iterV->second.end() == iterW)
69 Element element(pClusterU, pClusterV, pClusterW, iterW->second);
70 elementList.push_back(element);
73 std::sort(elementList.begin(), elementList.end());
82 if ((1 != clusterListU.size()) || (1 != clusterListV.size()) || (1 != clusterListW.size()))
85 pClusterU = *(clusterListU.begin());
86 pClusterV = *(clusterListV.begin());
87 pClusterW = *(clusterListW.begin());
96 unsigned int &nU,
unsigned int &nV,
unsigned int &nW)
const
98 ClusterList clusterListU, clusterListV, clusterListW;
99 this->
GetConnectedElements(pCluster, ignoreUnavailable, elementList, clusterListU, clusterListV, clusterListW);
100 nU = clusterListU.size();
101 nV = clusterListV.size();
102 nW = clusterListW.size();
110 for (
typename TheTensor::const_iterator iterU = this->
begin(), iterUEnd = this->
end(); iterU != iterUEnd; ++iterU)
111 sortedKeyClusters.push_back(iterU->first);
123 typename OverlapList::const_iterator iter = overlapList.find(pClusterW);
125 if (overlapList.end() != iter)
128 if (!overlapList.insert(
typename OverlapList::value_type(pClusterW, overlapResult)).second)
135 if (navigationUV.end() == std::find(navigationUV.begin(), navigationUV.end(), pClusterV))
136 navigationUV.push_back(pClusterV);
137 if (navigationVW.end() == std::find(navigationVW.begin(), navigationVW.end(), pClusterW))
138 navigationVW.push_back(pClusterW);
139 if (navigationWU.end() == std::find(navigationWU.begin(), navigationWU.end(), pClusterU))
140 navigationWU.push_back(pClusterU);
154 typename OverlapMatrix::iterator iterV = iterU->second.find(pClusterV);
156 if (iterU->second.end() == iterV)
159 typename OverlapList::iterator iterW = iterV->second.find(pClusterW);
161 if (iterV->second.end() == iterW)
164 iterW->second = overlapResult;
183 ClusterNavigationMap::iterator thisIter = navIter++;
184 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
186 if (thisIter->second.end() != listIter)
187 thisIter->second.erase(listIter);
189 if (thisIter->second.empty())
190 additionalRemovals.push_back(thisIter->first);
198 typename OverlapMatrix::iterator iter = iterU->second.find(pCluster);
200 if (iterU->second.end() != iter)
201 iterU->second.erase(iter);
206 ClusterNavigationMap::iterator thisIter = navIter++;
207 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
209 if (thisIter->second.end() != listIter)
210 thisIter->second.erase(listIter);
212 if (thisIter->second.empty())
213 additionalRemovals.push_back(thisIter->first);
221 for (
typename OverlapMatrix::iterator iterV = iterU->second.begin(), iterVEnd = iterU->second.end(); iterV != iterVEnd; ++iterV)
223 typename OverlapList::iterator iter = iterV->second.find(pCluster);
225 if (iterV->second.end() != iter)
226 iterV->second.erase(iter);
232 ClusterNavigationMap::iterator thisIter = navIter++;
233 ClusterList::iterator listIter = std::find(thisIter->second.begin(), thisIter->second.end(), pCluster);
235 if (thisIter->second.end() != listIter)
236 thisIter->second.erase(listIter);
238 if (thisIter->second.empty())
239 additionalRemovals.push_back(thisIter->first);
245 for (ClusterList::const_iterator iter = additionalRemovals.begin(), iterEnd = additionalRemovals.end(); iter != iterEnd; ++iter)
255 ClusterList localClusterListU, localClusterListV, localClusterListW;
256 this->
ExploreConnections(pCluster, ignoreUnavailable, localClusterListU, localClusterListV, localClusterListW);
260 clusterListU.clear();
261 clusterListV.clear();
262 clusterListW.clear();
264 for (
typename TheTensor::const_iterator iterU = this->
begin(), iterUEnd = this->
end(); iterU != iterUEnd; ++iterU)
266 if (localClusterListU.end() == std::find(localClusterListU.begin(), localClusterListU.end(), iterU->first))
271 for (
typename OverlapList::const_iterator iterW = iterV->second.begin(), iterWEnd = iterV->second.end(); iterW != iterWEnd; ++iterW)
273 if (ignoreUnavailable && (!iterU->first->IsAvailable() || !iterV->first->IsAvailable() || !iterW->first->IsAvailable()))
276 Element element(iterU->first, iterV->first, iterW->first, iterW->second);
277 elementList.push_back(element);
279 if (clusterListU.end() == std::find(clusterListU.begin(), clusterListU.end(), iterU->first))
280 clusterListU.push_back(iterU->first);
281 if (clusterListV.end() == std::find(clusterListV.begin(), clusterListV.end(), iterV->first))
282 clusterListV.push_back(iterV->first);
283 if (clusterListW.end() == std::find(clusterListW.begin(), clusterListW.end(), iterW->first))
284 clusterListW.push_back(iterW->first);
289 std::sort(elementList.begin(), elementList.end());
310 if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pCluster))
313 clusterList.push_back(pCluster);
314 ClusterNavigationMap::const_iterator iter = navigationMap.find(pCluster);
316 if (navigationMap.end() == iter)
319 for (ClusterList::const_iterator cIter = iter->second.begin(), cIterEnd = iter->second.end(); cIter != cIterEnd; ++cIter)
320 this->
ExploreConnections(*cIter, ignoreUnavailable, clusterListU, clusterListV, clusterListW);
Header file for the cluster class.
Header file for the cluster helper class.
Header file for the lar overlap tensor class.
Header file for the lar shower overlap result class.
Header file for the lar track overlap result class.
Header file defining relevant internal typedefs, sort and string conversion functions.
Header file defining status codes and relevant preprocessor macros.
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,...
TheMatrix::const_iterator const_iterator
const pandora::Cluster * GetCluster(const pandora::HitType hitType) const
Get the address of the given hit type cluster.
const pandora::Cluster * m_pClusterW
The address of the w cluster.
const pandora::Cluster * m_pClusterU
The address of the u cluster.
const pandora::Cluster * m_pClusterV
The address of the v cluster.
const_iterator end() const
Returns an iterator referring to the past-the-end element in the overlap tensor.
ClusterNavigationMap m_clusterNavigationMapWU
The cluster navigation map W->U.
void SetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Set overlap result.
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
void ReplaceOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
SetReplace an existing overlap result.
ClusterNavigationMap m_clusterNavigationMapUV
The cluster navigation map U->V.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterNavigationMap
TheTensor m_overlapTensor
The overlap tensor.
void GetUnambiguousElements(const bool ignoreUnavailable, ElementList &elementList) const
Get unambiguous elements.
void ExploreConnections(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Explore connections associated with a given cluster.
const_iterator begin() const
Returns an iterator referring to the first element in the overlap tensor.
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
std::unordered_map< const pandora::Cluster *, OverlapResult > OverlapList
bool DefaultAmbiguityFunction(const pandora::ClusterList &clusterListU, const pandora::ClusterList &clusterListV, const pandora::ClusterList &clusterListW, const pandora::Cluster *&pClusterU, const pandora::Cluster *&pClusterV, const pandora::Cluster *&pClusterW) const
Default ambiguity function, checking that only one U, V and W cluster is found.
std::vector< Element > ElementList
void RemoveCluster(const pandora::Cluster *const pCluster)
Remove entries from tensor corresponding to specified cluster.
ClusterNavigationMap m_clusterNavigationMapVW
The cluster navigation map V->W.
bool IsAvailable() const
Whether the cluster is available to be added to a particle flow object.
StatusCodeException class.
HitType
Calorimeter hit type enum.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList