CMS 3D CMS Logo

MEEBGeom.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cstdlib>
3 #include <string>
4 #include <cassert>
5 using namespace std;
6 
9 
10 #include <TGraph.h>
11 
12 //GHM ClassImp(MEEBGeom)
13 
15  int iz = 1;
16  if (ieta < 0)
17  iz = -1;
18  ieta *= iz;
19  assert(ieta > 0 && ieta <= 85);
20  if (iphi < 0)
21  iphi += 360;
22  assert(iphi > 0 && iphi <= 360);
23  return iz;
24 }
25 
27  int iz = 1;
28  if (ieta < 0)
29  iz = -1;
30  ieta *= iz;
31  assert(ieta > 0 && ieta <= 85);
32 
33  // int iphi_ = iphi+10;
34  int iphi_ = iphi;
35  if (iphi_ > 360)
36  iphi_ -= 360;
37  assert(iphi_ > 0 && iphi_ <= 360);
38 
39  int ism = (iphi_ - 1) / 20 + 1;
40  assert(ism >= 1 && ism <= 18);
41  // if( iz==1 ) ism += 18;
42  if (iz == -1)
43  ism += 18;
44 
45  return ism;
46 }
47 
49  int ism = sm(ieta, iphi);
50  return dccFromSm(ism);
51 }
52 
54  assert(ism >= 1 && ism <= 36);
55  int iz = 1;
56  if (ism > 18)
57  iz = -1;
58  if (iz == -1)
59  ism -= 18;
60  assert(ism >= 1 && ism <= 18);
61  int idcc = 9 + ism;
62  if (iz == +1)
63  idcc += 18;
64  return idcc;
65 }
66 
67 int MEEBGeom::smFromDcc(int idcc) {
68  if (idcc > 600)
69  idcc -= 600; // also works with FEDids
70  assert(idcc >= 10 && idcc <= 45);
71  int ism = idcc - 9;
72  if (ism > 18)
73  ism -= 18;
74  else
75  ism += 18;
76  return ism;
77 }
78 
79 TString MEEBGeom::smName(int ism) {
80  assert(ism >= 1 && ism <= 36);
81  TString out = "EB+";
82  if (ism > 18) {
83  out = "EB-";
84  ism -= 18;
85  }
86  out += ism;
87  return out;
88 }
89 
91  std::pair<EBLocalCoord, EBLocalCoord> ixy = localCoord(ieta, iphi);
92  return lm_channel(ixy.first / 5, ixy.second / 5);
93 }
94 
96  std::pair<EBLocalCoord, EBLocalCoord> ixy = localCoord(ieta, iphi);
97  return tt_channel(ixy.first / 5, ixy.second / 5);
98 }
99 
101  std::pair<EBLocalCoord, EBLocalCoord> ixy = localCoord(ieta, iphi);
102  return crystal_channel(ixy.first, ixy.second);
103 }
104 
106  int ilmmod = lmmod(ieta, iphi);
107  return (ilmmod % 2 == 0) ? 1 : 0;
108 }
109 
111  int idcc = dcc(ieta, iphi);
112  int ism = idcc - 9;
113  int iside = side(ieta, iphi);
114  int ilmr = 1 + 2 * (ism - 1) + iside;
115  return ilmr;
116 }
117 
118 std::pair<MEEBGeom::EBLocalCoord, MEEBGeom::EBLocalCoord> MEEBGeom::localCoord(MEEBGeom::EBGlobalCoord ieta,
120  int iz = 1;
121  if (ieta < 0)
122  iz = -1;
123  ieta *= iz;
124  assert(ieta > 0 && ieta <= 85);
125 
126  // int iphi_ = iphi+10;
127  int iphi_ = iphi;
128  if (iphi_ > 360)
129  iphi_ -= 360;
130  assert(iphi_ > 0 && iphi_ <= 360);
131 
132  int ix = ieta - 1;
133 
134  int iy = (iphi_ - 1) % 20;
135  if (iz == -1)
136  iy = 19 - iy;
137  // if( iz==1 ) iy = 19-iy;
138 
139  return std::pair<EBLocalCoord, EBLocalCoord>(ix, iy);
140 }
141 
142 std::pair<MEEBGeom::EBLocalCoord, MEEBGeom::EBLocalCoord> MEEBGeom::localCoord(int icr) {
143  assert(icr >= 1 && icr <= 1700);
144  int ix = (icr - 1) / 20;
145  int iy = 19 - (icr - 1) % 20;
146  return std::pair<EBLocalCoord, EBLocalCoord>(ix, iy);
147 }
148 
149 std::pair<MEEBGeom::EBGlobalCoord, MEEBGeom::EBGlobalCoord> MEEBGeom::globalCoord(int ism,
152  assert(ism >= 1 && ism <= 36);
153  assert(ix >= 0 && ix < 85);
154  assert(iy >= 0 && iy < 20);
155  // int iz=-1;
156  int iz = 1;
157  if (ism > 18) {
158  iz = -1;
159  ism -= 18;
160  }
161  if (iz == -1)
162  iy = 19 - iy;
163  // if( iz==1 ) iy = 19-iy;
164 
165  int ieta = ix + 1;
166  ieta *= iz;
167  // int iphi = -9 + iy + 20*(ism-1);
168  int iphi = 1 + iy + 20 * (ism - 1);
169 
170  return std::pair<EBGlobalCoord, EBGlobalCoord>(ieta, iphi);
171 }
172 
173 std::pair<float, float> MEEBGeom::globalCoord(int ism, float x, float y) {
174  assert(ism >= 1 && ism <= 36);
175  int iz = 1;
176  if (ism > 18) {
177  iz = -1;
178  ism -= 18;
179  }
180  if (iz == -1)
181  y = 19 - y;
182 
183  float eta = x + 1;
184  eta *= iz;
185  // float phi = -9 + y + 20*(ism-1);
186  float phi = 1 + y + 20 * (ism - 1);
187 
188  return std::pair<float, float>(eta, phi);
189 }
190 
191 std::pair<MEEBGeom::EBGlobalCoord, MEEBGeom::EBGlobalCoord> MEEBGeom::globalCoord(int ism, int icr) {
192  assert(ism >= 1 && ism <= 36);
193  assert(icr >= 1 && icr <= 1700);
194 
195  int ix = (icr - 1) / 20;
196  int iy = 19 - (icr - 1) % 20;
197 
198  return globalCoord(ism, ix, iy);
199 }
200 
202  static const int idx_[] = {
203  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
204  1, 2, 2, 2, 2, 4, 4, 4, 4,
205  6, 6, 6, 6, 8, 8, 8, 8, // 3
206  1, 2, 2, 2, 2, 4, 4, 4, 4,
207  6, 6, 6, 6, 8, 8, 8, 8, // 2
208  1, 3, 3, 3, 3, 5, 5, 5, 5,
209  7, 7, 7, 7, 9, 9, 9, 9, // 1
210  1, 3, 3, 3, 3, 5, 5, 5, 5,
211  7, 7, 7, 7, 9, 9, 9, 9 // 0
212  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
213  };
214 
215  int iym, ixm, il, ic, ii;
216  iym = 4;
217  ixm = 17;
218  int iX_ = iX + 1;
219  int iY_ = iY + 1;
220  il = iym - iY_;
221  ic = iX_ - 1;
222  ii = il * ixm + ic;
223  if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int))) {
224  return -1;
225  };
226  return idx_[ii];
227 }
228 
230  static const int idx_[] = {
231  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
232  1, 1, 1, 2, 2, 1, 1, 2, 2,
233  1, 1, 2, 2, 1, 1, 2, 2, // 3
234  1, 1, 1, 2, 2, 1, 1, 2, 2,
235  1, 1, 2, 2, 1, 1, 2, 2, // 2
236  1, 1, 1, 2, 2, 1, 1, 2, 2,
237  1, 1, 2, 2, 1, 1, 2, 2, // 1
238  1, 1, 1, 2, 2, 1, 1, 2, 2,
239  1, 1, 2, 2, 1, 1, 2, 2 // 0
240  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
241  };
242 
243  int iym, ixm, il, ic, ii;
244  iym = 4;
245  ixm = 17;
246  int iX_ = iX + 1;
247  int iY_ = iY + 1;
248  il = iym - iY_;
249  ic = iX_ - 1;
250  ii = il * ixm + ic;
251  if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int))) {
252  return -1;
253  };
254  return idx_[ii];
255 }
256 
258  static const int idx_[] = {
259  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
260  1, 3, 5, 7, 9, 11, 13, 15, 17,
261  19, 21, 23, 25, 27, 29, 31, 33, // 3
262  1, 3, 5, 7, 9, 11, 13, 15, 17,
263  19, 21, 23, 25, 27, 29, 31, 33, // 2
264  2, 4, 6, 8, 10, 12, 14, 16, 18,
265  20, 22, 24, 26, 28, 30, 32, 34, // 1
266  2, 4, 6, 8, 10, 12, 14, 16, 18,
267  20, 22, 24, 26, 28, 30, 32, 34 // 0
268  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
269  };
270 
271  int iym, ixm, il, ic, ii;
272  iym = 4;
273  ixm = 17;
274  int iX_ = iX + 1;
275  int iY_ = iY + 1;
276  il = iym - iY_;
277  ic = iX_ - 1;
278  ii = il * ixm + ic;
279  if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int))) {
280  return -1;
281  };
282  return idx_[ii];
283 }
284 
286  static const int idx_[] = {
287  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
288  1, 2, 2, 4, 4, 6, 6, 8, 8,
289  10, 10, 12, 12, 14, 14, 16, 16, // 3
290  1, 2, 2, 4, 4, 6, 6, 8, 8,
291  10, 10, 12, 12, 14, 14, 16, 16, // 2
292  1, 3, 3, 5, 5, 7, 7, 9, 9,
293  11, 11, 13, 13, 15, 15, 17, 17, // 1
294  1, 3, 3, 5, 5, 7, 7, 9, 9,
295  11, 11, 13, 13, 15, 15, 17, 17 // 0
296  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
297  };
298 
299  int iym, ixm, il, ic, ii;
300  iym = 4;
301  ixm = 17;
302  int iX_ = iX + 1;
303  int iY_ = iY + 1;
304  il = iym - iY_;
305  ic = iX_ - 1;
306  ii = il * ixm + ic;
307  if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int))) {
308  return -1;
309  };
310  return idx_[ii];
311 }
312 
314  int itt = 4 * iX + 4 - iY; // :)
315 
316  return itt;
317 }
318 
320  // "Test beam numbering"
321  int icr = 20 * ix + 19 - iy + 1; // :)
322 
323  return icr;
324 }
325 
327  int iX = ix / 5;
328  int iY = iy / 5;
329  int itt = tt_channel(iX, iY);
330  int type = tt_type(iX, iY);
331 
332  int iVFE = ix % 5 + 1;
333  int islot = iy % 5 + 1;
334  if (iVFE % 2 == 1)
335  islot = 6 - islot;
336  int icr = 5 * (iVFE - 1) + (islot - 1);
337  // rotate for type-1 towers
338  if (type == 1) {
339  icr = 24 - icr;
340  }
341  icr += 25 * (itt - 1);
342 
343  return icr;
344 }
345 
346 TGraph* MEEBGeom::getGraphBoundary(int type, int num, bool global) {
347  int ism_ = 0;
348  if (type == iSuperModule) {
349  ism_ = num;
350  } else if (type == iLMRegion) {
351  ism_ = (num - 1) / 2 + 1;
352  if (ism_ > 18)
353  ism_ -= 18;
354  else
355  ism_ += 18;
356  } else
357  abort();
358 
359  int ism = 1;
360  if (global)
361  ism = ism_;
362 
363  // std::list< std::pair< float, float > > l;
364  // getBoundary( l, type, num, global, ism );
365  // int n = l.size();
366  // if( n==0 ) return 0;
367 
368  float ix[100];
369  float iy[100];
370  int ixmin = 0;
371  int ixmax = 84;
372  int iymin = 0;
373  int iymax = 19;
374 
375  int n(0);
376  if (type == iSuperModule) {
377  n = 5;
378  ix[0] = ixmin - 0.5;
379  iy[0] = iymin - 0.5;
380  ix[1] = ixmin - 0.5;
381  iy[1] = iymax + 0.5;
382  ix[2] = ixmax + 0.5;
383  iy[2] = iymax + 0.5;
384  ix[3] = ixmax + 0.5;
385  iy[3] = iymin - 0.5;
386  ix[4] = ix[0];
387  iy[4] = iy[0];
388  } else if (type == iLMRegion) {
389  int iside = num;
390  if (global) {
391  iside = (num - 1) % 2;
392  }
393 
394  if (iside == 1) {
395  n = 5;
396  ix[0] = ixmin + 5 - 0.5;
397  iy[0] = iymin + 10 - 0.5;
398  ix[1] = ixmin + 5 - 0.5;
399  iy[1] = iymax + 0.5;
400  ix[2] = ixmax + 0.5;
401  iy[2] = iymax + 0.5;
402  ix[3] = ixmax + 0.5;
403  iy[3] = iymin + 10 - 0.5;
404  ix[4] = ix[0];
405  iy[4] = iy[0];
406  } else {
407  n = 7;
408  ix[0] = ixmin - 0.5;
409  iy[0] = iymin - 0.5;
410  ix[1] = ixmin - 0.5;
411  iy[1] = iymax + 0.5;
412  ix[2] = ixmin + 5 - 0.5;
413  iy[2] = iymax + 0.5;
414  ix[3] = ixmin + 5 - 0.5;
415  iy[3] = iymax - 10 + 0.5;
416  ix[4] = ixmax + 0.5;
417  iy[4] = iymax - 10 + 0.5;
418  ix[5] = ixmax + 0.5;
419  iy[5] = iymin - 0.5;
420  ix[6] = ix[0];
421  iy[6] = iy[0];
422  }
423  }
424 
425  if (global) {
426  for (int ii = 0; ii < n; ii++) {
427  std::pair<float, float> xy = globalCoord(ism, ix[ii], iy[ii]);
428  ix[ii] = xy.first;
429  iy[ii] = xy.second;
430  }
431  }
432 
433  // int ii=0;
434  // std::list< std::pair< float, float > >::const_iterator l_it;
435  // for( l_it=l.begin(); l_it!=l.end(); l_it++ )
436  // {
437  // // std::cout << "[" << l_it->first << "," << l_it->second << "]" << std::endl;
438  // ix[ii] = l_it->first;
439  // iy[ii] = l_it->second;
440  // ii++;
441  // }
442 
443  // assert( ii==n );
444  return new TGraph(n, ix, iy);
445 }
446 
447 std::pair<int, int> MEEBGeom::pn(int ilmmod) {
448  switch (ilmmod) {
449  case 1:
450  return std::pair<int, int>(0, 5);
451  case 2:
452  return std::pair<int, int>(1, 6);
453  case 3:
454  return std::pair<int, int>(1, 6);
455  case 4:
456  return std::pair<int, int>(2, 7);
457  case 5:
458  return std::pair<int, int>(2, 7);
459  case 6:
460  return std::pair<int, int>(3, 8);
461  case 7:
462  return std::pair<int, int>(3, 8);
463  case 8:
464  return std::pair<int, int>(4, 9);
465  case 9:
466  return std::pair<int, int>(4, 9);
467  default:
468  abort();
469  }
470  return std::pair<int, int>(-1, -1);
471 }
472 
473 std::pair<int, int> MEEBGeom::memFromLmr(int ilmr) {
474  std::pair<int, int> dccAndSide_ = ME::dccAndSide(ilmr);
475  int idcc = dccAndSide_.first;
476  return std::pair<int, int>(idcc, idcc);
477 }
478 
479 std::vector<int> MEEBGeom::lmmodFromLmr(int ilmr) {
480  std::pair<int, int> dccAndSide_ = ME::dccAndSide(ilmr);
481  int iside = dccAndSide_.second;
482  std::vector<int> vec;
483  for (int ilmmod = 1; ilmmod <= 9; ilmmod++) {
484  if ((ilmmod + iside) % 2 == 1)
485  vec.push_back(ilmmod);
486  }
487  return vec;
488 }
489 
490 int MEEBGeom::apdRefTower(int ilmmod) {
491  switch (ilmmod) {
492  /* case 1: return 1;
493  case 2: return 5;
494  case 3: return 7;
495  case 4: return 21;
496  case 5: return 23;
497  case 6: return 37;
498  case 7: return 39;
499  case 8: return 53;
500  case 9: return 55;
501  */
502  case 1:
503  return 2;
504  case 2:
505  return 6;
506  case 3:
507  return 8;
508  case 4:
509  return 22;
510  case 5:
511  return 24;
512  case 6:
513  return 38;
514  case 7:
515  return 40;
516  case 8:
517  return 54;
518  case 9:
519  return 56;
520  default:
521  abort();
522  }
523  return 0;
524 }
525 
526 std::vector<int> MEEBGeom::apdRefChannels(int ilmmod) {
527  std::vector<int> vec;
528  switch (ilmmod) {
529  case 1:
530  vec.push_back(0);
531  vec.push_back(24);
532  break;
533  case 2:
534  vec.push_back(0);
535  vec.push_back(24);
536  break;
537  case 3:
538  vec.push_back(0);
539  vec.push_back(24);
540  break;
541  case 4:
542  vec.push_back(0);
543  vec.push_back(24);
544  break;
545  case 5:
546  vec.push_back(0);
547  vec.push_back(24);
548  break;
549  case 6:
550  vec.push_back(0);
551  vec.push_back(24);
552  break;
553  case 7:
554  vec.push_back(0);
555  vec.push_back(24);
556  break;
557  case 8:
558  vec.push_back(0);
559  vec.push_back(24);
560  break;
561  case 9:
562  vec.push_back(0);
563  vec.push_back(24);
564  break;
565  default:
566  abort();
567  }
568  return vec;
569 }
MEEBGeom::tt_type
static int tt_type(EBTTLocalCoord iX, EBTTLocalCoord iY)
Definition: MEEBGeom.cc:229
MEEBGeom::lmmodFromLmr
static std::vector< int > lmmodFromLmr(int ilmr)
Definition: MEEBGeom.cc:479
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
MEEBGeom::electronic_channel
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:326
MEEBGeom::smName
static TString smName(int ism)
Definition: MEEBGeom.cc:79
MEEBGeom::sm
static int sm(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:26
MEEBGeom::lmr
static int lmr(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:110
MEEBGeom.h
cms::cuda::assert
assert(be >=bs)
MEEBGeom::dcc
static int dcc(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:48
MEEBGeom::pn
static std::pair< int, int > pn(int ilmmod)
Definition: MEEBGeom.cc:447
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
MEEBGeom::side
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:105
MEEBGeom::globalCoord
static EtaPhiCoord globalCoord(int ism, EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:149
PVValHelper::eta
Definition: PVValidationHelpers.h:69
ME::dccAndSide
static std::pair< int, int > dccAndSide(int ilmr)
Definition: ME.cc:295
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
MEEBGeom::barrel
static int barrel(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:14
MEEBGeom::EBTTLocalCoord
int EBTTLocalCoord
Definition: MEEBGeom.h:22
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
MEEBGeom::memFromLmr
static std::pair< int, int > memFromLmr(int ilmr)
Definition: MEEBGeom.cc:473
MEEBGeom::EBGlobalCoord
int EBGlobalCoord
Definition: MEEBGeom.h:21
MEEBGeom::hv_channel
static int hv_channel(EBTTLocalCoord iX, EBTTLocalCoord iY)
Definition: MEEBGeom.cc:257
MEEBGeom::lv_channel
static int lv_channel(EBTTLocalCoord iX, EBTTLocalCoord iY)
Definition: MEEBGeom.cc:285
ME.h
MEEBGeom::lm_channel
static int lm_channel(EBTTLocalCoord iX, EBTTLocalCoord iY)
Definition: MEEBGeom.cc:201
MEEBGeom::apdRefTower
static int apdRefTower(int ilmmod)
Definition: MEEBGeom.cc:490
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
MEEBGeom::smFromDcc
static int smFromDcc(int idcc)
Definition: MEEBGeom.cc:67
ecalpyutils::ism
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:51
type
type
Definition: HCALResponse.h:21
MEEBGeom::dccFromSm
static int dccFromSm(int ism)
Definition: MEEBGeom.cc:53
std
Definition: JetResolutionObject.h:76
MEEBGeom::tt
static int tt(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:95
MEEBGeom::getGraphBoundary
static TGraph * getGraphBoundary(int type, int num, bool global=false)
Definition: MEEBGeom.cc:346
MEEBGeom::lmmod
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:90
MEEBGeom::localCoord
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:142
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
MEEBGeom::tt_channel
static int tt_channel(EBTTLocalCoord iX, EBTTLocalCoord iY)
Definition: MEEBGeom.cc:313
MEEBGeom::apdRefChannels
static std::vector< int > apdRefChannels(int ilmmod)
Definition: MEEBGeom.cc:526
MEEBGeom::EBLocalCoord
int EBLocalCoord
Definition: MEEBGeom.h:20
cuy.ii
ii
Definition: cuy.py:590
MEEBGeom::crystal
static int crystal(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:100
MEEBGeom::crystal_channel
static int crystal_channel(EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:319