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