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