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 #include <cstddef>
6 
11 public:
12  using LayerSetIndex = unsigned short;
13 
14  template <typename T>
15  class LayerSet {
16  public:
17  using internal_iterator_type = std::vector<LayerSetIndex>::const_iterator;
18  using value_type = typename T::value_type;
19  using difference_type = typename internal_iterator_type::difference_type;
20 
22  : container_(container), begin_(begin), end_(end) {}
23 
24  LayerSetIndex size() const { return end_ - begin_; }
25 
26  const value_type &operator[](size_t i) const { return (*container_)[*(begin_ + i)]; }
27 
28  private:
29  const T *container_ = nullptr;
32  };
33 
34  template <typename T>
35  class LayerSetRange {
36  public:
37  LayerSetRange(const T *container, const SeedingLayerSetsLooper *info) : container_(container), info_(info) {}
38 
40  public:
41  using internal_iterator_type = std::vector<LayerSetIndex>::const_iterator;
43  using difference_type = typename internal_iterator_type::difference_type;
44 
45  //const_iterator() = default;
47  : container_(container), info_(info), iter_(iter) {}
48 
50 
52  std::advance(iter_, info_->nlayers_);
53  return *this;
54  }
56  const_iterator clone(*this);
57  ++(*this);
58  return clone;
59  }
60 
61  bool operator==(const const_iterator &other) const { return iter_ == other.iter_; }
62  bool operator!=(const const_iterator &other) const { return !operator==(other); }
63 
64  private:
65  const T *container_ = nullptr;
66  const SeedingLayerSetsLooper *info_ = nullptr;
68  };
69 
71  const_iterator cbegin() const { return begin(); }
73  const_iterator cend() const { return end(); }
74 
75  private:
76  const T *container_ = nullptr;
78  };
79 
80  SeedingLayerSetsLooper() = default;
81 
88  SeedingLayerSetsLooper(unsigned short nlayers, const std::vector<LayerSetIndex> *layerSetIndices)
89  : nlayers_(nlayers), layerSetIndices_(layerSetIndices) {}
90 
91  template <typename T>
92  LayerSetRange<T> makeRange(const T &container) const {
93  return LayerSetRange<T>(&container, this);
94  }
95 
96 private:
98  unsigned short nlayers_ = 0;
99 
105  const std::vector<LayerSetIndex> *layerSetIndices_ = nullptr;
106 };
107 
108 #endif
typename internal_iterator_type::difference_type difference_type
static const TGPicture * info(bool iBackgroundIsBlack)
const std::vector< LayerSetIndex > * layerSetIndices_
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 const_iterator &other) const
LayerSetRange< T > makeRange(const T &container) const
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
unsigned short nlayers_
Number of layers in a SeedingLayerSet.
const SeedingLayerSetsLooper * info_
bool operator==(const const_iterator &other) const
long double T
const value_type & operator[](size_t i) const