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), 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*,
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
ihd::RegionLayerSets::region
const TrackingRegion & region() const
Definition: IntermediateHitDoublets.h:61
IntermediateHitDoublets::RegionFiller
Helper class enforcing correct way of filling the doublets of a region.
Definition: IntermediateHitDoublets.h:174
IntermediateHitDoublets::LayerPairHitDoublets::doublets_
HitDoublets doublets_
pair of indices to the layer
Definition: IntermediateHitDoublets.h:158
ihd::RegionLayerSets::cend
const_iterator cend() const
Definition: IntermediateHitDoublets.h:67
ihd::RegionIndex::RegionIndex
RegionIndex(const TrackingRegion *reg, unsigned int ind)
Definition: IntermediateHitDoublets.h:18
IntermediateHitDoublets::RegionFiller::addDoublets
void addDoublets(const SeedingLayerSetsHits::SeedingLayerSet &layerSet, HitDoublets &&doublets)
Definition: IntermediateHitDoublets.h:185
HLT_FULL_cff.seedingLayers
seedingLayers
Definition: HLT_FULL_cff.py:9861
IntermediateHitDoublets::LayerPairHitDoublets::layerPair_
LayerPair layerPair_
Definition: IntermediateHitDoublets.h:157
IntermediateHitDoublets::LayerPairHitDoublets
Definition: IntermediateHitDoublets.h:145
IntermediateHitDoublets::cbegin
const_iterator cbegin() const
Definition: IntermediateHitDoublets.h:227
IntermediateHitDoublets::shrink_to_fit
void shrink_to_fit()
Definition: IntermediateHitDoublets.h:211
IntermediateHitDoublets::cend
const_iterator cend() const
Definition: IntermediateHitDoublets.h:229
IntermediateHitDoublets::RegionFiller::RegionFiller
RegionFiller(IntermediateHitDoublets *obj)
Definition: IntermediateHitDoublets.h:177
IntermediateHitDoublets::layerPairsSize
size_t layerPairsSize() const
Definition: IntermediateHitDoublets.h:224
ihd::const_iterator::operator!=
bool operator!=(const const_iterator &other) const
Definition: IntermediateHitDoublets.h:112
IntermediateHitDoublets::RegionFiller::RegionFiller
RegionFiller()
Definition: IntermediateHitDoublets.h:176
ihd::RegionLayerSets::cbegin
const_iterator cbegin() const
Definition: IntermediateHitDoublets.h:65
SeedingLayerSetsHits
Definition: SeedingLayerSetsHits.h:18
IntermediateHitDoublets::dummyFiller
static RegionFiller dummyFiller()
Definition: IntermediateHitDoublets.h:195
ihd::const_iterator::operator*
value_type operator*() const
Definition: IntermediateHitDoublets.h:93
IntermediateHitDoublets::beginRegion
RegionFiller beginRegion(const TrackingRegion *region)
Definition: IntermediateHitDoublets.h:216
IntermediateHitDoublets::LayerPairHitDoublets::outerLayerIndex
SeedingLayerSetsHits::LayerIndex outerLayerIndex() const
Definition: IntermediateHitDoublets.h:152
IntermediateHitDoublets::LayerPairHitDoublets::doublets
const HitDoublets & doublets() const
Definition: IntermediateHitDoublets.h:154
HLT_FULL_cff.doublets
doublets
Definition: HLT_FULL_cff.py:9872
ihd::RegionIndex::layerSetBeginIndex_
unsigned int layerSetBeginIndex_
Definition: IntermediateHitDoublets.h:36
ihd::RegionLayerSets
Definition: IntermediateHitDoublets.h:48
ihd::RegionIndex::layerHitMapCache
LayerHitMapCache & layerHitMapCache()
Definition: IntermediateHitDoublets.h:27
IntermediateHitDoublets::layerSetsBegin
std::vector< LayerPairHitDoublets >::const_iterator layerSetsBegin() const
Definition: IntermediateHitDoublets.h:234
LayerHitMapCache.h
ihd::RegionLayerSets::layerHitMapCache
const LayerHitMapCache & layerHitMapCache() const
Definition: IntermediateHitDoublets.h:62
LayerHitMapCache
Definition: LayerHitMapCache.h:14
IntermediateHitDoublets::regionsBegin
std::vector< RegionIndex >::const_iterator regionsBegin() const
Definition: IntermediateHitDoublets.h:232
ihd::RegionLayerSets::layerSetsBegin_
const const_iterator layerSetsBegin_
Definition: IntermediateHitDoublets.h:72
SeedingLayerSetsHits.h
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
ihd::const_iterator::operator==
bool operator==(const const_iterator &other) const
Definition: IntermediateHitDoublets.h:111
ihd::RegionIndex::region_
const TrackingRegion * region_
Definition: IntermediateHitDoublets.h:34
ihd::const_iterator::value_type
ValueType value_type
Definition: IntermediateHitDoublets.h:88
mps_fire.end
end
Definition: mps_fire.py:242
ihd::const_iterator::const_iterator
const_iterator(const HitSetType *hst, internal_iterator_type iter)
Definition: IntermediateHitDoublets.h:91
IntermediateHitDoublets::end
const_iterator end() const
Definition: IntermediateHitDoublets.h:228
trackingPlots.other
other
Definition: trackingPlots.py:1464
ihd
Definition: IntermediateHitDoublets.h:7
utilities.cache
def cache(function)
Definition: utilities.py:3
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
IntermediateHitDoublets::IntermediateHitDoublets
IntermediateHitDoublets(const SeedingLayerSetsHits *seedingLayers)
Definition: IntermediateHitDoublets.h:200
ihd::RegionLayerSets::RegionLayerSets
RegionLayerSets(const TrackingRegion *region, const LayerHitMapCache *cache, const TMP *, const_iterator begin, const_iterator end)
Definition: IntermediateHitDoublets.h:54
ihd::RegionLayerSets::end
const_iterator end() const
Definition: IntermediateHitDoublets.h:66
ihd::const_iterator::difference_type
internal_iterator_type::difference_type difference_type
Definition: IntermediateHitDoublets.h:89
HitDoublets
Definition: RecHitsSortedInPhi.h:124
IntermediateHitDoublets::seedingLayerHits
const SeedingLayerSetsHits & seedingLayerHits() const
Definition: IntermediateHitDoublets.h:221
IntermediateHitDoublets::empty
bool empty() const
Definition: IntermediateHitDoublets.h:222
SeedingLayerSetsHits::LayerIndex
unsigned short LayerIndex
Definition: SeedingLayerSetsHits.h:29
IntermediateHitDoublets::operator=
IntermediateHitDoublets & operator=(IntermediateHitDoublets &&)=default
Json::ValueType
ValueType
Type of the value held by a Value object.
Definition: value.h:23
ihd::RegionIndex::layerSetBeginIndex
unsigned int layerSetBeginIndex() const
Definition: IntermediateHitDoublets.h:30
ihd::const_iterator::internal_iterator_type
typename std::vector< RegionIndex >::const_iterator internal_iterator_type
Definition: IntermediateHitDoublets.h:87
ihd::RegionIndex::cache_
LayerHitMapCache cache_
pointer to TrackingRegion (owned elsewhere)
Definition: IntermediateHitDoublets.h:35
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
IntermediateHitDoublets::const_iterator
ihd::const_iterator< RegionLayerSets, IntermediateHitDoublets > const_iterator
Iterator over regions.
Definition: IntermediateHitDoublets.h:169
IntermediateHitDoublets::LayerPairHitDoublets::LayerPairHitDoublets
LayerPairHitDoublets(const SeedingLayerSetsHits::SeedingLayerSet &layerSet, HitDoublets &&doublets)
Definition: IntermediateHitDoublets.h:147
ihd::RegionLayerSets::cache_
const LayerHitMapCache * cache_
Definition: IntermediateHitDoublets.h:71
IntermediateHitDoublets::layerSetsEnd
std::vector< LayerPairHitDoublets >::const_iterator layerSetsEnd() const
Definition: IntermediateHitDoublets.h:235
ihd::RegionLayerSets::const_iterator
typename std::vector< T >::const_iterator const_iterator
Definition: IntermediateHitDoublets.h:50
IntermediateHitDoublets::RegionFiller::valid
bool valid() const
Definition: IntermediateHitDoublets.h:181
IntermediateHitDoublets
Definition: IntermediateHitDoublets.h:131
ihd::RegionIndex::layerSetEndIndex
unsigned int layerSetEndIndex() const
Definition: IntermediateHitDoublets.h:31
IntermediateHitDoublets::LayerPairHitDoublets::innerLayerIndex
SeedingLayerSetsHits::LayerIndex innerLayerIndex() const
Definition: IntermediateHitDoublets.h:151
ihd::RegionIndex::setLayerSetsEnd
void setLayerSetsEnd(unsigned int end)
Definition: IntermediateHitDoublets.h:23
IntermediateHitDoublets::begin
const_iterator begin() const
Definition: IntermediateHitDoublets.h:226
IntermediateHitDoublets::regions_
std::vector< RegionIndex > regions_
Pointer to SeedingLayerSetsHits (owned elsewhere)
Definition: IntermediateHitDoublets.h:240
ihd::RegionIndex::operator=
RegionIndex & operator=(RegionIndex &&)=default
ihd::RegionLayerSets::layerSetsEnd_
const const_iterator layerSetsEnd_
Definition: IntermediateHitDoublets.h:73
IntermediateHitDoublets::regionsEnd
std::vector< RegionIndex >::const_iterator regionsEnd() const
Definition: IntermediateHitDoublets.h:233
ihd::const_iterator::operator++
const_iterator & operator++()
Definition: IntermediateHitDoublets.h:101
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
IntermediateHitDoublets::RegionFiller::~RegionFiller
~RegionFiller()=default
IntermediateHitDoublets::layerPairs_
std::vector< LayerPairHitDoublets > layerPairs_
Container of regions, each element has indices pointing to layerPairs_.
Definition: IntermediateHitDoublets.h:241
ihd::const_iterator::iter_
internal_iterator_type iter_
Definition: IntermediateHitDoublets.h:116
ihd::RegionLayerSets::begin
const_iterator begin() const
Definition: IntermediateHitDoublets.h:64
IntermediateHitDoublets::RegionFiller::obj_
IntermediateHitDoublets * obj_
Definition: IntermediateHitDoublets.h:191
SeedingLayerSetsHits::SeedingLayerSet
Definition: SeedingLayerSetsHits.h:65
ihd::const_iterator::operator++
const_iterator operator++(int)
Definition: IntermediateHitDoublets.h:105
ihd::const_iterator
Definition: IntermediateHitDoublets.h:85
IntermediateHitDoublets::LayerPairHitDoublets::layerPair
const LayerPair & layerPair() const
Definition: IntermediateHitDoublets.h:150
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
TrackingRegion
Definition: TrackingRegion.h:41
IntermediateHitDoublets::~IntermediateHitDoublets
~IntermediateHitDoublets()=default
ihd::RegionIndex
Definition: IntermediateHitDoublets.h:16
IntermediateHitDoublets::RegionFiller::layerHitMapCache
LayerHitMapCache & layerHitMapCache()
Definition: IntermediateHitDoublets.h:183
ihd::const_iterator::hitSets_
const HitSetType * hitSets_
Definition: IntermediateHitDoublets.h:115
ihd::RegionIndex::layerSetEndIndex_
unsigned int layerSetEndIndex_
index of the beginning of layer sets of this region
Definition: IntermediateHitDoublets.h:37
IntermediateHitDoublets::reserve
void reserve(size_t nregions, size_t nlayersets)
Definition: IntermediateHitDoublets.h:206
ihd::RegionIndex::layerHitMapCache
const LayerHitMapCache & layerHitMapCache() const
Definition: IntermediateHitDoublets.h:28
IntermediateHitDoublets::regionSize
size_t regionSize() const
Definition: IntermediateHitDoublets.h:223
ihd::RegionLayerSets::region_
const TrackingRegion * region_
Definition: IntermediateHitDoublets.h:70
ihd::RegionIndex::region
const TrackingRegion & region() const
Definition: IntermediateHitDoublets.h:25
IntermediateHitDoublets::IntermediateHitDoublets
IntermediateHitDoublets()
Definition: IntermediateHitDoublets.h:199
IntermediateHitDoublets::LayerPair
std::tuple< SeedingLayerSetsHits::LayerIndex, SeedingLayerSetsHits::LayerIndex > LayerPair
Definition: IntermediateHitDoublets.h:133
IntermediateHitDoublets::seedingLayers_
const SeedingLayerSetsHits * seedingLayers_
Definition: IntermediateHitDoublets.h:238