CMS 3D CMS Logo

RegionsSeedingHitSets.h
Go to the documentation of this file.
1 #ifndef RecoTracker_TkHitPairs_RegionsSeedingHitSets_H
2 #define RecoTracker_TkHitPairs_RegionsSeedingHitSets_H
3 
6 
13 public:
16 
19 
22 
24  class RegionFiller {
25  public:
26  RegionFiller() : obj_(nullptr) {}
28 
30  if (obj_)
31  obj_->regions_.back().setLayerSetsEnd(obj_->hitSets_.size());
32  }
33 
34  bool valid() const { return obj_ != nullptr; }
35 
36  template <typename... Args>
37  void emplace_back(Args&&... args) {
38  obj_->hitSets_.emplace_back(std::forward<Args>(args)...);
39  }
40 
41  private:
43  };
44 
45  // allows declaring local variables with auto
46  static RegionFiller dummyFiller() { return RegionFiller(); }
47 
48  // constructors
49  RegionsSeedingHitSets() = default;
54  ~RegionsSeedingHitSets() = default;
55 
56  void reserve(size_t nregions, size_t nhitsets) {
57  regions_.reserve(nregions);
58  hitSets_.reserve(nhitsets);
59  }
60 
61  void shrink_to_fit() {
62  regions_.shrink_to_fit();
63  hitSets_.shrink_to_fit();
64  }
65 
67  regions_.emplace_back(region, hitSets_.size());
68  return RegionFiller(this);
69  }
70 
71  bool empty() const { return regions_.empty(); }
72  size_t regionSize() const { return regions_.size(); }
73  size_t size() const { return hitSets_.size(); }
74 
75  const_iterator begin() const { return const_iterator(this, regions_.begin()); }
76  const_iterator cbegin() const { return begin(); }
77  const_iterator end() const { return const_iterator(this, regions_.end()); }
78  const_iterator cend() const { return end(); }
79 
80  // used internally by the helper classes
81  std::vector<SeedingHitSet>::const_iterator layerSetsBegin() const { return hitSets_.begin(); }
82  std::vector<SeedingHitSet>::const_iterator layerSetsEnd() const { return hitSets_.end(); }
83 
84 private:
85  std::vector<RegionIndex> regions_;
86  std::vector<SeedingHitSet> hitSets_;
87 };
88 
89 #endif
RegionFiller beginRegion(const TrackingRegion *region)
const_iterator begin() const
const_iterator end() const
RegionsSeedingHitSets()=default
static RegionFiller dummyFiller()
std::vector< SeedingHitSet > hitSets_
Container of regions, each element has indices pointing to hitSets_.
RegionFiller(RegionsSeedingHitSets *obj)
std::vector< RegionIndex > regions_
void reserve(size_t nregions, size_t nhitsets)
const_iterator cend() const
Helper class enforcing correct way of filling the doublets of a region.
std::vector< SeedingHitSet >::const_iterator layerSetsEnd() const
std::vector< SeedingHitSet >::const_iterator layerSetsBegin() const
const_iterator cbegin() const
~RegionsSeedingHitSets()=default
RegionsSeedingHitSets & operator=(const RegionsSeedingHitSets &)=delete
ihd::const_iterator< RegionSeedingHitSets, RegionsSeedingHitSets > const_iterator
Iterator over regions.