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 #include <iostream>
10 using namespace std;
11 
14 
15  // For SFLX2a, we use copy# 1-3
16  int vL2ax[3] = { 4, 6, 10};
17  int vL2ay[3] = {29, 31, 35};
18  // For SFLX2b, we use copy# 1
19  int vL2bx[1] = {2};
20  int vL2by[1] = {25};
21  // For SFLX3a, we use copy# 4-6
22  int vL3ax[3] = {30, 34, 36};
23  int vL3ay[3] = {35, 31, 29};
24  // For SFLX3b, we use copy# 2
25  int vL3bx[1] = {38};
26  int vL3by[1] = {25};
27  // For SFLX1a, we use odd number in copy# 1-52
28  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};
29  int vL1ay[26] = {21, 25, 21, 33, 29, 25, 21, 21, 25, 21, 31, 27, 32, 28, 31, 27, 25, 21, 21, 33, 29, 25, 21, 25, 21, 21};
30  // For SFLX1b, we use copy# 2
31  int vL1bx[1] = {22};
32  int vL1by[1] = {27};
33  // For SFLX1c, we use copy# 1
34  int vL1cx[1] = {18};
35  int vL1cy[1] = {27};
36  // For SFLX1d, we use copy# 2
37  int vL1dx[1] = {26};
38  int vL1dy[1] = {23};
39  // For SFLX1e, we use copy# 1
40  int vL1ex[1] = {14};
41  int vL1ey[1] = {23};
42  // For SFLX0a, we use odd number if copy# 1-46
43  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};
44  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};
45  // For SFL0b, we use copy# 2
46  int vL0bx[1] = {24};
47  int vL0by[1] = {26};
48  // For SFL0c, we use copy# 1
49  int vL0cx[1] = {16};
50  int vL0cy[1] = {26};
51 
52  for (int i=0; i<1; ++i) {
53  L1bx[i] = vL1bx[i];
54  L1by[i] = vL1by[i];
55  L1cx[i] = vL1cx[i];
56  L1cy[i] = vL1cy[i];
57  L1dx[i] = vL1dx[i];
58  L1dy[i] = vL1dy[i];
59  L1ex[i] = vL1ex[i];
60  L1ey[i] = vL1ey[i];
61  L0bx[i] = vL0bx[i];
62  L0by[i] = vL0by[i];
63  L0cx[i] = vL0cx[i];
64  L0cy[i] = vL0cy[i];
65  L3bx[i] = vL3bx[i];
66  L3by[i] = vL3by[i];
67  L2bx[i] = vL2bx[i];
68  L2by[i] = vL2by[i];
69  }
70 
71  for (int i=0; i<3; ++i) {
72  L3ax[i] = vL3ax[i];
73  L3ay[i] = vL3ay[i];
74  L2ax[i] = vL2ax[i];
75  L2ay[i] = vL2ay[i];
76  }
77 
78  for (int i=0; i<23; ++i) {
79  L0ax[i] = vL0ax[i];
80  L0ay[i] = vL0ay[i];
81  }
82 
83  for (int i=0; i<26; ++i) {
84  L1ax[i] = vL1ax[i];
85  L1ay[i] = vL1ay[i];
86  }
87 
88  edm::LogInfo("EcalGeom") << "Creating EcalPreshowerNumberingScheme";
89 }
90 
92  edm::LogInfo("EcalGeom") << "Deleting EcalPreshowerNumberingScheme";
93 }
94 
95 uint32_t EcalPreshowerNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const {
96 
97  int level = baseNumber.getLevels();
98  uint32_t intIndex = 0;
99  if (level > 0) {
100 
101  // depth index - silicon layer 1-st or 2-nd
102  int layer = 0;
103  if(baseNumber.getLevelName(0) == "SFSX") {
104  layer = 1;
105  } else if (baseNumber.getLevelName(0) == "SFSY") {
106  layer = 2;
107  } else {
108  edm::LogWarning("EcalGeom") << "EcalPreshowerNumberingScheme: Wrong name"
109  << " of Presh. Si. Strip : "
110  << baseNumber.getLevelName(0);
111  }
112 
113  // Z index +Z = 1 ; -Z = 2
114  int zside = baseNumber.getCopyNumber("EREG");
115  zside=2*(1-zside)+1;
116 
117  // box number
118  int box = baseNumber.getCopyNumber(2);
119 
120  int x=0,y=0,ix,iy,id;
121  int mapX[10] ={0,0,0,0,0,0,0,0,0,0}; int mapY[10] ={0,0,0,0,0,0,0,0,0,0};
122  const std::string& ladd = baseNumber.getLevelName(3);
123  int ladd_copy = baseNumber.getCopyNumber(3);
124 
125  if(ladd=="SFLX0a" || ladd=="SFLY0a" ) {
126  mapX[5] = mapX[6] = mapX[7] = mapX[8] = mapX[9] = 1;
127  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 4;
128  mapY[5] = 0; mapY[6] = 1; mapY[7] = 2; mapY[8] = 3; mapY[9] = 4;
129 
130  id = (int) ((float)ladd_copy/2+0.5);
131 
132  x = L0ax[id-1] + mapX[box-1000-1];
133  y = L0ay[id-1] + mapY[box-1000-1];
134 
135  if ((ladd_copy%2) == 0) {
136  if (mapX[box-1000-1]==0) x += 1;
137  else if (mapX[box-1000-1]==1) x -= 1;
138  y = 41 - y;
139  }
140  }
141  if(ladd=="SFLX0b" || ladd=="SFLY0b") {
142  mapX[4] = mapX[5] = mapX[6] = mapX[7] = mapX[8] = 1;
143  mapY[0] = 1; mapY[1] = 2; mapY[2] = 3; mapY[3] = 4; mapY[4] = 0;
144  mapY[5] = 1; mapY[6] = 2; mapY[7] = 3; mapY[8] = 4; mapY[9] = 0;
145 
146  x = L0bx[0] + mapX[box-2000-1];
147  y = L0by[0] + mapY[box-2000-1];
148 
149  if (ladd_copy == 1) {
150  x = 41 - x;
151  y = 41 - y;
152  }
153  }
154  if(ladd=="SFLX0c" || ladd=="SFLY0c") {
155  mapX[5] = mapX[6] = mapX[7] = mapX[8] = 1;
156  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 4;
157  mapY[5] = 1; mapY[6] = 2; mapY[7] = 3; mapY[8] = 4; mapY[9] = 0;
158 
159  x = L0cx[0] + mapX[box-3000-1];
160  y = L0cy[0] + mapY[box-3000-1];
161 
162  if (ladd_copy == 2) {
163  x = 41 - x;
164  y = 41 - y;
165  }
166  }
167  if(ladd=="SFLX1a" || ladd=="SFLY1a" ) {
168  mapX[4] = mapX[5] = mapX[6] = mapX[7] = 1;
169  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 0;
170  mapY[5] = 1; mapY[6] = 2; mapY[7] = 3; mapY[8] = 0; mapY[9] = 0;
171 
172  id = (int) ((float)ladd_copy/2+0.5);
173 
174  x = L1ax[id-1] + mapX[box-4000-1];
175  y = L1ay[id-1] + mapY[box-4000-1];
176 
177  if ((ladd_copy%2) == 0) {
178  if (mapX[box-4000-1]==0) x += 1;
179  else if (mapX[box-4000-1]==1) x -= 1;
180  y = 41 - y;
181  }
182  }
183  if(ladd=="SFLX1b" || ladd=="SFLY1b" ) {
184  mapX[3] = mapX[4] = mapX[5] = mapX[6] = 1;
185  mapY[0] = 1; mapY[1] = 2; mapY[2] = 3; mapY[3] = 0; mapY[4] = 1;
186  mapY[5] = 2; mapY[6] = 3; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
187 
188  x = L1bx[0] + mapX[box-5000-1];
189  y = L1by[0] + mapY[box-5000-1];
190 
191  if (ladd_copy == 1) {
192  x = 41 - x;
193  y = 41 - y;
194  }
195  }
196  if(ladd=="SFLX1c" || ladd=="SFLY1c" ) {
197  mapX[4] = mapX[5] = mapX[6] = 1;
198  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 1;
199  mapY[5] = 2; mapY[6] = 3; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
200 
201  x = L1cx[0] + mapX[box-6000-1];
202  y = L1cy[0] + mapY[box-6000-1];
203 
204  if (ladd_copy == 2) {
205  x = 41 - x;
206  y = 41 - y;
207  }
208  }
209  if(ladd=="SFLX1d" || ladd=="SFLY1d" ) {
210  mapX[2] = mapX[3] = mapX[4] = mapX[5] = 1;
211  mapY[0] = 2; mapY[1] = 3; mapY[2] = 0; mapY[3] = 1; mapY[4] = 2;
212  mapY[5] = 3; mapY[6] = 0; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
213 
214  x = L1dx[0] + mapX[box-7000-1];
215  y = L1dy[0] + mapY[box-7000-1];
216 
217  if (ladd_copy == 1) {
218  x = 41 - x;
219  y = 41 - y;
220  }
221  }
222  if(ladd=="SFLX1e" || ladd=="SFLY1e") {
223  mapX[4] = mapX[5] = 1;
224  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 2;
225  mapY[5] = 3; mapY[6] = 0; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
226 
227  x = L1ex[0] + mapX[box-8000-1];
228  y = L1ey[0] + mapY[box-8000-1];
229 
230  if (ladd_copy == 2) {
231  x = 41 - x;
232  y = 41 - y;
233  }
234  }
235  if(ladd=="SFLX3a" || ladd=="SFLY3a" ) {
236  mapX[4] = mapX[5] = mapX[6] = 1;
237  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 0;
238  mapY[5] = 1; mapY[6] = 2; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
239 
240  id = (ladd_copy>3)? ladd_copy-3 : 4-ladd_copy;
241 
242  x = L3ax[id-1] + mapX[box-9000-1];
243  y = L3ay[id-1] + mapY[box-9000-1];
244 
245  if (ladd_copy<4) {
246  x = 41 - x;
247  y = 41 - y;
248  }
249  }
250  if(ladd=="SFLX3b" || ladd=="SFLY3b") {
251  mapX[4] = mapX[5] = 1;
252  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 0;
253  mapY[5] = 1; mapY[6] = 0; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
254 
255  x = L3bx[0] + mapX[box-11000-1];
256  y = L3by[0] + mapY[box-11000-1];
257 
258  if (ladd_copy == 1) {
259  x = 41 - x;
260  y = 41 - y;
261  }
262  }
263  if(ladd=="SFLX2a" || ladd=="SFLY2a") {
264  mapX[3] = mapX[4] = mapX[5] = mapX[6] = 1;
265  mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 0; mapY[4] = 1;
266  mapY[5] = 2; mapY[6] = 3; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
267 
268  id = (ladd_copy>3)? 7-ladd_copy : ladd_copy;
269 
270  x = L2ax[id-1] + mapX[box-10000-1];
271  y = L2ay[id-1] + mapY[box-10000-1];
272 
273  if (ladd_copy>3) {
274  x = 41 - x;
275  y = 41 - y;
276  }
277  }
278  if(ladd=="SFLX2b" || ladd=="SFLY2b") {
279  mapX[2] = mapX[3] = mapX[4] = mapX[5] = 1;
280  mapY[0] = 0; mapY[1] = 1; mapY[2] = 0; mapY[3] = 1; mapY[4] = 2;
281  mapY[5] = 3; mapY[6] = 0; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0;
282 
283  x = L2bx[0] + mapX[box-12000-1];
284  y = L2by[0] + mapY[box-12000-1];
285 
286  if (ladd_copy == 2) {
287  x = 41 - x;
288  y = 41 - y;
289  }
290  }
291 
292  if (zside<0 && layer == 1) x = 41 - x;
293 
294  ix = x;
295  iy = y;
296 
297  if (layer == 2) {
298  x = (zside>0) ? iy : 41 - iy;
299  y = 41 - ix;
300  }
301 
302  // strip number inside wafer
303  int strip = baseNumber.getCopyNumber(0);
304 
305  if (layer == 1) {
306  if (zside>0 && y<=20)
307  strip = 33 - strip;
308  else if (zside<0 && y>20)
309  strip = 33 - strip;
310  } else if (layer == 2) {
311  if (zside>0 && x<=20)
312  strip = 33 - strip;
313  else if (zside<0 && x>20)
314  strip = 33 -strip;
315  }
316 
317  intIndex = ESDetId(strip, x, y, layer, zside).rawId();
318 
319  LogDebug("EcalGeom") << "EcalPreshowerNumberingScheme : zside "<<zside<<" Ladd "<< ladd << " ladd_copy: "<<ladd_copy<<" box "<<box<<" x "<<x<<" y "<<y<<" layer "<<layer<<" strip " << strip<<" UnitID 0x" << std::hex << intIndex << std::dec;
320 
321  for (int ich = 0; ich < level; ich++) {
322  LogDebug("EcalGeom") << "Name = " << baseNumber.getLevelName(ich)
323  << " copy = " << baseNumber.getCopyNumber(ich);
324  }
325  }
326 
327  return intIndex;
328 }
329 
#define LogDebug(id)
std::string const & getLevelName(int level) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
int getCopyNumber(int level) const
int zside(DetId const &)
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
int getLevels() const