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):
38  container_(container), info_(info)
39  {}
40 
42  public:
43  using internal_iterator_type = std::vector<LayerSetIndex>::const_iterator;
45  using difference_type = typename internal_iterator_type::difference_type;
46 
47  //const_iterator() = default;
49  container_(container), info_(info), iter_(iter) {}
50 
51  value_type operator*() const { return value_type(container_, iter_, iter_+info_->nlayers_); }
52 
53  const_iterator& operator++() { std::advance(iter_, info_->nlayers_); return *this; }
55  const_iterator clone(*this);
56  ++(*this);
57  return clone;
58  }
59 
60  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
61  bool operator!=(const const_iterator& other) const { return !operator==(other); }
62 
63  private:
64  const T *container_ = nullptr;
65  const SeedingLayerSetsLooper *info_ = nullptr;
67  };
68 
69  const_iterator begin() const { return const_iterator(container_, info_, info_->layerSetIndices_->begin()); }
70  const_iterator cbegin() const { return begin(); }
71  const_iterator end() const { return const_iterator(container_, info_, info_->layerSetIndices_->end()); }
72  const_iterator cend() const { return end(); }
73 
74  private:
75  const T *container_ = nullptr;
77  };
78 
79 
80 
81  SeedingLayerSetsLooper() = default;
82 
90  const std::vector<LayerSetIndex> *layerSetIndices):
91  nlayers_(nlayers),
92  layerSetIndices_(layerSetIndices)
93  {}
94 
95  template <typename T>
96  LayerSetRange<T> makeRange(const T& container) const {
97  return LayerSetRange<T>(&container, this);
98  }
99 
100 private:
102  unsigned short nlayers_ = 0;
103 
109  const std::vector<LayerSetIndex> *layerSetIndices_ = nullptr;
110 };
111 
112 #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