CMS 3D CMS Logo

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 #include <cmath>
7 #include <sstream>
8 #include <iostream>
9 #include <memory>
10 
11 #include "CLHEP/Random/RandGauss.h"
16 
18  : //"generic" set of conditions
19  theDefaultParameters_(3.0, //pedestal
20  0.5, //pedestal width
21  {0.2, 0.2}, //gains
22  {0.0, 0.0}, //gain widths
23  0, //ZS threshold
24  0, //QIE type
25  {0.0, 0.0, 0.0, 0.0}, //QIE offsets
26  {0.9, 0.9, 0.9, 0.9}, //QIE slopes
27  125, //MC shape
28  105, //Reco shape
29  0.0, //photoelectronsToAnalog
30  {0.0} //dark current
31  ),
32  setHB_(false),
33  setHE_(false),
34  setHF_(false),
35  setHO_(false),
36  setHBUpgrade_(false),
37  setHEUpgrade_(false),
38  setHFUpgrade_(false),
39  useHBUpgrade_(false),
40  useHEUpgrade_(false),
41  useHOUpgrade_(true),
42  useHFUpgrade_(false),
43  testHFQIE10_(false),
44  testHEPlan1_(false) {}
45 
50  else if (!useHBUpgrade_ && setHB_)
51  return theHBParameters_;
52  else
53  return theDefaultParameters_;
54  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
55  bool b_isHEPlan1 = testHEPlan1_ ? isHEPlan1(fId) : false;
56  if ((useHEUpgrade_ || b_isHEPlan1) && setHEUpgrade_)
58  else if (!useHEUpgrade_ && !b_isHEPlan1 && setHE_)
59  return theHEParameters_;
60  else
61  return theDefaultParameters_;
62  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
65  else if (testHFQIE10_ && fId.isHcalDetId()) {
66  HcalDetId hid(fId);
67  //special mixed case for HF 2016
68  if (hid.iphi() == 39 && hid.zside() == 1 &&
69  (hid.depth() >= 3 || (hid.depth() == 2 && (hid.ieta() == 30 || hid.ieta() == 34))) && setHFUpgrade_)
71  else if (setHF_)
72  return theHFParameters_;
73  else
74  return theDefaultParameters_;
75  } else if (!useHFUpgrade_ && setHF_)
76  return theHFParameters_;
77  else
78  return theDefaultParameters_;
79  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
80  if (setHO_)
81  return theHOParameters_;
82  else
83  return theDefaultParameters_;
84  } else
85  return theDefaultParameters_;
86 }
87 
89  int index = 0;
91  HcalDetId hid(fId);
92  if ((hid.ieta() > -5) && (hid.ieta() < 5))
93  index = 0;
94  else
95  index = 1;
96  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
97  HcalDetId hid(fId);
98  if (hid.depth() % 2 == 1)
99  index = 0; //depths 1,3
100  else if (hid.depth() % 2 == 0)
101  index = 1; //depths 2,4
102  }
103  return index;
104 }
105 
107  HcalGenericDetId fId, bool fSmear, bool eff, const HcalTopology* topo, double intlumi) {
108  HcalPedestalWidth width = makePedestalWidth(fId, eff, topo, intlumi);
109  float value0 = getParameters(fId).pedestal();
110  if (eff) {
111  //account for dark current + crosstalk
112  auto sipmpar = makeHardcodeSiPMParameter(fId, topo, intlumi);
113  auto sipmchar = makeHardcodeSiPMCharacteristics();
114  value0 += sipmpar.getDarkCurrent() * 25. / (1. - sipmchar->getCrossTalk(sipmpar.getType()));
115  }
116  float value[4] = {value0, value0, value0, value0};
117  if (fSmear) {
118  for (int i = 0; i < 4; i++) {
119  value[i] = 0.0f;
120  while (value[i] <= 0.0f)
121  // ignore correlations, assume 10K pedestal run
122  value[i] = value0 + (float)CLHEP::RandGauss::shoot(0.0, width.getWidth(i) / 100.);
123  }
124  }
125  HcalPedestal result(fId.rawId(), value[0], value[1], value[2], value[3]);
126  return result;
127 }
128 
130  bool eff,
131  const HcalTopology* topo,
132  double intlumi) {
133  float value = getParameters(fId).pedestalWidth();
134  float width2 = value * value;
135  // everything in fC
136 
137  if (eff) {
138  //account for dark current + crosstalk
139  auto sipmpar = makeHardcodeSiPMParameter(fId, topo, intlumi);
140  auto sipmchar = makeHardcodeSiPMCharacteristics();
141  //add in quadrature
142  width2 += sipmpar.getDarkCurrent() * 25. / std::pow(1 - sipmchar->getCrossTalk(sipmpar.getType()), 3) *
143  sipmpar.getFCByPE();
144  }
145 
147  for (int i = 0; i < 4; i++) {
148  for (int j = 0; j < 4; j++) {
149  result.setSigma(i, j, 0.0);
150  }
151  result.setSigma(i, i, width2);
152  }
153  return result;
154 }
155 
156 HcalGain HcalDbHardcode::makeGain(HcalGenericDetId fId, bool fSmear) const { // GeV/fC
158  float value0 = getParameters(fId).gain(getGainIndex(fId));
159  float value[4] = {value0, value0, value0, value0};
160  if (fSmear) {
161  for (int i = 0; i < 4; i++) {
162  value[i] = 0.0f;
163  while (value[i] <= 0.0f)
164  value[i] = value0 + (float)CLHEP::RandGauss::shoot(0.0, width.getValue(i));
165  }
166  }
167  HcalGain result(fId.rawId(), value[0], value[1], value[2], value[3]);
168  return result;
169 }
170 
172  float value = getParameters(fId).gainWidth(getGainIndex(fId));
174  return result;
175 }
176 
178  int value = getParameters(fId).zsThreshold();
180  return result;
181 }
182 
184  HcalQIECoder result(fId.rawId());
185  // slope in ADC/fC
186  const HcalHardcodeParameters& param(getParameters(fId));
187  for (unsigned range = 0; range < 4; range++) {
188  for (unsigned capid = 0; capid < 4; capid++) {
189  result.setOffset(capid, range, param.qieOffset(range));
190  result.setSlope(capid, range, param.qieSlope(range));
191  }
192  }
193 
194  return result;
195 }
196 
198  HcalQIENum qieType = (HcalQIENum)(getParameters(fId).qieType());
199  HcalQIEType result(fId.rawId(), qieType);
200  return result;
201 }
202 
205  float lowEdges[64];
206  for (int i = 0; i < 64; i++) {
207  lowEdges[i] = -1.5 + i;
208  }
209  result.setMinCharges(lowEdges);
210  return result;
211 }
212 
214 
216  int r1bit[5];
217  r1bit[0] = 9; // [0,9]
218  int syncPhase = 0;
219  r1bit[1] = 1;
220  int binOfMaximum = 0;
221  r1bit[2] = 4;
222  float phase = -25.0f; // [-25.0,25.0]
223  float Xphase = (phase + 32.0f) * 4.0f; // never change this line
224  // (offset 50nsec, 0.25ns step)
225  int Iphase = Xphase;
226  r1bit[3] = 8; // [0,256] offset 50ns, .25ns step
227  int timeSmearing = 0;
228  r1bit[4] = 1; // bool
229 
230  const HcalHardcodeParameters& hparam(getParameters(fId));
231  int pulseShapeID = hparam.mcShape(); // a0
232 
234  syncPhase = 1; // a1 bool
235  binOfMaximum = 5; // a2
236  phase = 5.0f; // a3 [-25.0,25.0]
237  Xphase = (phase + 32.0f) * 4.0f; // never change this line
238  // (offset 50nsec, 0.25ns step)
239  Iphase = Xphase;
240  timeSmearing = 1; // a4
241 
242  }
243 
245  syncPhase = 1; // a1 bool
246  binOfMaximum = 5; // a2
247  phase = 5.0f; // a3 [-25.0,25.0]
248  Xphase = (phase + 32.0f) * 4.0f; // never change this line
249  // (offset 50nsec, 0.25ns step)
250  Iphase = Xphase;
251  timeSmearing = 1; // a4
252 
253  }
254 
255  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
256  syncPhase = 1; // a1 bool
257  binOfMaximum = 5; // a2
258  phase = 5.0f; // a3 [-25.0,25.0]
259  Xphase = (phase + 32.0f) * 4.0f; // never change this line
260  // (offset 50nsec, 0.25ns step)
261  Iphase = Xphase;
262  timeSmearing = 0; // a4
263 
264  HcalDetId cell = HcalDetId(fId);
265  if (cell.ieta() == 1 && cell.iphi() == 1)
266  pulseShapeID = 125;
267 
268  }
269 
271  syncPhase = 1; // a1 bool
272  binOfMaximum = 3; // a2
273  phase = 14.0f; // a3 [-25.0,25.0]
274  Xphase = (phase + 32.0f) * 4.0f; // never change this line
275  // (offset 50nsec, 0.25ns step)
276  Iphase = Xphase;
277  timeSmearing = 0; // a4
278 
279  }
280 
281  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenZDC) {
282  pulseShapeID = 401; // a0
283  syncPhase = 1; // a1 bool
284  binOfMaximum = 5; // a2
285  phase = -4.0f; // a3 [-25.0,25.0]
286  Xphase = (phase + 32.0f) * 4.0f; // never change this line
287  // (offset 50nsec, 0.25ns step)
288  Iphase = Xphase;
289  timeSmearing = 0; // a4
290  }
291 
292  int rshift[7];
293  rshift[0] = 0;
294  for (int k = 0; k < 5; k++) {
295  rshift[k + 1] = rshift[k] + r1bit[k];
296  }
297 
298  int packingScheme = 1; // a5
299  unsigned int param = pulseShapeID | syncPhase << rshift[1] | (binOfMaximum << rshift[2]) | (Iphase << rshift[3]) |
300  (timeSmearing << rshift[4] | packingScheme << 27);
301 
302  HcalMCParam result(fId.rawId(), param);
303  return result;
304 }
305 
307  // Mostly comes from S.Kunori's macro
308  int p1bit[6];
309 
310  // param1
311  int containmentCorrectionFlag = 0;
312  p1bit[0] = 1; // bool
313  int containmentCorrectionPreSample = 0;
314  p1bit[1] = 1; // bool
315  float phase = 13.0; // [-25.0,25.0]
316  float Xphase = (phase + 32.0) * 4.0; //never change this line
317  // (offset 50nsec, 0.25ns step)
318  int Iphase = Xphase;
319  p1bit[2] = 8; // [0,256]
320  // (offset 50ns, 0.25ns step
321  int firstSample = 4;
322  p1bit[3] = 4; // [0,9]
323  int samplesToAdd = 2;
324  p1bit[4] = 4; // [0,9]
325  p1bit[5] = 9; // [0,9]
326 
327  const HcalHardcodeParameters& hparam(getParameters(fId));
328  int pulseShapeID = hparam.recoShape(); // a5
329 
330  int q2bit[10];
331  // param2.
332  int useLeakCorrection = 0;
333  q2bit[0] = 1; // bool
334  int LeakCorrectionID = 0;
335  q2bit[1] = 4; // [0,15]
336  int correctForTimeslew = 0;
337  q2bit[2] = 1; // bool
338  int timeCorrectionID = 0;
339  q2bit[3] = 4; // [0,15]
340  int correctTiming = 0;
341  q2bit[4] = 1; // bool
342  int firstAuxTS = 0;
343  q2bit[5] = 4; // [0,15]
344  int specialCaseID = 0;
345  q2bit[6] = 4; // [0,15]
346  int noiseFlaggingID = 0;
347  q2bit[7] = 4; // [0,15]
348  int pileupCleaningID = 0;
349  q2bit[8] = 4; // [0,15]
350  int packingScheme = 1;
351  q2bit[9] = 4;
352 
355  // param1.
356  containmentCorrectionFlag = 1; // p0
357  containmentCorrectionPreSample = 0; // p1
358  float phase = 6.0;
359  float Xphase = (phase + 32.0) * 4.0; // never change this line
360  //(offset 50nsec, 0.25ns step)
361  Iphase = Xphase; // p2
362  firstSample = 4; // p3
363  samplesToAdd = 2; // p4
364 
365  // param2.
366  useLeakCorrection = 0; // q0
367  LeakCorrectionID = 0; // q1
368  correctForTimeslew = 1; // q2
369  timeCorrectionID = 0; // q3
370  correctTiming = 1; // q4
371  firstAuxTS = 4; // q5
372  specialCaseID = 0; // q6
373  noiseFlaggingID = 1; // q7
374  pileupCleaningID = 0; // q8
375  }
376 
377  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
378  // param1.
379  containmentCorrectionFlag = 1; // p0
380  containmentCorrectionPreSample = 0; // p1
381  float phase = 13.0;
382  float Xphase = (phase + 32.0) * 4.0; // never change this line
383  // (offset 50nsec, 0.25ns step)
384  Iphase = Xphase; // p2
385  firstSample = 4; // p3
386  samplesToAdd = 4; // p4
387 
388  // param2.
389  useLeakCorrection = 0; // q0
390  LeakCorrectionID = 0; // q1
391  correctForTimeslew = 1; // q2
392  timeCorrectionID = 0; // q3
393  correctTiming = 1; // q4
394  firstAuxTS = 4; // q5
395  specialCaseID = 0; // q6
396  noiseFlaggingID = 1; // q7
397  pileupCleaningID = 0; // q8
398 
399  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
400  // param1.
401  containmentCorrectionFlag = 0; // p0
402  containmentCorrectionPreSample = 0; // p1
403  float phase = 13.0;
404  float Xphase = (phase + 32.0) * 4.0; // never change this line
405  // (offset 50nsec, 0.25ns step)
406  Iphase = Xphase; // p2
407  firstSample = 2; // p3
408  samplesToAdd = 1; // p4
409 
410  // param2.
411  useLeakCorrection = 0; // q0
412  LeakCorrectionID = 0; // q1
413  correctForTimeslew = 0; // q2
414  timeCorrectionID = 0; // q3
415  correctTiming = 1; // q4
416  firstAuxTS = 1; // q5
417  specialCaseID = 0; // q6
418  noiseFlaggingID = 1; // q7
419  pileupCleaningID = 0; // q8
420  }
421 
422  // Packing parameters in two words
423 
424  int p1shift[7];
425  p1shift[0] = 0;
426  for (int k = 0; k < 6; k++) {
427  int j = k + 1;
428  p1shift[j] = p1shift[k] + p1bit[k];
429  // cout<<" j= "<<j<<" shift "<< p1shift[j]<<endl;
430  }
431  int param1 = 0;
432  param1 = containmentCorrectionFlag | (containmentCorrectionPreSample << p1shift[1]) | (Iphase << p1shift[2]) |
433  (firstSample << p1shift[3]) | (samplesToAdd << p1shift[4]) | (pulseShapeID << p1shift[5]);
434 
435  int q2shift[10];
436  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 | (LeakCorrectionID << q2shift[1]) | (correctForTimeslew << q2shift[2]) |
444  (timeCorrectionID << q2shift[3]) | (correctTiming << q2shift[4]) | (firstAuxTS << q2shift[5]) |
445  (specialCaseID << q2shift[6]) | (noiseFlaggingID << q2shift[7]) | (pileupCleaningID << q2shift[8]) |
446  (packingScheme << q2shift[9]);
447 
448  HcalRecoParam result(fId.rawId(), param1, param2);
449 
450  return result;
451 }
452 
454  int nhits = 0;
455  float phase = 0.0;
456  float rms = 0.0;
458  nhits = 4;
459  phase = 4.5;
460  rms = 6.5;
461  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
462  nhits = 4;
463  phase = 9.3;
464  rms = 7.8;
465  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
466  nhits = 4;
467  phase = 8.6;
468  rms = 2.3;
469  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) {
470  nhits = 4;
471  phase = 12.4;
472  rms = 12.29;
473  }
475 
476  return result;
477 }
478 
479 #define EMAP_NHBHECR 9
480 #define EMAP_NHFCR 3
481 #define EMAP_NHOCR 4
482 #define EMAP_NFBR 8
483 #define EMAP_NFCH 3
484 #define EMAP_NHTRS 3
485 #define EMAP_NHSETS 4
486 #define EMAP_NTOPBOT 2
487 #define EMAP_NHTRSHO 4
488 #define EMAP_NHSETSHO 3
489 
490 std::unique_ptr<HcalDcsMap> HcalDbHardcode::makeHardcodeDcsMap() const {
491  HcalDcsMapAddons::Helper dcs_map_helper;
492  dcs_map_helper.mapGeomId2DcsId(HcalDetId(HcalBarrel, -16, 1, 1),
494  dcs_map_helper.mapGeomId2DcsId(HcalDetId(HcalForward, -41, 3, 1),
496  dcs_map_helper.mapGeomId2DcsId(HcalDetId(HcalForward, -26, 25, 2),
498  dcs_map_helper.mapGeomId2DcsId(HcalDetId(HcalBarrel, -15, 68, 1),
500  dcs_map_helper.mapGeomId2DcsId(HcalDetId(HcalOuter, -14, 1, 4),
502  dcs_map_helper.mapGeomId2DcsId(HcalDetId(HcalForward, 41, 71, 2),
504  return std::make_unique<HcalDcsMap>(dcs_map_helper);
505 }
506 
507 std::unique_ptr<HcalElectronicsMap> HcalDbHardcode::makeHardcodeMap(const std::vector<HcalGenericDetId>& cells) const {
508  static const int kUTCAMask = 0x4000000; //set bit 26 for uTCA version
509  static const int kLinearIndexMax = 0x7FFFF; //19 bits
510  static const int kTriggerBitMask = 0x02000000; //2^25
511  uint32_t counter = 0;
512  uint32_t counterTrig = 0;
514  for (const auto& fId : cells) {
515  if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel ||
516  fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap ||
517  fId.genericSubdet() == HcalGenericDetId::HcalGenForward ||
518  fId.genericSubdet() == HcalGenericDetId::HcalGenOuter || fId.genericSubdet() == HcalGenericDetId::HcalGenZDC) {
519  ++counter;
520  assert(counter < kLinearIndexMax);
521  uint32_t raw = counter;
522  raw |= kUTCAMask;
523  HcalElectronicsId elId(raw);
524  emapHelper.mapEId2chId(elId, fId);
525  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenTriggerTower) {
526  ++counterTrig;
527  assert(counterTrig < kLinearIndexMax);
528  uint32_t raw = counterTrig;
529  raw |= kUTCAMask | kTriggerBitMask;
530  HcalElectronicsId elId(raw);
531  emapHelper.mapEId2tId(elId, fId);
532  }
533  }
534  return std::make_unique<HcalElectronicsMap>(emapHelper);
535 }
536 
537 std::unique_ptr<HcalFrontEndMap> HcalDbHardcode::makeHardcodeFrontEndMap(
538  const std::vector<HcalGenericDetId>& cells) const {
540  std::stringstream mystream;
541  std::string detector[5] = {"XX", "HB", "HE", "HO", "HF"};
542  for (const auto& fId : cells) {
543  if (fId.isHcalDetId()) {
544  HcalDetId id = HcalDetId(fId.rawId());
545  HcalSubdetector subdet = id.subdet();
546  int ieta = id.ietaAbs();
547  int iside = id.zside();
548  int iphi = id.iphi();
549  std::string det, rbx;
550  int irm(0);
551  char tempbuff[30];
552  char sidesign = (iside == -1) ? 'M' : 'P';
553  if (subdet == HcalBarrel || subdet == HcalEndcap) {
554  det = detector[subdet];
555  irm = (iphi + 1) % 4 + 1;
556  int iwedge(0);
557  if (ieta >= 21 && (irm == 1 || irm == 3))
558  iwedge = (iphi + 1 + irm + 1) / 4;
559  else
560  iwedge = (iphi + irm + 1) / 4;
561  if (iwedge > 18)
562  iwedge -= 18;
563  sprintf(tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge, '\0');
564  mystream << tempbuff;
565  rbx = mystream.str();
566  mystream.str("");
567  emapHelper.loadObject(id, irm, rbx);
568  } else if (subdet == HcalForward) {
569  det = detector[subdet];
570  int hfphi(0);
571  if ((iside == 1 && ieta == 40) || (iside == -1 && ieta == 41)) {
572  irm = ((iphi + 1) / 2) % 36 + 1;
573  hfphi = ((iphi + 1) / 6) % 12 + 1;
574  } else {
575  irm = (iphi + 1) / 2;
576  hfphi = (iphi - 1) / 6 + 1;
577  }
578  irm = (irm - 1) % 3 + 1;
579  sprintf(tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, hfphi, '\0');
580  mystream << tempbuff;
581  rbx = mystream.str();
582  mystream.str("");
583  emapHelper.loadObject(id, irm, rbx);
584  } else if (subdet == HcalOuter) {
585  det = detector[subdet];
586  int ring(0), sector(0);
587  if (ieta <= 4)
588  ring = 0;
589  else if (ieta >= 5 && ieta <= 10)
590  ring = 1;
591  else
592  ring = 2;
593  for (int i = -2; i < iphi; i += 6)
594  sector++;
595  if (sector > 12)
596  sector = 1;
597  irm = ((iphi + 1) / 2) % 6 + 1;
598  if (ring != 0 && sector % 2 != 0)
599  sector++;
600  if (ring == 0)
601  sprintf(tempbuff, "%s%i%2.2d", det.c_str(), ring, sector);
602  else
603  sprintf(tempbuff, "%s%i%c%2.2d", det.c_str(), ring, sidesign, sector);
604  mystream << tempbuff;
605  rbx = mystream.str();
606  mystream.str("");
607  emapHelper.loadObject(id, irm, rbx);
608  }
609  }
610  }
611  return std::make_unique<HcalFrontEndMap>(emapHelper);
612 }
613 
615  //check for cached value
616  auto eta_depth_pair = std::make_pair(ieta, depth);
617  auto nLayers = theLayersInDepths_.find(eta_depth_pair);
618  if (nLayers != theLayersInDepths_.end()) {
619  return nLayers->second;
620  } else {
621  std::vector<int> segmentation;
622  topo->getDepthSegmentation(ieta, segmentation);
623  //assume depth segmentation vector is sorted
624  int nLayersInDepth = std::distance(std::lower_bound(segmentation.begin(), segmentation.end(), depth),
625  std::upper_bound(segmentation.begin(), segmentation.end(), depth));
626  theLayersInDepths_.insert(std::make_pair(eta_depth_pair, nLayersInDepth));
627  return nLayersInDepth;
628  }
629 }
630 
632  if (fId.isHcalDetId()) {
633  HcalDetId hid(fId);
634  //special mixed case for HE 2017
635  if (hid.zside() == 1 && (hid.iphi() == 63 || hid.iphi() == 64 || hid.iphi() == 65 || hid.iphi() == 66))
636  return true;
637  }
638  return false;
639 }
640 
642  const HcalTopology* topo,
643  double intlumi) {
644  // SiPMParameter defined for each DetId the following quantities:
645  // SiPM type, PhotoElectronToAnalog, Dark Current, two auxiliary words
646  // These numbers come from some measurements done with SiPMs
647  // rule for type: cells with >4 layers use larger device (3.3mm diameter), otherwise 2.8mm
648  HcalSiPMType theType = HcalNoSiPM;
649  double thePe2fC = getParameters(fId).photoelectronsToAnalog();
650  double theDC = getParameters(fId).darkCurrent(0, intlumi);
652  if (useHBUpgrade_) {
653  HcalDetId hid(fId);
654  int nLayersInDepth = getLayersInDepth(hid.ietaAbs(), hid.depth(), topo);
655  if (nLayersInDepth > 4) {
656  theType = HcalHBHamamatsu2;
657  theDC = getParameters(fId).darkCurrent(1, intlumi);
658  } else {
659  theType = HcalHBHamamatsu1;
660  theDC = getParameters(fId).darkCurrent(0, intlumi);
661  }
662  } else
663  theType = HcalHPD;
664  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
665  if (useHEUpgrade_ || (testHEPlan1_ && isHEPlan1(fId))) {
666  HcalDetId hid(fId);
667  int nLayersInDepth = getLayersInDepth(hid.ietaAbs(), hid.depth(), topo);
668  if (nLayersInDepth > 4) {
669  theType = HcalHEHamamatsu2;
670  theDC = getParameters(fId).darkCurrent(1, intlumi);
671  } else {
672  theType = HcalHEHamamatsu1;
673  theDC = getParameters(fId).darkCurrent(0, intlumi);
674  }
675  } else
676  theType = HcalHPD;
677  } else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
678  if (useHOUpgrade_)
679  theType = HcalHOHamamatsu;
680  else
681  theType = HcalHPD;
682  }
683 
684  return HcalSiPMParameter(fId.rawId(), theType, thePe2fC, theDC, 0, 0);
685 }
686 
687 std::unique_ptr<HcalSiPMCharacteristics> HcalDbHardcode::makeHardcodeSiPMCharacteristics() const {
688  // SiPMCharacteristics are constants for each type of SiPM:
689  // Type, # of pixels, 3 parameters for non-linearity, cross talk parameter, ..
690  // Obtained from data sheet and measurements
691  // types (in order): HcalHOZecotek=1, HcalHOHamamatsu, HcalHEHamamatsu1, HcalHEHamamatsu2, HcalHBHamamatsu1, HcalHBHamamatsu2, HcalHPD
693  for (unsigned ip = 0; ip < theSiPMCharacteristics_.size(); ++ip) {
694  auto& ps = theSiPMCharacteristics_[ip];
695  sipmHelper.loadObject(ip + 1,
696  ps.getParameter<int>("pixels"),
697  ps.getParameter<double>("nonlin1"),
698  ps.getParameter<double>("nonlin2"),
699  ps.getParameter<double>("nonlin3"),
700  ps.getParameter<double>("crosstalk"),
701  0,
702  0);
703  }
704  return std::make_unique<HcalSiPMCharacteristics>(sipmHelper);
705 }
706 
708  // For each detId parameters for trigger primitive
709  // mask for channel validity and self trigger information, fine grain
710  // bit information and auxiliary words
711  uint32_t bitInfo = ((44 << 16) | 30);
712  return HcalTPChannelParameter(fId.rawId(), 0, bitInfo, 0, 0);
713 }
714 
716  // Parameters for a given TP algorithm:
717  // FineGrain Algorithm Version for HBHE, ADC threshold fof TDC mask of HF,
718  // TDC mask for HF, Self Trigger bits, auxiliary words
719  tppar.loadObject(0, 0, 0xFFFFFFFFFFFFFFFF, 0, 0, 0);
720 }
const double pedestalWidth() const
HcalMCParam makeMCParam(HcalGenericDetId fId) const
HcalHardcodeParameters theHOParameters_
bool mapEId2chId(HcalElectronicsId fElectronicsId, DetId fId)
std::map< std::pair< int, int >, int > theLayersInDepths_
void getDepthSegmentation(const unsigned ring, std::vector< int > &readoutDepths, const bool flag=false) const
constexpr int nLayers
Definition: Common.h:13
const HcalHardcodeParameters & getParameters(HcalGenericDetId fId) const
HcalCalibrationQIECoder makeCalibrationQIECoder(HcalGenericDetId fId) const
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
bool loadObject(DetId fId, int rm, std::string rbx)
load a new entry
const int recoShape() const
std::vector< edm::ParameterSet > theSiPMCharacteristics_
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
std::unique_ptr< HcalElectronicsMap > makeHardcodeMap(const std::vector< HcalGenericDetId > &cells) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool isHEPlan1(HcalGenericDetId fId) const
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGainWidth.h:20
HcalHardcodeParameters theDefaultParameters_
const double gainWidth(unsigned index) const
const double photoelectronsToAnalog() const
HcalTimingParam makeTimingParam(HcalGenericDetId fId) const
HcalRecoParam makeRecoParam(HcalGenericDetId fId) const
HcalHardcodeParameters theHEUpgradeParameters_
int depth() const
get the tower depth
Definition: HcalDetId.h:164
void makeHardcodeFrontEndMap(HcalFrontEndMap &emap, const std::vector< HcalGenericDetId > &cells) const
HcalHardcodeParameters theHBUpgradeParameters_
HcalQIECoder makeQIECoder(HcalGenericDetId fId) const
std::unique_ptr< HcalDcsMap > makeHardcodeDcsMap() const
int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
HcalQIEShape makeQIEShape() const
HcalSubdetector
Definition: HcalAssistant.h:31
HcalSiPMType
Definition: HcalSiPMType.h:4
void makeHardcodeTPParameters(HcalTPParameters &tppar) const
double f[11][100]
const int getGainIndex(HcalGenericDetId fId) const
HcalQIENum
Definition: HcalQIENum.h:4
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
Definition: HcalDcsMap.cc:143
Definition: value.py:1
const double pedestal() const
bool mapEId2tId(HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
HcalHardcodeParameters theHBParameters_
bool isHcalDetId() const
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
HcalTPChannelParameter makeHardcodeTPChannelParameter(HcalGenericDetId fId) const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
HcalGainWidth makeGainWidth(HcalGenericDetId fId) const
std::unique_ptr< HcalSiPMCharacteristics > makeHardcodeSiPMCharacteristics() const
HcalGain makeGain(HcalGenericDetId fId, bool fSmear=false) const
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
bool loadObject(int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
const double darkCurrent(unsigned index, double intlumi) const
void loadObject(int version, int adcCut, uint64_t tdcMask, uint32_t tbits, int auxi1, int auxi2)
HcalQIEType makeQIEType(HcalGenericDetId fId) const
const double gain(unsigned index) const
static std::atomic< unsigned int > counter
int getLayersInDepth(int ieta, int depth, const HcalTopology *topo)
HcalHardcodeParameters theHFParameters_
HcalPedestal makePedestal(HcalGenericDetId fId, bool fSmear, bool eff, const HcalTopology *topo, double intlumi)
HcalHardcodeParameters theHEParameters_
const int zsThreshold() const
HcalSiPMParameter makeHardcodeSiPMParameter(HcalGenericDetId fId, const HcalTopology *topo, double intlumi)
HcalGenericSubdetector genericSubdet() const
Readout chain identification for Hcal.
HcalHardcodeParameters theHFUpgradeParameters_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
HcalZSThreshold makeZSThreshold(HcalGenericDetId fId) const
HcalPedestalWidth makePedestalWidth(HcalGenericDetId fId, bool eff, const HcalTopology *topo, double intlumi)