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 
60  TkLayerMap(int layer,
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 
93  TkLayerMap(int layer,
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
TkLayerMap::get_lowY
double get_lowY() const
Definition: TkDetMap.h:143
TkLayerMap::TIB_L3
Definition: TkDetMap.h:23
TkDetMap::TkDetMap
TkDetMap(const TrackerTopology *tTopo)
Definition: TkDetMap.h:177
TkLayerMap::TIB_L2
Definition: TkDetMap.h:22
TkLayerMap::get_nchX
std::size_t get_nchX() const
Definition: TkDetMap.h:139
TkLayerMap::TOB_L4
Definition: TkDetMap.h:34
TkLayerMap::TECM_W4
Definition: TkDetMap.h:40
TkLayerMap::modulesInRingFront_
std::vector< uint32_t > modulesInRingFront_
Definition: TkDetMap.h:169
TkLayerMap::modulesInRingBack_
std::vector< uint32_t > modulesInRingBack_
Definition: TkDetMap.h:169
TkLayerMap::nRod_
uint32_t nRod_
Definition: TkDetMap.h:170
TkDetMap::TkMap
std::vector< TkLayerMap > TkMap
Definition: TkDetMap.h:209
TkLayerMap::TECP_W9
Definition: TkDetMap.h:54
TrackerTopology
Definition: TrackerTopology.h:16
TkLayerMap::TOB_L1
Definition: TkDetMap.h:31
TkDetMap::getLayerName
static std::string getLayerName(int in)
Definition: TkDetMap.cc:237
TkLayerMap::XYbin::ix
int16_t ix
Definition: TkDetMap.h:15
TkLayerMap::TECM_W5
Definition: TkDetMap.h:41
TkLayerMap::TECM_W1
Definition: TkDetMap.h:37
TkLayerMap::TIDP_D1
Definition: TkDetMap.h:28
TkDetMap::getXY
const TkLayerMap::XYbin & getXY(DetId detid, DetId &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
Definition: TkDetMap.cc:548
TkLayerMap::highX_
double highX_
Definition: TkDetMap.h:163
SiStripDetId.h
TkLayerMap::XYbin::iy
int16_t iy
Definition: TkDetMap.h:15
TkLayerMap::TECP_W6
Definition: TkDetMap.h:51
TkLayerMap::TkLayerMap
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
TkLayerMap::TOB_L6
Definition: TkDetMap.h:36
TkLayerMap::getXY_TEC
XYbin getXY_TEC(DetId detid) const
Definition: TkDetMap.cc:215
TkDetMap::setLayerMap
void setLayerMap(int layer, const TkLayerMap &lyrMap)
Definition: TkDetMap.h:182
TkLayerMap::binToDet_
std::vector< DetId > binToDet_
Definition: TkDetMap.h:172
TkLayerMap::getXY
const XYbin getXY(DetId detid, int layerEnumNb=TkLayerMap::INVALID) const
Definition: TkDetMap.cc:156
TkLayerMap::initMap_TID
void initMap_TID(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:93
TkDetMap::getLayerNum
static int getLayerNum(const std::string &in)
Definition: TkDetMap.cc:311
TkLayerMap::getBinToDet
const std::vector< DetId > & getBinToDet() const
Definition: TkDetMap.h:145
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
TkLayerMap::getXY_TOB
XYbin getXY_TOB(DetId detid) const
Definition: TkDetMap.cc:192
DetId
Definition: DetId.h:17
TkLayerMap::get_lowX
double get_lowX() const
Definition: TkDetMap.h:141
TkLayerMap::TECP_W5
Definition: TkDetMap.h:50
TkLayerMap::TOB_L5
Definition: TkDetMap.h:35
TkLayerMap::TIDM_D3
Definition: TkDetMap.h:27
TkDetMap::getDetFromBin
DetId getDetFromBin(int layer, int ix, int iy) const
Definition: TkDetMap.h:191
TkLayerMap::getDetFromBin
DetId getDetFromBin(int ix, int iy) const
Definition: TkDetMap.h:147
TkLayerMap::TIDP_D2
Definition: TkDetMap.h:29
TkLayerMap::TkLayerEnum
TkLayerEnum
Definition: TkDetMap.h:19
TkLayerMap::getXY_TIB
XYbin getXY_TIB(DetId detid) const
Definition: TkDetMap.cc:177
TkDetMap
Definition: TkDetMap.h:175
TkLayerMap::TECP_W4
Definition: TkDetMap.h:49
TkDetMap::findLayer
int16_t findLayer(DetId detid, DetId &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
Definition: TkDetMap.cc:568
TkLayerMap::TECM_W6
Definition: TkDetMap.h:42
TkLayerMap::lowY_
double lowY_
Definition: TkDetMap.h:165
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TkLayerMap::binForRing_
std::vector< uint32_t > binForRing_
Definition: TkDetMap.h:169
TkLayerMap::TIDP_D3
Definition: TkDetMap.h:30
TkLayerMap::TECM_W9
Definition: TkDetMap.h:45
TkLayerMap::TECM_W8
Definition: TkDetMap.h:44
TkLayerMap::layerSearch
static const int16_t layerSearch(DetId detid, const TrackerTopology *tTopo)
Definition: TkDetMap.cc:141
TkLayerMap::XYbin::x
float x
Definition: TkDetMap.h:16
TkLayerMap::TECM_W7
Definition: TkDetMap.h:43
TkLayerMap::TECM_W2
Definition: TkDetMap.h:38
TkLayerMap::nchY_
std::size_t nchY_
Definition: TkDetMap.h:164
TkLayerMap::get_highY
double get_highY() const
Definition: TkDetMap.h:144
recoMuon::in
Definition: RecoMuonEnumerators.h:6
TkLayerMap
Definition: TkDetMap.h:10
TkDetMap::getDetsForLayer
std::vector< DetId > getDetsForLayer(int layer) const
Definition: TkDetMap.h:196
TkLayerMap::TECP_W7
Definition: TkDetMap.h:52
TkLayerMap::TkLayerMap
TkLayerMap()
Definition: TkDetMap.h:58
TkLayerMap::NUMLAYERS
Definition: TkDetMap.h:55
TkLayerMap::getXY_TID
XYbin getXY_TID(DetId detid) const
Definition: TkDetMap.cc:203
TkLayerMap::TIB_L1
Definition: TkDetMap.h:21
TkLayerMap::lowX_
double lowX_
Definition: TkDetMap.h:163
TkLayerMap::TIB_L4
Definition: TkDetMap.h:24
TkLayerMap::bin
std::size_t bin(std::size_t ix, std::size_t iy) const
Definition: TkDetMap.h:134
TkLayerMap::initMap_TEC
void initMap_TEC(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:117
TkLayerMap::TECP_W8
Definition: TkDetMap.h:53
TkLayerMap::TECP_W1
Definition: TkDetMap.h:46
TkLayerMap::get_highX
double get_highX() const
Definition: TkDetMap.h:142
TkLayerMap::get_nchY
std::size_t get_nchY() const
Definition: TkDetMap.h:140
TkLayerMap::TECP_W2
Definition: TkDetMap.h:47
TkLayerMap::TECP_W3
Definition: TkDetMap.h:48
TkLayerMap::highY_
double highY_
Definition: TkDetMap.h:165
TkDetMap::getComponents
void getComponents(int layer, int &nchX, double &lowX, double &highX, int &nchY, double &lowY, double &highY) const
Definition: TkDetMap.cc:589
TkLayerMap::TIDM_D2
Definition: TkDetMap.h:26
TkLayerMap::XYbin::y
float y
Definition: TkDetMap.h:16
TkLayerMap::XYbin::XYbin
XYbin(int16_t _ix=-999, int16_t _iy=-999, float _x=-999., float _y=-999.)
Definition: TkDetMap.h:13
TkDetMap::getDetFromBin
DetId getDetFromBin(const std::string &layerName, int ix, int iy) const
Definition: TkDetMap.h:192
TkLayerMap::initMap
void initMap(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:9
TkLayerMap::TIDM_D1
Definition: TkDetMap.h:25
TkDetMap::tTopo_
const TrackerTopology * tTopo_
Definition: TkDetMap.h:210
TkLayerMap::TkLayerMap
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
TkLayerMap::TECM_W3
Definition: TkDetMap.h:39
TkLayerMap::tTopo_
const TrackerTopology * tTopo_
Definition: TkDetMap.h:166
TkLayerMap::singleExtStr_
std::vector< uint32_t > singleExtStr_
Definition: TkDetMap.h:168
TkLayerMap::layer_
int layer_
Definition: TkDetMap.h:161
SiStripSubdetector::Subdetector
Subdetector
Definition: SiStripEnums.h:5
TkLayerMap::TOB_L3
Definition: TkDetMap.h:33
TkLayerMap::initMap_TIB
void initMap_TIB(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:58
TkLayerMap::XYbin
Definition: TkDetMap.h:12
TkDetMap::getSubDetLayerSide
static void getSubDetLayerSide(int in, SiStripDetId::SubDetector &, uint32_t &layer, uint32_t &side)
Definition: TkDetMap.cc:383
TkDetMap::setLayerMap
void setLayerMap(int layer, TkLayerMap &&lyrMap)
Definition: TkDetMap.h:183
TkLayerMap::nchX_
std::size_t nchX_
Definition: TkDetMap.h:162
TkLayerMap::initMap_TOB
void initMap_TOB(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:75
TkLayerMap::nStringExt_
uint32_t nStringExt_
Definition: TkDetMap.h:170
TkLayerMap::INVALID
Definition: TkDetMap.h:20
TkLayerMap::TOB_L2
Definition: TkDetMap.h:32