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;
507  if (HcalDetId(fId).depth() == 1) value0 = 0.003333;
508  else if (HcalDetId(fId).depth() == 2) value0 = 0.003333;
509  else if (HcalDetId(fId).depth() == 3) value0 = 0.003333;
510  else if (HcalDetId(fId).depth() == 4) value0 = 0.003333;
511  else value0 = 0.003333; // GeV/fC
512  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
513  if (HcalDetId(fId).depth() == 1) value0 = 0.003333;
514  else if (HcalDetId(fId).depth() == 2) value0 = 0.003333;
515  else if (HcalDetId(fId).depth() == 3) value0 = 0.003333;
516  else if (HcalDetId(fId).depth() == 4) value0 = 0.003333;
517  else value0 = 0.003333; // GeV/fC
518  // if (fId.genericSubdet() != HcalGenericDetId::HcalGenForward) value0 = 0.177; // GeV/fC
519  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
520  HcalDetId hid(fId);
521  if ((hid.ieta() > -5) && (hid.ieta() < 5))
522  value0 = 0.0125;
523  else
524  value0 = 0.02083; // GeV/fC
525  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
526  if (HcalDetId(fId).depth() == 1) value0 = 0.2146;
527  else if (HcalDetId(fId).depth() == 2) value0 = 0.3375;
528  } else value0 = 0.003333; // GeV/fC
529  float value [4] = {value0, value0, value0, value0};
530  if (fSmear) for (int i = 0; i < 4; i++) value [i] = CLHEP::RandGauss::shoot (value0, width.getValue (i));
531  HcalGain result (fId.rawId (), value[0], value[1], value[2], value[3]);
532  return result;
533 }
534 
536  float value = 0;
538  return result;
539 }
540 
542  HcalQIECoder result (fId.rawId ());
543  float offset = 0.0;
545  0.36 : 0.333; // ADC/fC
546 
547  // qie8/qie10 attribution - 0/1
549  result.setQIEIndex(0);
550  slope = 1.0;
551  } else
552  result.setQIEIndex(1);
553 
554  for (unsigned range = 0; range < 4; range++) {
555  for (unsigned capid = 0; capid < 4; capid++) {
556  result.setOffset (capid, range, offset);
557  result.setSlope (capid, range, slope);
558  }
559  }
560 
561  return result;
562 }
563 
566  float lowEdges [64];
567  for (int i = 0; i < 64; i++) lowEdges[i] = -1.5 + i*1.0;
568  result.setMinCharges (lowEdges);
569  return result;
570 }
571 
573 
574  // std::cout << " !!! HcalDbHardcode::makeQIEShape " << std::endl;
575 
576  return HcalQIEShape ();
577 }
578 
579 
580 #define EMAP_NHBHECR 9
581 #define EMAP_NHFCR 3
582 #define EMAP_NHOCR 4
583 #define EMAP_NFBR 8
584 #define EMAP_NFCH 3
585 #define EMAP_NHTRS 3
586 #define EMAP_NHSETS 4
587 #define EMAP_NTOPBOT 2
588 #define EMAP_NHTRSHO 4
589 #define EMAP_NHSETSHO 3
590 
592  dcs_map.mapGeomId2DcsId(HcalDetId(HcalBarrel, -16, 1, 1),
594  dcs_map.mapGeomId2DcsId(HcalDetId(HcalForward, -41, 3, 1),
596  dcs_map.mapGeomId2DcsId(HcalDetId(HcalForward, -26, 25, 2),
598  dcs_map.mapGeomId2DcsId(HcalDetId(HcalBarrel, -15, 68, 1),
600  dcs_map.mapGeomId2DcsId(HcalDetId(HcalOuter, -14, 1, 4),
602  dcs_map.mapGeomId2DcsId(HcalDetId(HcalForward, 41, 71, 2),
604 }
605 
607 
608  /* HBHE crate numbering */
609  int hbhecrate[EMAP_NHBHECR]={0,1,4,5,10,11,14,15,17};
610  /* HF crate numbering */
611  int hfcrate[EMAP_NHFCR]={2,9,12};
612  /* HO crate numbering */
613  int hocrate[EMAP_NHOCR]={3,7,6,13};
614  /* HBHE FED numbering of DCCs */
615  int fedhbhenum[EMAP_NHBHECR][2]={{702,703},{704,705},{700,701},
616  {706,707},{716,717},{708,709},
617  {714,715},{710,711},{712,713}};
618  /* HF FED numbering of DCCs */
619  int fedhfnum[EMAP_NHFCR][2]={{718,719},{720,721},{722,723}};
620  /* HO FED numbering of DCCs */
621  int fedhonum[EMAP_NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
622  /* HBHE/HF htr slot offsets for set of three htrs */
623  int ihslot[EMAP_NHSETS]={2,5,13,16};
624  /* HO htr slot offsets for three sets of four htrs */
625  int ihslotho[EMAP_NHSETSHO][EMAP_NHTRSHO]={{2,3,4,5},{6,7,13,14},{15,16,17,18}};
626  /* iphi (lower) starting index for each HBHE crate */
627  int ihbhephis[EMAP_NHBHECR]={11,19,3,27,67,35,59,43,51};
628  /* iphi (lower) starting index for each HF crate */
629  int ihfphis[EMAP_NHFCR]={3,27,51};
630  /* iphi (lower) starting index for each HO crate */
631  int ihophis[EMAP_NHOCR]={71,17,35,53};
632  /* ihbheetadepth - unique HBHE {eta,depth} assignments per fiber and fiber channel */
633  int ihbheetadepth[EMAP_NHTRS][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
634  {{{{11,1},{ 7,1},{ 3,1}}, /* htr 0 (HB) -bot(+top) */
635  {{ 5,1},{ 1,1},{ 9,1}},
636  {{11,1},{ 7,1},{ 3,1}},
637  {{ 5,1},{ 1,1},{ 9,1}},
638  {{10,1},{ 6,1},{ 2,1}},
639  {{ 8,1},{ 4,1},{12,1}},
640  {{10,1},{ 6,1},{ 2,1}},
641  {{ 8,1},{ 4,1},{12,1}}},
642  {{{11,1},{ 7,1},{ 3,1}}, /* htr 0 (HB) +bot(-top) */
643  {{ 5,1},{ 1,1},{ 9,1}},
644  {{11,1},{ 7,1},{ 3,1}},
645  {{ 5,1},{ 1,1},{ 9,1}},
646  {{10,1},{ 6,1},{ 2,1}},
647  {{ 8,1},{ 4,1},{12,1}},
648  {{10,1},{ 6,1},{ 2,1}},
649  {{ 8,1},{ 4,1},{12,1}}}},
650  {{{{16,2},{15,2},{14,1}}, /* htr 1 (HBHE) -bot(+top) */
651  {{15,1},{13,1},{16,1}},
652  {{16,2},{15,2},{14,1}},
653  {{15,1},{13,1},{16,1}},
654  {{17,1},{16,3},{26,1}},
655  {{18,1},{18,2},{26,2}},
656  {{17,1},{16,3},{25,1}},
657  {{18,1},{18,2},{25,2}}},
658  {{{16,2},{15,2},{14,1}}, /* htr 1 (HBHE) +bot(-top) */
659  {{15,1},{13,1},{16,1}},
660  {{16,2},{15,2},{14,1}},
661  {{15,1},{13,1},{16,1}},
662  {{17,1},{16,3},{25,1}},
663  {{18,1},{18,2},{25,2}},
664  {{17,1},{16,3},{26,1}},
665  {{18,1},{18,2},{26,2}}}},
666  {{{{28,1},{28,2},{29,1}}, /* htr 2 (HE) -bot(+top) */
667  {{28,3},{24,2},{24,1}},
668  {{27,1},{27,2},{29,2}},
669  {{27,3},{23,2},{23,1}},
670  {{19,2},{20,1},{22,2}},
671  {{19,1},{20,2},{22,1}},
672  {{19,2},{20,1},{21,2}},
673  {{19,1},{20,2},{21,1}}},
674  {{{27,1},{27,2},{29,2}}, /* htr 2 (HE) +bot(-top) */
675  {{27,3},{23,2},{23,1}},
676  {{28,1},{28,2},{29,1}},
677  {{28,3},{24,2},{24,1}},
678  {{19,2},{20,1},{21,2}},
679  {{19,1},{20,2},{21,1}},
680  {{19,2},{20,1},{22,2}},
681  {{19,1},{20,2},{22,1}}}}
682  };
683  /* ihfetadepth - unique HF {eta,depth} assignments per fiber and fiber channel */
684  int ihfetadepth[EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
685  {{{33,1},{31,1},{29,1}}, /* top */
686  {{32,1},{30,1},{34,1}},
687  {{33,2},{31,2},{29,2}},
688  {{32,2},{30,2},{34,2}},
689  {{34,2},{32,2},{30,2}},
690  {{31,2},{29,2},{33,2}},
691  {{34,1},{32,1},{30,1}},
692  {{31,1},{29,1},{33,1}}},
693  {{{41,1},{37,1},{35,1}}, /* bot */
694  {{38,1},{36,1},{39,1}},
695  {{41,2},{37,2},{35,2}},
696  {{38,2},{36,2},{39,2}},
697  {{40,2},{38,2},{36,2}},
698  {{37,2},{35,2},{39,2}},
699  {{40,1},{38,1},{36,1}},
700  {{37,1},{35,1},{39,1}}}
701  };
702  /* ihoetasidephi - unique HO {eta,side,phi} assignments per fiber and fiber channel */
703  int ihoetasidephi[EMAP_NHTRSHO][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][3]={
704  {{{{ 1,-1,0},{ 2,-1,0},{ 3,-1,0}}, /* htr 0 (HO) top */
705  {{ 1,-1,1},{ 2,-1,1},{ 3,-1,1}},
706  {{ 1,-1,2},{ 2,-1,2},{ 3,-1,2}},
707  {{ 1,-1,3},{ 2,-1,3},{ 3,-1,3}},
708  {{ 1,-1,4},{ 2,-1,4},{ 3,-1,4}},
709  {{ 1,-1,5},{ 2,-1,5},{ 3,-1,5}},
710  {{14, 1,0},{14, 1,1},{14, 1,2}},
711  {{14, 1,3},{14, 1,4},{14, 1,5}}},
712  {{{ 1, 1,0},{ 2, 1,0},{ 3, 1,0}}, /* htr 0 (HO) bot */
713  {{ 1, 1,1},{ 2, 1,1},{ 3, 1,1}},
714  {{ 1, 1,2},{ 2, 1,2},{ 3, 1,2}},
715  {{ 1, 1,3},{ 2, 1,3},{ 3, 1,3}},
716  {{ 1, 1,4},{ 2, 1,4},{ 3, 1,4}},
717  {{ 1, 1,5},{ 2, 1,5},{ 3, 1,5}},
718  {{15, 1,0},{15, 1,1},{15, 1,2}},
719  {{15, 1,3},{15, 1,4},{15, 1,5}}}},
720  {{{{ 6, 1,0},{ 6, 1,1},{ 6, 1,2}}, /* htr 1 (HO) top */
721  {{ 6, 1,3},{ 6, 1,4},{ 6, 1,5}},
722  {{ 7, 1,0},{ 7, 1,1},{ 7, 1,2}},
723  {{ 7, 1,3},{ 7, 1,4},{ 7, 1,5}},
724  {{ 8, 1,0},{ 8, 1,1},{ 8, 1,2}},
725  {{ 8, 1,3},{ 8, 1,4},{ 8, 1,5}},
726  {{ 9, 1,0},{ 9, 1,1},{ 9, 1,2}},
727  {{ 9, 1,3},{ 9, 1,4},{ 9, 1,5}}},
728  {{{10, 1,0},{10, 1,1},{10, 1,2}}, /* htr 1 (HO) bot */
729  {{10, 1,3},{10, 1,4},{10, 1,5}},
730  {{11, 1,0},{11, 1,1},{11, 1,2}},
731  {{11, 1,3},{11, 1,4},{11, 1,5}},
732  {{12, 1,0},{12, 1,1},{12, 1,2}},
733  {{12, 1,3},{12, 1,4},{12, 1,5}},
734  {{13, 1,0},{13, 1,1},{13, 1,2}},
735  {{13, 1,3},{13, 1,4},{13, 1,5}}}},
736  {{{{ 4,-1,0},{ 4,-1,1},{ 0, 0,0}}, /* htr 2 (HO) top */
737  {{ 4,-1,2},{ 4,-1,3},{ 0, 0,0}},
738  {{ 4,-1,4},{ 4,-1,5},{ 0, 0,0}},
739  {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
740  {{ 5,-1,0},{ 5,-1,1},{ 5,-1,2}},
741  {{ 5,-1,3},{ 5,-1,4},{ 5,-1,5}},
742  {{14,-1,0},{14,-1,1},{14,-1,2}},
743  {{14,-1,3},{14,-1,4},{14,-1,5}}},
744  {{{ 4, 1,0},{ 4, 1,1},{ 0, 0,0}}, /* htr 2 (HO) bot */
745  {{ 4, 1,2},{ 4, 1,3},{ 0, 0,0}},
746  {{ 4, 1,4},{ 4, 1,5},{ 0, 0,0}},
747  {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
748  {{ 5, 1,0},{ 5, 1,1},{ 5, 1,2}},
749  {{ 5, 1,3},{ 5, 1,4},{ 5, 1,5}},
750  {{15,-1,0},{15,-1,1},{15,-1,2}},
751  {{15,-1,3},{15,-1,4},{15,-1,5}}}},
752  {{{{ 6,-1,0},{ 6,-1,1},{ 6,-1,2}}, /* htr 3 (HO) top */
753  {{ 6,-1,3},{ 6,-1,4},{ 6,-1,5}},
754  {{ 7,-1,0},{ 7,-1,1},{ 7,-1,2}},
755  {{ 7,-1,3},{ 7,-1,4},{ 7,-1,5}},
756  {{ 8,-1,0},{ 8,-1,1},{ 8,-1,2}},
757  {{ 8,-1,3},{ 8,-1,4},{ 8,-1,5}},
758  {{ 9,-1,0},{ 9,-1,1},{ 9,-1,2}},
759  {{ 9,-1,3},{ 9,-1,4},{ 9,-1,5}}},
760  {{{10,-1,0},{10,-1,1},{10,-1,2}}, /* htr 3 (HO) bot */
761  {{10,-1,3},{10,-1,4},{10,-1,5}},
762  {{11,-1,0},{11,-1,1},{11,-1,2}},
763  {{11,-1,3},{11,-1,4},{11,-1,5}},
764  {{12,-1,0},{12,-1,1},{12,-1,2}},
765  {{12,-1,3},{12,-1,4},{12,-1,5}},
766  {{13,-1,0},{13,-1,1},{13,-1,2}},
767  {{13,-1,3},{13,-1,4},{13,-1,5}}}}
768  };
769  int ic,is,ih,itb,ifb,ifc,ifwtb,iphi_loc;
770  int iside,ieta,iphi,idepth,icrate,ihtr,ihtr_fi,ifi_ch,ispigot,idcc,ifed;
771  // int idcc_sl;
772  std::string det;
773  std::string fpga;
774  // printf(" side eta phi depth det crate htr fpga htr_fi fi_ch spigo dcc dcc_sl fedid\n");
775  /* all HBHE crates */
776  for(ic=0; ic<EMAP_NHBHECR; ic++){
777  /* four sets of three htrs per crate */
778  for(is=0; is<EMAP_NHSETS; is++){
779  /* three htrs per set */
780  for(ih=0; ih<EMAP_NHTRS; ih++){
781  /* top and bottom */
782  for(itb=0; itb<EMAP_NTOPBOT; itb++){
783  /* eight fibers per HTR FPGA */
784  for(ifb=0; ifb<EMAP_NFBR; ifb++){
785  /* three channels per fiber */
786  for(ifc=0; ifc<EMAP_NFCH; ifc++){
787  icrate=hbhecrate[ic];
788  iside=is<EMAP_NHSETS/2?-1:1;
789  ifwtb=(is/2+itb+1)%2;
790  ieta=ihbheetadepth[ih][ifwtb][ifb][ifc][0];
791  idepth=ihbheetadepth[ih][ifwtb][ifb][ifc][1];
792  ihtr=ihslot[is]+ih;
793  det=((ieta>16||idepth>2)?("HE"):("HB"));
794  fpga=((itb%2)==1)?("bot"):("top");
795  ihtr_fi=ifb+1;
796  ifi_ch=ifc;
797  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;
798  ispigot=(is%2)*6+ih*2+itb;
799  idcc=is<EMAP_NHSETS/2?1:2;
800  // idcc_sl=idcc==1?9:19;
801  ifed=fedhbhenum[ic][idcc-1];
803  HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
804  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
805  HcalDetId hId((det=="HB")?(HcalBarrel):(HcalEndcap),ieta*iside,iphi,idepth);
806  emap.mapEId2chId(elId,hId);
807 
808  // 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);
809  }}}}}}
810  /* all HF crates */
811  for(ic=0; ic<EMAP_NHFCR; ic++){
812  /* four sets of three htrs per crate */
813  for(is=0; is<EMAP_NHSETS; is++){
814  /* three htrs per set */
815  for(ih=0; ih<EMAP_NHTRS; ih++){
816  /* top and bottom */
817  for(itb=0; itb<EMAP_NTOPBOT; itb++){
818  /* eight fibers per HTR FPGA */
819  for(ifb=0; ifb<EMAP_NFBR; ifb++){
820  /* three channels per fiber */
821  for(ifc=0; ifc<EMAP_NFCH; ifc++){
822  icrate=hfcrate[ic];
823  iside=is<EMAP_NHSETS/2?-1:1;
824  ieta=ihfetadepth[itb][ifb][ifc][0];
825  idepth=ihfetadepth[itb][ifb][ifc][1];
826  ihtr=ihslot[is]+ih;
827  det="HF";
828  fpga=((itb%2)==1)?("bot"):("top");
829  ihtr_fi=ifb+1;
830  ifi_ch=ifc;
831  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;
832  ispigot=(is%2)*6+ih*2+itb;
833  idcc=is<EMAP_NHSETS/2?1:2;
834  // idcc_sl=idcc==1?9:19;
835  ifed=fedhfnum[ic][idcc-1];
836  HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
837  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
838  HcalDetId hId(HcalForward,ieta*iside,iphi,idepth);
839  emap.mapEId2chId(elId,hId);
840  // 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);
841  }}}}}}
842  /* all HO crates */
843  for(ic=0; ic<EMAP_NHOCR; ic++){
844  /* three sets of four htrs per crate */
845  for(is=0; is<EMAP_NHSETSHO; is++){
846  /* four htrs per set */
847  for(ih=0; ih<EMAP_NHTRSHO; ih++){
848  /* top and bottom */
849  for(itb=0; itb<EMAP_NTOPBOT; itb++){
850  /* eight fibers per HTR FPGA */
851  for(ifb=0; ifb<EMAP_NFBR; ifb++){
852  /* three channels per fiber */
853  for(ifc=0; ifc<EMAP_NFCH; ifc++){
854  icrate=hocrate[ic];
855  idepth=1;
856  ieta=ihoetasidephi[ih][itb][ifb][ifc][0];
857  iside=ihoetasidephi[ih][itb][ifb][ifc][1];
858  iphi_loc=ihoetasidephi[ih][itb][ifb][ifc][2];
859  ihtr=ihslotho[is][ih];
860  det="HO";
861  fpga=((itb%2)==1)?("bot"):("top");
862  ihtr_fi=ifb+1;
863  ifi_ch=ifc;
864  iphi=(ihophis[ic]+is*6+iphi_loc-1)%72+1;
865  ispigot=ihtr<9?(ihtr-2)*2+itb:(ihtr-13)*2+itb;
866  idcc=ihtr<9?1:2;
867  // idcc_sl=idcc==1?9:19;
868  ifed=fedhonum[ic][idcc-1];
869  HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
870  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
871  if (ieta==0) { // unmapped
873  } else {
874  HcalDetId hId(HcalOuter,ieta*iside,iphi,idepth+3); // HO is officially "depth=4"
875  emap.mapEId2chId(elId,hId);
876  }
877  // 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);
878  }}}}}}
879 
880 
881  emap.sort();
882 
883 }
#define EMAP_NHFCR
static const HcalDetId Undefined
Definition: HcalDetId.h:52
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:205
#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:45
HcalQIECoder makeQIECoder(HcalGenericDetId fId)
HcalPedestalWidth makePedestalWidth(HcalGenericDetId fId)
void makeHardcodeDcsMap(HcalDcsMap &dcs_map)
int depth() const
get the tower depth
Definition: HcalDetId.h:42
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:38
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:40
Definition: DetId.h:20
#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)