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:
28 
30  if(obj_) obj_->regions_.back().setLayerSetsEnd(obj_->hitSets_.size());
31  }
32 
33  bool valid() const { return obj_ != nullptr; }
34 
35  template <typename... Args>
36  void emplace_back(Args&&... args) {
37  obj_->hitSets_.emplace_back(std::forward<Args>(args)...);
38  }
39  private:
41  };
42 
43  // allows declaring local variables with auto
44  static RegionFiller dummyFiller() { return RegionFiller(); }
45 
46  // constructors
47  RegionsSeedingHitSets() = default;
52  ~RegionsSeedingHitSets() = default;
53 
54  void reserve(size_t nregions, size_t nhitsets) {
55  regions_.reserve(nregions);
56  hitSets_.reserve(nhitsets);
57  }
58 
59  void shrink_to_fit() {
60  regions_.shrink_to_fit();
61  hitSets_.shrink_to_fit();
62  }
63 
65  regions_.emplace_back(region, hitSets_.size());
66  return RegionFiller(this);
67  }
68 
69  bool empty() const { return regions_.empty(); }
70  size_t regionSize() const { return regions_.size(); }
71  size_t size() const { return hitSets_.size(); }
72 
73  const_iterator begin() const { return const_iterator(this, regions_.begin()); }
74  const_iterator cbegin() const { return begin(); }
75  const_iterator end() const { return const_iterator(this, regions_.end()); }
76  const_iterator cend() const { return end(); }
77 
78  // used internally by the helper classes
79  std::vector<SeedingHitSet>::const_iterator layerSetsBegin() const { return hitSets_.begin(); }
80  std::vector<SeedingHitSet>::const_iterator layerSetsEnd() const { return hitSets_.end(); }
81 
82 private:
83  std::vector<RegionIndex> regions_;
84  std::vector<SeedingHitSet> hitSets_;
85 };
86 
87 #endif
std::vector< SeedingHitSet >::const_iterator layerSetsEnd() const
RegionFiller beginRegion(const TrackingRegion *region)
#define nullptr
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)
Helper class enforcing correct way of filling the doublets of a region.
std::vector< SeedingHitSet >::const_iterator layerSetsBegin() const
const_iterator begin() const
const_iterator cbegin() const
~RegionsSeedingHitSets()=default
RegionsSeedingHitSets & operator=(const RegionsSeedingHitSets &)=delete
const_iterator cend() const
const_iterator end() const
ihd::const_iterator< RegionSeedingHitSets, RegionsSeedingHitSets > const_iterator
Iterator over regions.