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  RegionIndex(RegionIndex&&) = default;
24  RegionIndex& operator=(RegionIndex&&) = default;
25 
26  void setLayerSetsEnd(unsigned int end) { layerSetEndIndex_ = end; }
27 
28  const TrackingRegion& region() const { return *region_; }
29 
31  const LayerHitMapCache& layerHitMapCache() const { return cache_; }
32 
33  unsigned int layerSetBeginIndex() const { return layerSetBeginIndex_; }
34  unsigned int layerSetEndIndex() const { return layerSetEndIndex_; }
35 
36  private:
39  unsigned int layerSetBeginIndex_;
40  unsigned int layerSetEndIndex_;
41  };
42 
50  template <typename T>
52  public:
53  using const_iterator = typename std::vector<T>::const_iterator;
54 
55  // Taking T* to have compatible interface with IntermediateHitTriplets::RegionLayerSets
56  template <typename TMP>
58  region_(region), cache_(cache), layerSetsBegin_(begin), layerSetsEnd_(end) {}
59 
60  const TrackingRegion& region() const { return *region_; }
61  const LayerHitMapCache& layerHitMapCache() const { return *cache_; }
62 
63  const_iterator begin() const { return layerSetsBegin_; }
64  const_iterator cbegin() const { return begin(); }
65  const_iterator end() const { return layerSetsEnd_; }
66  const_iterator cend() const { return end(); }
67 
68  private:
73  };
74 
83  template<typename ValueType, typename HitSetType>
85  public:
86  using internal_iterator_type = typename std::vector<RegionIndex>::const_iterator;
88  using difference_type = internal_iterator_type::difference_type;
89 
90  const_iterator(const HitSetType *hst, internal_iterator_type iter): hitSets_(hst), iter_(iter) {}
91 
93  return value_type(&(iter_->region()),
94  &(iter_->layerHitMapCache()),
95  hitSets_,
96  hitSets_->layerSetsBegin() + iter_->layerSetBeginIndex(),
97  hitSets_->layerSetsBegin() + iter_->layerSetEndIndex());
98  }
99 
100  const_iterator& operator++() { ++iter_; return *this; }
102  const_iterator clone(*this);
103  ++iter_;
104  return clone;
105  }
106 
107  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
108  bool operator!=(const const_iterator& other) const { return !operator==(other); }
109 
110  private:
111  const HitSetType *hitSets_;
113  };
114 }
115 
128 public:
129  using LayerPair = std::tuple<SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex>;
131 
142  public:
144  layerPair_(layerSet[0].index(), layerSet[1].index()),
145  doublets_(std::move(doublets))
146  {}
147 
148  const LayerPair& layerPair() const { return layerPair_; }
149  SeedingLayerSetsHits::LayerIndex innerLayerIndex() const { return std::get<0>(layerPair_); }
150  SeedingLayerSetsHits::LayerIndex outerLayerIndex() const { return std::get<1>(layerPair_); }
151 
152  const HitDoublets& doublets() const { return doublets_; }
153 
154  private:
157  };
158 
160 
163 
165 
168 
170 
172  class RegionFiller {
173  public:
174  RegionFiller(): obj_(nullptr) {}
175  explicit RegionFiller(IntermediateHitDoublets *obj): obj_(obj) {}
176 
177  ~RegionFiller() = default;
178 
179  bool valid() const { return obj_ != nullptr; }
180 
181  LayerHitMapCache& layerHitMapCache() { return obj_->regions_.back().layerHitMapCache(); }
182 
184  obj_->layerPairs_.emplace_back(layerSet, std::move(doublets));
185  obj_->regions_.back().setLayerSetsEnd(obj_->layerPairs_.size());
186  }
187  private:
189  };
190 
191  // allows declaring local variables with auto
192  static RegionFiller dummyFiller() { return RegionFiller(); }
193 
195 
196  IntermediateHitDoublets(): seedingLayers_(nullptr) {}
197  explicit IntermediateHitDoublets(const SeedingLayerSetsHits *seedingLayers): seedingLayers_(seedingLayers) {}
198  IntermediateHitDoublets(const IntermediateHitDoublets& rh); // only to make ROOT dictionary generation happy
201  ~IntermediateHitDoublets() = default;
202 
203  void reserve(size_t nregions, size_t nlayersets) {
204  regions_.reserve(nregions);
205  layerPairs_.reserve(nregions*nlayersets);
206  }
207 
208  void shrink_to_fit() {
209  regions_.shrink_to_fit();
210  layerPairs_.shrink_to_fit();
211  }
212 
214  regions_.emplace_back(region, layerPairs_.size());
215  return RegionFiller(this);
216  }
217 
218  const SeedingLayerSetsHits& seedingLayerHits() const { return *seedingLayers_; }
219  bool empty() const { return regions_.empty(); }
220  size_t regionSize() const { return regions_.size(); }
221  size_t layerPairsSize() const { return layerPairs_.size(); }
222 
223  const_iterator begin() const { return const_iterator(this, regions_.begin()); }
224  const_iterator cbegin() const { return begin(); }
225  const_iterator end() const { return const_iterator(this, regions_.end()); }
226  const_iterator cend() const { return end(); }
227 
228  // used internally by all the helper classes
229  std::vector<RegionIndex>::const_iterator regionsBegin() const { return regions_.begin(); }
230  std::vector<RegionIndex>::const_iterator regionsEnd() const { return regions_.end(); }
231  std::vector<LayerPairHitDoublets>::const_iterator layerSetsBegin() const { return layerPairs_.begin(); }
232  std::vector<LayerPairHitDoublets>::const_iterator layerSetsEnd() const { return layerPairs_.end(); }
233 
234 private:
236 
237  std::vector<RegionIndex> regions_;
238  std::vector<LayerPairHitDoublets> layerPairs_;
239 };
240 
241 #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)
#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
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:39
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:32
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