CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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;
48  ~RegionsSeedingHitSets() = default;
49 
51  regions_.swap(rh.regions_);
52  hitSets_.swap(rh.hitSets_);
53  }
54 
55  void reserve(size_t nregions, size_t nhitsets) {
56  regions_.reserve(nregions);
57  hitSets_.reserve(nhitsets);
58  }
59 
60  void shrink_to_fit() {
61  regions_.shrink_to_fit();
62  hitSets_.shrink_to_fit();
63  }
64 
66  regions_.emplace_back(region, hitSets_.size());
67  return RegionFiller(this);
68  }
69 
70  bool empty() const { return regions_.empty(); }
71  size_t regionSize() const { return regions_.size(); }
72  size_t size() const { return hitSets_.size(); }
73 
74  const_iterator begin() const { return const_iterator(this, regions_.begin()); }
75  const_iterator cbegin() const { return begin(); }
76  const_iterator end() const { return const_iterator(this, regions_.end()); }
77  const_iterator cend() const { return end(); }
78 
79  // used internally by the helper classes
80  std::vector<SeedingHitSet>::const_iterator layerSetsBegin() const { return hitSets_.begin(); }
81  std::vector<SeedingHitSet>::const_iterator layerSetsEnd() const { return hitSets_.end(); }
82 
83 private:
84  std::vector<RegionIndex> regions_;
85  std::vector<SeedingHitSet> hitSets_;
86 };
87 
88 #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
void swap(RegionsSeedingHitSets &rh)
const_iterator cend() const
const_iterator end() const
ihd::const_iterator< RegionSeedingHitSets, RegionsSeedingHitSets > const_iterator
Iterator over regions.