CMS 3D CMS Logo

EcalPreshowerNumberingScheme.cc
Go to the documentation of this file.
1 // File: EcalPreshowerNumberingScheme.cc
3 // Description: Numbering scheme for preshower detector
5 
8 
9 //#define EDM_ML_DEBUG
10 
12  // For SFLX2a, we use copy# 1-3
13  int vL2ax[3] = {4, 6, 10};
14  int vL2ay[3] = {29, 31, 35};
15  // For SFLX2b, we use copy# 1
16  int vL2bx[1] = {2};
17  int vL2by[1] = {25};
18  // For SFLX3a, we use copy# 4-6
19  int vL3ax[3] = {30, 34, 36};
20  int vL3ay[3] = {35, 31, 29};
21  // For SFLX3b, we use copy# 2
22  int vL3bx[1] = {38};
23  int vL3by[1] = {25};
24  // For SFLX1a, we use odd number in copy# 1-52
25  int vL1ax[26] = {2, 4, 4, 8, 8, 8, 8, 10, 12, 12, 14, 14, 20, 20, 26, 26, 28, 28, 30, 32, 32, 32, 32, 36, 36, 38};
26  int vL1ay[26] = {21, 25, 21, 33, 29, 25, 21, 21, 25, 21, 31, 27, 32,
27  28, 31, 27, 25, 21, 21, 33, 29, 25, 21, 25, 21, 21};
28  // For SFLX1b, we use copy# 2
29  int vL1bx[1] = {22};
30  int vL1by[1] = {27};
31  // For SFLX1c, we use copy# 1
32  int vL1cx[1] = {18};
33  int vL1cy[1] = {27};
34  // For SFLX1d, we use copy# 2
35  int vL1dx[1] = {26};
36  int vL1dy[1] = {23};
37  // For SFLX1e, we use copy# 1
38  int vL1ex[1] = {14};
39  int vL1ey[1] = {23};
40  // For SFLX0a, we use odd number if copy# 1-46
41  int vL0ax[23] = {6, 6, 10, 10, 12, 12, 14, 16, 16, 18, 18, 20, 22, 22, 24, 24, 26, 28, 28, 30, 30, 34, 34};
42  int vL0ay[23] = {26, 21, 30, 25, 34, 29, 35, 36, 31, 36, 31, 36, 36, 31, 36, 31, 35, 34, 29, 30, 25, 26, 21};
43  // For SFL0b, we use copy# 2
44  int vL0bx[1] = {24};
45  int vL0by[1] = {26};
46  // For SFL0c, we use copy# 1
47  int vL0cx[1] = {16};
48  int vL0cy[1] = {26};
49 
50  for (int i = 0; i < 1; ++i) {
51  L1bx[i] = vL1bx[i];
52  L1by[i] = vL1by[i];
53  L1cx[i] = vL1cx[i];
54  L1cy[i] = vL1cy[i];
55  L1dx[i] = vL1dx[i];
56  L1dy[i] = vL1dy[i];
57  L1ex[i] = vL1ex[i];
58  L1ey[i] = vL1ey[i];
59  L0bx[i] = vL0bx[i];
60  L0by[i] = vL0by[i];
61  L0cx[i] = vL0cx[i];
62  L0cy[i] = vL0cy[i];
63  L3bx[i] = vL3bx[i];
64  L3by[i] = vL3by[i];
65  L2bx[i] = vL2bx[i];
66  L2by[i] = vL2by[i];
67  }
68 
69  for (int i = 0; i < 3; ++i) {
70  L3ax[i] = vL3ax[i];
71  L3ay[i] = vL3ay[i];
72  L2ax[i] = vL2ax[i];
73  L2ay[i] = vL2ay[i];
74  }
75 
76  for (int i = 0; i < 23; ++i) {
77  L0ax[i] = vL0ax[i];
78  L0ay[i] = vL0ay[i];
79  }
80 
81  for (int i = 0; i < 26; ++i) {
82  L1ax[i] = vL1ax[i];
83  L1ay[i] = vL1ay[i];
84  }
85 
86  edm::LogVerbatim("EcalGeom") << "Creating EcalPreshowerNumberingScheme";
87 }
88 
90  edm::LogVerbatim("EcalGeom") << "Deleting EcalPreshowerNumberingScheme";
91 }
92 
93 /*
94  * Compute the Ecal Preshower DetId.
95  * General NB: if possible, it would be way better to just access the DetID from a hash map from G4 Volume,
96  * rather than recomputing it for each SimHit - see Tracker.
97  */
98 uint32_t EcalPreshowerNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const {
99  const int numberOfHierarchyLevels = baseNumber.getLevels();
100  uint32_t intIndex = 0;
101  if (numberOfHierarchyLevels > 0) {
102  // depth index - silicon layer 1-st or 2-nd
103  int layer = 0;
104  if (baseNumber.getLevelName(0).find("SFSX") != std::string::npos) {
105  layer = 1;
106  } else if (baseNumber.getLevelName(0).find("SFSY") != std::string::npos) {
107  layer = 2;
108  } else {
109  edm::LogWarning("EcalGeom") << "EcalPreshowerNumberingScheme: Wrong name"
110  << " of Presh. Si. Strip : " << baseNumber.getLevelName(0);
111  }
112 
113  // Access different hierarchy levels
114  static constexpr int stripHierachyLevel = 0;
115  static constexpr int boxHierachyLevel = 2;
116  static constexpr int ladderHierachyLevel = 3;
117  static constexpr int regionHierachyLevel = 5;
118 
119  // Z index +Z = 1 ; -Z = 2
120 
121  int zs = baseNumber.getCopyNumber(regionHierachyLevel);
122  int zside = 2 * (1 - zs) + 1;
123 
124  // box number
125  int box = baseNumber.getCopyNumber(boxHierachyLevel);
126 
127  int x = 0, y = 0, ix, iy, id;
128  int mapX[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
129  int mapY[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
130  const std::string& ladd = baseNumber.getLevelName(3).substr(0, 6);
131  int ladd_copy = baseNumber.getCopyNumber(ladderHierachyLevel);
132 
133  if (ladd == "SFLX0a" || ladd == "SFLY0a") {
134  mapX[5] = mapX[6] = mapX[7] = mapX[8] = mapX[9] = 1;
135  mapY[0] = 0;
136  mapY[1] = 1;
137  mapY[2] = 2;
138  mapY[3] = 3;
139  mapY[4] = 4;
140  mapY[5] = 0;
141  mapY[6] = 1;
142  mapY[7] = 2;
143  mapY[8] = 3;
144  mapY[9] = 4;
145 
146  id = (int)((float)ladd_copy / 2 + 0.5);
147 
148  x = L0ax[id - 1] + mapX[box - 1000 - 1];
149  y = L0ay[id - 1] + mapY[box - 1000 - 1];
150 
151  if ((ladd_copy % 2) == 0) {
152  if (mapX[box - 1000 - 1] == 0)
153  x += 1;
154  else if (mapX[box - 1000 - 1] == 1)
155  x -= 1;
156  y = 41 - y;
157  }
158  }
159  if (ladd == "SFLX0b" || ladd == "SFLY0b") {
160  mapX[4] = mapX[5] = mapX[6] = mapX[7] = mapX[8] = 1;
161  mapY[0] = 1;
162  mapY[1] = 2;
163  mapY[2] = 3;
164  mapY[3] = 4;
165  mapY[4] = 0;
166  mapY[5] = 1;
167  mapY[6] = 2;
168  mapY[7] = 3;
169  mapY[8] = 4;
170  mapY[9] = 0;
171 
172  x = L0bx[0] + mapX[box - 2000 - 1];
173  y = L0by[0] + mapY[box - 2000 - 1];
174 
175  if (ladd_copy == 1) {
176  x = 41 - x;
177  y = 41 - y;
178  }
179  }
180  if (ladd == "SFLX0c" || ladd == "SFLY0c") {
181  mapX[5] = mapX[6] = mapX[7] = mapX[8] = 1;
182  mapY[0] = 0;
183  mapY[1] = 1;
184  mapY[2] = 2;
185  mapY[3] = 3;
186  mapY[4] = 4;
187  mapY[5] = 1;
188  mapY[6] = 2;
189  mapY[7] = 3;
190  mapY[8] = 4;
191  mapY[9] = 0;
192 
193  x = L0cx[0] + mapX[box - 3000 - 1];
194  y = L0cy[0] + mapY[box - 3000 - 1];
195 
196  if (ladd_copy == 2) {
197  x = 41 - x;
198  y = 41 - y;
199  }
200  }
201  if (ladd == "SFLX1a" || ladd == "SFLY1a") {
202  mapX[4] = mapX[5] = mapX[6] = mapX[7] = 1;
203  mapY[0] = 0;
204  mapY[1] = 1;
205  mapY[2] = 2;
206  mapY[3] = 3;
207  mapY[4] = 0;
208  mapY[5] = 1;
209  mapY[6] = 2;
210  mapY[7] = 3;
211  mapY[8] = 0;
212  mapY[9] = 0;
213 
214  id = (int)((float)ladd_copy / 2 + 0.5);
215 
216  x = L1ax[id - 1] + mapX[box - 4000 - 1];
217  y = L1ay[id - 1] + mapY[box - 4000 - 1];
218 
219  if ((ladd_copy % 2) == 0) {
220  if (mapX[box - 4000 - 1] == 0)
221  x += 1;
222  else if (mapX[box - 4000 - 1] == 1)
223  x -= 1;
224  y = 41 - y;
225  }
226  }
227  if (ladd == "SFLX1b" || ladd == "SFLY1b") {
228  mapX[3] = mapX[4] = mapX[5] = mapX[6] = 1;
229  mapY[0] = 1;
230  mapY[1] = 2;
231  mapY[2] = 3;
232  mapY[3] = 0;
233  mapY[4] = 1;
234  mapY[5] = 2;
235  mapY[6] = 3;
236  mapY[7] = 0;
237  mapY[8] = 0;
238  mapY[9] = 0;
239 
240  x = L1bx[0] + mapX[box - 5000 - 1];
241  y = L1by[0] + mapY[box - 5000 - 1];
242 
243  if (ladd_copy == 1) {
244  x = 41 - x;
245  y = 41 - y;
246  }
247  }
248  if (ladd == "SFLX1c" || ladd == "SFLY1c") {
249  mapX[4] = mapX[5] = mapX[6] = 1;
250  mapY[0] = 0;
251  mapY[1] = 1;
252  mapY[2] = 2;
253  mapY[3] = 3;
254  mapY[4] = 1;
255  mapY[5] = 2;
256  mapY[6] = 3;
257  mapY[7] = 0;
258  mapY[8] = 0;
259  mapY[9] = 0;
260 
261  x = L1cx[0] + mapX[box - 6000 - 1];
262  y = L1cy[0] + mapY[box - 6000 - 1];
263 
264  if (ladd_copy == 2) {
265  x = 41 - x;
266  y = 41 - y;
267  }
268  }
269  if (ladd == "SFLX1d" || ladd == "SFLY1d") {
270  mapX[2] = mapX[3] = mapX[4] = mapX[5] = 1;
271  mapY[0] = 2;
272  mapY[1] = 3;
273  mapY[2] = 0;
274  mapY[3] = 1;
275  mapY[4] = 2;
276  mapY[5] = 3;
277  mapY[6] = 0;
278  mapY[7] = 0;
279  mapY[8] = 0;
280  mapY[9] = 0;
281 
282  x = L1dx[0] + mapX[box - 7000 - 1];
283  y = L1dy[0] + mapY[box - 7000 - 1];
284 
285  if (ladd_copy == 1) {
286  x = 41 - x;
287  y = 41 - y;
288  }
289  }
290  if (ladd == "SFLX1e" || ladd == "SFLY1e") {
291  mapX[4] = mapX[5] = 1;
292  mapY[0] = 0;
293  mapY[1] = 1;
294  mapY[2] = 2;
295  mapY[3] = 3;
296  mapY[4] = 2;
297  mapY[5] = 3;
298  mapY[6] = 0;
299  mapY[7] = 0;
300  mapY[8] = 0;
301  mapY[9] = 0;
302 
303  x = L1ex[0] + mapX[box - 8000 - 1];
304  y = L1ey[0] + mapY[box - 8000 - 1];
305 
306  if (ladd_copy == 2) {
307  x = 41 - x;
308  y = 41 - y;
309  }
310  }
311  if (ladd == "SFLX3a" || ladd == "SFLY3a") {
312  mapX[4] = mapX[5] = mapX[6] = 1;
313  mapY[0] = 0;
314  mapY[1] = 1;
315  mapY[2] = 2;
316  mapY[3] = 3;
317  mapY[4] = 0;
318  mapY[5] = 1;
319  mapY[6] = 2;
320  mapY[7] = 0;
321  mapY[8] = 0;
322  mapY[9] = 0;
323 
324  id = (ladd_copy > 3) ? ladd_copy - 3 : 4 - ladd_copy;
325 
326  x = L3ax[id - 1] + mapX[box - 9000 - 1];
327  y = L3ay[id - 1] + mapY[box - 9000 - 1];
328 
329  if (ladd_copy < 4) {
330  x = 41 - x;
331  y = 41 - y;
332  }
333  }
334  if (ladd == "SFLX3b" || ladd == "SFLY3b") {
335  mapX[4] = mapX[5] = 1;
336  mapY[0] = 0;
337  mapY[1] = 1;
338  mapY[2] = 2;
339  mapY[3] = 3;
340  mapY[4] = 0;
341  mapY[5] = 1;
342  mapY[6] = 0;
343  mapY[7] = 0;
344  mapY[8] = 0;
345  mapY[9] = 0;
346 
347  x = L3bx[0] + mapX[box - 11000 - 1];
348  y = L3by[0] + mapY[box - 11000 - 1];
349 
350  if (ladd_copy == 1) {
351  x = 41 - x;
352  y = 41 - y;
353  }
354  }
355  if (ladd == "SFLX2a" || ladd == "SFLY2a") {
356  mapX[3] = mapX[4] = mapX[5] = mapX[6] = 1;
357  mapY[0] = 0;
358  mapY[1] = 1;
359  mapY[2] = 2;
360  mapY[3] = 0;
361  mapY[4] = 1;
362  mapY[5] = 2;
363  mapY[6] = 3;
364  mapY[7] = 0;
365  mapY[8] = 0;
366  mapY[9] = 0;
367 
368  id = (ladd_copy > 3) ? 7 - ladd_copy : ladd_copy;
369 
370  x = L2ax[id - 1] + mapX[box - 10000 - 1];
371  y = L2ay[id - 1] + mapY[box - 10000 - 1];
372 
373  if (ladd_copy > 3) {
374  x = 41 - x;
375  y = 41 - y;
376  }
377  }
378  if (ladd == "SFLX2b" || ladd == "SFLY2b") {
379  mapX[2] = mapX[3] = mapX[4] = mapX[5] = 1;
380  mapY[0] = 0;
381  mapY[1] = 1;
382  mapY[2] = 0;
383  mapY[3] = 1;
384  mapY[4] = 2;
385  mapY[5] = 3;
386  mapY[6] = 0;
387  mapY[7] = 0;
388  mapY[8] = 0;
389  mapY[9] = 0;
390 
391  x = L2bx[0] + mapX[box - 12000 - 1];
392  y = L2by[0] + mapY[box - 12000 - 1];
393 
394  if (ladd_copy == 2) {
395  x = 41 - x;
396  y = 41 - y;
397  }
398  }
399 
400  if (zside < 0 && layer == 1)
401  x = 41 - x;
402 
403  ix = x;
404  iy = y;
405 
406  if (layer == 2) {
407  x = (zside > 0) ? iy : 41 - iy;
408  y = 41 - ix;
409  }
410 
411  // strip number inside wafer
412  int strip = baseNumber.getCopyNumber(stripHierachyLevel);
413 
414  if (layer == 1) {
415  if (zside > 0 && y <= 20)
416  strip = 33 - strip;
417  else if (zside < 0 && y > 20)
418  strip = 33 - strip;
419  } else if (layer == 2) {
420  if (zside > 0 && x <= 20)
421  strip = 33 - strip;
422  else if (zside < 0 && x > 20)
423  strip = 33 - strip;
424  }
425 
426  intIndex = ESDetId(strip, x, y, layer, zside).rawId();
427 
428 #ifdef EDM_ML_DEBUG
429  edm::LogVerbatim("EcalGeom") << "EcalPreshowerNumberingScheme : zside " << zs << ":" << zside << " Ladd " << ladd
430  << " ladd_copy: " << ladd_copy << " box " << box << " x " << x << " y " << y
431  << " layer " << layer << " strip " << strip << " UnitID 0x" << std::hex << intIndex
432  << std::dec;
433 
434  for (int ich = 0; ich < numberOfHierarchyLevels; ich++)
435  edm::LogVerbatim("EcalGeom") << "Name = " << baseNumber.getLevelName(ich)
436  << " copy = " << baseNumber.getCopyNumber(ich);
437 #endif
438  }
439 
440  return intIndex;
441 }
EcalPreshowerNumberingScheme::L0by
int L0by[1]
Definition: EcalPreshowerNumberingScheme.h:38
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
EcalPreshowerNumberingScheme::L1dy
int L1dy[1]
Definition: EcalPreshowerNumberingScheme.h:32
EcalBaseNumber::getCopyNumber
int getCopyNumber(int level) const
Definition: EcalBaseNumber.cc:24
EcalBaseNumber::getLevelName
std::string const & getLevelName(int level) const
Definition: EcalBaseNumber.cc:35
EcalPreshowerNumberingScheme::L1ex
int L1ex[1]
Definition: EcalPreshowerNumberingScheme.h:33
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
EcalPreshowerNumberingScheme::L3bx
int L3bx[1]
Definition: EcalPreshowerNumberingScheme.h:19
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
EcalPreshowerNumberingScheme::L3by
int L3by[1]
Definition: EcalPreshowerNumberingScheme.h:20
EcalPreshowerNumberingScheme::~EcalPreshowerNumberingScheme
~EcalPreshowerNumberingScheme() override
Definition: EcalPreshowerNumberingScheme.cc:89
EcalBaseNumber
Definition: EcalBaseNumber.h:12
ESDetId
Definition: ESDetId.h:15
DDAxes::x
ESDetId.h
EcalPreshowerNumberingScheme::getUnitID
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
Definition: EcalPreshowerNumberingScheme.cc:98
EcalPreshowerNumberingScheme::L0cy
int L0cy[1]
Definition: EcalPreshowerNumberingScheme.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalPreshowerNumberingScheme::L2bx
int L2bx[1]
Definition: EcalPreshowerNumberingScheme.h:23
EcalPreshowerNumberingScheme::L0ax
int L0ax[23]
Definition: EcalPreshowerNumberingScheme.h:35
EcalPreshowerNumberingScheme::L2by
int L2by[1]
Definition: EcalPreshowerNumberingScheme.h:24
EcalPreshowerNumberingScheme::L2ax
int L2ax[3]
Definition: EcalPreshowerNumberingScheme.h:21
EcalNumberingScheme
Definition: EcalNumberingScheme.h:14
EcalPreshowerNumberingScheme::L1cy
int L1cy[1]
Definition: EcalPreshowerNumberingScheme.h:30
EcalPreshowerNumberingScheme::L1bx
int L1bx[1]
Definition: EcalPreshowerNumberingScheme.h:27
EcalPreshowerNumberingScheme::L3ay
int L3ay[3]
Definition: EcalPreshowerNumberingScheme.h:18
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
createfilelist.int
int
Definition: createfilelist.py:10
EcalPreshowerNumberingScheme::L1cx
int L1cx[1]
Definition: EcalPreshowerNumberingScheme.h:29
EcalPreshowerNumberingScheme::EcalPreshowerNumberingScheme
EcalPreshowerNumberingScheme()
Definition: EcalPreshowerNumberingScheme.cc:11
EcalPreshowerNumberingScheme::L1ax
int L1ax[26]
Definition: EcalPreshowerNumberingScheme.h:25
EcalPreshowerNumberingScheme::L0ay
int L0ay[23]
Definition: EcalPreshowerNumberingScheme.h:36
EcalPreshowerNumberingScheme::L0cx
int L0cx[1]
Definition: EcalPreshowerNumberingScheme.h:39
EcalBaseNumber::getLevels
int getLevels() const
Definition: EcalBaseNumber.cc:22
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
EcalPreshowerNumberingScheme::L1by
int L1by[1]
Definition: EcalPreshowerNumberingScheme.h:28
EcalPreshowerNumberingScheme.h
EcalPreshowerNumberingScheme::L3ax
int L3ax[3]
Definition: EcalPreshowerNumberingScheme.h:17
EcalPreshowerNumberingScheme::L1ay
int L1ay[26]
Definition: EcalPreshowerNumberingScheme.h:26
EcalPreshowerNumberingScheme::L0bx
int L0bx[1]
Definition: EcalPreshowerNumberingScheme.h:37
EcalPreshowerNumberingScheme::L2ay
int L2ay[3]
Definition: EcalPreshowerNumberingScheme.h:22
EcalPreshowerNumberingScheme::L1dx
int L1dx[1]
Definition: EcalPreshowerNumberingScheme.h:31
edm::Log
Definition: MessageLogger.h:70
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
EcalPreshowerNumberingScheme::L1ey
int L1ey[1]
Definition: EcalPreshowerNumberingScheme.h:34