CMS 3D CMS Logo

SeedingLayerSetsHits.h
Go to the documentation of this file.
1 #ifndef TrackingTools_TransientTrackingRecHit_SeedingLayerSetsHits
2 #define TrackingTools_TransientTrackingRecHit_SeedingLayerSetsHits
3 
6 
7 #include <vector>
8 #include <string>
9 #include <utility>
10 
11 class DetLayer;
12 
19 public:
21  using TkHitRef = BaseTrackerRecHit const &;
23  using OwnedHits = std::vector<HitPointer>;
24 
26  using Hits = std::vector<ConstRecHitPointer>;
27 
28  typedef unsigned short LayerSetIndex;
29  typedef unsigned short LayerIndex;
30  typedef unsigned int HitIndex;
31 
37  class SeedingLayer {
38  public:
41 
48  LayerIndex index() const { return index_; }
49  const std::string &name() const { return (*seedingLayerSets_->layerNames_)[index_]; }
50  const DetLayer *detLayer() const { return (*seedingLayerSets_->layerDets_)[index_]; }
51  Hits hits() const { return seedingLayerSets_->hits(index_); }
52 
53  private:
56  };
57 
66  public:
68  public:
69  typedef std::vector<LayerSetIndex>::const_iterator internal_iterator_type;
71  typedef internal_iterator_type::difference_type difference_type;
72 
75  : seedingLayerSets_(sls), iter_(iter) {}
76 
78 
80  ++iter_;
81  return *this;
82  }
84  const_iterator clone(*this);
85  ++clone;
86  return clone;
87  }
88 
89  bool operator==(const const_iterator &other) const { return iter_ == other.iter_; }
90  bool operator!=(const const_iterator &other) const { return !operator==(other); }
91 
92  private:
95  };
96 
99  std::vector<LayerSetIndex>::const_iterator begin,
100  std::vector<LayerSetIndex>::const_iterator end)
101  : seedingLayerSets_(sls), begin_(begin), end_(end) {}
102 
104  LayerSetIndex size() const { return end_ - begin_; }
105 
118  SeedingLayerSet slice(size_t begin, size_t end) const {
119  assert(begin < size());
120  assert(0 < end && end <= size());
121  assert(begin < end);
123  }
124 
127 
128  // iterators for range-for
130  const_iterator cbegin() const { return begin(); }
132  const_iterator cend() const { return end(); }
133 
134  private:
136  std::vector<LayerSetIndex>::const_iterator begin_; // Iterator to SeedingLayerSetsHits::layerSetIndices_, first layer
137  std::vector<LayerSetIndex>::const_iterator end_; // Iterator to SeedingLayerSetsHits::layerSetIndices_, last+1 layer
138  };
139 
141  public:
142  typedef std::vector<LayerSetIndex>::const_iterator internal_iterator_type;
144  typedef internal_iterator_type::difference_type difference_type;
145 
148  : seedingLayerSets_(sls), iter_(iter) {}
149 
152  }
153 
155  std::advance(iter_, seedingLayerSets_->nlayers_);
156  return *this;
157  }
159  const_iterator clone(*this);
160  ++(*this);
161  return clone;
162  }
163 
164  bool operator==(const const_iterator &other) const { return iter_ == other.iter_; }
165  bool operator!=(const const_iterator &other) const { return !operator==(other); }
166 
167  private:
170  };
171 
172  SeedingLayerSetsHits() = default;
173 
182  SeedingLayerSetsHits(unsigned short nlayers,
183  const std::vector<LayerSetIndex> *layerSetIndices,
184  const std::vector<std::string> *layerNames,
185  const std::vector<const DetLayer *> *layerDets);
186 
187  ~SeedingLayerSetsHits() = default;
188  SeedingLayerSetsHits(SeedingLayerSetsHits const &) = delete;
192 
193  void shrink_to_fit();
194  void addHits(LayerIndex layerIndex, OwnedHits &&hits);
195 
197  unsigned short numberOfLayersInSet() const { return nlayers_; }
199  unsigned short size() const { return nlayers_ > 0 ? layerSetIndices_->size() / nlayers_ : 0; }
200 
203  std::vector<LayerSetIndex>::const_iterator begin = layerSetIndices_->begin() + nlayers_ * index;
204  std::vector<LayerSetIndex>::const_iterator end = begin + nlayers_;
205  return SeedingLayerSet(this, begin, end);
206  }
207 
208  // iterators for range-for
209  const_iterator begin() const { return const_iterator(this, layerSetIndices_->begin()); }
210  const_iterator cbegin() const { return begin(); }
211  const_iterator end() const { return const_iterator(this, layerSetIndices_->end()); }
212  const_iterator cend() const { return end(); }
213 
214  // for more efficient edm::Event::put()
216  std::swap(nlayers_, other.nlayers_);
217  std::swap(layerSetIndices_, other.layerSetIndices_);
218  layerHitIndices_.swap(other.layerHitIndices_);
219  std::swap(layerNames_, other.layerNames_);
220  std::swap(layerDets_, other.layerDets_);
221  rechits_.swap(other.rechits_);
222  }
223 
224  void print() const;
225 
226 private:
227  Hits hits(LayerIndex layerIndex) const;
228 
230  unsigned short nlayers_ = 0;
231 
237  const std::vector<LayerSetIndex> *layerSetIndices_ = nullptr;
238 
239  // following are indexed by LayerIndex
240  std::vector<HitIndex> layerHitIndices_; // Indices to first hits in rechits_
241  const std::vector<std::string> *layerNames_ = nullptr; // Names of the layers
242  const std::vector<const DetLayer *> *layerDets_ = nullptr; // Pointers to corresponding DetLayer objects
243 
249 };
250 
251 #endif
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::internal_iterator_type
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
Definition: SeedingLayerSetsHits.h:69
SeedingLayerSetsHits::SeedingLayer::SeedingLayer
SeedingLayer(const SeedingLayerSetsHits *sls, LayerIndex index)
Definition: SeedingLayerSetsHits.h:40
SeedingLayerSetsHits::const_iterator::operator==
bool operator==(const const_iterator &other) const
Definition: SeedingLayerSetsHits.h:164
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::const_iterator
const_iterator(const SeedingLayerSetsHits *sls, internal_iterator_type iter)
Definition: SeedingLayerSetsHits.h:74
SeedingLayerSetsHits::SeedingLayer::index
LayerIndex index() const
Definition: SeedingLayerSetsHits.h:48
SeedingLayerSetsHits::layerHitIndices_
std::vector< HitIndex > layerHitIndices_
Definition: SeedingLayerSetsHits.h:240
SeedingLayerSetsHits::const_iterator::value_type
SeedingLayerSet value_type
Definition: SeedingLayerSetsHits.h:143
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::operator*
value_type operator*() const
Definition: SeedingLayerSetsHits.h:77
SeedingLayerSetsHits::SeedingLayerSetsHits
SeedingLayerSetsHits()=default
DetLayer
Definition: DetLayer.h:21
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::seedingLayerSets_
const SeedingLayerSetsHits * seedingLayerSets_
Definition: SeedingLayerSetsHits.h:93
SeedingLayerSetsHits::const_iterator::const_iterator
const_iterator()
Definition: SeedingLayerSetsHits.h:146
SeedingLayerSetsHits::size
unsigned short size() const
Get the number of SeedingLayerSets.
Definition: SeedingLayerSetsHits.h:199
SeedingLayerSetsHits::const_iterator::difference_type
internal_iterator_type::difference_type difference_type
Definition: SeedingLayerSetsHits.h:144
SeedingLayerSetsHits::SeedingLayerSet::size
LayerSetIndex size() const
Number of layers in this set.
Definition: SeedingLayerSetsHits.h:104
SeedingLayerSetsHits::SeedingLayer::detLayer
const DetLayer * detLayer() const
Definition: SeedingLayerSetsHits.h:50
SeedingLayerSetsHits
Definition: SeedingLayerSetsHits.h:18
SeedingLayerSetsHits::SeedingLayerSet::begin
const_iterator begin() const
Definition: SeedingLayerSetsHits.h:129
SeedingLayerSetsHits::TkHitRef
BaseTrackerRecHit const & TkHitRef
Definition: SeedingLayerSetsHits.h:21
cms::cuda::assert
assert(be >=bs)
mayown_ptr
Definition: mayown_ptr.h:13
SeedingLayerSetsHits::SeedingLayerSet::slice
SeedingLayerSet slice(size_t begin, size_t end) const
Definition: SeedingLayerSetsHits.h:118
SeedingLayerSetsHits::const_iterator::internal_iterator_type
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
Definition: SeedingLayerSetsHits.h:142
SeedingLayerSetsHits::SeedingLayerSet::end
const_iterator end() const
Definition: SeedingLayerSetsHits.h:131
SeedingLayerSetsHits::cend
const_iterator cend() const
Definition: SeedingLayerSetsHits.h:212
SeedingLayerSetsHits::SeedingLayer::index_
LayerIndex index_
Definition: SeedingLayerSetsHits.h:55
SeedingLayerSetsHits::~SeedingLayerSetsHits
~SeedingLayerSetsHits()=default
SeedingLayerSetsHits::LayerSetIndex
unsigned short LayerSetIndex
Definition: SeedingLayerSetsHits.h:28
SeedingLayerSetsHits::const_iterator::operator!=
bool operator!=(const const_iterator &other) const
Definition: SeedingLayerSetsHits.h:165
SeedingLayerSetsHits::cbegin
const_iterator cbegin() const
Definition: SeedingLayerSetsHits.h:210
SeedingLayerSetsHits::SeedingLayerSet::const_iterator
Definition: SeedingLayerSetsHits.h:67
SeedingLayerSetsHits::const_iterator::const_iterator
const_iterator(const SeedingLayerSetsHits *sls, internal_iterator_type iter)
Definition: SeedingLayerSetsHits.h:147
SeedingLayerSetsHits::print
void print() const
Definition: SeedingLayerSetsHits.cc:43
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
SeedingLayerSetsHits::SeedingLayerSet::begin_
std::vector< LayerSetIndex >::const_iterator begin_
Definition: SeedingLayerSetsHits.h:136
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
BaseTrackerRecHit
Definition: BaseTrackerRecHit.h:15
SeedingLayerSetsHits::shrink_to_fit
void shrink_to_fit()
Definition: SeedingLayerSetsHits.cc:17
SeedingLayerSetsHits::SeedingLayerSet::cbegin
const_iterator cbegin() const
Definition: SeedingLayerSetsHits.h:130
trackingPlots.other
other
Definition: trackingPlots.py:1460
SeedingLayerSetsHits::ConstRecHitPointer
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingLayerSetsHits.h:25
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::operator++
const_iterator operator++(int)
Definition: SeedingLayerSetsHits.h:83
SeedingLayerSetsHits::SeedingLayerSet::seedingLayerSets_
const SeedingLayerSetsHits * seedingLayerSets_
Definition: SeedingLayerSetsHits.h:135
SeedingLayerSetsHits::numberOfLayersInSet
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
Definition: SeedingLayerSetsHits.h:197
SeedingLayerSetsHits::const_iterator
Definition: SeedingLayerSetsHits.h:140
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SeedingLayerSetsHits::rechits_
OwnedHits rechits_
Definition: SeedingLayerSetsHits.h:248
SeedingLayerSetsHits::const_iterator::iter_
internal_iterator_type iter_
Definition: SeedingLayerSetsHits.h:169
SeedingLayerSetsHits::layerSetIndices_
const std::vector< LayerSetIndex > * layerSetIndices_
Definition: SeedingLayerSetsHits.h:237
SeedingLayerSetsHits::SeedingLayer::name
const std::string & name() const
Definition: SeedingLayerSetsHits.h:49
SeedingLayerSetsHits::LayerIndex
unsigned short LayerIndex
Definition: SeedingLayerSetsHits.h:29
SeedingLayerSetsHits::SeedingLayer::SeedingLayer
SeedingLayer()
Definition: SeedingLayerSetsHits.h:39
SeedingLayerSetsHits::const_iterator::operator++
const_iterator operator++(int)
Definition: SeedingLayerSetsHits.h:158
SeedingLayerSetsHits::SeedingLayerSet::cend
const_iterator cend() const
Definition: SeedingLayerSetsHits.h:132
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::value_type
SeedingLayer value_type
Definition: SeedingLayerSetsHits.h:70
SeedingLayerSetsHits::SeedingLayerSet::end_
std::vector< LayerSetIndex >::const_iterator end_
Definition: SeedingLayerSetsHits.h:137
SeedingLayerSetsHits::operator=
SeedingLayerSetsHits & operator=(SeedingLayerSetsHits const &)=delete
SeedingLayerSetsHits::layerDets_
const std::vector< const DetLayer * > * layerDets_
Definition: SeedingLayerSetsHits.h:242
SeedingLayerSetsHits::const_iterator::seedingLayerSets_
const SeedingLayerSetsHits * seedingLayerSets_
Definition: SeedingLayerSetsHits.h:168
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::difference_type
internal_iterator_type::difference_type difference_type
Definition: SeedingLayerSetsHits.h:71
SeedingLayerSetsHits::SeedingLayer
Definition: SeedingLayerSetsHits.h:37
SeedingLayerSetsHits::SeedingLayer::hits
Hits hits() const
Definition: SeedingLayerSetsHits.h:51
BaseTrackerRecHit.h
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::operator++
const_iterator & operator++()
Definition: SeedingLayerSetsHits.h:79
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::const_iterator
const_iterator()
Definition: SeedingLayerSetsHits.h:73
SeedingLayerSetsHits::OwnedHits
std::vector< HitPointer > OwnedHits
Definition: SeedingLayerSetsHits.h:23
SeedingLayerSetsHits::const_iterator::operator++
const_iterator & operator++()
Definition: SeedingLayerSetsHits.h:154
mayown_ptr.h
SeedingLayerSetsHits::layerNames_
const std::vector< std::string > * layerNames_
Definition: SeedingLayerSetsHits.h:241
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::operator==
bool operator==(const const_iterator &other) const
Definition: SeedingLayerSetsHits.h:89
SeedingLayerSetsHits::SeedingLayerSet::SeedingLayerSet
SeedingLayerSet()
Definition: SeedingLayerSetsHits.h:97
SeedingLayerSetsHits::Hits
std::vector< ConstRecHitPointer > Hits
Definition: SeedingLayerSetsHits.h:26
SeedingLayerSetsHits::end
const_iterator end() const
Definition: SeedingLayerSetsHits.h:211
SeedingLayerSetsHits::hits
Hits hits(LayerIndex layerIndex) const
Definition: SeedingLayerSetsHits.cc:30
SeedingLayerSetsHits::SeedingLayerSet::SeedingLayerSet
SeedingLayerSet(const SeedingLayerSetsHits *sls, std::vector< LayerSetIndex >::const_iterator begin, std::vector< LayerSetIndex >::const_iterator end)
Definition: SeedingLayerSetsHits.h:98
SeedingLayerSetsHits::SeedingLayerSet
Definition: SeedingLayerSetsHits.h:65
SeedingLayerSetsHits::HitIndex
unsigned int HitIndex
Definition: SeedingLayerSetsHits.h:30
SeedingLayerSetsHits::SeedingLayerSet::operator[]
SeedingLayer operator[](LayerSetIndex index) const
Get a given SeedingLayer (index is between 0 and size()-1)
Definition: SeedingLayerSetsHits.h:126
SeedingLayerSetsHits::SeedingLayer::seedingLayerSets_
const SeedingLayerSetsHits * seedingLayerSets_
Definition: SeedingLayerSetsHits.h:54
SeedingLayerSetsHits::const_iterator::operator*
value_type operator*() const
Definition: SeedingLayerSetsHits.h:150
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::iter_
internal_iterator_type iter_
Definition: SeedingLayerSetsHits.h:94
SeedingLayerSetsHits::operator[]
SeedingLayerSet operator[](LayerSetIndex index) const
Get the SeedingLayerSet at a given index.
Definition: SeedingLayerSetsHits.h:202
SeedingLayerSetsHits::SeedingLayerSet::const_iterator::operator!=
bool operator!=(const const_iterator &other) const
Definition: SeedingLayerSetsHits.h:90
SeedingLayerSetsHits::addHits
void addHits(LayerIndex layerIndex, OwnedHits &&hits)
Definition: SeedingLayerSetsHits.cc:19
nlayers
Definition: HIMultiTrackSelector.h:48
SeedingLayerSetsHits::swap
void swap(SeedingLayerSetsHits &other)
Definition: SeedingLayerSetsHits.h:215
SeedingLayerSetsHits::begin
const_iterator begin() const
Definition: SeedingLayerSetsHits.h:209
SeedingLayerSetsHits::nlayers_
unsigned short nlayers_
Number of layers in a SeedingLayerSet.
Definition: SeedingLayerSetsHits.h:230