Belle II Software  release-05-02-19
ClusterCache.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef PXD_CLUSTERCACHE_H
12 #define PXD_CLUSTERCACHE_H
13 
14 #include <deque>
15 #include <pxd/reconstruction/ClusterCandidate.h>
16 
17 namespace Belle2 {
22  namespace PXD {
23 
80  class ClusterCache {
81  public:
83  typedef std::deque<ClusterCandidate>::iterator iterator;
85  typedef std::deque<ClusterCandidate>::const_iterator const_iterator;
86 
87  enum {
90  };
92  explicit ClusterCache(unsigned int maxU = c_defaultNumberColumns);
93 
95  ClusterCache(const ClusterCache&) = delete;
96 
98  ClusterCache& operator=(const ClusterCache&) = delete;
99 
101  ~ClusterCache();
103  void clear();
104 
112  ClusterCandidate& findCluster(unsigned int u, unsigned int v);
113 
124  std::deque<ClusterCandidate>::iterator begin() { return m_clusters.begin(); }
126  std::deque<ClusterCandidate>::iterator end() { return m_currCluster; }
127 
129  bool empty() const { return m_clusters.begin() == m_currCluster; }
130 
131  private:
132 
135 
141  void switchRow(unsigned int v);
142 
144  const unsigned int m_maxU;
146  unsigned int m_curV;
152  std::deque<ClusterCandidate> m_clusters;
160  std::deque<ClusterCandidate>::iterator m_currCluster;
161  };
162 
163  }
164 
166 }
167 
168 #endif //PXD_CLUSTERCACHE_H
Belle2::PXD::ClusterCache::iterator
std::deque< ClusterCandidate >::iterator iterator
Define iterator type.
Definition: ClusterCache.h:91
Belle2::PXD::ClusterCache::clear
void clear()
Clear the cache structure.
Definition: ClusterCache.cc:43
Belle2::PXD::ClusterCandidate
Class representing a possible cluster during clustering of the PXD It supports merging of different c...
Definition: ClusterCandidate.h:41
Belle2::PXD::ClusterCache::switchRow
void switchRow(unsigned int v)
Switch the internal rows.
Definition: ClusterCache.cc:105
Belle2::PXD::ClusterCache::const_iterator
std::deque< ClusterCandidate >::const_iterator const_iterator
Define const iterator type.
Definition: ClusterCache.h:93
Belle2::PXD::ClusterCache::m_currCluster
std::deque< ClusterCandidate >::iterator m_currCluster
iterator to the next free cluster to be used if a new cluster is needed.
Definition: ClusterCache.h:168
Belle2::PXD::ClusterCache::end
std::deque< ClusterCandidate >::iterator end()
Return iterator to the end of created clusters.
Definition: ClusterCache.h:134
Belle2::PXD::ClusterCache::ClusterCache
ClusterCache(unsigned int maxU=c_defaultNumberColumns)
Create a new cache.
Definition: ClusterCache.cc:29
Belle2::PXD::ClusterCache::m_curV
unsigned int m_curV
current v coordinate, needed to switch top row
Definition: ClusterCache.h:154
Belle2::PXD::ClusterCache::m_clusters
std::deque< ClusterCandidate > m_clusters
list of all the clusters created so far
Definition: ClusterCache.h:160
Belle2::PXD::ClusterCache::~ClusterCache
~ClusterCache()
Delete the cache and free the memory.
Definition: ClusterCache.cc:36
Belle2::PXD::ClusterCache::begin
std::deque< ClusterCandidate >::iterator begin()
Return iterator to the begin of of created clusters.
Definition: ClusterCache.h:132
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PXD::ClusterCache::c_defaultNumberColumns
@ c_defaultNumberColumns
Default maximum number of PIXEL columns the cache can handle.
Definition: ClusterCache.h:97
Belle2::PXD::ClusterCache
Class to remember recently assigned clusters This class will remember the current and the last pixel ...
Definition: ClusterCache.h:88
Belle2::PXD::ClusterCache::empty
bool empty() const
Check if there are any clusters.
Definition: ClusterCache.h:137
Belle2::PXD::ClusterCache::mergeCluster
ClusterCandidate * mergeCluster(ClusterCandidate *cls1, ClusterCandidate *cls2)
Merge two cluster and update the list of cached clusters.
Definition: ClusterCache.cc:95
Belle2::PXD::ClusterCache::m_clsCur
ClusterCandidate ** m_clsCur
cache of the current row
Definition: ClusterCache.h:158
Belle2::PXD::ClusterCache::m_maxU
const unsigned int m_maxU
number of columns of the cache.
Definition: ClusterCache.h:152
Belle2::PXD::ClusterCache::m_clsTop
ClusterCandidate ** m_clsTop
cache of the top row
Definition: ClusterCache.h:156
Belle2::PXD::ClusterCache::findCluster
ClusterCandidate & findCluster(unsigned int u, unsigned int v)
Find a cluster adjacent to the given coordinates.
Definition: ClusterCache.cc:52
Belle2::PXD::ClusterCache::operator=
ClusterCache & operator=(const ClusterCache &)=delete
No operator=.