CMS 3D CMS Logo

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 
7 #include <cmath>
8 #include <map>
9 #include <sstream>
10 #include <vector>
11 #include <cstdint>
12 
24 public:
26  enum SubDet { TIB = 0, TOB = 1, TID = 2, TEC = 3, ALLSUBDETS = 4 };
27  enum Layer { TIBLAYERS = 4, TOBLAYERS = 6, TIDLAYERS = 3, TECLAYERS = 9, ALLLAYERS = 10 };
28 
30  typedef std::pair<uint32_t, std::vector<FedChannelConnection>> Element;
31  typedef std::vector<Element> ElementCabling;
32  typedef std::vector<ElementCabling> WedgeCabling;
33  typedef std::vector<WedgeCabling> RegionCabling;
34  typedef std::vector<RegionCabling> Cabling;
35 
38  typedef std::pair<double, double> Position;
39  typedef std::pair<uint32_t, uint32_t> PositionIndex;
40 
43  typedef uint32_t ElementIndex;
44 
45  SiStripRegionCabling(const uint32_t, const uint32_t, const double);
46 
48 
51  inline void setRegionCabling(const Cabling &);
52 
53  inline const Cabling &getRegionCabling() const;
54 
55  inline const uint32_t etadivisions() const;
56 
57  inline const uint32_t phidivisions() const;
58 
62  inline const std::pair<double, double> regionDimensions() const;
63 
64  inline const Position position(const uint32_t) const;
65 
66  inline const Position position(const PositionIndex) const;
67 
68  inline const PositionIndex positionIndex(const uint32_t) const;
69 
70  const PositionIndex positionIndex(const Position) const;
71 
72  const uint32_t region(const Position) const;
73 
74  inline const uint32_t region(const PositionIndex) const;
75 
78  PositionIndex increment(const PositionIndex, int, int) const;
79 
83  inline static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer);
84 
85  inline const ElementIndex elementIndex(const PositionIndex, const SubDet, const uint32_t layer) const;
86 
87  inline const ElementIndex elementIndex(const Position, const SubDet, const uint32_t layer) const;
88 
89  inline static const uint32_t layer(const ElementIndex);
90 
91  inline static const SubDet subdet(const ElementIndex);
92 
93  inline static const uint32_t region(const ElementIndex);
94 
95  // /** Methods for extracting det-id information */
96  //
97  static const SubDet subdetFromDetId(const uint32_t detid);
98 
100  void print(std::stringstream &) const;
101 
102 private:
104 
108 
110  double etamax_;
111 
113  Cabling regioncabling_;
114 };
115 
116 inline void SiStripRegionCabling::setRegionCabling(const Cabling &regioncabling) { regioncabling_ = regioncabling; }
117 
119 
120 inline const uint32_t SiStripRegionCabling::etadivisions() const { return static_cast<uint32_t>(etadivisions_); }
121 
122 inline const uint32_t SiStripRegionCabling::phidivisions() const { return static_cast<uint32_t>(phidivisions_); }
123 
124 inline const std::pair<double, double> SiStripRegionCabling::regionDimensions() const {
125  return std::pair<double, double>((2. * etamax_) / etadivisions_, 2. * M_PI / phidivisions_);
126 }
127 
130  return position(index);
131 }
132 
134  return Position(regionDimensions().first * (index.first + .5) - etamax_,
135  regionDimensions().second * (index.second + .5) - M_PI);
136 }
137 
139  return PositionIndex(region / phidivisions_, region % phidivisions_);
140 }
141 
142 inline const uint32_t SiStripRegionCabling::region(const PositionIndex index) const {
143  return index.first * phidivisions_ + index.second;
144 }
145 
146 inline const uint32_t SiStripRegionCabling::elementIndex(const uint32_t region,
147  const SubDet subdet,
148  const uint32_t layer) {
149  return region * ALLSUBDETS * ALLLAYERS + subdet * ALLLAYERS + layer;
150 }
151 
153  const SubDet subdet,
154  const uint32_t layer) const {
155  return elementIndex(region(index), subdet, layer);
156 }
157 
159  const SubDet subdet,
160  const uint32_t layer) const {
161  return elementIndex(region(position), subdet, layer);
162 }
163 
164 inline const uint32_t SiStripRegionCabling::layer(const uint32_t index) { return index % ALLLAYERS; }
165 
167  return static_cast<SiStripRegionCabling::SubDet>((index / ALLLAYERS) % ALLSUBDETS);
168 }
169 
170 inline const uint32_t SiStripRegionCabling::region(const uint32_t index) { return index / (ALLSUBDETS * ALLLAYERS); }
171 
172 #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
std::pair< uint32_t, uint32_t > PositionIndex
std::pair< uint32_t, std::vector< FedChannelConnection > > Element
const PositionIndex positionIndex(const uint32_t) const
std::vector< Element > ElementCabling
U second(std::pair< T, U > const &p)
void setRegionCabling(const Cabling &)
const uint32_t phidivisions() const
static const SubDet subdet(const ElementIndex)
static const SubDet subdetFromDetId(const uint32_t detid)
std::vector< RegionCabling > Cabling
const Cabling & getRegionCabling() const
#define M_PI
const Position position(const uint32_t) const
std::pair< double, double > Position
std::vector< WedgeCabling > RegionCabling
const uint32_t region(const Position) const
const uint32_t etadivisions() const
std::vector< ElementCabling > WedgeCabling
PositionIndex increment(const PositionIndex, int, int) const
static const uint32_t layer(const ElementIndex)