CMS 3D CMS Logo

SeedingLayerSetsLooper.h
Go to the documentation of this file.
1 #ifndef TrackingTools_TransientTrackingRecHit_SeedingLayerSetsLooper
2 #define TrackingTools_TransientTrackingRecHit_SeedingLayerSetsLooper
3 
4 #include <vector>
5 
10 public:
11  using LayerSetIndex = unsigned short;
12 
13  template <typename T>
14  class LayerSet {
15  public:
16  using internal_iterator_type = std::vector<LayerSetIndex>::const_iterator;
17  using value_type = typename T::value_type;
18  using difference_type = typename internal_iterator_type::difference_type;
19 
21  container_(container), begin_(begin), end_(end) {}
22 
23  LayerSetIndex size() const { return end_-begin_; }
24 
25  const value_type& operator[](size_t i) const { return (*container_)[*(begin_+i)]; }
26 
27  private:
28  const T *container_ = nullptr;
31  };
32 
33  template <typename T>
34  class LayerSetRange {
35  public:
36  LayerSetRange(const T *container, const SeedingLayerSetsLooper *info):
37  container_(container), info_(info)
38  {}
39 
41  public:
42  using internal_iterator_type = std::vector<LayerSetIndex>::const_iterator;
44  using difference_type = typename internal_iterator_type::difference_type;
45 
46  //const_iterator() = default;
48  container_(container), info_(info), iter_(iter) {}
49 
50  value_type operator*() const { return value_type(container_, iter_, iter_+info_->nlayers_); }
51 
52  const_iterator& operator++() { std::advance(iter_, info_->nlayers_); return *this; }
54  const_iterator clone(*this);
55  ++(*this);
56  return clone;
57  }
58 
59  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
60  bool operator!=(const const_iterator& other) const { return !operator==(other); }
61 
62  private:
63  const T *container_ = nullptr;
64  const SeedingLayerSetsLooper *info_ = nullptr;
66  };
67 
68  const_iterator begin() const { return const_iterator(container_, info_, info_->layerSetIndices_->begin()); }
69  const_iterator cbegin() const { return begin(); }
70  const_iterator end() const { return const_iterator(container_, info_, info_->layerSetIndices_->end()); }
71  const_iterator cend() const { return end(); }
72 
73  private:
74  const T *container_ = nullptr;
76  };
77 
78 
79 
80  SeedingLayerSetsLooper() = default;
81 
89  const std::vector<LayerSetIndex> *layerSetIndices):
90  nlayers_(nlayers),
91  layerSetIndices_(layerSetIndices)
92  {}
93 
94  template <typename T>
95  LayerSetRange<T> makeRange(const T& container) const {
96  return LayerSetRange<T>(&container, this);
97  }
98 
99 private:
101  unsigned short nlayers_ = 0;
102 
108  const std::vector<LayerSetIndex> *layerSetIndices_ = nullptr;
109 };
110 
111 #endif
typename internal_iterator_type::difference_type difference_type
static const TGPicture * info(bool iBackgroundIsBlack)
const std::vector< LayerSetIndex > * layerSetIndices_
bool operator!=(const const_iterator &other) const
SeedingLayerSetsLooper(unsigned short nlayers, const std::vector< LayerSetIndex > *layerSetIndices)
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
SeedingLayerSetsLooper()=default
LayerSet(const T *container, internal_iterator_type begin, internal_iterator_type end)
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
#define end
Definition: vmac.h:39
const_iterator(const T *container, const SeedingLayerSetsLooper *info, internal_iterator_type iter)
typename internal_iterator_type::difference_type difference_type
LayerSetRange(const T *container, const SeedingLayerSetsLooper *info)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
bool operator==(const const_iterator &other) const
#define begin
Definition: vmac.h:32
unsigned short nlayers_
Number of layers in a SeedingLayerSet.
LayerSetRange< T > makeRange(const T &container) const
const SeedingLayerSetsLooper * info_
long double T
const value_type & operator[](size_t i) const