8 #ifndef LAR_OVERLAP_TENSOR_H
9 #define LAR_OVERLAP_TENSOR_H 1
11 #include "Pandora/PandoraInternal.h"
13 #include <unordered_map>
42 Element(
const pandora::Cluster *
const pClusterU,
const pandora::Cluster *
const pClusterV,
const pandora::Cluster *
const pClusterW,
52 const pandora::Cluster *
GetCluster(
const pandora::HitType hitType)
const;
119 const pandora::ClusterList &clusterListW,
const pandora::Cluster *&pClusterU,
const pandora::Cluster *&pClusterV,
120 const pandora::Cluster *&pClusterW)
const;
131 void GetNConnections(
const pandora::Cluster *
const pCluster,
const bool ignoreUnavailable,
unsigned int &nU,
unsigned int &nV,
unsigned int &nW)
const;
153 unsigned int &nU,
unsigned int &nV,
unsigned int &nW)
const;
156 typedef std::unordered_map<const pandora::Cluster *, OverlapResult>
OverlapList;
157 typedef std::unordered_map<const pandora::Cluster *, OverlapList>
OverlapMatrix;
158 typedef std::unordered_map<const pandora::Cluster *, OverlapMatrix>
TheTensor;
189 const pandora::Cluster *
const pClusterU,
const pandora::Cluster *
const pClusterV,
const pandora::Cluster *
const pClusterW)
const;
199 const OverlapList &
GetOverlapList(
const pandora::Cluster *
const pClusterU,
const pandora::Cluster *
const pClusterV)
const;
239 void SetOverlapResult(
const pandora::Cluster *
const pClusterU,
const pandora::Cluster *
const pClusterV,
240 const pandora::Cluster *
const pClusterW,
const OverlapResult &overlapResult);
250 void ReplaceOverlapResult(
const pandora::Cluster *
const pClusterU,
const pandora::Cluster *
const pClusterV,
251 const pandora::Cluster *
const pClusterW,
const OverlapResult &overlapResult);
276 pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW)
const;
286 void ExploreConnections(
const pandora::Cluster *
const pCluster,
const bool ignoreUnavailable, pandora::ClusterList &clusterListU,
287 pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW)
const;
297 template <
typename T>
299 const pandora::Cluster *
const pCluster,
const bool ignoreUnavailable,
unsigned int &nU,
unsigned int &nV,
unsigned int &nW)
const
302 this->GetConnectedElements(pCluster, ignoreUnavailable, elementList, nU, nV, nW);
307 template <
typename T>
310 unsigned int nU(0), nV(0), nW(0);
311 this->GetConnectedElements(pCluster, ignoreUnavailable, elementList, nU, nV, nW);
316 template <
typename T>
319 return m_overlapTensor.begin();
324 template <
typename T>
327 return m_overlapTensor.end();
332 template <
typename T>
334 const pandora::Cluster *
const pClusterU,
const pandora::Cluster *
const pClusterV,
const pandora::Cluster *
const pClusterW)
const
336 const OverlapList &overlapList(this->GetOverlapList(pClusterU, pClusterV));
337 typename OverlapList::const_iterator iter = overlapList.find(pClusterW);
339 if (overlapList.end() == iter)
340 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
347 template <
typename T>
349 const pandora::Cluster *
const pClusterU,
const pandora::Cluster *
const pClusterV)
const
351 const OverlapMatrix &overlapMatrix(this->GetOverlapMatrix(pClusterU));
354 if (overlapMatrix.end() == iter)
355 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
362 template <
typename T>
365 typename TheTensor::const_iterator iter = m_overlapTensor.find(pClusterU);
367 if (m_overlapTensor.end() == iter)
368 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
375 template <
typename T>
378 return m_clusterNavigationMapUV;
383 template <
typename T>
386 return m_clusterNavigationMapVW;
391 template <
typename T>
394 return m_clusterNavigationMapWU;
399 template <
typename T>
402 m_overlapTensor.clear();
403 m_clusterNavigationMapUV.clear();
404 m_clusterNavigationMapVW.clear();
405 m_clusterNavigationMapWU.clear();
411 template <
typename T>
413 const pandora::Cluster *
const pClusterW,
const OverlapResult &overlapResult) :
414 m_pClusterU(pClusterU),
415 m_pClusterV(pClusterV),
416 m_pClusterW(pClusterW),
417 m_overlapResult(overlapResult)
423 template <
typename T>
431 template <
typename T>
439 template <
typename T>
447 template <
typename T>
450 return m_overlapResult;
455 template <
typename T>
466 #endif // #ifndef LAR_OVERLAP_TENSOR_H
LongitudinalOverlapResult class.
OverlapResult m_overlapResult
The overlap result.
ClusterNavigationMap m_clusterNavigationMapVW
The cluster navigation map V->W.
const ClusterNavigationMap & GetClusterNavigationMapVW() const
Get the cluster navigation map V->W.
ClusterNavigationMap m_clusterNavigationMapUV
The cluster navigation map U->V.
const pandora::Cluster * GetClusterW() const
Get the address of the w cluster.
const_iterator begin() const
Returns an iterator referring to the first element in the overlap tensor.
void GetNConnections(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, unsigned int &nU, unsigned int &nV, unsigned int &nW) const
Get the number of connections for a specified cluster.
const pandora::Cluster * m_pClusterW
The address of the w cluster.
std::unordered_map< const pandora::Cluster *, OverlapMatrix > TheTensor
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
const ClusterNavigationMap & GetClusterNavigationMapUV() const
Get the cluster navigation map U->V.
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.
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.
const pandora::Cluster * GetClusterU() const
Get the address of the u cluster.
TheTensor m_overlapTensor
The overlap tensor.
const OverlapList & GetOverlapList(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV) const
Get the overlap list for a specified pair of clusters.
const_iterator end() const
Returns an iterator referring to the past-the-end element in the overlap tensor.
void SetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Set overlap result.
void Clear()
Clear overlap tensor.
std::vector< Element > ElementList
void GetUnambiguousElements(const bool ignoreUnavailable, ElementList &elementList) const
Get unambiguous elements.
const OverlapMatrix & GetOverlapMatrix(const pandora::Cluster *const pClusterU) const
Get the cluster overlap matrix for a specified cluster.
TheMatrix::const_iterator const_iterator
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
Element(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Constructor.
const pandora::Cluster * GetCluster(const pandora::HitType hitType) const
Get the address of the given hit type cluster.
const pandora::Cluster * m_pClusterU
The address of the u cluster.
ClusterNavigationMap m_clusterNavigationMapWU
The cluster navigation map W->U.
const OverlapResult & GetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW) const
Get the overlap result for a specified trio of clusters.
std::unordered_map< const pandora::Cluster *, OverlapResult > OverlapList
bool operator<(const Element &rhs) const
Element less than operator.
const OverlapResult & GetOverlapResult() const
Get the overlap result.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterNavigationMap
const pandora::Cluster * m_pClusterV
The address of the v cluster.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
const pandora::Cluster * GetClusterV() const
Get the address of the v cluster.
void RemoveCluster(const pandora::Cluster *const pCluster)
Remove entries from tensor corresponding to specified cluster.
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::unordered_map< const pandora::Cluster *, OverlapList > OverlapMatrix
const ClusterNavigationMap & GetClusterNavigationMapWU() const
Get the cluster navigation map W->U.
TheTensor::const_iterator const_iterator