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>
5 #include <boost/cstdint.hpp>
7 
8 class TrackerTopology;
9 
11 {
12 public:
13  struct XYbin{
14  XYbin(int16_t _ix=-999, int16_t _iy=-999, float _x=-999., float _y=-999.)
15  : ix(_ix), iy(_iy), x(_x), y(_y) {}
16  int16_t ix,iy;
17  float x,y;
18  };
19 
20  enum TkLayerEnum { INVALID=0,
27  NUMLAYERS }; //35
28 
30 
31  TkLayerMap( int layer
32  , std::size_t nchX, double lowX, double highX
33  , std::size_t nchY, double lowY, double highY
34  , const TrackerTopology* tTopo, const std::vector<uint32_t>& tkDetIdList
35  , const std::vector<uint32_t>& singleExtString = {}
36  , const std::vector<uint32_t>& modulesInRingFront = {}
37  , const std::vector<uint32_t>& modulesInRingBack = {}
38  , const std::vector<uint32_t>& binForRing = {}
39  , uint32_t nstring_ext = 0, uint32_t nrod = 0
40  )
41  : layer_(layer)
42  , nchX_(nchX), lowX_(lowX), highX_(highX)
43  , nchY_(nchY), lowY_(lowY), highY_(highY)
44  , tTopo_(tTopo)
45  , singleExtStr_(singleExtString)
46  , modulesInRingFront_(modulesInRingFront), modulesInRingBack_(modulesInRingBack)
47  , binForRing_(binForRing)
48  , nStringExt_(nstring_ext), nRod_(nrod)
49  , binToDet_(std::vector<DetId>(std::size_t(nchX*nchY), 0))
50  {
51  initMap(tkDetIdList);
52  }
53 
54  TkLayerMap( int layer
55  , std::size_t nchX, double lowX, double highX
56  , std::size_t nchY, double lowY, double highY
57  , const TrackerTopology* tTopo, const std::vector<uint32_t>& tkDetIdList
58  , std::vector<uint32_t>&& singleExtString = {}
59  , std::vector<uint32_t>&& modulesInRingFront = {}
60  , std::vector<uint32_t>&& modulesInRingBack = {}
61  , std::vector<uint32_t>&& binForRing = {}
62  , uint32_t nstring_ext = 0, uint32_t nrod = 0
63  )
64  : layer_(layer)
65  , nchX_(nchX), lowX_(lowX), highX_(highX)
66  , nchY_(nchY), lowY_(lowY), highY_(highY)
67  , tTopo_(tTopo)
68  , singleExtStr_(singleExtString)
69  , modulesInRingFront_(modulesInRingFront), modulesInRingBack_(modulesInRingBack)
70  , binForRing_(binForRing)
71  , nStringExt_(nstring_ext), nRod_(nrod)
72  , binToDet_(std::vector<DetId>(std::size_t(nchX*nchY), 0))
73  {
74  initMap(tkDetIdList);
75  }
76 
77  void initMap(const std::vector<uint32_t>& tkDetIdList);
78 private:
79  void initMap_TIB(const std::vector<uint32_t>& tkDetIdList);
80  void initMap_TOB(const std::vector<uint32_t>& tkDetIdList);
81  void initMap_TID(const std::vector<uint32_t>& tkDetIdList);
82  void initMap_TEC(const std::vector<uint32_t>& tkDetIdList);
83 
84  std::size_t bin(std::size_t ix, std::size_t iy) const { return (ix-1)+nchX_*(iy-1); }
85 
86 public:
87  static const int16_t layerSearch(DetId detid, const TrackerTopology* tTopo);
88 
89  std::size_t get_nchX() const { return nchX_; }
90  std::size_t get_nchY() const { return nchY_; }
91  double get_lowX() const { return lowX_; }
92  double get_highX() const { return highX_; }
93  double get_lowY() const { return lowY_; }
94  double get_highY() const { return highY_; }
95  const std::vector<DetId>& getBinToDet() const { return binToDet_; }
96 
97  DetId getDetFromBin(int ix, int iy) const {
98  const auto idx = bin(ix, iy);
99  return ( idx < nchX_*nchY_ ) ? binToDet_[idx] : DetId(0);
100  }
101 
102  const XYbin getXY(DetId detid, int layerEnumNb = TkLayerMap::INVALID) const;
103 private:
104  XYbin getXY_TIB(DetId detid) const;
105  XYbin getXY_TOB(DetId detid) const;
106  XYbin getXY_TID(DetId detid) const;
107  XYbin getXY_TEC(DetId detid) const;
108 
109 private:
110  int layer_; //In the enumerator sequence
111  std::size_t nchX_;
112  double lowX_, highX_;
113  std::size_t nchY_;
114  double lowY_, highY_;
116 
117  std::vector<uint32_t> singleExtStr_; // for TIB
118  std::vector<uint32_t> modulesInRingFront_, modulesInRingBack_, binForRing_; // for TEC
119  uint32_t nStringExt_, nRod_;
120 
121  std::vector<DetId> binToDet_;
122 };
123 
124 class TkDetMap
125 {
126 public:
127  TkDetMap(const TrackerTopology* tTopo) : tTopo_(tTopo) { TkMap.resize(TkLayerMap::NUMLAYERS); } // maximal number of layers
128 
129  // modifiers
130  void setLayerMap(int layer, const TkLayerMap& lyrMap ) { TkMap[layer] = lyrMap; }
131  void setLayerMap(int layer, TkLayerMap&& lyrMap ) { TkMap[layer] = lyrMap; }
132 
133  // conversion
134  static std::string getLayerName(int in);
135  static int getLayerNum(const std::string& in);
136 
137  static void getSubDetLayerSide(int in, SiStripDetId::SubDetector&, uint32_t& layer, uint32_t& side);
138 
139  DetId getDetFromBin(int layer, int ix, int iy) const
140  { return TkMap[layer].getDetFromBin(ix, iy); }
141  DetId getDetFromBin(const std::string& layerName, int ix, int iy) const
142  { return getDetFromBin(getLayerNum(layerName), ix, iy); }
143 
144  std::vector<DetId> getDetsForLayer(int layer) const
145  { return TkMap[layer].getBinToDet(); } // const vector& -> vector conversion will copy
146 
147  // getXY and findLayer with caching, getComponents (for TkHistoMap)
148  const TkLayerMap::XYbin& getXY(DetId detid,
149  DetId& cached_detid, int16_t& cached_layer, TkLayerMap::XYbin& cached_XYbin) const;
150  int16_t findLayer(DetId detid,
151  DetId& cached_detid, int16_t& cached_layer, TkLayerMap::XYbin& cached_XYbin) const;
152  void getComponents(int layer,
153  int& nchX, double& lowX, double& highX,
154  int& nchY, double& lowY, double& highY) const;
155 
156  private:
157  std::vector<TkLayerMap> TkMap;
159 };
160 
161 #endif
DetId getDetFromBin(int ix, int iy) const
Definition: TkDetMap.h:97
double get_highX() const
Definition: TkDetMap.h:92
std::vector< uint32_t > binForRing_
Definition: TkDetMap.h:118
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:31
void setLayerMap(int layer, const TkLayerMap &lyrMap)
Definition: TkDetMap.h:130
TkDetMap(const TrackerTopology *tTopo)
Definition: TkDetMap.h:127
const TrackerTopology * tTopo_
Definition: TkDetMap.h:115
std::size_t get_nchX() const
Definition: TkDetMap.h:89
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:114
static const int16_t layerSearch(DetId detid, const TrackerTopology *tTopo)
Definition: TkDetMap.cc:123
void initMap_TIB(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:59
std::vector< DetId > getDetsForLayer(int layer) const
Definition: TkDetMap.h:144
uint32_t nStringExt_
Definition: TkDetMap.h:119
double lowX_
Definition: TkDetMap.h:112
std::vector< TkLayerMap > TkMap
Definition: TkDetMap.h:157
XYbin getXY_TID(DetId detid) const
Definition: TkDetMap.cc:196
std::vector< uint32_t > modulesInRingBack_
Definition: TkDetMap.h:118
uint32_t nRod_
Definition: TkDetMap.h:119
XYbin getXY_TIB(DetId detid) const
Definition: TkDetMap.cc:159
std::size_t get_nchY() const
Definition: TkDetMap.h:90
double get_lowX() const
Definition: TkDetMap.h:91
DetId getDetFromBin(const std::string &layerName, int ix, int iy) const
Definition: TkDetMap.h:141
XYbin(int16_t _ix=-999, int16_t _iy=-999, float _x=-999., float _y=-999.)
Definition: TkDetMap.h:14
double highY_
Definition: TkDetMap.h:114
void initMap_TID(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:91
std::vector< uint32_t > singleExtStr_
Definition: TkDetMap.h:117
std::size_t nchX_
Definition: TkDetMap.h:111
std::vector< DetId > binToDet_
Definition: TkDetMap.h:121
Definition: DetId.h:18
int layer_
Definition: TkDetMap.h:110
const XYbin getXY(DetId detid, int layerEnumNb=TkLayerMap::INVALID) const
Definition: TkDetMap.cc:139
XYbin getXY_TEC(DetId detid) const
Definition: TkDetMap.cc:212
double get_highY() const
Definition: TkDetMap.h:94
std::size_t bin(std::size_t ix, std::size_t iy) const
Definition: TkDetMap.h:84
std::vector< uint32_t > modulesInRingFront_
Definition: TkDetMap.h:118
DetId getDetFromBin(int layer, int ix, int iy) const
Definition: TkDetMap.h:139
XYbin getXY_TOB(DetId detid) const
Definition: TkDetMap.cc:180
double highX_
Definition: TkDetMap.h:112
const TrackerTopology * tTopo_
Definition: TkDetMap.h:158
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:54
void setLayerMap(int layer, TkLayerMap &&lyrMap)
Definition: TkDetMap.h:131
std::size_t nchY_
Definition: TkDetMap.h:113
const std::vector< DetId > & getBinToDet() const
Definition: TkDetMap.h:95
void initMap_TEC(const std::vector< uint32_t > &tkDetIdList)
Definition: TkDetMap.cc:107
double get_lowY() const
Definition: TkDetMap.h:93
TkLayerMap()
Definition: TkDetMap.h:29