CMS 3D CMS Logo

phase1PixelTopology.h
Go to the documentation of this file.
1 #ifndef Geometry_TrackerGeometryBuilder_phase1PixelTopology_h
2 #define Geometry_TrackerGeometryBuilder_phase1PixelTopology_h
3 
4 #include <cstdint>
5 #include <array>
6 
7 namespace phase1PixelTopology {
8 
9  constexpr uint16_t numRowsInRoc = 80;
10  constexpr uint16_t numColsInRoc = 52;
11  constexpr uint16_t lastRowInRoc = numRowsInRoc - 1;
12  constexpr uint16_t lastColInRoc = numColsInRoc - 1;
13 
14  constexpr uint16_t numRowsInModule = 2 * numRowsInRoc;
15  constexpr uint16_t numColsInModule = 8 * numColsInRoc;
16  constexpr uint16_t lastRowInModule = numRowsInModule - 1;
17  constexpr uint16_t lastColInModule = numColsInModule - 1;
18 
19  constexpr int16_t xOffset = -81;
20  constexpr int16_t yOffset = -54 * 4;
21 
22  constexpr uint32_t numPixsInModule = uint32_t(numRowsInModule) * uint32_t(numColsInModule);
23 
24  constexpr uint32_t numberOfModules = 1856;
25  constexpr uint32_t numberOfLayers = 10;
26  constexpr uint32_t layerStart[numberOfLayers + 1] = {0,
27  96,
28  320,
29  672, // barrel
30  1184,
31  1296,
32  1408, // positive endcap
33  1520,
34  1632,
35  1744, // negative endcap
37  constexpr char const* layerName[numberOfLayers] = {
38  "BL1",
39  "BL2",
40  "BL3",
41  "BL4", // barrel
42  "E+1",
43  "E+2",
44  "E+3", // positive endcap
45  "E-1",
46  "E-2",
47  "E-3" // negative endcap
48  };
49 
50  constexpr uint32_t numberOfModulesInBarrel = 1184;
52 
53  template <class Function, std::size_t... Indices>
54  constexpr auto map_to_array_helper(Function f, std::index_sequence<Indices...>)
55  -> std::array<typename std::result_of<Function(std::size_t)>::type, sizeof...(Indices)> {
56  return {{f(Indices)...}};
57  }
58 
59  template <int N, class Function>
60  constexpr auto map_to_array(Function f) -> std::array<typename std::result_of<Function(std::size_t)>::type, N> {
61  return map_to_array_helper(f, std::make_index_sequence<N>{});
62  }
63 
64  constexpr uint32_t findMaxModuleStride() {
65  bool go = true;
66  int n = 2;
67  while (go) {
68  for (uint8_t i = 1; i < std::size(layerStart); ++i) {
69  if (layerStart[i] % n != 0) {
70  go = false;
71  break;
72  }
73  }
74  if (!go)
75  break;
76  n *= 2;
77  }
78  return n / 2;
79  }
80 
81  constexpr uint32_t maxModuleStride = findMaxModuleStride();
82 
83  constexpr uint8_t findLayer(uint32_t detId) {
84  for (uint8_t i = 0; i < std::size(layerStart); ++i)
85  if (detId < layerStart[i + 1])
86  return i;
87  return std::size(layerStart);
88  }
89 
90  constexpr uint8_t findLayerFromCompact(uint32_t detId) {
91  detId *= maxModuleStride;
92  for (uint8_t i = 0; i < std::size(layerStart); ++i)
93  if (detId < layerStart[i + 1])
94  return i;
95  return std::size(layerStart);
96  }
97 
99  constexpr std::array<uint8_t, layerIndexSize> layer = map_to_array<layerIndexSize>(findLayerFromCompact);
100 
101  constexpr bool validateLayerIndex() {
102  bool res = true;
103  for (auto i = 0U; i < numberOfModules; ++i) {
104  auto j = i / maxModuleStride;
105  res &= (layer[j] < 10);
106  res &= (i >= layerStart[layer[j]]);
107  res &= (i < layerStart[layer[j] + 1]);
108  }
109  return res;
110  }
111 
112  static_assert(validateLayerIndex(), "layer from detIndex algo is buggy");
113 
114  // this is for the ROC n<512 (upgrade 1024)
115  constexpr inline uint16_t divu52(uint16_t n) {
116  n = n >> 2;
117  uint16_t q = (n >> 1) + (n >> 4);
118  q = q + (q >> 4) + (q >> 5);
119  q = q >> 3;
120  uint16_t r = n - q * 13;
121  return q + ((r + 3) >> 4);
122  }
123 
124  constexpr inline bool isEdgeX(uint16_t px) { return (px == 0) | (px == lastRowInModule); }
125 
126  constexpr inline bool isEdgeY(uint16_t py) { return (py == 0) | (py == lastColInModule); }
127 
128  constexpr inline uint16_t toRocX(uint16_t px) { return (px < numRowsInRoc) ? px : px - numRowsInRoc; }
129 
130  constexpr inline uint16_t toRocY(uint16_t py) {
131  auto roc = divu52(py);
132  return py - 52 * roc;
133  }
134 
135  constexpr inline bool isBigPixX(uint16_t px) { return (px == 79) | (px == 80); }
136 
137  constexpr inline bool isBigPixY(uint16_t py) {
138  auto ly = toRocY(py);
139  return (ly == 0) | (ly == lastColInRoc);
140  }
141 
142  constexpr inline uint16_t localX(uint16_t px) {
143  auto shift = 0;
144  if (px > lastRowInRoc)
145  shift += 1;
146  if (px > numRowsInRoc)
147  shift += 1;
148  return px + shift;
149  }
150 
151  constexpr inline uint16_t localY(uint16_t py) {
152  auto roc = divu52(py);
153  auto shift = 2 * roc;
154  auto yInRoc = py - 52 * roc;
155  if (yInRoc > 0)
156  shift += 1;
157  return py + shift;
158  }
159 
160  //FIXME move it elsewhere?
169  float endCapZ[2]; // just for pos and neg Layer1
170  };
171 
172 } // namespace phase1PixelTopology
173 
174 #endif // Geometry_TrackerGeometryBuilder_phase1PixelTopology_h
phase1PixelTopology::AverageGeometry::ladderMinZ
float ladderMinZ[numberOfLaddersInBarrel]
Definition: phase1PixelTopology.h:167
mps_fire.i
i
Definition: mps_fire.py:428
phase1PixelTopology::AverageGeometry::ladderZ
float ladderZ[numberOfLaddersInBarrel]
Definition: phase1PixelTopology.h:163
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
phase1PixelTopology::localY
constexpr uint16_t localY(uint16_t py)
Definition: phase1PixelTopology.h:151
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
phase1PixelTopology::lastColInModule
constexpr uint16_t lastColInModule
Definition: phase1PixelTopology.h:17
phase1PixelTopology::numberOfLayers
constexpr uint32_t numberOfLayers
Definition: phase1PixelTopology.h:25
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
phase1PixelTopology::toRocY
constexpr uint16_t toRocY(uint16_t py)
Definition: phase1PixelTopology.h:130
phase1PixelTopology::numRowsInRoc
constexpr uint16_t numRowsInRoc
Definition: phase1PixelTopology.h:9
phase1PixelTopology::numberOfModulesInBarrel
constexpr uint32_t numberOfModulesInBarrel
Definition: phase1PixelTopology.h:50
phase1PixelTopology::layerIndexSize
constexpr uint32_t layerIndexSize
Definition: phase1PixelTopology.h:98
phase1PixelTopology::lastRowInModule
constexpr uint16_t lastRowInModule
Definition: phase1PixelTopology.h:16
mps_check.array
array
Definition: mps_check.py:216
Indices
Indices
Definition: EdmEventSize.cc:28
phase1PixelTopology::AverageGeometry::ladderY
float ladderY[numberOfLaddersInBarrel]
Definition: phase1PixelTopology.h:165
phase1PixelTopology::map_to_array
constexpr auto map_to_array(Function f) -> std::array< typename std::result_of< Function(std::size_t)>::type, N >
Definition: phase1PixelTopology.h:60
phase1PixelTopology::AverageGeometry::ladderR
float ladderR[numberOfLaddersInBarrel]
Definition: phase1PixelTopology.h:166
N
#define N
Definition: blowfish.cc:9
phase1PixelTopology::numberOfModules
constexpr uint32_t numberOfModules
Definition: phase1PixelTopology.h:24
phase1PixelTopology::numColsInModule
constexpr uint16_t numColsInModule
Definition: phase1PixelTopology.h:15
phase1PixelTopology::numRowsInModule
constexpr uint16_t numRowsInModule
Definition: phase1PixelTopology.h:14
phase1PixelTopology::lastColInRoc
constexpr uint16_t lastColInRoc
Definition: phase1PixelTopology.h:12
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
phase1PixelTopology::isEdgeY
constexpr bool isEdgeY(uint16_t py)
Definition: phase1PixelTopology.h:126
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
phase1PixelTopology::map_to_array_helper
constexpr auto map_to_array_helper(Function f, std::index_sequence< Indices... >) -> std::array< typename std::result_of< Function(std::size_t)>::type, sizeof...(Indices)>
Definition: phase1PixelTopology.h:54
phase1PixelTopology::localX
constexpr uint16_t localX(uint16_t px)
Definition: phase1PixelTopology.h:142
phase1PixelTopology::numberOfLaddersInBarrel
constexpr uint32_t numberOfLaddersInBarrel
Definition: phase1PixelTopology.h:51
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
phase1PixelTopology::lastRowInRoc
constexpr uint16_t lastRowInRoc
Definition: phase1PixelTopology.h:11
phase1PixelTopology::xOffset
constexpr int16_t xOffset
Definition: phase1PixelTopology.h:19
phase1PixelTopology::validateLayerIndex
constexpr bool validateLayerIndex()
Definition: phase1PixelTopology.h:101
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
phase1PixelTopology::findLayer
constexpr uint8_t findLayer(uint32_t detId)
Definition: phase1PixelTopology.h:83
phase1PixelTopology::numColsInRoc
constexpr uint16_t numColsInRoc
Definition: phase1PixelTopology.h:10
res
Definition: Electron.h:6
phase1PixelTopology::maxModuleStride
constexpr uint32_t maxModuleStride
Definition: phase1PixelTopology.h:81
phase1PixelTopology::AverageGeometry
Definition: phase1PixelTopology.h:161
alignCSCRings.r
r
Definition: alignCSCRings.py:93
phase1PixelTopology::AverageGeometry::ladderX
float ladderX[numberOfLaddersInBarrel]
Definition: phase1PixelTopology.h:164
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
phase1PixelTopology::isBigPixY
constexpr bool isBigPixY(uint16_t py)
Definition: phase1PixelTopology.h:137
phase1PixelTopology::AverageGeometry::endCapZ
float endCapZ[2]
Definition: phase1PixelTopology.h:169
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
phase1PixelTopology::toRocX
constexpr uint16_t toRocX(uint16_t px)
Definition: phase1PixelTopology.h:128
phase1PixelTopology::isEdgeX
constexpr bool isEdgeX(uint16_t px)
Definition: phase1PixelTopology.h:124
phase1PixelTopology::yOffset
constexpr int16_t yOffset
Definition: phase1PixelTopology.h:20
phase1PixelTopology::findLayerFromCompact
constexpr uint8_t findLayerFromCompact(uint32_t detId)
Definition: phase1PixelTopology.h:90
PixelMapPlotter.roc
roc
Definition: PixelMapPlotter.py:498
phase1PixelTopology::isBigPixX
constexpr bool isBigPixX(uint16_t px)
Definition: phase1PixelTopology.h:135
phase1PixelTopology::layerStart
constexpr uint32_t layerStart[numberOfLayers+1]
Definition: phase1PixelTopology.h:26
phase1PixelTopology::numPixsInModule
constexpr uint32_t numPixsInModule
Definition: phase1PixelTopology.h:22
phase1PixelTopology::AverageGeometry::ladderMaxZ
float ladderMaxZ[numberOfLaddersInBarrel]
Definition: phase1PixelTopology.h:168
phase1PixelTopology::findMaxModuleStride
constexpr uint32_t findMaxModuleStride()
Definition: phase1PixelTopology.h:64
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
reco::parser::Function
Function
Definition: Function.h:18
phase1PixelTopology::layerName
constexpr char const * layerName[numberOfLayers]
Definition: phase1PixelTopology.h:37
phase1PixelTopology
Definition: phase1PixelTopology.h:7
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
phase1PixelTopology::divu52
constexpr uint16_t divu52(uint16_t n)
Definition: phase1PixelTopology.h:115
phase1PixelTopology::AverageGeometry::numberOfLaddersInBarrel
static constexpr auto numberOfLaddersInBarrel
Definition: phase1PixelTopology.h:162