CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripRegionCabling.h
Go to the documentation of this file.
1 #ifndef CalibTracker_SiStripConnectivity_SiStripRegionCabling_H
2 #define CalibTracker_SiStripConnectivity_SiStripRegionCabling_H
3 #define _USE_MATH_DEFINES
4 
5 #include <boost/cstdint.hpp>
10 #include <sstream>
11 #include <vector>
12 #include <map>
13 #include <cmath>
14 
26 
27  public:
28 
30  enum SubDet {TIB = 0, TOB = 1, TID = 2, TEC = 3, ALLSUBDETS = 4};
31  enum Layer {TIBLAYERS = 4, TOBLAYERS = 6, TIDLAYERS = 3, TECLAYERS = 9, ALLLAYERS = 10};
32 
34  typedef std::map< uint32_t, std::vector<FedChannelConnection> > ElementCabling;
35  typedef std::vector< ElementCabling > WedgeCabling;
36  typedef std::vector< WedgeCabling > RegionCabling;
37  typedef std::vector< RegionCabling > Cabling;
38 
41  typedef std::pair<double,double> Position;
42  typedef std::pair<uint32_t,uint32_t> PositionIndex;
43 
46  typedef uint32_t ElementIndex;
47 
48  SiStripRegionCabling(const uint32_t,const uint32_t, const double);
49 
51 
54  inline void setRegionCabling(const Cabling&);
55 
56  inline const Cabling& getRegionCabling() const;
57 
58  inline const uint32_t etadivisions() const;
59 
60  inline const uint32_t phidivisions() const;
61 
65  inline const std::pair<double,double> regionDimensions() const;
66 
67  inline const Position position(const uint32_t) const;
68 
69  inline const Position position(const PositionIndex) const;
70 
71  inline const PositionIndex positionIndex(const uint32_t) const;
72 
73  const PositionIndex positionIndex(const Position) const;
74 
75  const uint32_t region(const Position) const;
76 
77  inline const uint32_t region(const PositionIndex) const;
78 
81  PositionIndex increment(const PositionIndex, int, int) const;
82 
86  inline static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer);
87 
88  inline const ElementIndex elementIndex(const PositionIndex, const SubDet, const uint32_t layer) const;
89 
90  inline const ElementIndex elementIndex(const Position, const SubDet, const uint32_t layer) const;
91 
92  inline static const uint32_t layer(const ElementIndex);
93 
94  inline static const SubDet subdet(const ElementIndex);
95 
96  inline static const uint32_t region(const ElementIndex);
97 
100  static const SubDet subdetFromDetId(const uint32_t detid);
101 
102  static const uint32_t layerFromDetId(const uint32_t detid);
103 
104  static const uint32_t physicalLayerFromDetId(const uint32_t detid);
105 
106  static const uint32_t physicalLayer(const SubDet, const uint32_t layer);
107 
111  template <class T>
112  void updateSiStripRefGetter(edm::RefGetter<T>& refgetter,
113  const edm::Handle< edm::LazyGetter<T> >& lazygetter,
114  const ElementIndex) const;
115 
116  template <class T>
117  void updateSiStripRefGetter(edm::RefGetter<T>& refgetter,
118  const edm::Handle< edm::LazyGetter<T> >& lazygetter,
119  const Position position,
120  const double deltaeta,
121  const double deltaphi,
122  const SubDet subdet,
123  const uint32_t layer) const;
124 
126  void print( std::stringstream& ) const;
127 
128  private:
129 
131 
135 
137  double etamax_;
138 
141 };
142 
143 inline void SiStripRegionCabling::setRegionCabling(const Cabling& regioncabling) {
144  regioncabling_ = regioncabling;
145 }
146 
148  return regioncabling_;
149 }
150 
151 inline const uint32_t SiStripRegionCabling::etadivisions() const {
152  return static_cast<uint32_t>(etadivisions_);
153 }
154 
155 inline const uint32_t SiStripRegionCabling::phidivisions() const {
156  return static_cast<uint32_t>(phidivisions_);
157 }
158 
159 inline const std::pair<double,double> SiStripRegionCabling::regionDimensions() const {
160  return std::pair<double,double>((2.*etamax_)/etadivisions_,2.*M_PI/phidivisions_);
161 }
162 
163 inline const SiStripRegionCabling::Position SiStripRegionCabling::position(const uint32_t region) const {
164  PositionIndex index = positionIndex(region);
165  return position(index);
166 }
167 
169  return Position(regionDimensions().first*(index.first+.5) - etamax_, regionDimensions().second*(index.second+.5)- M_PI);
170 }
171 
173  return PositionIndex(region/phidivisions_,region%phidivisions_);
174 }
175 
176 inline const uint32_t SiStripRegionCabling::region(const PositionIndex index) const {
177  return index.first*phidivisions_ + index.second;
178 }
179 
180 inline const uint32_t SiStripRegionCabling::elementIndex(const uint32_t region, const SubDet subdet, const uint32_t layer) {
181  return region*ALLSUBDETS*ALLLAYERS + subdet*ALLLAYERS + layer;
182 }
183 
184 inline const uint32_t SiStripRegionCabling::elementIndex(const PositionIndex index, const SubDet subdet, const uint32_t layer) const {
185  return elementIndex(region(index),subdet,layer);
186 }
187 
188 inline const uint32_t SiStripRegionCabling::elementIndex(const Position position, const SubDet subdet, const uint32_t layer) const {
189  return elementIndex(region(position),subdet,layer);
190 }
191 
192 inline const uint32_t SiStripRegionCabling::layer(const uint32_t index) {
193  return index%ALLLAYERS;
194 }
195 
197  return static_cast<SiStripRegionCabling::SubDet>((index/ALLLAYERS)%ALLSUBDETS);
198 }
199 
200 inline const uint32_t SiStripRegionCabling::region(const uint32_t index) {
201  return index/(ALLSUBDETS*ALLLAYERS);
202 }
203 
204 template <class T>
205 void SiStripRegionCabling::updateSiStripRefGetter(edm::RefGetter<T>& refgetter, const edm::Handle< edm::LazyGetter<T> >& lazygetter, const uint32_t index) const {
206  if (!refgetter.find(index)) refgetter.push_back(lazygetter,index);
207 }
208 
209 template <class T>
210 void SiStripRegionCabling::updateSiStripRefGetter(edm::RefGetter<T>& refgetter, const edm::Handle< edm::LazyGetter<T> >& lazygetter, const SiStripRegionCabling::Position pos, const double deltaeta, const double deltaphi, const SubDet sub, const uint32_t layer) const {
211 
213  Position center = position(index);
214  double offeta = pos.first-center.first;
215  double offphi = pos.second-center.second;
216  double toteta = deltaeta/regionDimensions().first;
217  double totphi = deltaphi/regionDimensions().second;
218  uint32_t plueta = static_cast<uint32_t>(offeta+.5+toteta);
219  uint32_t pluphi = static_cast<uint32_t>(offphi+.5+totphi);
220  uint32_t mineta = static_cast<uint32_t>(-offeta+.5+toteta);
221  uint32_t minphi = static_cast<uint32_t>(-offphi+.5+totphi);
222 
223  for (uint32_t i=0;i<mineta+plueta+1;i++) {
224  for (uint32_t j=0;j<minphi+pluphi+1;j++) {
225  const uint32_t k=elementIndex(increment(index,i-mineta,j-minphi),sub,layer);
226  updateSiStripRefGetter<T>(refgetter,lazygetter,k);
227  }
228  }
229 }
230 
231 #endif
static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer)
void print(std::stringstream &) const
const std::pair< double, double > regionDimensions() const
int i
Definition: DBlmapReader.cc:9
static const uint32_t physicalLayer(const SubDet, const uint32_t layer)
const PositionIndex positionIndex(const uint32_t) const
void push_back(const edm::Handle< LazyGetter< T > > &, const uint32_t &)
Add a new region to the end of the collection.
Definition: RefGetter.h:110
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
U second(std::pair< T, U > const &p)
void setRegionCabling(const Cabling &)
static const uint32_t physicalLayerFromDetId(const uint32_t detid)
const uint32_t phidivisions() const
std::vector< ElementCabling > WedgeCabling
void updateSiStripRefGetter(edm::RefGetter< T > &refgetter, const edm::Handle< edm::LazyGetter< T > > &lazygetter, const ElementIndex) const
static const SubDet subdet(const ElementIndex)
static const SubDet subdetFromDetId(const uint32_t detid)
std::pair< double, double > Position
int j
Definition: DBlmapReader.cc:9
const Cabling & getRegionCabling() const
bool first
Definition: L1TdeRCT.cc:94
int k[5][pyjets_maxn]
const Position position(const uint32_t) const
#define M_PI
Definition: BFit3D.cc:3
static const uint32_t layerFromDetId(const uint32_t detid)
bool find(uint32_t) const
Returns true if region already defined.
Definition: RefGetter.h:170
const uint32_t region(const Position) const
const uint32_t etadivisions() const
PositionIndex increment(const PositionIndex, int, int) const
std::vector< WedgeCabling > RegionCabling
std::pair< uint32_t, uint32_t > PositionIndex
static const uint32_t layer(const ElementIndex)
std::map< uint32_t, std::vector< FedChannelConnection > > ElementCabling
std::vector< RegionCabling > Cabling