CMS 3D CMS Logo

TkDetMap.h
Go to the documentation of this file.
1 #ifndef CalibTracker_SiStripCommon_TKHistoMap_h
2 #define CalibTracker_SiStripCommon_TKHistoMap_h
3 
4 #include <vector>
6 #include <cstdint>
7 
8 class TrackerTopology;
9 
10 class TkLayerMap {
11 public:
12  struct XYbin {
13  XYbin(int16_t _ix = -999, int16_t _iy = -999, float _x = -999., float _y = -999.)
14  : ix(_ix), iy(_iy), x(_x), y(_y) {}
15  int16_t ix, iy;
16  float x, y;
17  };
18 
19  enum TkLayerEnum {
20  INVALID = 0,
24  TIB_L4, //1-4
27  TIDM_D3, //5-7
30  TIDP_D3, //8-10
36  TOB_L6, //11-16
45  TECM_W9, //17-25
54  TECP_W9, //26-34
56  }; //35
57 
59 
61  std::size_t nchX,
62  double lowX,
63  double highX,
64  std::size_t nchY,
65  double lowY,
66  double highY,
67  const TrackerTopology* tTopo,
68  const std::vector<uint32_t>& tkDetIdList,
69  const std::vector<uint32_t>& singleExtString = {},
70  const std::vector<uint32_t>& modulesInRingFront = {},
71  const std::vector<uint32_t>& modulesInRingBack = {},
72  const std::vector<uint32_t>& binForRing = {},
73  uint32_t nstring_ext = 0,
74  uint32_t nrod = 0)
75  : layer_(layer),
76  nchX_(nchX),
77  lowX_(lowX),
78  highX_(highX),
79  nchY_(nchY),
80  lowY_(lowY),
81  highY_(highY),
82  tTopo_(tTopo),
83  singleExtStr_(singleExtString),
84  modulesInRingFront_(modulesInRingFront),
85  modulesInRingBack_(modulesInRingBack),
86  binForRing_(binForRing),
87  nStringExt_(nstring_ext),
88  nRod_(nrod),
89  binToDet_(std::vector<DetId>(std::size_t(nchX * nchY), 0)) {
90  initMap(tkDetIdList);
91  }
92 
94  std::size_t nchX,
95  double lowX,
96  double highX,
97  std::size_t nchY,
98  double lowY,
99  double highY,
100  const TrackerTopology* tTopo,
101  const std::vector<uint32_t>& tkDetIdList,
102  std::vector<uint32_t>&& singleExtString = {},
103  std::vector<uint32_t>&& modulesInRingFront = {},
104  std::vector<uint32_t>&& modulesInRingBack = {},
105  std::vector<uint32_t>&& binForRing = {},
106  uint32_t nstring_ext = 0,
107  uint32_t nrod = 0)
108  : layer_(layer),
109  nchX_(nchX),
110  lowX_(lowX),
111  highX_(highX),
112  nchY_(nchY),
113  lowY_(lowY),
114  highY_(highY),
115  tTopo_(tTopo),
116  singleExtStr_(singleExtString),
117  modulesInRingFront_(modulesInRingFront),
118  modulesInRingBack_(modulesInRingBack),
119  binForRing_(binForRing),
120  nStringExt_(nstring_ext),
121  nRod_(nrod),
122  binToDet_(std::vector<DetId>(std::size_t(nchX * nchY), 0)) {
123  initMap(tkDetIdList);
124  }
125 
126  void initMap(const std::vector<uint32_t>& tkDetIdList);
127 
128 private:
129  void initMap_TIB(const std::vector<uint32_t>& tkDetIdList);
130  void initMap_TOB(const std::vector<uint32_t>& tkDetIdList);
131  void initMap_TID(const std::vector<uint32_t>& tkDetIdList);
132  void initMap_TEC(const std::vector<uint32_t>& tkDetIdList);
133 
134  std::size_t bin(std::size_t ix, std::size_t iy) const { return (ix - 1) + nchX_ * (iy - 1); }
135 
136 public:
137  static const int16_t layerSearch(DetId detid, const TrackerTopology* tTopo);
138 
139  std::size_t get_nchX() const { return nchX_; }
140  std::size_t get_nchY() const { return nchY_; }
141  double get_lowX() const { return lowX_; }
142  double get_highX() const { return highX_; }
143  double get_lowY() const { return lowY_; }
144  double get_highY() const { return highY_; }
145  const std::vector<DetId>& getBinToDet() const { return binToDet_; }
146 
147  DetId getDetFromBin(int ix, int iy) const {
148  const auto idx = bin(ix, iy);
149  return (idx < nchX_ * nchY_) ? binToDet_[idx] : DetId(0);
150  }
151 
152  const XYbin getXY(DetId detid, int layerEnumNb = TkLayerMap::INVALID) const;
153 
154 private:
155  XYbin getXY_TIB(DetId detid) const;
156  XYbin getXY_TOB(DetId detid) const;
157  XYbin getXY_TID(DetId detid) const;
158  XYbin getXY_TEC(DetId detid) const;
159 
160 private:
161  int layer_; //In the enumerator sequence
162  std::size_t nchX_;
163  double lowX_, highX_;
164  std::size_t nchY_;
165  double lowY_, highY_;
167 
168  std::vector<uint32_t> singleExtStr_; // for TIB
169  std::vector<uint32_t> modulesInRingFront_, modulesInRingBack_, binForRing_; // for TEC
170  uint32_t nStringExt_, nRod_;
171 
172  std::vector<DetId> binToDet_;
173 };
174 
175 class TkDetMap {
176 public:
177  TkDetMap(const TrackerTopology* tTopo) : tTopo_(tTopo) {
179  } // maximal number of layers
180 
181  // modifiers
182  void setLayerMap(int layer, const TkLayerMap& lyrMap) { TkMap[layer] = lyrMap; }
183  void setLayerMap(int layer, TkLayerMap&& lyrMap) { TkMap[layer] = lyrMap; }
184 
185  // conversion
186  static std::string getLayerName(int in);
187  static int getLayerNum(const std::string& in);
188 
189  static void getSubDetLayerSide(int in, SiStripDetId::SubDetector&, uint32_t& layer, uint32_t& side);
190 
191  DetId getDetFromBin(int layer, int ix, int iy) const { return TkMap[layer].getDetFromBin(ix, iy); }
192  DetId getDetFromBin(const std::string& layerName, int ix, int iy) const {
193  return getDetFromBin(getLayerNum(layerName), ix, iy);
194  }
195 
196  std::vector<DetId> getDetsForLayer(int layer) const {
197  return TkMap[layer].getBinToDet();
198  } // const vector& -> vector conversion will copy
199 
200  // getXY and findLayer with caching, getComponents (for TkHistoMap)
201  const TkLayerMap::XYbin& getXY(DetId detid,
202  DetId& cached_detid,
203  int16_t& cached_layer,
204  TkLayerMap::XYbin& cached_XYbin) const;
205  int16_t findLayer(DetId detid, DetId& cached_detid, int16_t& cached_layer, TkLayerMap::XYbin& cached_XYbin) const;
206  void getComponents(int layer, int& nchX, double& lowX, double& highX, int& nchY, double& lowY, double& highY) const;
207 
208 private:
209  std::vector<TkLayerMap> TkMap;
211 };
212 
213 #endif
double get_highX() const
Definition: TkDetMap.h:142
const XYbin getXY(DetId detid, int layerEnumNb=TkLayerMap::INVALID) const
Definition: TkDetMap.cc:156
static std::string getLayerName(int in)
Definition: TkDetMap.cc:237
static void getSubDetLayerSide(int in, SiStripDetId::SubDetector &, uint32_t &layer, uint32_t &side)
Definition: TkDetMap.cc:383
constexpr char const * layerName[numberOfLayers]
std::vector< uint32_t > binForRing_
Definition: TkDetMap.h:169
TkLayerMap(int layer, std::size_t nchX, double lowX, double highX, std::size_t nchY, double lowY, double highY, const TrackerTopology *tTopo, const std::vector< uint32_t > &tkDetIdList, const std::vector< uint32_t > &singleExtString={}, const std::vector< uint32_t > &modulesInRingFront={}, const std::vector< uint32_t > &modulesInRingBack={}, const std::vector< uint32_t > &binForRing={}, uint32_t nstring_ext=0, uint32_t nrod=0)
Definition: TkDetMap.h:60
void setLayerMap(int layer, const TkLayerMap &lyrMap)
Definition: TkDetMap.h:182
TkDetMap(const TrackerTopology *tTopo)
Definition: TkDetMap.h:177
DetId getDetFromBin(int ix, int iy) const
Definition: TkDetMap.h:147
const TrackerTopology * tTopo_
Definition: TkDetMap.h:166
void initMap_TOB(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:75
void initMap(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:9
double lowY_
Definition: TkDetMap.h:165
static const int16_t layerSearch(DetId detid, const TrackerTopology *tTopo)
Definition: TkDetMap.cc:141
double get_lowY() const
Definition: TkDetMap.h:143
void initMap_TIB(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:58
uint32_t nStringExt_
Definition: TkDetMap.h:170
double lowX_
Definition: TkDetMap.h:163
std::size_t get_nchX() const
Definition: TkDetMap.h:139
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< DetId > getDetsForLayer(int layer) const
Definition: TkDetMap.h:196
std::size_t bin(std::size_t ix, std::size_t iy) const
Definition: TkDetMap.h:134
std::vector< TkLayerMap > TkMap
Definition: TkDetMap.h:209
static int getLayerNum(const std::string &in)
Definition: TkDetMap.cc:311
const TkLayerMap::XYbin & getXY(DetId detid, DetId &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
Definition: TkDetMap.cc:548
int16_t findLayer(DetId detid, DetId &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
Definition: TkDetMap.cc:568
std::vector< uint32_t > modulesInRingBack_
Definition: TkDetMap.h:169
uint32_t nRod_
Definition: TkDetMap.h:170
XYbin(int16_t _ix=-999, int16_t _iy=-999, float _x=-999., float _y=-999.)
Definition: TkDetMap.h:13
std::size_t get_nchY() const
Definition: TkDetMap.h:140
double highY_
Definition: TkDetMap.h:165
DetId getDetFromBin(int layer, int ix, int iy) const
Definition: TkDetMap.h:191
void initMap_TID(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:93
std::vector< uint32_t > singleExtStr_
Definition: TkDetMap.h:168
std::size_t nchX_
Definition: TkDetMap.h:162
XYbin getXY_TEC(DetId detid) const
Definition: TkDetMap.cc:215
std::vector< DetId > binToDet_
Definition: TkDetMap.h:172
Definition: DetId.h:17
const std::vector< DetId > & getBinToDet() const
Definition: TkDetMap.h:145
int layer_
Definition: TkDetMap.h:161
XYbin getXY_TOB(DetId detid) const
Definition: TkDetMap.cc:192
void getComponents(int layer, int &nchX, double &lowX, double &highX, int &nchY, double &lowY, double &highY) const
Definition: TkDetMap.cc:589
double get_lowX() const
Definition: TkDetMap.h:141
XYbin getXY_TIB(DetId detid) const
Definition: TkDetMap.cc:177
std::vector< uint32_t > modulesInRingFront_
Definition: TkDetMap.h:169
double get_highY() const
Definition: TkDetMap.h:144
double highX_
Definition: TkDetMap.h:163
const TrackerTopology * tTopo_
Definition: TkDetMap.h:210
XYbin getXY_TID(DetId detid) const
Definition: TkDetMap.cc:203
TkLayerMap(int layer, std::size_t nchX, double lowX, double highX, std::size_t nchY, double lowY, double highY, const TrackerTopology *tTopo, const std::vector< uint32_t > &tkDetIdList, std::vector< uint32_t > &&singleExtString={}, std::vector< uint32_t > &&modulesInRingFront={}, std::vector< uint32_t > &&modulesInRingBack={}, std::vector< uint32_t > &&binForRing={}, uint32_t nstring_ext=0, uint32_t nrod=0)
Definition: TkDetMap.h:93
void setLayerMap(int layer, TkLayerMap &&lyrMap)
Definition: TkDetMap.h:183
std::size_t nchY_
Definition: TkDetMap.h:164
DetId getDetFromBin(const std::string &layerName, int ix, int iy) const
Definition: TkDetMap.h:192
void initMap_TEC(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:117
TkLayerMap()
Definition: TkDetMap.h:58