CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IntermediateHitTriplets.h
Go to the documentation of this file.
1 #ifndef RecoPixelVertexing_PixelTriplets_IntermediateHitTriplets_h
2 #define RecoPixelVertexing_PixelTriplets_IntermediateHitTriplets_h
3 
8 
23 public:
30 
32 
42  public:
44  layerTriplet_(layerTriplet),
45  tripletsBegin_(tripletsBegin), tripletsEnd_(tripletsBegin)
46  {}
47 
48  void setTripletsEnd(unsigned int end) { tripletsEnd_ = end; }
49 
50  const LayerTriplet& layerTriplet() const { return layerTriplet_; }
51 
52  unsigned int tripletsBegin() const { return tripletsBegin_; }
53  unsigned int tripletsEnd() const { return tripletsEnd_; }
54 
55  private:
57  unsigned int tripletsBegin_;
58  unsigned int tripletsEnd_;
59  };
60 
62 
68  public:
69  using const_iterator = std::vector<OrderedHitTriplet>::const_iterator;
70 
72  const PLayerHitTriplets *layerTriplet):
73  hitSets_(hitSets),
74  layerTriplet_(layerTriplet)
75  {}
76 
77  using TripletRange = std::pair<std::vector<OrderedHitTriplet>::const_iterator,
78  std::vector<OrderedHitTriplet>::const_iterator>;
79 
83 
85  const_iterator cbegin() const { return begin(); }
87  const_iterator cend() const { return end(); }
88 
89  private:
92  };
93 
95 
107  public:
108  using PLayerHitTripletsConstIterator = std::vector<PLayerHitTriplets>::const_iterator;
109  using TripletConstIterator = std::vector<OrderedHitTriplet>::const_iterator;
110 
112  public:
115  using difference_type = internal_iterator_type::difference_type;
116 
117  struct end_tag {};
118 
122  const_iterator(const IntermediateHitTriplets *hitSets, const RegionLayerSets *regionLayerSets):
123  hitSets_(hitSets),
124  regionLayerSets_(regionLayerSets),
125  iter_(regionLayerSets->layerSetsBegin())
126  {
127  assert(regionLayerSets->layerSetsBegin() != regionLayerSets->layerSetsEnd());
128  }
129 
135  const_iterator(const IntermediateHitTriplets *hitSets, const RegionLayerSets *regionLayerSets, end_tag):
136  iter_(regionLayerSets->layerSetsEnd())
137  {}
138 
140  return value_type(hitSets_, &(*iter_));
141  }
142 
144  ++iter_;
145  return *this;
146  }
147 
149  const_iterator clone(*this);
150  operator++();
151  return clone;
152  }
153 
154  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
155  bool operator!=(const const_iterator& other) const { return !operator==(other); }
156 
157  private:
161  };
162 
164  const LayerHitMapCache *cache,
165  const IntermediateHitTriplets *hitSets,
166  PLayerHitTripletsConstIterator tripletBegin,
167  PLayerHitTripletsConstIterator tripletEnd):
168  region_(region),
169  cache_(cache),
170  hitSets_(hitSets),
171  layerSetsBegin_(tripletBegin), layerSetsEnd_(tripletEnd)
172  {}
173 
174  const TrackingRegion& region() const { return *region_; }
175  const LayerHitMapCache& layerHitMapCache() const { return *cache_; }
177 
180  return const_iterator(hitSets_, this);
181  else
182  return end();
183  }
184  const_iterator cbegin() const { return begin(); }
185  const_iterator end() const { return const_iterator(hitSets_, this, const_iterator::end_tag()); }
186  const_iterator cend() const { return end(); }
187 
188  // used internally by the LayerHitTriplets helper class
191 
192  private:
193  const TrackingRegion *region_ = nullptr;
194  const LayerHitMapCache *cache_ = nullptr;
198  };
199 
201 
204 
206 
208  class RegionFiller {
209  public:
212 
213  ~RegionFiller() = default;
214 
215  bool valid() const { return obj_ != nullptr; }
216 
217  LayerHitMapCache& layerHitMapCache() { return obj_->regions_.back().layerHitMapCache(); }
218 
219  void addTriplets(const LayerPair& layerPair,
220  const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers,
221  const OrderedHitTriplets& triplets,
222  const std::vector<int>& thirdLayerIndex,
223  const std::vector<size_t>& permutations) {
224  assert(triplets.size() == thirdLayerIndex.size());
225  assert(triplets.size() == permutations.size());
226 
227  if(triplets.empty()) {
228  return;
229  }
230 
231  int prevLayer = -1;
232  for(size_t i=0, size=permutations.size(); i<size; ++i) {
233  // We go through the 'triplets' in the order defined by
234  // 'permutations', which is sorted such that we first go through
235  // triplets from (3rd) layer 0, then layer 1 and so on.
236  const size_t realIndex = permutations[i];
237 
238  const int layer = thirdLayerIndex[realIndex];
239  if(layer != prevLayer) {
240  prevLayer = layer;
241  obj_->layerTriplets_.emplace_back(LayerTriplet(std::get<0>(layerPair), std::get<1>(layerPair), thirdLayers[layer].index()), obj_->hitTriplets_.size());
242  }
243 
244  obj_->hitTriplets_.emplace_back(triplets[realIndex]);
245  obj_->layerTriplets_.back().setTripletsEnd(obj_->hitTriplets_.size());
246  }
247 
248  obj_->regions_.back().setLayerSetsEnd(obj_->layerTriplets_.size());
249  }
250  private:
252  };
253 
254  // allows declaring local variables with auto
255  static RegionFiller dummyFiller() { return RegionFiller(); }
256 
258 
260  explicit IntermediateHitTriplets(const SeedingLayerSetsHits *seedingLayers): seedingLayers_(seedingLayers) {}
261  IntermediateHitTriplets(const IntermediateHitTriplets& rh); // only to make ROOT dictionary generation happy
262  ~IntermediateHitTriplets() = default;
263 
269  }
270 
271  void reserve(size_t nregions, size_t nlayersets, size_t ntriplets) {
272  regions_.reserve(nregions);
273  layerTriplets_.reserve(nregions*nlayersets);
274  hitTriplets_.reserve(ntriplets);
275  }
276 
277  void shrink_to_fit() {
278  regions_.shrink_to_fit();
279  layerTriplets_.shrink_to_fit();
280  hitTriplets_.shrink_to_fit();
281  }
282 
284  regions_.emplace_back(region, layerTriplets_.size());
285  return RegionFiller(this);
286  }
287 
289  bool empty() const { return regions_.empty(); }
290  size_t regionSize() const { return regions_.size(); }
291  size_t tripletsSize() const { return hitTriplets_.size(); }
292 
293  const_iterator begin() const { return const_iterator(this, regions_.begin()); }
294  const_iterator cbegin() const { return begin(); }
295  const_iterator end() const { return const_iterator(this, regions_.end()); }
296  const_iterator cend() const { return end(); }
297 
298  // used internally by all the helper classes
299  std::vector<RegionIndex>::const_iterator regionsBegin() const { return regions_.begin(); }
300  std::vector<RegionIndex>::const_iterator regionsEnd() const { return regions_.end(); }
301  std::vector<PLayerHitTriplets>::const_iterator layerSetsBegin() const { return layerTriplets_.begin(); }
302  std::vector<PLayerHitTriplets>::const_iterator layerSetsEnd() const { return layerTriplets_.end(); }
303  std::vector<OrderedHitTriplet>::const_iterator tripletsBegin() const { return hitTriplets_.begin(); }
304  std::vector<OrderedHitTriplet>::const_iterator tripletsEnd() const { return hitTriplets_.end(); }
305 
306 private:
308 
309  std::vector<RegionIndex> regions_;
310  std::vector<PLayerHitTriplets> layerTriplets_;
311  std::vector<OrderedHitTriplet> hitTriplets_;
312 };
313 
314 #endif
static RegionFiller dummyFiller()
const_iterator begin() const
LayerHitTriplets(const IntermediateHitTriplets *hitSets, const PLayerHitTriplets *layerTriplet)
int i
Definition: DBlmapReader.cc:9
SeedingLayerSetsHits::LayerIndex outerLayerIndex() const
const_iterator(const IntermediateHitTriplets *hitSets, const RegionLayerSets *regionLayerSets, end_tag)
std::tuple< SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex > LayerTriplet
std::vector< PLayerHitTriplets >::const_iterator layerSetsEnd() const
std::vector< RegionIndex >::const_iterator regionsEnd() const
assert(m_qm.get())
const_iterator cbegin() const
IntermediateHitTriplets(const SeedingLayerSetsHits *seedingLayers)
std::vector< PLayerHitTriplets >::const_iterator layerSetsBegin() const
std::vector< OrderedHitTriplet >::const_iterator const_iterator
#define nullptr
void swap(IntermediateHitTriplets &rh)
std::vector< RegionIndex >::const_iterator regionsBegin() const
const_iterator end() const
std::vector< PLayerHitTriplets >::const_iterator PLayerHitTripletsConstIterator
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void addTriplets(const LayerPair &layerPair, const std::vector< SeedingLayerSetsHits::SeedingLayer > &thirdLayers, const OrderedHitTriplets &triplets, const std::vector< int > &thirdLayerIndex, const std::vector< size_t > &permutations)
RegionLayerSets(const TrackingRegion *region, const LayerHitMapCache *cache, const IntermediateHitTriplets *hitSets, PLayerHitTripletsConstIterator tripletBegin, PLayerHitTripletsConstIterator tripletEnd)
const SeedingLayerSetsHits & seedingLayerHits() const
std::tuple< SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex > LayerPair
std::vector< RegionIndex > regions_
Pointer to SeedingLayerSetsHits (owned elsewhere)
const_iterator cend() const
PLayerHitTripletsConstIterator layerSetsEnd() const
void reserve(size_t nregions, size_t nlayersets, size_t ntriplets)
const PLayerHitTripletsConstIterator layerSetsBegin_
std::vector< OrderedHitTriplet >::const_iterator TripletConstIterator
SeedingLayerSetsHits::LayerIndex middleLayerIndex() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
RegionFiller beginRegion(const TrackingRegion *region)
PLayerHitTripletsConstIterator layerSetsBegin() const
const SeedingLayerSetsHits * seedingLayers_
SeedingLayerSetsHits::LayerIndex innerLayerIndex() const
RegionFiller(IntermediateHitTriplets *obj)
const_iterator(const IntermediateHitTriplets *hitSets, const RegionLayerSets *regionLayerSets)
Helper class enforcing correct way of filling the doublets of a region.
std::pair< std::vector< OrderedHitTriplet >::const_iterator, std::vector< OrderedHitTriplet >::const_iterator > TripletRange
const PLayerHitTripletsConstIterator layerSetsEnd_
std::vector< PLayerHitTriplets > layerTriplets_
Container of regions, each element has indices pointing to layerTriplets_.
virtual unsigned int size() const
ihd::const_iterator< RegionLayerSets, IntermediateHitTriplets > const_iterator
Iterator over regions.
std::vector< OrderedHitTriplet > hitTriplets_
Container of layer triplets, each element has indices pointing to hitTriplets_.
PLayerHitTriplets(const LayerTriplet &layerTriplet, unsigned int tripletsBegin)
tuple size
Write out results.
const LayerHitMapCache & layerHitMapCache() const
std::vector< OrderedHitTriplet >::const_iterator tripletsBegin() const
~IntermediateHitTriplets()=default
std::vector< OrderedHitTriplet >::const_iterator tripletsEnd() const