CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SeedingLayerSetsHits.h
Go to the documentation of this file.
1 #ifndef TrackingTools_TransientTrackingRecHit_SeedingLayerSetsHits
2 #define TrackingTools_TransientTrackingRecHit_SeedingLayerSetsHits
3 
5 
6 #include <vector>
7 #include <string>
8 #include <utility>
9 
10 class DetLayer;
11 
25 public:
27  typedef std::vector<ConstRecHitPointer> Hits;
28 
29  typedef unsigned short LayerSetIndex;
30  typedef unsigned short LayerIndex;
31  typedef unsigned int HitIndex;
32 
38  class SeedingLayer {
39  public:
42  seedingLayerSets_(sls), index_(index) {}
43 
50  LayerIndex index() const { return index_; }
51  const std::string& name() const { return (*seedingLayerSets_->layerNames_)[index_]; }
52  const DetLayer *detLayer() const { return seedingLayerSets_->layerDets_[index_]; }
53  Hits hits() const { return seedingLayerSets_->hits(index_); }
54 
55  private:
58  };
59 
68  public:
70  public:
71  typedef std::vector<LayerSetIndex>::const_iterator internal_iterator_type;
73  typedef internal_iterator_type::difference_type difference_type;
74 
77 
79 
80  const_iterator& operator++() { ++iter_; return *this; }
82  const_iterator clone(*this);
83  ++clone;
84  return clone;
85  }
86 
87  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
88  bool operator!=(const const_iterator& other) const { return !operator==(other); }
89 
90  private:
93  };
94 
96  SeedingLayerSet(const SeedingLayerSetsHits *sls, std::vector<LayerSetIndex>::const_iterator begin, std::vector<LayerSetIndex>::const_iterator end):
97  seedingLayerSets_(sls), begin_(begin), end_(end) {}
98 
100  LayerSetIndex size() const { return end_-begin_; }
101 
104  return SeedingLayer(seedingLayerSets_, *(begin_+index));
105  }
106 
107  // iterators for range-for
109  const_iterator cbegin() const { return begin(); }
111  const_iterator cend() const { return end(); }
112 
113  private:
115  std::vector<LayerSetIndex>::const_iterator begin_; // Iterator to SeedingLayerSetsHits::layerSetIndices_, first layer
116  std::vector<LayerSetIndex>::const_iterator end_; // Iterator to SeedingLayerSetsHits::layerSetIndices_, last+1 layer
117  };
118 
120  public:
121  typedef std::vector<LayerSetIndex>::const_iterator internal_iterator_type;
123  typedef internal_iterator_type::difference_type difference_type;
124 
127 
129 
130  const_iterator& operator++() { std::advance(iter_, seedingLayerSets_->nlayers_); return *this; }
132  const_iterator clone(*this);
133  ++clone;
134  return clone;
135  }
136 
137  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
138  bool operator!=(const const_iterator& other) const { return !operator==(other); }
139 
140  private:
143  };
144 
145 
147 
156  SeedingLayerSetsHits(unsigned short nlayers,
157  const std::vector<LayerSetIndex> *layerSetIndices,
158  const std::vector<std::string> *layerNames,
159  const std::vector<const DetLayer *>& layerDets);
160 
162 
163  void swapHits(std::vector<HitIndex>& layerHitIndices, Hits& hits);
164 
165 
167  unsigned short numberOfLayersInSet() const { return nlayers_; }
169  unsigned short size() const { return nlayers_ > 0 ? layerSetIndices_->size() / nlayers_ : 0; }
170 
173  std::vector<LayerSetIndex>::const_iterator begin = layerSetIndices_->begin()+nlayers_*index;
174  std::vector<LayerSetIndex>::const_iterator end = begin+nlayers_;
175  return SeedingLayerSet(this, begin, end);
176  }
177 
178  // iterators for range-for
179  const_iterator begin() const { return const_iterator(this, layerSetIndices_->begin()); }
180  const_iterator cbegin() const { return begin(); }
181  const_iterator end() const { return const_iterator(this, layerSetIndices_->end()); }
182  const_iterator cend() const { return end(); }
183 
184  // for more efficient edm::Event::put()
185  void swap(SeedingLayerSetsHits& other) {
186  std::swap(nlayers_, other.nlayers_);
190  layerDets_.swap(other.layerDets_);
191  rechits_.swap(other.rechits_);
192  }
193 
194  void print() const;
195 
196 private:
197  Hits hits(LayerIndex layerIndex) const;
198 
200  unsigned short nlayers_;
201 
207  const std::vector<LayerSetIndex> *layerSetIndices_;
208 
209  // following are indexed by LayerIndex
210  std::vector<HitIndex> layerHitIndices_; // Indices to first hits in rechits_
211  const std::vector<std::string> *layerNames_; // Names of the layers
212  std::vector<const DetLayer *> layerDets_; // Pointers to corresponding DetLayer objects
213 
218  std::vector<ConstRecHitPointer> rechits_;
219 };
220 
221 #endif
const_iterator end() const
LayerSetIndex size() const
Number of layers in this set.
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
std::vector< ConstRecHitPointer > rechits_
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
const_iterator(const SeedingLayerSetsHits *sls, internal_iterator_type iter)
SeedingLayer operator[](LayerSetIndex index) const
Get a given SeedingLayer (index is between 0 and size()-1)
unsigned short LayerSetIndex
const_iterator begin() const
const_iterator cend() const
void swap(SeedingLayerSetsHits &other)
bool operator!=(const const_iterator &other) const
void swapHits(std::vector< HitIndex > &layerHitIndices, Hits &hits)
Hits hits(LayerIndex layerIndex) const
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
std::vector< LayerSetIndex >::const_iterator begin_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
SeedingLayerSet operator[](LayerSetIndex index) const
Get the SeedingLayerSet at a given index.
bool operator!=(const const_iterator &other) const
SeedingLayer(const SeedingLayerSetsHits *sls, LayerIndex index)
internal_iterator_type::difference_type difference_type
const SeedingLayerSetsHits * seedingLayerSets_
const std::vector< LayerSetIndex > * layerSetIndices_
const std::string & name() const
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
std::vector< ConstRecHitPointer > Hits
SeedingLayerSet(const SeedingLayerSetsHits *sls, std::vector< LayerSetIndex >::const_iterator begin, std::vector< LayerSetIndex >::const_iterator end)
const SeedingLayerSetsHits * seedingLayerSets_
const_iterator cbegin() const
internal_iterator_type::difference_type difference_type
bool operator==(const const_iterator &other) const
const DetLayer * detLayer() const
const_iterator(const SeedingLayerSetsHits *sls, internal_iterator_type iter)
std::vector< HitIndex > layerHitIndices_
std::vector< const DetLayer * > layerDets_
tuple clone
Definition: statics.py:58
unsigned short nlayers_
Number of layers in a SeedingLayerSet.
bool operator==(const const_iterator &other) const
std::vector< LayerSetIndex >::const_iterator end_
const std::vector< std::string > * layerNames_
const SeedingLayerSetsHits * seedingLayerSets_
unsigned short size() const
Get the number of SeedingLayerSets.