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