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