CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 uint16_t pixelThickness = 285;
23  constexpr uint16_t pixelPitchX = 100;
24  constexpr uint16_t pixelPitchY = 150;
25 
26  constexpr uint32_t numPixsInModule = uint32_t(numRowsInModule) * uint32_t(numColsInModule);
27 
28  constexpr uint32_t numberOfModules = 1856;
29  constexpr uint32_t numberOfLayers = 10;
30 #ifdef __CUDA_ARCH__
32 #endif
33  constexpr uint32_t layerStart[numberOfLayers + 1] = {0,
34  96,
35  320,
36  672, // barrel
37  1184,
38  1296,
39  1408, // positive endcap
40  1520,
41  1632,
42  1744, // negative endcap
44  constexpr char const* layerName[numberOfLayers] = {
45  "BL1",
46  "BL2",
47  "BL3",
48  "BL4", // barrel
49  "E+1",
50  "E+2",
51  "E+3", // positive endcap
52  "E-1",
53  "E-2",
54  "E-3" // negative endcap
55  };
56 
57  constexpr uint32_t numberOfModulesInBarrel = 1184;
59 
60  template <class Function, std::size_t... Indices>
61  constexpr auto map_to_array_helper(Function f, std::index_sequence<Indices...>)
63  return {{f(Indices)...}};
64  }
65 
66  template <int N, class Function>
68  return map_to_array_helper(f, std::make_index_sequence<N>{});
69  }
70 
71  constexpr uint32_t findMaxModuleStride() {
72  bool go = true;
73  int n = 2;
74  while (go) {
75  for (uint8_t i = 1; i < std::size(layerStart); ++i) {
76  if (layerStart[i] % n != 0) {
77  go = false;
78  break;
79  }
80  }
81  if (!go)
82  break;
83  n *= 2;
84  }
85  return n / 2;
86  }
87 
88  constexpr uint32_t maxModuleStride = findMaxModuleStride();
89 
90  constexpr uint8_t findLayer(uint32_t detId, uint8_t sl = 0) {
91  for (uint8_t i = sl; i < std::size(layerStart); ++i)
92  if (detId < layerStart[i + 1])
93  return i;
94  return std::size(layerStart);
95  }
96 
97  constexpr uint8_t findLayerFromCompact(uint32_t detId) {
98  detId *= maxModuleStride;
99  for (uint8_t i = 0; i < std::size(layerStart); ++i)
100  if (detId < layerStart[i + 1])
101  return i;
102  return std::size(layerStart);
103  }
104 
106 #ifdef __CUDA_ARCH__
107  __device__
108 #endif
109  constexpr std::array<uint8_t, layerIndexSize>
110  layer = map_to_array<layerIndexSize>(findLayerFromCompact);
111 
112  constexpr uint8_t getLayer(uint32_t detId) {
114  }
115 
116  constexpr bool validateLayerIndex() {
117  bool res = true;
118  for (auto i = 0U; i < numberOfModules; ++i) {
119  auto j = i / maxModuleStride;
120  res &= (layer[j] < 10);
121  res &= (i >= layerStart[layer[j]]);
122  res &= (i < layerStart[layer[j] + 1]);
123  }
124  return res;
125  }
126 
127  static_assert(validateLayerIndex(), "layer from detIndex algo is buggy");
128 
129  // this is for the ROC n<512 (upgrade 1024)
130  constexpr inline uint16_t divu52(uint16_t n) {
131  n = n >> 2;
132  uint16_t q = (n >> 1) + (n >> 4);
133  q = q + (q >> 4) + (q >> 5);
134  q = q >> 3;
135  uint16_t r = n - q * 13;
136  return q + ((r + 3) >> 4);
137  }
138 
139  constexpr inline bool isEdgeX(uint16_t px) { return (px == 0) | (px == lastRowInModule); }
140 
141  constexpr inline bool isEdgeY(uint16_t py) { return (py == 0) | (py == lastColInModule); }
142 
143  constexpr inline uint16_t toRocX(uint16_t px) { return (px < numRowsInRoc) ? px : px - numRowsInRoc; }
144 
145  constexpr inline uint16_t toRocY(uint16_t py) {
146  auto roc = divu52(py);
147  return py - 52 * roc;
148  }
149 
150  constexpr inline bool isBigPixX(uint16_t px) { return (px == 79) | (px == 80); }
151 
152  constexpr inline bool isBigPixY(uint16_t py) {
153  auto ly = toRocY(py);
154  return (ly == 0) | (ly == lastColInRoc);
155  }
156 
157  constexpr inline uint16_t localX(uint16_t px) {
158  auto shift = 0;
159  if (px > lastRowInRoc)
160  shift += 1;
161  if (px > numRowsInRoc)
162  shift += 1;
163  return px + shift;
164  }
165 
166  constexpr inline uint16_t localY(uint16_t py) {
167  auto roc = divu52(py);
168  auto shift = 2 * roc;
169  auto yInRoc = py - 52 * roc;
170  if (yInRoc > 0)
171  shift += 1;
172  return py + shift;
173  }
174 
175  //FIXME move it elsewhere?
184  float endCapZ[2]; // just for pos and neg Layer1
185  };
186 
187 } // namespace phase1PixelTopology
188 
189 #endif // Geometry_TrackerGeometryBuilder_phase1PixelTopology_h
constexpr uint16_t lastRowInModule
constexpr uint32_t findMaxModuleStride()
constexpr uint16_t divu52(uint16_t n)
constexpr uint16_t pixelPitchY
constexpr char const * layerName[numberOfLayers]
float ladderZ[numberOfLaddersInBarrel]
constexpr uint32_t numberOfModulesInBarrel
constexpr uint32_t numberOfLayers
constexpr uint16_t numRowsInRoc
constexpr uint16_t localY(uint16_t py)
constexpr auto map_to_array(Function f) -> std::array< typename std::result_of< Function(std::size_t)>::type, N >
constexpr uint32_t numberOfModules
constexpr uint16_t lastColInModule
constexpr uint16_t numColsInModule
constexpr uint16_t numRowsInModule
constexpr uint16_t lastColInRoc
constexpr std::array< uint8_t, layerIndexSize > layer
constexpr uint32_t layerIndexSize
float ladderR[numberOfLaddersInBarrel]
constexpr uint16_t pixelPitchX
Indices
Definition: EdmEventSize.cc:28
constexpr uint32_t numberOfLaddersInBarrel
constexpr uint16_t numColsInRoc
constexpr bool isEdgeY(uint16_t py)
constexpr uint8_t getLayer(uint32_t detId)
float ladderMinZ[numberOfLaddersInBarrel]
constexpr bool isBigPixY(uint16_t py)
constexpr bool validateLayerIndex()
constexpr bool isEdgeX(uint16_t px)
constexpr uint16_t lastRowInRoc
#define N
Definition: blowfish.cc:9
constexpr bool isBigPixX(uint16_t px)
constexpr int16_t xOffset
constexpr uint16_t localX(uint16_t px)
constexpr uint16_t pixelThickness
constexpr uint32_t maxModuleStride
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)>
float ladderY[numberOfLaddersInBarrel]
float ladderMaxZ[numberOfLaddersInBarrel]
constexpr uint32_t layerStart[numberOfLayers+1]
static unsigned int const shift
constexpr uint32_t numPixsInModule
float ladderX[numberOfLaddersInBarrel]
#define __device__
constexpr int16_t yOffset
tuple size
Write out results.
constexpr uint8_t findLayerFromCompact(uint32_t detId)
constexpr uint16_t toRocX(uint16_t px)
constexpr uint8_t findLayer(uint32_t detId, uint8_t sl=0)
constexpr uint16_t toRocY(uint16_t py)