CMS 3D CMS Logo

IntermediateHitDoublets.h
Go to the documentation of this file.
1 #ifndef RecoTracker_TkHitPairs_IntermediateHitDoublets_h
2 #define RecoTracker_TkHitPairs_IntermediateHitDoublets_h
3 
6 
7 namespace ihd {
16  class RegionIndex {
17  public:
18  RegionIndex(const TrackingRegion *reg, unsigned int ind):
19  region_(reg),
22  {}
23 
24  void setLayerSetsEnd(unsigned int end) { layerSetEndIndex_ = end; }
25 
26  const TrackingRegion& region() const { return *region_; }
27 
29  const LayerHitMapCache& layerHitMapCache() const { return cache_; }
30 
31  unsigned int layerSetBeginIndex() const { return layerSetBeginIndex_; }
32  unsigned int layerSetEndIndex() const { return layerSetEndIndex_; }
33 
34  private:
37  unsigned int layerSetBeginIndex_;
38  unsigned int layerSetEndIndex_;
39  };
40 
48  template <typename T>
50  public:
51  using const_iterator = typename std::vector<T>::const_iterator;
52 
53  // Taking T* to have compatible interface with IntermediateHitTriplets::RegionLayerSets
54  template <typename TMP>
56  region_(region), cache_(cache), layerSetsBegin_(begin), layerSetsEnd_(end) {}
57 
58  const TrackingRegion& region() const { return *region_; }
59  const LayerHitMapCache& layerHitMapCache() const { return *cache_; }
60 
61  const_iterator begin() const { return layerSetsBegin_; }
62  const_iterator cbegin() const { return begin(); }
63  const_iterator end() const { return layerSetsEnd_; }
64  const_iterator cend() const { return end(); }
65 
66  private:
71  };
72 
81  template<typename ValueType, typename HitSetType>
83  public:
84  using internal_iterator_type = typename std::vector<RegionIndex>::const_iterator;
86  using difference_type = internal_iterator_type::difference_type;
87 
88  const_iterator(const HitSetType *hst, internal_iterator_type iter): hitSets_(hst), iter_(iter) {}
89 
91  return value_type(&(iter_->region()),
92  &(iter_->layerHitMapCache()),
93  hitSets_,
94  hitSets_->layerSetsBegin() + iter_->layerSetBeginIndex(),
95  hitSets_->layerSetsBegin() + iter_->layerSetEndIndex());
96  }
97 
98  const_iterator& operator++() { ++iter_; return *this; }
100  const_iterator clone(*this);
101  ++iter_;
102  return clone;
103  }
104 
105  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
106  bool operator!=(const const_iterator& other) const { return !operator==(other); }
107 
108  private:
109  const HitSetType *hitSets_;
111  };
112 }
113 
126 public:
127  using LayerPair = std::tuple<SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex>;
129 
140  public:
142  layerPair_(layerSet[0].index(), layerSet[1].index()),
143  doublets_(std::move(doublets))
144  {}
145 
146  const LayerPair& layerPair() const { return layerPair_; }
147  SeedingLayerSetsHits::LayerIndex innerLayerIndex() const { return std::get<0>(layerPair_); }
148  SeedingLayerSetsHits::LayerIndex outerLayerIndex() const { return std::get<1>(layerPair_); }
149 
150  const HitDoublets& doublets() const { return doublets_; }
151 
152  private:
155  };
156 
158 
161 
163 
166 
168 
170  class RegionFiller {
171  public:
172  RegionFiller(): obj_(nullptr) {}
173  explicit RegionFiller(IntermediateHitDoublets *obj): obj_(obj) {}
174 
175  ~RegionFiller() = default;
176 
177  bool valid() const { return obj_ != nullptr; }
178 
179  LayerHitMapCache& layerHitMapCache() { return obj_->regions_.back().layerHitMapCache(); }
180 
182  obj_->layerPairs_.emplace_back(layerSet, std::move(doublets));
183  obj_->regions_.back().setLayerSetsEnd(obj_->layerPairs_.size());
184  }
185  private:
187  };
188 
189  // allows declaring local variables with auto
190  static RegionFiller dummyFiller() { return RegionFiller(); }
191 
193 
194  IntermediateHitDoublets(): seedingLayers_(nullptr) {}
195  explicit IntermediateHitDoublets(const SeedingLayerSetsHits *seedingLayers): seedingLayers_(seedingLayers) {}
196  IntermediateHitDoublets(const IntermediateHitDoublets& rh); // only to make ROOT dictionary generation happy
197  ~IntermediateHitDoublets() = default;
198 
200  std::swap(seedingLayers_, rh.seedingLayers_);
201  std::swap(regions_, rh.regions_);
202  std::swap(layerPairs_, rh.layerPairs_);
203  }
204 
205  void reserve(size_t nregions, size_t nlayersets) {
206  regions_.reserve(nregions);
207  layerPairs_.reserve(nregions*nlayersets);
208  }
209 
210  void shrink_to_fit() {
211  regions_.shrink_to_fit();
212  layerPairs_.shrink_to_fit();
213  }
214 
216  regions_.emplace_back(region, layerPairs_.size());
217  return RegionFiller(this);
218  }
219 
220  const SeedingLayerSetsHits& seedingLayerHits() const { return *seedingLayers_; }
221  bool empty() const { return regions_.empty(); }
222  size_t regionSize() const { return regions_.size(); }
223  size_t layerPairsSize() const { return layerPairs_.size(); }
224 
225  const_iterator begin() const { return const_iterator(this, regions_.begin()); }
226  const_iterator cbegin() const { return begin(); }
227  const_iterator end() const { return const_iterator(this, regions_.end()); }
228  const_iterator cend() const { return end(); }
229 
230  // used internally by all the helper classes
231  std::vector<RegionIndex>::const_iterator regionsBegin() const { return regions_.begin(); }
232  std::vector<RegionIndex>::const_iterator regionsEnd() const { return regions_.end(); }
233  std::vector<LayerPairHitDoublets>::const_iterator layerSetsBegin() const { return layerPairs_.begin(); }
234  std::vector<LayerPairHitDoublets>::const_iterator layerSetsEnd() const { return layerPairs_.end(); }
235 
236 private:
238 
239  std::vector<RegionIndex> regions_;
240  std::vector<LayerPairHitDoublets> layerPairs_;
241 };
242 
243 #endif
std::vector< RegionIndex >::const_iterator regionsEnd() const
const_iterator & operator++()
RegionLayerSets(const TrackingRegion *region, const LayerHitMapCache *cache, const TMP *, const_iterator begin, const_iterator end)
RegionFiller(IntermediateHitDoublets *obj)
static RegionFiller dummyFiller()
void swap(IntermediateHitDoublets &rh)
LayerHitMapCache & layerHitMapCache()
std::tuple< SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex > LayerPair
const_iterator begin() const
unsigned int layerSetEndIndex_
index of the beginning of layer sets of this region
internal_iterator_type iter_
const_iterator operator++(int)
const LayerHitMapCache * cache_
typename std::vector< T >::const_iterator const_iterator
const_iterator end() const
const const_iterator layerSetsEnd_
const_iterator cbegin() const
const_iterator begin() const
internal_iterator_type::difference_type difference_type
Helper class enforcing correct way of filling the doublets of a region.
RegionFiller beginRegion(const TrackingRegion *region)
#define nullptr
IntermediateHitDoublets(const SeedingLayerSetsHits *seedingLayers)
unsigned int layerSetBeginIndex() const
LayerPairHitDoublets(const SeedingLayerSetsHits::SeedingLayerSet &layerSet, HitDoublets &&doublets)
const TrackingRegion & region() const
std::vector< LayerPairHitDoublets >::const_iterator layerSetsBegin() const
const_iterator cbegin() const
SeedingLayerSetsHits::LayerIndex innerLayerIndex() const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
const HitSetType * hitSets_
const TrackingRegion * region_
bool operator==(const const_iterator &other) const
ValueType
Type of the value held by a Value object.
Definition: value.h:23
#define end
Definition: vmac.h:37
unsigned int layerSetEndIndex() const
const_iterator cend() const
def cache(function)
const TrackingRegion & region() const
RegionIndex(const TrackingRegion *reg, unsigned int ind)
const LayerHitMapCache & layerHitMapCache() const
value_type operator*() const
std::vector< RegionIndex >::const_iterator regionsBegin() const
const LayerHitMapCache & layerHitMapCache() const
const_iterator(const HitSetType *hst, internal_iterator_type iter)
void addDoublets(const SeedingLayerSetsHits::SeedingLayerSet &layerSet, HitDoublets &&doublets)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
LayerHitMapCache cache_
pointer to TrackingRegion (owned elsewhere)
unsigned int layerSetBeginIndex_
#define begin
Definition: vmac.h:30
SeedingLayerSetsHits::LayerIndex outerLayerIndex() const
void reserve(size_t nregions, size_t nlayersets)
const_iterator cend() const
std::vector< RegionIndex > regions_
Pointer to SeedingLayerSetsHits (owned elsewhere)
std::vector< LayerPairHitDoublets >::const_iterator layerSetsEnd() const
typename std::vector< RegionIndex >::const_iterator internal_iterator_type
std::vector< LayerPairHitDoublets > layerPairs_
Container of regions, each element has indices pointing to layerPairs_.
bool operator!=(const const_iterator &other) const
void setLayerSetsEnd(unsigned int end)
HitDoublets doublets_
pair of indices to the layer
const SeedingLayerSetsHits * seedingLayers_
const_iterator end() const
const TrackingRegion * region_
const const_iterator layerSetsBegin_
def move(src, dest)
Definition: eostools.py:510
const SeedingLayerSetsHits & seedingLayerHits() const