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
SeedingLayerSetsLooper::LayerSetRange::const_iterator::operator==
bool operator==(const const_iterator &other) const
Definition: SeedingLayerSetsLooper.h:61
SeedingLayerSetsLooper::LayerSetRange::const_iterator::difference_type
typename internal_iterator_type::difference_type difference_type
Definition: SeedingLayerSetsLooper.h:43
mps_fire.i
i
Definition: mps_fire.py:428
SeedingLayerSetsLooper::LayerSet::value_type
typename T::value_type value_type
Definition: SeedingLayerSetsLooper.h:18
SeedingLayerSetsLooper::LayerSetRange
Definition: SeedingLayerSetsLooper.h:35
SeedingLayerSetsLooper::nlayers_
unsigned short nlayers_
Number of layers in a SeedingLayerSet.
Definition: SeedingLayerSetsLooper.h:98
SeedingLayerSetsLooper::LayerSet::difference_type
typename internal_iterator_type::difference_type difference_type
Definition: SeedingLayerSetsLooper.h:19
SeedingLayerSetsLooper::LayerSet::LayerSet
LayerSet(const T *container, internal_iterator_type begin, internal_iterator_type end)
Definition: SeedingLayerSetsLooper.h:21
SeedingLayerSetsLooper::makeRange
LayerSetRange< T > makeRange(const T &container) const
Definition: SeedingLayerSetsLooper.h:92
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
SeedingLayerSetsLooper::LayerSetRange::const_iterator::iter_
internal_iterator_type iter_
Definition: SeedingLayerSetsLooper.h:67
SeedingLayerSetsLooper::LayerSet
Definition: SeedingLayerSetsLooper.h:15
SeedingLayerSetsLooper::LayerSetRange::begin
const_iterator begin() const
Definition: SeedingLayerSetsLooper.h:70
SeedingLayerSetsLooper::LayerSetIndex
unsigned short LayerSetIndex
Definition: SeedingLayerSetsLooper.h:12
SeedingLayerSetsLooper::LayerSet::end_
internal_iterator_type end_
Definition: SeedingLayerSetsLooper.h:31
SeedingLayerSetsLooper::layerSetIndices_
const std::vector< LayerSetIndex > * layerSetIndices_
Definition: SeedingLayerSetsLooper.h:105
SeedingLayerSetsLooper::LayerSetRange::const_iterator::operator++
const_iterator operator++(int)
Definition: SeedingLayerSetsLooper.h:55
SeedingLayerSetsLooper::LayerSet::operator[]
const value_type & operator[](size_t i) const
Definition: SeedingLayerSetsLooper.h:26
SeedingLayerSetsLooper::LayerSetRange::end
const_iterator end() const
Definition: SeedingLayerSetsLooper.h:72
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
SeedingLayerSetsLooper::LayerSetRange::const_iterator::value_type
LayerSet< T > value_type
Definition: SeedingLayerSetsLooper.h:42
SeedingLayerSetsLooper::LayerSetRange::const_iterator::operator!=
bool operator!=(const const_iterator &other) const
Definition: SeedingLayerSetsLooper.h:62
mps_fire.end
end
Definition: mps_fire.py:242
trackingPlots.other
other
Definition: trackingPlots.py:1460
SeedingLayerSetsLooper::SeedingLayerSetsLooper
SeedingLayerSetsLooper(unsigned short nlayers, const std::vector< LayerSetIndex > *layerSetIndices)
Definition: SeedingLayerSetsLooper.h:88
SeedingLayerSetsLooper::LayerSetRange::container_
const T * container_
Definition: SeedingLayerSetsLooper.h:76
SeedingLayerSetsLooper::LayerSet::container_
const T * container_
Definition: SeedingLayerSetsLooper.h:29
SeedingLayerSetsLooper::LayerSetRange::LayerSetRange
LayerSetRange(const T *container, const SeedingLayerSetsLooper *info)
Definition: SeedingLayerSetsLooper.h:37
SeedingLayerSetsLooper::LayerSet::internal_iterator_type
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
Definition: SeedingLayerSetsLooper.h:17
SeedingLayerSetsLooper::LayerSet::size
LayerSetIndex size() const
Definition: SeedingLayerSetsLooper.h:24
SeedingLayerSetsLooper::LayerSetRange::const_iterator::const_iterator
const_iterator(const T *container, const SeedingLayerSetsLooper *info, internal_iterator_type iter)
Definition: SeedingLayerSetsLooper.h:46
SeedingLayerSetsLooper
Definition: SeedingLayerSetsLooper.h:10
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
SeedingLayerSetsLooper::LayerSet::begin_
internal_iterator_type begin_
Definition: SeedingLayerSetsLooper.h:30
SeedingLayerSetsLooper::LayerSetRange::const_iterator
Definition: SeedingLayerSetsLooper.h:39
SeedingLayerSetsLooper::LayerSetRange::cend
const_iterator cend() const
Definition: SeedingLayerSetsLooper.h:73
SeedingLayerSetsLooper::LayerSetRange::const_iterator::container_
const T * container_
Definition: SeedingLayerSetsLooper.h:65
T
long double T
Definition: Basic3DVectorLD.h:48
SeedingLayerSetsLooper::LayerSetRange::const_iterator::operator*
value_type operator*() const
Definition: SeedingLayerSetsLooper.h:49
SeedingLayerSetsLooper::LayerSetRange::const_iterator::operator++
const_iterator & operator++()
Definition: SeedingLayerSetsLooper.h:51
SeedingLayerSetsLooper::LayerSetRange::const_iterator::internal_iterator_type
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
Definition: SeedingLayerSetsLooper.h:41
SeedingLayerSetsLooper::LayerSetRange::cbegin
const_iterator cbegin() const
Definition: SeedingLayerSetsLooper.h:71
SeedingLayerSetsLooper::SeedingLayerSetsLooper
SeedingLayerSetsLooper()=default
SeedingLayerSetsLooper::LayerSetRange::info_
const SeedingLayerSetsLooper * info_
Definition: SeedingLayerSetsLooper.h:77
SeedingLayerSetsLooper::LayerSetRange::const_iterator::info_
const SeedingLayerSetsLooper * info_
Definition: SeedingLayerSetsLooper.h:66
nlayers
Definition: HIMultiTrackSelector.h:48