CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDbHardcode.cc
Go to the documentation of this file.
1 //
2 // F.Ratnikov (UMd), Dec 14, 2005
3 //
4 #include <vector>
5 #include <string>
6 
7 #include "CLHEP/Random/RandGauss.h"
10 
13  float value0 = fId.genericSubdet() == HcalGenericDetId::HcalGenForward ? 11. : 18.; // fC
14  if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) value0 = 10.;
15  float value [4] = {value0, value0, value0, value0};
16  if (fSmear) {
17  for (int i = 0; i < 4; i++) {
18  value [i] = CLHEP::RandGauss::shoot (value0, width.getWidth (i) / 100.); // ignore correlations, assume 10K pedestal run
19  while (value [i] <= 0) value [i] = CLHEP::RandGauss::shoot (value0, width.getWidth (i));
20  }
21  }
22  HcalPedestal result (fId.rawId (),
23  value[0], value[1], value[2], value[3]
24  );
25  return result;
26 }
27 
28 
30  HcalPedestalWidth width = makePedestalWidth (fId, lumi);
31  // float value0 = fId.genericSubdet() == HcalGenericDetId::HcalGenForward ? 11. : 18.; // fC
32 
33  // Temporary disabling of lumi-dependent pedestal to avoid it being too big
34  // for TDC evaluations...
35  // float value0 = 4.* width.getWidth(0); // to be far enough from 0
36  float value0 = fId.genericSubdet() == HcalGenericDetId::HcalGenForward ? 11. : 18.; // fC
37 
38  float value [4] = {value0, value0, value0, value0};
39  if (fSmear) {
40  for (int i = 0; i < 4; i++) {
41  value [i] = CLHEP::RandGauss::shoot (value0, width.getWidth (i) / 100.); // ignore correlations, assume 10K pedestal run
42  while (value [i] <= 0) value [i] = CLHEP::RandGauss::shoot (value0, width.getWidth (i));
43  }
44  }
45  HcalPedestal result (fId.rawId (),
46  value[0], value[1], value[2], value[3]
47  );
48  return result;
49 }
50 
52  float value = 0;
53  if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel) value = 5.0;
54  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) value = 5.0;
55  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) value = 1.5;
56  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward)value = 2.0;
57  // everything in fC
58 
60  for (int i = 0; i < 4; i++) {
61  double width = value;
62  for (int j = 0; j < 4; j++) {
63  result.setSigma (i, j, i == j ? width * width : 0);
64  }
65  }
66  return result;
67 }
68 
69 // Upgrade option with lumi dependence, assuming factor ~20 for HB
70 // while factor ~8 (~2.5 less) for HE at 3000 fb-1
71 // Tab.1.6 (p.10) and Fig. 5.7 (p.91) of HCAL Upgrade TDR
72 
74  float value = 0;
75  double eff_lumi = lumi - 200.; // offset to account for actual putting of SiPMs into
76  // operations
77  if(eff_lumi < 0.) eff_lumi = 0.;
79  value = 5.0 + 1.7 * sqrt(eff_lumi);
81  value = 5.0 + 0.7 * sqrt(eff_lumi);
82  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) value = 1.5;
83  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward)value = 2.0;
84  // everything in fC
85 
86  /*
87  if (fId.isHcalDetId()) {
88  HcalDetId cell = HcalDetId(fId);
89  int sub = cell.subdet();
90  int dep = cell.depth();
91  int ieta = cell.ieta();
92  int iphi = cell.iphi();
93 
94  std::cout << "HCAL subdet " << sub << " (" << ieta << "," << iphi
95  << "," << dep << ") " << " noise = " << value << std::endl;
96  }
97  */
98 
100  for (int i = 0; i < 4; i++) {
101  double width = value;
102  for (int j = 0; j < 4; j++) {
103  result.setSigma (i, j, i == j ? width * width : 0);
104  }
105  }
106  return result;
107 }
108 
109 
111 
112 
113  /*
114  std::cout << std::endl << " HcalDbHardcode::makeMCParam fId "
115  << fId
116  << " fId.genericSubdet() = " << fId.genericSubdet() << std::endl;
117  if(fId.isHcalZDCDetId()) {
118  std::cout << "... ZDC " << std::endl;
119 
120 
121  HcalZDCDetId cell(fId);
122  int side = cell.zside();
123  int depth = cell.depth();
124  int ch = cell.channel();
125  std::cout << "ZDC side/depth/chanel = "
126  << side << " " << depth << " " << ch
127  << std::endl;
128  }
129  else if (fId.isHcalDetId()) {
130  HcalDetId cell = HcalDetId(fId);
131  int sub = cell.subdet();
132  int dep = cell.depth();
133  int ieta = cell.ieta();
134  int iphi = cell.iphi();
135 
136  std::cout << " HCAL "
137  << " subdet " << sub << " ieta " << ieta << " iphi " << iphi
138  << " depth " << dep << std::endl;
139  }
140  else { std::cout << "...Something else ! " << std::endl; }
141 
142  */
143 
144  int r1bit[5];
145  int pulseShapeID = 125; r1bit[0] = 9; // [0,9]
146  int syncPhase = 0; r1bit[1] = 1;
147  int binOfMaximum = 0; r1bit[2] = 4;
148  float phase = -25.0; // [-25.0,25.0]
149  float Xphase = (phase + 32.0) * 4.0; // never change this line
150  // (offset 50nsec, 0.25ns step)
151  int Iphase = Xphase; r1bit[3] = 8; // [0,256] offset 50ns, .25ns step
152  int timeSmearing = 0; r1bit[4] = 1; // bool
153 
154 
156 
157  syncPhase = 1; // a0 bool
158  binOfMaximum = 5; // a1
159  phase = 5.0; // a2 [-25.0,25.0]
160  Xphase = (phase + 32.0) * 4.0; // never change this line
161  // (offset 50nsec, 0.25ns step)
162  Iphase = Xphase;
163  timeSmearing = 1; // a3
164  pulseShapeID = 201; // a4 201 - Zecotec shape
165  // 202 - Hamamatsu
166 
167  }
168 
169  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
170 
171  syncPhase = 1; // a0 bool
172  binOfMaximum = 5; // a1
173  phase = 5.0; // a2 [-25.0,25.0]
174  Xphase = (phase + 32.0) * 4.0; // never change this line
175  // (offset 50nsec, 0.25ns step)
176  Iphase = Xphase;
177  timeSmearing = 1; // a3
178  pulseShapeID = 201; // a4
179 
180  }
181 
182  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
183 
184  syncPhase = 1; // a0 bool
185  binOfMaximum = 5; // a1
186  phase = 5.0; // a2 [-25.0,25.0]
187  Xphase = (phase + 32.0) * 4.0; // never change this line
188  // (offset 50nsec, 0.25ns step)
189  Iphase = Xphase;
190  timeSmearing = 0; // a3
191  pulseShapeID = 201; // a4
192 
193  HcalDetId cell = HcalDetId(fId);
194  if (cell.ieta() == 1 && cell.iphi() == 1) pulseShapeID = 125;
195 
196  }
197 
198  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
199 
200  syncPhase = 1; // a0 bool
201  binOfMaximum = 3; // a1
202  phase = 14.0; // a2 [-25.0,25.0]
203  Xphase = (phase + 32.0) * 4.0; // never change this line
204  // (offset 50nsec, 0.25ns step)
205  Iphase = Xphase;
206  timeSmearing = 0; // a3
207  pulseShapeID = 301; // a4
208 
209  }
210 
211  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenZDC) {
212 
213  // std::cout << " >>> ZDC " << std::endl;
214 
215  syncPhase = 1; // a0 bool
216  binOfMaximum = 5; // a1
217  phase = -4.0; // a2 [-25.0,25.0]
218  Xphase = (phase + 32.0) * 4.0; // never change this line
219  // (offset 50nsec, 0.25ns step)
220  Iphase = Xphase;
221  timeSmearing = 0; // a3
222  pulseShapeID = 401; // a4
223 
224  }
225 
226 
227  int rshift[7];
228  rshift[0]=0;
229  for(int k=0; k<5; k++) {
230  int j=k+1;
231  rshift[j]=rshift[k]+r1bit[k];
232  // cout<<" j= "<<j<<" shift "<< rshift[j]<<endl;
233  }
234 
235  int packingScheme = 1;
236  unsigned int param = pulseShapeID |
237  syncPhase<<rshift[1] |
238  (binOfMaximum << rshift[2]) |
239  (Iphase << rshift[3]) |
240  (timeSmearing << rshift[4] | packingScheme << 27);
241 
242  /*
243 
244  int a0 = param%512;
245  int a1 = (param/512)%2;
246  int a2 = (param/(512*2))%16;
247  int a3 = (param/(512*2*16))%256;
248  int a4 = (param/(512*2*16*256))%2;
249  a3 = (a3/4)-32;
250  int a5 = (param/(512*2*16*256*2*16))%16;
251 
252  */
253 
254 
255  // unpacking a la CondFormats/HcalObjects/interface/HcalMCParam.h
256 
257  /*
258  int shape = param&0x1FF;
259  syncPhase = (param>>9)&0x1;
260  binOfMaximum = (param>>10)&0xF;
261  int timePhase = ((param>>14)&0xFF)/4-32;
262  timeSmearing = (param>>22)&0x1;
263  int packingSc = (param>>27)&0xF;
264 
265  std::cout << " shape " << shape << " sync.phase " << syncPhase
266  << " binOfMaximum " << binOfMaximum
267  << " timePhase " << timePhase
268  << " timeSmear " << timeSmearing
269  << " packingSc " << packingSc
270  << std::endl;
271  */
272 
273  /*
274  if(shape != a0)
275  { std::cout <<" error shape " << shape
276  << " a0 " << a0 << std::endl; }
277  if(syncPhase != a1)
278  { std::cout << " error syncPhase " << syncPhase
279  << " a1 " << a1 << std::endl; }
280  if(binOfMaximum != a2)
281  { std::cout << " error binOfMaximum " << binOfMaximum
282  << " a2 " << a2 << std::endl; }
283  if(timePhase != a3)
284  { std::cout << " error timePhase " << timePhase
285  << " a3 " << a3 << std::endl; }
286  if(timeSmearing != a4)
287  { std::cout << " error timeSmearing " << timeSmearing
288  << " a4 " << a4 << std::endl; }
289  if(packingSc != a5)
290  { std::cout << " error packing sceme " << packingSc
291  << " a5 " << a5 << std::endl; }
292  */
293 
294  HcalMCParam result(fId.rawId(), param);
295  return result;
296 
297 }
298 
300 
301  /*
302  if (fId.isHcalDetId()) {
303  HcalDetId cell = HcalDetId(fId);
304  int sub = cell.subdet();
305  int dep = cell.depth();
306  int ieta = cell.ieta();
307  int iphi = cell.iphi();
308 
309  std::cout << " HCAL "
310  << " subdet " << sub << " ieta " << ieta << " iphi " << iphi
311  << " depth " << dep << std::endl;
312  }
313  */
314 
315 
316  // Mostly comes from S.Kunori's macro
317  int p1bit[6];
318 
319  // param1
320  int containmentCorrectionFlag = 0; p1bit[0]=1; // bool
321  int containmentCorrectionPreSample = 0; p1bit[1]=1; // bool
322  float phase = 13.0; // [-25.0,25.0]
323  float Xphase = (phase + 32.0) * 4.0; //never change this line
324  // (offset 50nsec, 0.25ns step)
325  int Iphase = Xphase; p1bit[2]=8; // [0,256]
326  // (offset 50ns, 0.25ns step
327  int firstSample = 4; p1bit[3]=4; // [0,9]
328  int samplesToAdd = 2; p1bit[4]=4; // [0,9]
329  int pulseShapeID = 105; p1bit[5]=9; // [0,9]
330 
331  int q2bit[10];
332  // param2.
333  int useLeakCorrection = 0; q2bit[0]=1; // bool
334  int LeakCorrectionID = 0; q2bit[1]=4; // [0,15]
335  int correctForTimeslew = 0; q2bit[2]=1; // bool
336  int timeCorrectionID = 0; q2bit[3]=4; // [0,15]
337  int correctTiming = 0; q2bit[4]=1; // bool
338  int firstAuxTS = 0; q2bit[5]=4; // [0,15]
339  int specialCaseID = 0; q2bit[6]=4; // [0,15]
340  int noiseFlaggingID = 0; q2bit[7]=4; // [0,15]
341  int pileupCleaningID = 0; q2bit[8]=4; // [0,15]
342  int packingScheme = 1; q2bit[9]=4;
343 
344 
347  // param1.
348  containmentCorrectionFlag = 1; // p0
349  containmentCorrectionPreSample = 0; // p1
350  float phase = 25.0;
351  float Xphase = (phase + 32.0) * 4.0; // never change this line
352  //(offset 50nsec, 0.25ns step)
353  Iphase = Xphase; // p2
354  firstSample = 4; // p3
355  samplesToAdd = 2; // p4
356  pulseShapeID = 201; // p5
357 
358  // param2.
359  useLeakCorrection = 0; // q0
360  LeakCorrectionID = 0; // q1
361  correctForTimeslew = 1; // q2
362  timeCorrectionID = 0; // q3
363  correctTiming = 1; // q4
364  firstAuxTS = 4; // q5
365  specialCaseID = 0; // q6
366  noiseFlaggingID = 1; // q7
367  pileupCleaningID = 0; // q8
368  }
369 
370 
371  else if(fId.genericSubdet() == HcalGenericDetId::HcalGenOuter ) {
372  // param1.
373  containmentCorrectionFlag = 1; // p0
374  containmentCorrectionPreSample = 0; // p1
375  float phase = 13.0;
376  float Xphase = (phase + 32.0) * 4.0; // never change this line
377  // (offset 50nsec, 0.25ns step)
378  Iphase = Xphase; // p2
379  firstSample = 4; // p3
380  samplesToAdd = 4; // p4
381  pulseShapeID = 201; // p5
382  // param2.
383  useLeakCorrection = 0; // q0
384  LeakCorrectionID = 0; // q1
385  correctForTimeslew = 1; // q2
386  timeCorrectionID = 0; // q3
387  correctTiming = 1; // q4
388  firstAuxTS = 4; // q5
389  specialCaseID = 0; // q6
390  noiseFlaggingID = 1; // q7
391  pileupCleaningID = 0; // q8
392 
393  }
395  // param1.
396  containmentCorrectionFlag = 0; // p0
397  containmentCorrectionPreSample = 0; // p1
398  float phase = 13.0;
399  float Xphase = (phase + 32.0) * 4.0; // never change this line
400  // (offset 50nsec, 0.25ns step)
401  Iphase = Xphase; // p2
402  pulseShapeID = 301; // p5
403 
404  firstSample = 2; // p3
405  samplesToAdd = 1; // p4
406  pulseShapeID = 301; // p5
407 
408  // param2.
409  useLeakCorrection = 0; // q0
410  LeakCorrectionID = 0; // q1
411  correctForTimeslew = 0; // q2
412  timeCorrectionID = 0; // q3
413  correctTiming = 1; // q4
414  firstAuxTS = 1; // q5
415  specialCaseID = 0; // q6
416  noiseFlaggingID = 1; // q7
417  pileupCleaningID = 0; // q8
418  }
419 
420 
421  // Packing parameters in two words
422 
423  int p1shift[7]; p1shift[0] = 0;
424  for(int k = 0; k < 6; k++) {
425  int j = k + 1;
426  p1shift[j] = p1shift[k] + p1bit[k];
427  // cout<<" j= "<<j<<" shift "<< p1shift[j]<<endl;
428  }
429  int param1 = 0;
430  param1 = containmentCorrectionFlag |
431  (containmentCorrectionPreSample << p1shift[1]) |
432  (Iphase << p1shift[2]) |
433  (firstSample << p1shift[3]) |
434  (samplesToAdd << p1shift[4]) |
435  (pulseShapeID << p1shift[5]) ;
436 
437  int q2shift[10]; q2shift[0] = 0;
438  for(int k = 0; k < 9; k++) {
439  int j = k + 1;
440  q2shift[j] = q2shift[k] + q2bit[k];
441  // cout<<" j= "<<j<<" shift "<< q2shift[j]<<endl;
442  }
443  int param2 = 0;
444  param2 = useLeakCorrection |
445  (LeakCorrectionID << q2shift[1]) |
446  (correctForTimeslew << q2shift[2]) |
447  (timeCorrectionID << q2shift[3]) |
448  (correctTiming << q2shift[4]) |
449  (firstAuxTS << q2shift[5]) |
450  (specialCaseID << q2shift[6]) |
451  (noiseFlaggingID << q2shift[7]) |
452  (pileupCleaningID << q2shift[8]) |
453  (packingScheme << q2shift[9]) ;
454 
455  // Test printout
456  /*
457  int a0=param1%2;
458  int a1=(param1/2)%2;
459  int a2=(param1/(2*2))%256;
460  int a3=(param1/(2*2*256))%16;
461  int a4=(param1/(2*2*256*16))%16;
462  int a5=(param1/(2*2*256*16*16))%512;
463  a2=(a2/4)-32;
464 
465  int b0=param2%2;
466  int b1=(param2/2)%16;
467  int b2=(param2/(2*16))%2;
468  int b3=(param2/(2*16*2))%16;
469  int b4=(param2/(2*16*2*16))%2;
470  int b5=(param2/(2*16*2*16*2))%16;
471  int b6=(param2/(2*16*2*16*2*16))%16;
472  int b7=(param2/(2*16*2*16*2*16*16))%16;
473  int b8=(param2/(2*16*2*16*2*16*16*16))%16;
474  int b9=(param2/(2*16*2*16*2*16*16*16*16))%16;
475 
476  std::cout << " param1 (a012) " << a0 << " " <<a1 << " " << a2
477  << " (a345) " << a3 << " " << a4 << " "<< a5
478  << " param2 (b012) " << b0 << " " << b1 << " " <<b2
479  << " (b345) " << b3 << " " << b4 << " " << b5
480  << " (b678) " << b6 << " " << b7 << " " << b8 << " b9 " << b9
481  << std::endl;
482  */
483 
484 
485  HcalRecoParam result(fId.rawId(), param1, param2);
486 
487  return result;
488 }
489 
491  int nhits = 0;
492  float phase = 0.0;
493  float rms = 0.0;
494  if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel) {nhits=4; phase = 4.5; rms = 6.5;}
495  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {nhits=4;phase = 9.3; rms = 7.8;}
496  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {nhits=4;phase = 8.6; rms = 2.3;}
497  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {nhits=4;phase = 12.4; rms = 12.29;}
498  HcalTimingParam result(fId.rawId(), nhits,phase, rms);
499 
500  return result;
501 }
502 
503 
505  HcalGainWidth width = makeGainWidth (fId);
506  float value0 = 0;
507 
508  static float const hbhevalue = 1./90./10.; //90 is pe/GeV 10 is fC/pe.
510  HcalDetId hid(fId);
511  if (hid.depth() == 1) value0 = hbhevalue;
512  else if (hid.depth() == 2) value0 = hbhevalue;
513  else if (hid.depth() == 3) value0 = hbhevalue;
514  else if (hid.depth() == 4) value0 = hbhevalue;
515  else value0 = hbhevalue; // GeV/fC
516  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
517  HcalDetId hid(fId);
518  if (hid.depth() == 1) value0 = hbhevalue;
519  else if (hid.depth() == 2) value0 = hbhevalue;
520  else if (hid.depth() == 3) value0 = hbhevalue;
521  else if (hid.depth() == 4) value0 = hbhevalue;
522  else value0 = hbhevalue; // GeV/fC
523  // if (fId.genericSubdet() != HcalGenericDetId::HcalGenForward) value0 = 0.177; // GeV/fC
524  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
525  HcalDetId hid(fId);
526  if ((hid.ieta() > -5) && (hid.ieta() < 5))
527  value0 = 0.0125;
528  else
529  value0 = 0.02083; // GeV/fC
530  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
531  HcalDetId hid(fId);
532  if (hid.depth() == 1) value0 = 0.2146;
533  else if (hid.depth() == 2) value0 = 0.3375;
534  } else value0 = hbhevalue; // GeV/fC
535  float value [4] = {value0, value0, value0, value0};
536  if (fSmear) for (int i = 0; i < 4; i++) value [i] = CLHEP::RandGauss::shoot (value0, width.getValue (i));
537  HcalGain result (fId.rawId (), value[0], value[1], value[2], value[3]);
538  return result;
539 }
540 
542  float value = 0;
544  return result;
545 }
546 
548  HcalQIECoder result (fId.rawId ());
549  float offset = 0.0;
551  0.36 : 0.333; // ADC/fC
552 
553  // qie8/qie10 attribution - 0/1
555  slope = 1.0;
556  }
557 
558  for (unsigned range = 0; range < 4; range++) {
559  for (unsigned capid = 0; capid < 4; capid++) {
560  result.setOffset (capid, range, offset);
561  result.setSlope (capid, range, slope);
562  }
563  }
564 
565  return result;
566 }
567 
569  HcalQIENum qieType = QIE8; //default
570  if (testHFQIE10){ //2016 test
572  HcalDetId hid(fId);
573  if(hid.depth()>=3) qieType = QIE10;
574  }
575  }
576  else { //generic upgrade case: QIE8 for HO, QIE10 for HF, QIE11 for HBHE
578  qieType = QIE11;
579  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
580  qieType = QIE8;
581  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
582  qieType = QIE10;
583  }
584  }
585 
586  HcalQIEType result(fId.rawId(),qieType);
587  return result;
588 }
589 
592  float lowEdges [64];
593  for (int i = 0; i < 64; i++) lowEdges[i] = -1.5 + i*1.0;
594  result.setMinCharges (lowEdges);
595  return result;
596 }
597 
599 
600  // std::cout << " !!! HcalDbHardcode::makeQIEShape " << std::endl;
601 
602  return HcalQIEShape ();
603 }
604 
605 
606 #define EMAP_NHBHECR 9
607 #define EMAP_NHFCR 3
608 #define EMAP_NHOCR 4
609 #define EMAP_NFBR 8
610 #define EMAP_NFCH 3
611 #define EMAP_NHTRS 3
612 #define EMAP_NHSETS 4
613 #define EMAP_NTOPBOT 2
614 #define EMAP_NHTRSHO 4
615 #define EMAP_NHSETSHO 3
616 
618  dcs_map.mapGeomId2DcsId(HcalDetId(HcalBarrel, -16, 1, 1),
620  dcs_map.mapGeomId2DcsId(HcalDetId(HcalForward, -41, 3, 1),
622  dcs_map.mapGeomId2DcsId(HcalDetId(HcalForward, -26, 25, 2),
624  dcs_map.mapGeomId2DcsId(HcalDetId(HcalBarrel, -15, 68, 1),
626  dcs_map.mapGeomId2DcsId(HcalDetId(HcalOuter, -14, 1, 4),
628  dcs_map.mapGeomId2DcsId(HcalDetId(HcalForward, 41, 71, 2),
630 }
631 
633 
634  /* HBHE crate numbering */
635  int hbhecrate[EMAP_NHBHECR]={0,1,4,5,10,11,14,15,17};
636  /* HF crate numbering */
637  int hfcrate[EMAP_NHFCR]={2,9,12};
638  /* HO crate numbering */
639  int hocrate[EMAP_NHOCR]={3,7,6,13};
640  /* HBHE FED numbering of DCCs */
641  int fedhbhenum[EMAP_NHBHECR][2]={{702,703},{704,705},{700,701},
642  {706,707},{716,717},{708,709},
643  {714,715},{710,711},{712,713}};
644  /* HF FED numbering of DCCs */
645  int fedhfnum[EMAP_NHFCR][2]={{718,719},{720,721},{722,723}};
646  /* HO FED numbering of DCCs */
647  int fedhonum[EMAP_NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
648  /* HBHE/HF htr slot offsets for set of three htrs */
649  int ihslot[EMAP_NHSETS]={2,5,13,16};
650  /* HO htr slot offsets for three sets of four htrs */
651  int ihslotho[EMAP_NHSETSHO][EMAP_NHTRSHO]={{2,3,4,5},{6,7,13,14},{15,16,17,18}};
652  /* iphi (lower) starting index for each HBHE crate */
653  int ihbhephis[EMAP_NHBHECR]={11,19,3,27,67,35,59,43,51};
654  /* iphi (lower) starting index for each HF crate */
655  int ihfphis[EMAP_NHFCR]={3,27,51};
656  /* iphi (lower) starting index for each HO crate */
657  int ihophis[EMAP_NHOCR]={71,17,35,53};
658  /* ihbheetadepth - unique HBHE {eta,depth} assignments per fiber and fiber channel */
659  int ihbheetadepth[EMAP_NHTRS][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
660  {{{{11,1},{ 7,1},{ 3,1}}, /* htr 0 (HB) -bot(+top) */
661  {{ 5,1},{ 1,1},{ 9,1}},
662  {{11,1},{ 7,1},{ 3,1}},
663  {{ 5,1},{ 1,1},{ 9,1}},
664  {{10,1},{ 6,1},{ 2,1}},
665  {{ 8,1},{ 4,1},{12,1}},
666  {{10,1},{ 6,1},{ 2,1}},
667  {{ 8,1},{ 4,1},{12,1}}},
668  {{{11,1},{ 7,1},{ 3,1}}, /* htr 0 (HB) +bot(-top) */
669  {{ 5,1},{ 1,1},{ 9,1}},
670  {{11,1},{ 7,1},{ 3,1}},
671  {{ 5,1},{ 1,1},{ 9,1}},
672  {{10,1},{ 6,1},{ 2,1}},
673  {{ 8,1},{ 4,1},{12,1}},
674  {{10,1},{ 6,1},{ 2,1}},
675  {{ 8,1},{ 4,1},{12,1}}}},
676  {{{{16,2},{15,2},{14,1}}, /* htr 1 (HBHE) -bot(+top) */
677  {{15,1},{13,1},{16,1}},
678  {{16,2},{15,2},{14,1}},
679  {{15,1},{13,1},{16,1}},
680  {{17,1},{16,3},{26,1}},
681  {{18,1},{18,2},{26,2}},
682  {{17,1},{16,3},{25,1}},
683  {{18,1},{18,2},{25,2}}},
684  {{{16,2},{15,2},{14,1}}, /* htr 1 (HBHE) +bot(-top) */
685  {{15,1},{13,1},{16,1}},
686  {{16,2},{15,2},{14,1}},
687  {{15,1},{13,1},{16,1}},
688  {{17,1},{16,3},{25,1}},
689  {{18,1},{18,2},{25,2}},
690  {{17,1},{16,3},{26,1}},
691  {{18,1},{18,2},{26,2}}}},
692  {{{{28,1},{28,2},{29,1}}, /* htr 2 (HE) -bot(+top) */
693  {{28,3},{24,2},{24,1}},
694  {{27,1},{27,2},{29,2}},
695  {{27,3},{23,2},{23,1}},
696  {{19,2},{20,1},{22,2}},
697  {{19,1},{20,2},{22,1}},
698  {{19,2},{20,1},{21,2}},
699  {{19,1},{20,2},{21,1}}},
700  {{{27,1},{27,2},{29,2}}, /* htr 2 (HE) +bot(-top) */
701  {{27,3},{23,2},{23,1}},
702  {{28,1},{28,2},{29,1}},
703  {{28,3},{24,2},{24,1}},
704  {{19,2},{20,1},{21,2}},
705  {{19,1},{20,2},{21,1}},
706  {{19,2},{20,1},{22,2}},
707  {{19,1},{20,2},{22,1}}}}
708  };
709  /* ihfetadepth - unique HF {eta,depth} assignments per fiber and fiber channel */
710  int ihfetadepth[EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
711  {{{33,1},{31,1},{29,1}}, /* top */
712  {{32,1},{30,1},{34,1}},
713  {{33,2},{31,2},{29,2}},
714  {{32,2},{30,2},{34,2}},
715  {{34,2},{32,2},{30,2}},
716  {{31,2},{29,2},{33,2}},
717  {{34,1},{32,1},{30,1}},
718  {{31,1},{29,1},{33,1}}},
719  {{{41,1},{37,1},{35,1}}, /* bot */
720  {{38,1},{36,1},{39,1}},
721  {{41,2},{37,2},{35,2}},
722  {{38,2},{36,2},{39,2}},
723  {{40,2},{38,2},{36,2}},
724  {{37,2},{35,2},{39,2}},
725  {{40,1},{38,1},{36,1}},
726  {{37,1},{35,1},{39,1}}}
727  };
728  /* ihoetasidephi - unique HO {eta,side,phi} assignments per fiber and fiber channel */
729  int ihoetasidephi[EMAP_NHTRSHO][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][3]={
730  {{{{ 1,-1,0},{ 2,-1,0},{ 3,-1,0}}, /* htr 0 (HO) top */
731  {{ 1,-1,1},{ 2,-1,1},{ 3,-1,1}},
732  {{ 1,-1,2},{ 2,-1,2},{ 3,-1,2}},
733  {{ 1,-1,3},{ 2,-1,3},{ 3,-1,3}},
734  {{ 1,-1,4},{ 2,-1,4},{ 3,-1,4}},
735  {{ 1,-1,5},{ 2,-1,5},{ 3,-1,5}},
736  {{14, 1,0},{14, 1,1},{14, 1,2}},
737  {{14, 1,3},{14, 1,4},{14, 1,5}}},
738  {{{ 1, 1,0},{ 2, 1,0},{ 3, 1,0}}, /* htr 0 (HO) bot */
739  {{ 1, 1,1},{ 2, 1,1},{ 3, 1,1}},
740  {{ 1, 1,2},{ 2, 1,2},{ 3, 1,2}},
741  {{ 1, 1,3},{ 2, 1,3},{ 3, 1,3}},
742  {{ 1, 1,4},{ 2, 1,4},{ 3, 1,4}},
743  {{ 1, 1,5},{ 2, 1,5},{ 3, 1,5}},
744  {{15, 1,0},{15, 1,1},{15, 1,2}},
745  {{15, 1,3},{15, 1,4},{15, 1,5}}}},
746  {{{{ 6, 1,0},{ 6, 1,1},{ 6, 1,2}}, /* htr 1 (HO) top */
747  {{ 6, 1,3},{ 6, 1,4},{ 6, 1,5}},
748  {{ 7, 1,0},{ 7, 1,1},{ 7, 1,2}},
749  {{ 7, 1,3},{ 7, 1,4},{ 7, 1,5}},
750  {{ 8, 1,0},{ 8, 1,1},{ 8, 1,2}},
751  {{ 8, 1,3},{ 8, 1,4},{ 8, 1,5}},
752  {{ 9, 1,0},{ 9, 1,1},{ 9, 1,2}},
753  {{ 9, 1,3},{ 9, 1,4},{ 9, 1,5}}},
754  {{{10, 1,0},{10, 1,1},{10, 1,2}}, /* htr 1 (HO) bot */
755  {{10, 1,3},{10, 1,4},{10, 1,5}},
756  {{11, 1,0},{11, 1,1},{11, 1,2}},
757  {{11, 1,3},{11, 1,4},{11, 1,5}},
758  {{12, 1,0},{12, 1,1},{12, 1,2}},
759  {{12, 1,3},{12, 1,4},{12, 1,5}},
760  {{13, 1,0},{13, 1,1},{13, 1,2}},
761  {{13, 1,3},{13, 1,4},{13, 1,5}}}},
762  {{{{ 4,-1,0},{ 4,-1,1},{ 0, 0,0}}, /* htr 2 (HO) top */
763  {{ 4,-1,2},{ 4,-1,3},{ 0, 0,0}},
764  {{ 4,-1,4},{ 4,-1,5},{ 0, 0,0}},
765  {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
766  {{ 5,-1,0},{ 5,-1,1},{ 5,-1,2}},
767  {{ 5,-1,3},{ 5,-1,4},{ 5,-1,5}},
768  {{14,-1,0},{14,-1,1},{14,-1,2}},
769  {{14,-1,3},{14,-1,4},{14,-1,5}}},
770  {{{ 4, 1,0},{ 4, 1,1},{ 0, 0,0}}, /* htr 2 (HO) bot */
771  {{ 4, 1,2},{ 4, 1,3},{ 0, 0,0}},
772  {{ 4, 1,4},{ 4, 1,5},{ 0, 0,0}},
773  {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
774  {{ 5, 1,0},{ 5, 1,1},{ 5, 1,2}},
775  {{ 5, 1,3},{ 5, 1,4},{ 5, 1,5}},
776  {{15,-1,0},{15,-1,1},{15,-1,2}},
777  {{15,-1,3},{15,-1,4},{15,-1,5}}}},
778  {{{{ 6,-1,0},{ 6,-1,1},{ 6,-1,2}}, /* htr 3 (HO) top */
779  {{ 6,-1,3},{ 6,-1,4},{ 6,-1,5}},
780  {{ 7,-1,0},{ 7,-1,1},{ 7,-1,2}},
781  {{ 7,-1,3},{ 7,-1,4},{ 7,-1,5}},
782  {{ 8,-1,0},{ 8,-1,1},{ 8,-1,2}},
783  {{ 8,-1,3},{ 8,-1,4},{ 8,-1,5}},
784  {{ 9,-1,0},{ 9,-1,1},{ 9,-1,2}},
785  {{ 9,-1,3},{ 9,-1,4},{ 9,-1,5}}},
786  {{{10,-1,0},{10,-1,1},{10,-1,2}}, /* htr 3 (HO) bot */
787  {{10,-1,3},{10,-1,4},{10,-1,5}},
788  {{11,-1,0},{11,-1,1},{11,-1,2}},
789  {{11,-1,3},{11,-1,4},{11,-1,5}},
790  {{12,-1,0},{12,-1,1},{12,-1,2}},
791  {{12,-1,3},{12,-1,4},{12,-1,5}},
792  {{13,-1,0},{13,-1,1},{13,-1,2}},
793  {{13,-1,3},{13,-1,4},{13,-1,5}}}}
794  };
795  int ic,is,ih,itb,ifb,ifc,ifwtb,iphi_loc;
796  int iside,ieta,iphi,idepth,icrate,ihtr,ihtr_fi,ifi_ch,ispigot,idcc,ifed;
797  // int idcc_sl;
798  std::string det;
799  std::string fpga;
800  // printf(" side eta phi depth det crate htr fpga htr_fi fi_ch spigo dcc dcc_sl fedid\n");
801  /* all HBHE crates */
802  for(ic=0; ic<EMAP_NHBHECR; ic++){
803  /* four sets of three htrs per crate */
804  for(is=0; is<EMAP_NHSETS; is++){
805  /* three htrs per set */
806  for(ih=0; ih<EMAP_NHTRS; ih++){
807  /* top and bottom */
808  for(itb=0; itb<EMAP_NTOPBOT; itb++){
809  /* eight fibers per HTR FPGA */
810  for(ifb=0; ifb<EMAP_NFBR; ifb++){
811  /* three channels per fiber */
812  for(ifc=0; ifc<EMAP_NFCH; ifc++){
813  icrate=hbhecrate[ic];
814  iside=is<EMAP_NHSETS/2?-1:1;
815  ifwtb=(is/2+itb+1)%2;
816  ieta=ihbheetadepth[ih][ifwtb][ifb][ifc][0];
817  idepth=ihbheetadepth[ih][ifwtb][ifb][ifc][1];
818  ihtr=ihslot[is]+ih;
819  det=((ieta>16||idepth>2)?("HE"):("HB"));
820  fpga=((itb%2)==1)?("bot"):("top");
821  ihtr_fi=ifb+1;
822  ifi_ch=ifc;
823  iphi=(ieta>20)?(ihbhephis[ic]+(is%2)*4+itb*2-1)%72+1:(ihbhephis[ic]+(is%2)*4+itb*2+(ifb/2+is/2+1)%2-1)%72+1;
824  ispigot=(is%2)*6+ih*2+itb;
825  idcc=is<EMAP_NHSETS/2?1:2;
826  // idcc_sl=idcc==1?9:19;
827  ifed=fedhbhenum[ic][idcc-1];
829  HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
830  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
831  HcalDetId hId((det=="HB")?(HcalBarrel):(HcalEndcap),ieta*iside,iphi,idepth);
832  emap.mapEId2chId(elId,hId);
833 
834  // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
835  }}}}}}
836  /* all HF crates */
837  for(ic=0; ic<EMAP_NHFCR; ic++){
838  /* four sets of three htrs per crate */
839  for(is=0; is<EMAP_NHSETS; is++){
840  /* three htrs per set */
841  for(ih=0; ih<EMAP_NHTRS; ih++){
842  /* top and bottom */
843  for(itb=0; itb<EMAP_NTOPBOT; itb++){
844  /* eight fibers per HTR FPGA */
845  for(ifb=0; ifb<EMAP_NFBR; ifb++){
846  /* three channels per fiber */
847  for(ifc=0; ifc<EMAP_NFCH; ifc++){
848  icrate=hfcrate[ic];
849  iside=is<EMAP_NHSETS/2?-1:1;
850  ieta=ihfetadepth[itb][ifb][ifc][0];
851  idepth=ihfetadepth[itb][ifb][ifc][1];
852  ihtr=ihslot[is]+ih;
853  det="HF";
854  fpga=((itb%2)==1)?("bot"):("top");
855  ihtr_fi=ifb+1;
856  ifi_ch=ifc;
857  iphi=(ieta>39)?(ihfphis[ic]+(is%2)*12+ih*4-3)%72+1:(ihfphis[ic]+(is%2)*12+ih*4+(ifb/4)*2-1)%72+1;
858  ispigot=(is%2)*6+ih*2+itb;
859  idcc=is<EMAP_NHSETS/2?1:2;
860  // idcc_sl=idcc==1?9:19;
861  ifed=fedhfnum[ic][idcc-1];
862  HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
863  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
864  HcalDetId hId(HcalForward,ieta*iside,iphi,idepth);
865  emap.mapEId2chId(elId,hId);
866  // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
867  }}}}}}
868  /* all HO crates */
869  for(ic=0; ic<EMAP_NHOCR; ic++){
870  /* three sets of four htrs per crate */
871  for(is=0; is<EMAP_NHSETSHO; is++){
872  /* four htrs per set */
873  for(ih=0; ih<EMAP_NHTRSHO; ih++){
874  /* top and bottom */
875  for(itb=0; itb<EMAP_NTOPBOT; itb++){
876  /* eight fibers per HTR FPGA */
877  for(ifb=0; ifb<EMAP_NFBR; ifb++){
878  /* three channels per fiber */
879  for(ifc=0; ifc<EMAP_NFCH; ifc++){
880  icrate=hocrate[ic];
881  idepth=1;
882  ieta=ihoetasidephi[ih][itb][ifb][ifc][0];
883  iside=ihoetasidephi[ih][itb][ifb][ifc][1];
884  iphi_loc=ihoetasidephi[ih][itb][ifb][ifc][2];
885  ihtr=ihslotho[is][ih];
886  det="HO";
887  fpga=((itb%2)==1)?("bot"):("top");
888  ihtr_fi=ifb+1;
889  ifi_ch=ifc;
890  iphi=(ihophis[ic]+is*6+iphi_loc-1)%72+1;
891  ispigot=ihtr<9?(ihtr-2)*2+itb:(ihtr-13)*2+itb;
892  idcc=ihtr<9?1:2;
893  // idcc_sl=idcc==1?9:19;
894  ifed=fedhonum[ic][idcc-1];
895  HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
896  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
897  if (ieta==0) { // unmapped
899  } else {
900  HcalDetId hId(HcalOuter,ieta*iside,iphi,idepth+3); // HO is officially "depth=4"
901  emap.mapEId2chId(elId,hId);
902  }
903  // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
904  }}}}}}
905 
906 
907  emap.sort();
908 
909 }
#define EMAP_NHFCR
static const HcalDetId Undefined
Definition: HcalDetId.h:80
int i
Definition: DBlmapReader.cc:9
#define EMAP_NFCH
HcalQIEShape makeQIEShape()
tuple correctTiming
#define EMAP_NHSETSHO
#define EMAP_NTOPBOT
HcalTimingParam makeTimingParam(HcalGenericDetId fId)
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
Definition: HcalDcsMap.cc:235
Definition: HcalQIENum.h:4
#define EMAP_NHOCR
tuple lumi
Definition: fjr2json.py:35
static const double slope[3]
HcalQIEType makeQIEType(HcalGenericDetId fId, bool testHFQIE10)
HcalCalibrationQIECoder makeCalibrationQIECoder(HcalGenericDetId fId)
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGainWidth.h:21
void makeHardcodeMap(HcalElectronicsMap &emap)
tuple result
Definition: mps_fire.py:95
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
HcalQIECoder makeQIECoder(HcalGenericDetId fId)
HcalPedestalWidth makePedestalWidth(HcalGenericDetId fId)
void makeHardcodeDcsMap(HcalDcsMap &dcs_map)
HcalGain makeGain(HcalGenericDetId fId, bool fSmear=false)
T sqrt(T t)
Definition: SSEVec.h:18
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
int j
Definition: DBlmapReader.cc:9
#define EMAP_NHBHECR
HcalQIENum
Definition: HcalQIENum.h:4
HcalRecoParam makeRecoParam(HcalGenericDetId fId)
#define EMAP_NHTRS
bool mapEId2chId(HcalElectronicsId fElectronicsId, DetId fId)
bool isHcalDetId() const
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
Definition: DetId.h:18
#define EMAP_NHSETS
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
HcalGainWidth makeGainWidth(HcalGenericDetId fId)
tuple useLeakCorrection
#define EMAP_NHTRSHO
HcalGenericSubdetector genericSubdet() const
HcalMCParam makeMCParam(HcalGenericDetId fId)
#define EMAP_NFBR
Readout chain identification for Hcal.
HcalPedestal makePedestal(HcalGenericDetId fId, bool fSmear=false)