test
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 
4 
7 
8 #include <vector>
9 #include <string>
10 #include <utility>
11 
12 class DetLayer;
13 
14 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
15 
28 public:
30  using TkHitRef = BaseTrackerRecHit const &;
32  using OwnedHits=std::vector<HitPointer>;
33 
35  using Hits = std::vector<ConstRecHitPointer>;
36 
37  typedef unsigned short LayerSetIndex;
38  typedef unsigned short LayerIndex;
39  typedef unsigned int HitIndex;
40 
46  class SeedingLayer {
47  public:
50  seedingLayerSets_(sls), index_(index) {}
51 
58  LayerIndex index() const { return index_; }
59  const std::string& name() const { return (*seedingLayerSets_->layerNames_)[index_]; }
60  const DetLayer *detLayer() const { return seedingLayerSets_->layerDets_[index_]; }
61  Hits hits() const { return seedingLayerSets_->hits(index_); }
62 
63  private:
66  };
67 
76  public:
78  public:
79  typedef std::vector<LayerSetIndex>::const_iterator internal_iterator_type;
81  typedef internal_iterator_type::difference_type difference_type;
82 
85 
87 
88  const_iterator& operator++() { ++iter_; return *this; }
90  const_iterator clone(*this);
91  ++clone;
92  return clone;
93  }
94 
95  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
96  bool operator!=(const const_iterator& other) const { return !operator==(other); }
97 
98  private:
101  };
102 
104  SeedingLayerSet(const SeedingLayerSetsHits *sls, std::vector<LayerSetIndex>::const_iterator begin, std::vector<LayerSetIndex>::const_iterator end):
105  seedingLayerSets_(sls), begin_(begin), end_(end) {}
106 
108  LayerSetIndex size() const { return end_-begin_; }
109 
112  return SeedingLayer(seedingLayerSets_, *(begin_+index));
113  }
114 
115  // iterators for range-for
117  const_iterator cbegin() const { return begin(); }
119  const_iterator cend() const { return end(); }
120 
121  private:
123  std::vector<LayerSetIndex>::const_iterator begin_; // Iterator to SeedingLayerSetsHits::layerSetIndices_, first layer
124  std::vector<LayerSetIndex>::const_iterator end_; // Iterator to SeedingLayerSetsHits::layerSetIndices_, last+1 layer
125  };
126 
128  public:
129  typedef std::vector<LayerSetIndex>::const_iterator internal_iterator_type;
131  typedef internal_iterator_type::difference_type difference_type;
132 
135 
137 
138  const_iterator& operator++() { std::advance(iter_, seedingLayerSets_->nlayers_); return *this; }
140  const_iterator clone(*this);
141  ++clone;
142  return clone;
143  }
144 
145  bool operator==(const const_iterator& other) const { return iter_ == other.iter_; }
146  bool operator!=(const const_iterator& other) const { return !operator==(other); }
147 
148  private:
151  };
152 
153 
155 
164  SeedingLayerSetsHits(unsigned short nlayers,
165  const std::vector<LayerSetIndex> *layerSetIndices,
166  const std::vector<std::string> *layerNames,
167  const std::vector<const DetLayer *>& layerDets);
168 
174 
175 
176  void swapHits(std::vector<HitIndex>& layerHitIndices, OwnedHits& hits);
177 
178 
180  unsigned short numberOfLayersInSet() const { return nlayers_; }
182  unsigned short size() const { return nlayers_ > 0 ? layerSetIndices_->size() / nlayers_ : 0; }
183 
186  std::vector<LayerSetIndex>::const_iterator begin = layerSetIndices_->begin()+nlayers_*index;
187  std::vector<LayerSetIndex>::const_iterator end = begin+nlayers_;
188  return SeedingLayerSet(this, begin, end);
189  }
190 
191  // iterators for range-for
192  const_iterator begin() const { return const_iterator(this, layerSetIndices_->begin()); }
193  const_iterator cbegin() const { return begin(); }
194  const_iterator end() const { return const_iterator(this, layerSetIndices_->end()); }
195  const_iterator cend() const { return end(); }
196 
197  // for more efficient edm::Event::put()
198  void swap(SeedingLayerSetsHits& other) {
199  std::swap(nlayers_, other.nlayers_);
203  layerDets_.swap(other.layerDets_);
204  rechits_.swap(other.rechits_);
205  }
206 
207  void print() const;
208 
209 private:
210  Hits hits(LayerIndex layerIndex) const;
211 
213  unsigned short nlayers_;
214 
220  const std::vector<LayerSetIndex> *layerSetIndices_;
221 
222  // following are indexed by LayerIndex
223  std::vector<HitIndex> layerHitIndices_; // Indices to first hits in rechits_
224  const std::vector<std::string> *layerNames_; // Names of the layers
225  std::vector<const DetLayer *> layerDets_; // Pointers to corresponding DetLayer objects
226 
232 };
233 
234 
235 #else
236 class SeedingLayerSetsHits {
237 private:
239  SeedingLayerSetsHits& operator=(SeedingLayerSetsHits const&){return *this;}
240 
241  std::vector<BaseTrackerRecHit const*> rechits_;
242 
243 };
244 #endif
245 
246 #endif
void swapHits(std::vector< HitIndex > &layerHitIndices, OwnedHits &hits)
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< 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)
BaseTrackerRecHit const * ConstRecHitPointer
bool operator!=(const const_iterator &other) const
BaseTrackerRecHit const & TkHitRef
SeedingLayerSetsHits & operator=(SeedingLayerSetsHits const &)=delete
Hits hits(LayerIndex layerIndex) const
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< ConstRecHitPointer > Hits
std::vector< LayerSetIndex >::const_iterator internal_iterator_type
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
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
const_iterator(const SeedingLayerSetsHits *sls, internal_iterator_type iter)
std::vector< HitIndex > layerHitIndices_
std::vector< const DetLayer * > layerDets_
unsigned short nlayers_
Number of layers in a SeedingLayerSet.
std::vector< HitPointer > OwnedHits
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.