CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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), layerSetBeginIndex_(ind), layerSetEndIndex_(ind) {}
20  RegionIndex(RegionIndex&&) = default;
21  RegionIndex& operator=(RegionIndex&&) = default;
22 
23  void setLayerSetsEnd(unsigned int end) { layerSetEndIndex_ = end; }
24 
25  const TrackingRegion& region() const { return *region_; }
26 
28  const LayerHitMapCache& layerHitMapCache() const { return cache_; }
29 
30  unsigned int layerSetBeginIndex() const { return layerSetBeginIndex_; }
31  unsigned int layerSetEndIndex() const { return layerSetEndIndex_; }
32 
33  private:
36  unsigned int layerSetBeginIndex_;
37  unsigned int layerSetEndIndex_;
38  };
39 
47  template <typename T>
49  public:
50  using const_iterator = typename std::vector<T>::const_iterator;
51 
52  // Taking T* to have compatible interface with IntermediateHitTriplets::RegionLayerSets
53  template <typename TMP>
55  const LayerHitMapCache* cache,
56  const TMP*,
59  : region_(region), cache_(cache), layerSetsBegin_(begin), layerSetsEnd_(end) {}
60 
61  const TrackingRegion& region() const { return *region_; }
62  const LayerHitMapCache& layerHitMapCache() const { return *cache_; }
63 
64  const_iterator begin() const { return layerSetsBegin_; }
65  const_iterator cbegin() const { return begin(); }
66  const_iterator end() const { return layerSetsEnd_; }
67  const_iterator cend() const { return end(); }
68 
69  private:
74  };
75 
84  template <typename ValueType, typename HitSetType>
86  public:
87  using internal_iterator_type = typename std::vector<RegionIndex>::const_iterator;
89  using difference_type = internal_iterator_type::difference_type;
90 
91  const_iterator(const HitSetType* hst, internal_iterator_type iter) : hitSets_(hst), iter_(iter) {}
92 
94  return value_type(&(iter_->region()),
95  &(iter_->layerHitMapCache()),
96  hitSets_,
97  hitSets_->layerSetsBegin() + iter_->layerSetBeginIndex(),
98  hitSets_->layerSetsBegin() + iter_->layerSetEndIndex());
99  }
100 
102  ++iter_;
103  return *this;
104  }
106  const_iterator clone(*this);
107  ++iter_;
108  return clone;
109  }
110 
111  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
112  bool operator!=(const const_iterator& other) const { return !operator==(other); }
113 
114  private:
115  const HitSetType* hitSets_;
117  };
118 } // namespace ihd
119 
132 public:
133  using LayerPair = std::tuple<SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex>;
135 
146  public:
148  : layerPair_(layerSet[0].index(), layerSet[1].index()), doublets_(std::move(doublets)) {}
149 
150  const LayerPair& layerPair() const { return layerPair_; }
153 
154  const HitDoublets& doublets() const { return doublets_; }
155 
156  private:
159  };
160 
162 
165 
167 
170 
172 
174  class RegionFiller {
175  public:
176  RegionFiller() : obj_(nullptr) {}
178 
179  ~RegionFiller() = default;
180 
181  bool valid() const { return obj_ != nullptr; }
182 
183  LayerHitMapCache& layerHitMapCache() { return obj_->regions_.back().layerHitMapCache(); }
184 
186  obj_->layerPairs_.emplace_back(layerSet, std::move(doublets));
187  obj_->regions_.back().setLayerSetsEnd(obj_->layerPairs_.size());
188  }
189 
190  private:
192  };
193 
194  // allows declaring local variables with auto
195  static RegionFiller dummyFiller() { return RegionFiller(); }
196 
198 
201  IntermediateHitDoublets(const IntermediateHitDoublets& rh); // only to make ROOT dictionary generation happy
204  ~IntermediateHitDoublets() = default;
205 
206  void reserve(size_t nregions, size_t nlayersets) {
207  regions_.reserve(nregions);
208  layerPairs_.reserve(nregions * nlayersets);
209  }
210 
211  void shrink_to_fit() {
212  regions_.shrink_to_fit();
213  layerPairs_.shrink_to_fit();
214  }
215 
217  regions_.emplace_back(region, layerPairs_.size());
218  return RegionFiller(this);
219  }
220 
222  bool empty() const { return regions_.empty(); }
223  size_t regionSize() const { return regions_.size(); }
224  size_t layerPairsSize() const { return layerPairs_.size(); }
225 
226  const_iterator begin() const { return const_iterator(this, regions_.begin()); }
227  const_iterator cbegin() const { return begin(); }
228  const_iterator end() const { return const_iterator(this, regions_.end()); }
229  const_iterator cend() const { return end(); }
230 
231  // used internally by all the helper classes
232  std::vector<RegionIndex>::const_iterator regionsBegin() const { return regions_.begin(); }
233  std::vector<RegionIndex>::const_iterator regionsEnd() const { return regions_.end(); }
234  std::vector<LayerPairHitDoublets>::const_iterator layerSetsBegin() const { return layerPairs_.begin(); }
235  std::vector<LayerPairHitDoublets>::const_iterator layerSetsEnd() const { return layerPairs_.end(); }
236 
237 private:
239 
240  std::vector<RegionIndex> regions_;
241  std::vector<LayerPairHitDoublets> layerPairs_;
242 };
243 
244 #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()
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
RegionIndex & operator=(RegionIndex &&)=default
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)
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
def move
Definition: eostools.py:511
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
unsigned int layerSetEndIndex() const
const_iterator cend() const
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)
IntermediateHitDoublets & operator=(IntermediateHitDoublets &&)=default
ihd::const_iterator< RegionLayerSets, IntermediateHitDoublets > const_iterator
Iterator over regions.
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
~IntermediateHitDoublets()=default
LayerHitMapCache cache_
pointer to TrackingRegion (owned elsewhere)
unsigned int layerSetBeginIndex_
SeedingLayerSetsHits::LayerIndex outerLayerIndex() const
void reserve(size_t nregions, size_t nlayersets)
string end
Definition: dataset.py:937
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_
const SeedingLayerSetsHits & seedingLayerHits() const
def cache
Definition: utilities.py:3