CMS 3D CMS Logo

HcaluLUTTPGCoder.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <cmath>
4 #include <string>
30 
31 const float HcaluLUTTPGCoder::lsb_ = 1. / 16;
32 
36 
37 constexpr double MaximumFractionalError = 0.002; // 0.2% error allowed from this source
38 
40  : topo_{},
41  delay_{},
42  LUTGenerationMode_{},
43  FG_HF_thresholds_{},
44  bitToMask_{},
45  firstHBEta_{},
46  lastHBEta_{},
47  nHBEta_{},
48  maxDepthHB_{},
49  sizeHB_{},
50  firstHEEta_{},
51  lastHEEta_{},
52  nHEEta_{},
53  maxDepthHE_{},
54  sizeHE_{},
55  firstHFEta_{},
56  lastHFEta_{},
57  nHFEta_{},
58  maxDepthHF_{},
59  sizeHF_{},
60  cosh_ieta_28_HE_low_depths_{},
61  cosh_ieta_28_HE_high_depths_{},
62  cosh_ieta_29_HE_{},
63  allLinear_{},
64  contain1TSHB_{},
65  contain1TSHE_{},
66  applyFixPCC_{},
67  linearLSB_QIE8_{},
68  linearLSB_QIE11_{},
69  linearLSB_QIE11Overlap_{} {}
70 
72 
74  topo_ = top;
75  delay_ = delay;
76  LUTGenerationMode_ = true;
77  FG_HF_thresholds_ = {0, 0};
78  bitToMask_ = 0;
79  allLinear_ = false;
80  contain1TSHB_ = false;
81  contain1TSHE_ = false;
82  applyFixPCC_ = false;
83  linearLSB_QIE8_ = 1.;
84  linearLSB_QIE11_ = 1.;
86  pulseCorr_ = std::make_unique<HcalPulseContainmentManager>(MaximumFractionalError, false);
89  nHBEta_ = (lastHBEta_ - firstHBEta_ + 1);
91  sizeHB_ = 2 * nHBEta_ * nFi_ * maxDepthHB_;
94  nHEEta_ = (lastHEEta_ - firstHEEta_ + 1);
96  sizeHE_ = 2 * nHEEta_ * nFi_ * maxDepthHE_;
99  nHFEta_ = (lastHFEta_ - firstHFEta_ + 1);
101  sizeHF_ = 2 * nHFEta_ * nFi_ * maxDepthHF_;
102  size_t nluts = (size_t)(sizeHB_ + sizeHE_ + sizeHF_ + 1);
103  inputLUT_ = std::vector<HcaluLUTTPGCoder::Lut>(nluts);
104  gain_ = std::vector<float>(nluts, 0.);
105  ped_ = std::vector<float>(nluts, 0.);
107 }
108 
110  const std::vector<bool>& featureBits,
111  HcalTriggerPrimitiveDigi& tp) const {
112  throw cms::Exception("PROBLEM: This method should never be invoked!");
113 }
114 
116 
118  int retval(0);
119  if (id == HcalBarrel) {
120  retval = (depth - 1) + maxDepthHB_ * (iphi - 1);
121  if (ieta > 0)
122  retval += maxDepthHB_ * nFi_ * (ieta - firstHBEta_);
123  else
124  retval += maxDepthHB_ * nFi_ * (ieta + lastHBEta_ + nHBEta_);
125  } else if (id == HcalEndcap) {
126  retval = sizeHB_;
127  retval += (depth - 1) + maxDepthHE_ * (iphi - 1);
128  if (ieta > 0)
129  retval += maxDepthHE_ * nFi_ * (ieta - firstHEEta_);
130  else
131  retval += maxDepthHE_ * nFi_ * (ieta + lastHEEta_ + nHEEta_);
132  } else if (id == HcalForward) {
133  retval = sizeHB_ + sizeHE_;
134  retval += (depth - 1) + maxDepthHF_ * (iphi - 1);
135  if (ieta > 0)
136  retval += maxDepthHF_ * nFi_ * (ieta - firstHFEta_);
137  else
138  retval += maxDepthHF_ * nFi_ * (ieta + lastHFEta_ + nHFEta_);
139  }
140  return retval;
141 }
142 
143 int HcaluLUTTPGCoder::getLUTId(uint32_t rawid) const {
144  HcalDetId detid(rawid);
145  return getLUTId(detid.subdet(), detid.ieta(), detid.iphi(), detid.depth());
146 }
147 
148 int HcaluLUTTPGCoder::getLUTId(const HcalDetId& detid) const {
149  return getLUTId(detid.subdet(), detid.ieta(), detid.iphi(), detid.depth());
150 }
151 
152 void HcaluLUTTPGCoder::update(const char* filename, bool appendMSB) {
153  std::ifstream file(filename, std::ios::in);
154  assert(file.is_open());
155 
156  std::vector<HcalSubdetector> subdet;
158 
159  // Drop first (comment) line
160  std::getline(file, buffer);
161  std::getline(file, buffer);
162 
163  unsigned int index = buffer.find('H', 0);
164  while (index < buffer.length()) {
165  std::string subdetStr = buffer.substr(index, 2);
166  if (subdetStr == "HB")
167  subdet.push_back(HcalBarrel);
168  else if (subdetStr == "HE")
169  subdet.push_back(HcalEndcap);
170  else if (subdetStr == "HF")
171  subdet.push_back(HcalForward);
172  //TODO Check subdet
173  //else exception
174  index += 2;
175  index = buffer.find('H', index);
176  }
177 
178  // Get upper/lower ranges for ieta/iphi/depth
179  size_t nCol = subdet.size();
180  assert(nCol > 0);
181 
182  std::vector<int> ietaU;
183  std::vector<int> ietaL;
184  std::vector<int> iphiU;
185  std::vector<int> iphiL;
186  std::vector<int> depU;
187  std::vector<int> depL;
188  std::vector<Lut> lutFromFile(nCol);
189  LutElement lutValue;
190 
191  for (size_t i = 0; i < nCol; ++i) {
192  int ieta;
193  file >> ieta;
194  ietaL.push_back(ieta);
195  }
196 
197  for (size_t i = 0; i < nCol; ++i) {
198  int ieta;
199  file >> ieta;
200  ietaU.push_back(ieta);
201  }
202 
203  for (size_t i = 0; i < nCol; ++i) {
204  int iphi;
205  file >> iphi;
206  iphiL.push_back(iphi);
207  }
208 
209  for (size_t i = 0; i < nCol; ++i) {
210  int iphi;
211  file >> iphi;
212  iphiU.push_back(iphi);
213  }
214 
215  for (size_t i = 0; i < nCol; ++i) {
216  int dep;
217  file >> dep;
218  depL.push_back(dep);
219  }
220 
221  for (size_t i = 0; i < nCol; ++i) {
222  int dep;
223  file >> dep;
224  depU.push_back(dep);
225  }
226 
227  // Read Lut Entry
228  for (size_t i = 0; file >> lutValue; i = (i + 1) % nCol) {
229  lutFromFile[i].push_back(lutValue);
230  }
231 
232  // Check lut size
233  for (size_t i = 0; i < nCol; ++i)
234  assert(lutFromFile[i].size() == INPUT_LUT_SIZE);
235 
236  for (size_t i = 0; i < nCol; ++i) {
237  for (int ieta = ietaL[i]; ieta <= ietaU[i]; ++ieta) {
238  for (int iphi = iphiL[i]; iphi <= iphiU[i]; ++iphi) {
239  for (int depth = depL[i]; depth <= depU[i]; ++depth) {
240  HcalDetId id(subdet[i], ieta, iphi, depth);
241  if (!topo_->valid(id))
242  continue;
243 
244  int lutId = getLUTId(id);
245  for (size_t adc = 0; adc < INPUT_LUT_SIZE; ++adc) {
246  if (appendMSB) {
247  // Append FG bit LUT to MSB
248  // MSB = Most Significant Bit = bit 10
249  // Overwrite bit 10
250  LutElement msb = (lutFromFile[i][adc] != 0 ? QIE8_LUT_MSB : 0);
251  inputLUT_[lutId][adc] = (msb | (inputLUT_[lutId][adc] & QIE8_LUT_BITMASK));
252  } else
253  inputLUT_[lutId][adc] = lutFromFile[i][adc];
254  } // for adc
255  } // for depth
256  } // for iphi
257  } // for ieta
258  } // for nCol
259 }
260 
262  LutXml* _xml = new LutXml(filename);
263  _xml->create_lut_map();
266  for (unsigned int iphi = 0; iphi <= HcalDetId::kHcalPhiMask2; ++iphi) {
267  for (unsigned int depth = 1; depth < HcalDetId::kHcalDepthMask2; ++depth) {
268  for (int isub = 0; isub < 3; ++isub) {
269  HcalDetId detid(subdet[isub], ieta, iphi, depth);
270  if (!topo_->valid(detid))
271  continue;
272  int id = getLUTId(subdet[isub], ieta, iphi, depth);
273  std::vector<unsigned int>* lut = _xml->getLutFast(detid);
274  if (lut == nullptr)
275  throw cms::Exception("PROBLEM: No inputLUT_ in xml file for ") << detid << std::endl;
276  if (lut->size() != INPUT_LUT_SIZE)
277  throw cms::Exception("PROBLEM: Wrong inputLUT_ size in xml file for ") << detid << std::endl;
278  for (unsigned int i = 0; i < INPUT_LUT_SIZE; ++i)
279  inputLUT_[id][i] = (LutElement)lut->at(i);
280  }
281  }
282  }
283  }
284  delete _xml;
286 }
287 
289  // ieta = 28 and 29 are both associated with trigger tower 28
290  // so special handling is required. HF ieta=29 channels included in TT30
291  // are already handled correctly in cosh_ieta_
292  if (abs(ieta) >= 28 && subdet == HcalEndcap && allLinear_) {
293  if (abs(ieta) == 29)
294  return cosh_ieta_29_HE_;
295  if (abs(ieta) == 28) {
296  if (depth <= 3)
298  else
300  }
301  }
302 
303  return cosh_ieta_[ieta];
304 }
305 
307  cosh_ieta_ = std::vector<double>(lastHFEta_ + 1, -1.0);
308 
309  HcalTrigTowerGeometry triggeo(topo_);
310 
311  for (int i = 1; i <= firstHFEta_; ++i) {
312  double eta_low = 0., eta_high = 0.;
313  triggeo.towerEtaBounds(i, 0, eta_low, eta_high);
314  cosh_ieta_[i] = cosh((eta_low + eta_high) / 2.);
315  }
316  for (int i = firstHFEta_; i <= lastHFEta_; ++i) {
317  std::pair<double, double> etas = topo_->etaRange(HcalForward, i);
318  double eta1 = etas.first;
319  double eta2 = etas.second;
320  cosh_ieta_[i] = cosh((eta1 + eta2) / 2.);
321  }
322 
323  // trigger tower 28 in HE has a more complicated geometry
324  std::pair<double, double> eta28 = topo_->etaRange(HcalEndcap, 28);
325  std::pair<double, double> eta29 = topo_->etaRange(HcalEndcap, 29);
326  cosh_ieta_29_HE_ = cosh((eta29.first + eta29.second) / 2.);
327  cosh_ieta_28_HE_low_depths_ = cosh((eta28.first + eta28.second) / 2.);
328  // for higher depths in ieta = 28, the trigger tower extends past
329  // the ieta = 29 channels
330  cosh_ieta_28_HE_high_depths_ = cosh((eta28.first + eta29.second) / 2.);
331 }
332 
334  const HcalLutMetadata* metadata = conditions.getHcalLutMetadata();
335  assert(metadata != nullptr);
336  float nominalgain_ = metadata->getNominalGain();
337 
338  pulseCorr_ = std::make_unique<HcalPulseContainmentManager>(MaximumFractionalError, applyFixPCC_);
339  pulseCorr_->beginRun(&conditions, delay_);
340 
342 
343  // Here we will determine if we are using new version of TPs (1TS)
344  // i.e. are we using a new pulse filter scheme.
345  const HcalElectronicsMap* emap = conditions.getHcalMapping();
346 
347  int lastHBRing = topo_->lastHBRing();
348  int lastHERing = topo_->lastHERing();
349 
350  // First, determine if we should configure for the filter scheme
351  // Check the tp version to make this determination
352  bool foundHB = false;
353  bool foundHE = false;
354  bool newHBtp = false;
355  bool newHEtp = false;
356  std::vector<HcalElectronicsId> vIds = emap->allElectronicsIdTrigger();
357  for (std::vector<HcalElectronicsId>::const_iterator eId = vIds.begin(); eId != vIds.end(); eId++) {
358  // The first HB or HE id is enough to tell whether to use new scheme in HB or HE
359  if (foundHB and foundHE)
360  break;
361 
362  HcalTrigTowerDetId hcalTTDetId(emap->lookupTrigger(*eId));
363  if (hcalTTDetId.null())
364  continue;
365 
366  int aieta = abs(hcalTTDetId.ieta());
367 
368  // The absence of TT channels in the HcalTPChannelParameters
369  // is intepreted as to not use the new filter
370  int weight = -1.0;
371  auto tpParam = conditions.getHcalTPChannelParameter(hcalTTDetId, false);
372  if (tpParam)
373  weight = tpParam->getauxi1();
374 
375  if (aieta <= lastHBRing) {
376  foundHB = true;
377  if (weight != -1.0)
378  newHBtp = true;
379  } else if (aieta > lastHBRing and aieta < lastHERing) {
380  foundHE = true;
381  if (weight != -1.0)
382  newHEtp = true;
383  }
384  }
385 
386  for (const auto& id : metadata->getAllChannels()) {
387  if (not(id.det() == DetId::Hcal and topo_->valid(id)))
388  continue;
389 
390  HcalDetId cell(id);
391  HcalSubdetector subdet = cell.subdet();
392 
393  if (subdet != HcalBarrel and subdet != HcalEndcap and subdet != HcalForward)
394  continue;
395 
396  const HcalQIECoder* channelCoder = conditions.getHcalCoder(cell);
397  const HcalQIEShape* shape = conditions.getHcalShape(cell);
398  HcalCoderDb coder(*channelCoder, *shape);
399  const HcalLutMetadatum* meta = metadata->getValues(cell);
400 
401  unsigned int bit12_energy =
402  0; // defaults for energy requirement for bits 12-15 are high / low to avoid FG bit 0-4 being set when not intended
403  unsigned int bit13_energy = 0;
404  unsigned int bit14_energy = 999;
405  unsigned int bit15_energy = 999;
406 
407  bool is2018OrLater = topo_->triggerMode() >= HcalTopologyMode::TriggerMode_2018 or
409  if (is2018OrLater or topo_->dddConstants()->isPlan1(cell)) {
410  bit12_energy = 16; // depths 1,2 max energy
411  bit13_energy = 80; // depths 3+ min energy
412  bit14_energy = 64; // prompt min energy
413  bit15_energy = 64; // delayed min energy
414  }
415 
416  int lutId = getLUTId(cell);
417  Lut& lut = inputLUT_[lutId];
418  float ped = 0;
419  float gain = 0;
420  uint32_t status = 0;
421 
422  if (LUTGenerationMode_) {
423  const HcalCalibrations& calibrations = conditions.getHcalCalibrations(cell);
424  for (auto capId : {0, 1, 2, 3}) {
425  ped += calibrations.effpedestal(capId);
426  gain += calibrations.LUTrespcorrgain(capId);
427  }
428  ped /= 4.0;
429  gain /= 4.0;
430 
431  //Get Channel Quality
432  const HcalChannelStatus* channelStatus = conditions.getHcalChannelStatus(cell);
433  status = channelStatus->getValue();
434 
435  } else {
436  const HcalL1TriggerObject* myL1TObj = conditions.getHcalL1TriggerObject(cell);
437  ped = myL1TObj->getPedestal();
438  gain = myL1TObj->getRespGain();
439  status = myL1TObj->getFlag();
440  } // LUTGenerationMode_
441 
442  ped_[lutId] = ped;
443  gain_[lutId] = gain;
444  bool isMasked = ((status & bitToMask_) > 0);
445  float rcalib = meta->getRCalib();
446 
447  auto adc2fC = [channelCoder, shape](unsigned int adc) {
448  float fC = 0;
449  for (auto capId : {0, 1, 2, 3})
450  fC += channelCoder->charge(*shape, adc, capId);
451  return fC / 4;
452  };
453 
454  int qieType = conditions.getHcalQIEType(cell)->getValue();
455 
456  const size_t SIZE = qieType == QIE8 ? INPUT_LUT_SIZE : UPGRADE_LUT_SIZE;
457  const int MASK = qieType == QIE8 ? QIE8_LUT_BITMASK : qieType == QIE10 ? QIE10_LUT_BITMASK : QIE11_LUT_BITMASK;
458  double linearLSB = linearLSB_QIE8_;
459  if (qieType == QIE11 and cell.ietaAbs() == topo_->lastHBRing())
460  linearLSB = linearLSB_QIE11Overlap_;
461  else if (qieType == QIE11)
462  linearLSB = linearLSB_QIE11_;
463 
464  lut.resize(SIZE, 0);
465 
466  // Input LUT for HB/HE/HF
467  if (subdet == HcalBarrel || subdet == HcalEndcap) {
468  int granularity = meta->getLutGranularity();
469 
470  double correctionPhaseNS = conditions.getHcalRecoParam(cell)->correctionPhaseNS();
471 
472  if (qieType == QIE11) {
473  if (overrideDBweightsAndFilterHB_ and cell.ietaAbs() <= lastHBRing)
475  else if (overrideDBweightsAndFilterHE_ and cell.ietaAbs() > lastHBRing)
477  }
478  for (unsigned int adc = 0; adc < SIZE; ++adc) {
479  if (isMasked)
480  lut[adc] = 0;
481  else {
482  double nonlinearityCorrection = 1.0;
483  double containmentCorrection = 1.0;
484  // SiPM nonlinearity was not corrected in 2017
485  // and containment corrections were not
486  // ET-dependent prior to 2018
487  if (is2018OrLater) {
488  double containmentCorrection1TS = pulseCorr_->correction(cell, 1, correctionPhaseNS, adc2fC(adc));
489  // Use the 1-TS containment correction to estimate the charge of the pulse
490  // from the individual samples
491  double correctedCharge = containmentCorrection1TS * adc2fC(adc);
492  double containmentCorrection2TSCorrected =
493  pulseCorr_->correction(cell, 2, correctionPhaseNS, correctedCharge);
494  if (qieType == QIE11) {
495  // When contain1TS_ is set, it should still only apply for QIE11-related things
496  if ((((contain1TSHB_ and overrideDBweightsAndFilterHB_) or newHBtp) and cell.ietaAbs() <= lastHBRing) or
497  (((contain1TSHE_ and overrideDBweightsAndFilterHE_) or newHEtp) and cell.ietaAbs() > lastHBRing)) {
498  containmentCorrection = containmentCorrection1TS;
499  } else {
500  containmentCorrection = containmentCorrection2TSCorrected;
501  }
502 
503  const HcalSiPMParameter& siPMParameter(*conditions.getHcalSiPMParameter(cell));
505  conditions.getHcalSiPMCharacteristics()->getNonLinearities(siPMParameter.getType()));
506  const double fcByPE = siPMParameter.getFCByPE();
507  const double effectivePixelsFired = correctedCharge / fcByPE;
508  nonlinearityCorrection = corr.getRecoCorrectionFactor(effectivePixelsFired);
509  } else {
510  containmentCorrection = containmentCorrection2TSCorrected;
511  }
512  }
513  if (allLinear_)
514  lut[adc] = (LutElement)std::min(
515  std::max(0,
516  int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection * containmentCorrection /
517  linearLSB / cosh_ieta(cell.ietaAbs(), cell.depth(), HcalEndcap))),
518  MASK);
519  else
520  lut[adc] = (LutElement)std::min(std::max(0,
521  int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection *
522  containmentCorrection / nominalgain_ / granularity)),
523  MASK);
524 
525  unsigned int linearizedADC =
526  lut[adc]; // used for bits 12, 13, 14, 15 for Group 0 LUT for LLP time and depth bits that rely on linearized energies
527 
528  if (qieType == QIE11) {
529  if (subdet == HcalBarrel) { // edit since bits 12-15 not supported in HE yet
530  if ((linearizedADC < bit12_energy and cell.depth() <= 2) or (cell.depth() >= 3))
531  lut[adc] |= 1 << 12;
532  if (linearizedADC >= bit13_energy and cell.depth() >= 3)
533  lut[adc] |= 1 << 13;
534  if (linearizedADC >= bit14_energy)
535  lut[adc] |= 1 << 14;
536  if (linearizedADC >= bit15_energy)
537  lut[adc] |= 1 << 15;
538  }
539  }
540 
541  //Zeroing the 4th depth in the trigger towers where |ieta| = 16 to match the behavior in the uHTR firmware in Run3, where the 4th depth is not included in the sum over depths when constructing the TP energy for this tower.
542  if (abs(cell.ieta()) == 16 && cell.depth() == 4 &&
544  lut[adc] = 0;
545  }
546  }
547  }
548  } else if (subdet == HcalForward) {
549  for (unsigned int adc = 0; adc < SIZE; ++adc) {
550  if (isMasked)
551  lut[adc] = 0;
552  else {
553  lut[adc] =
554  std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib / lsb_ / cosh_ieta_[cell.ietaAbs()])), MASK);
555  if (adc > FG_HF_thresholds_[0])
556  lut[adc] |= QIE10_LUT_MSB0;
557  if (adc > FG_HF_thresholds_[1])
558  lut[adc] |= QIE10_LUT_MSB1;
559  }
560  }
561  }
562  }
563 }
564 
566  int lutId = getLUTId(df.id());
567  const Lut& lut = inputLUT_.at(lutId);
568  for (int i = 0; i < df.size(); i++) {
569  ics[i] = (lut.at(df[i].adc()) & QIE8_LUT_BITMASK);
570  }
571 }
572 
574  int lutId = getLUTId(df.id());
575  const Lut& lut = inputLUT_.at(lutId);
576  for (int i = 0; i < df.size(); i++) {
577  ics[i] = (lut.at(df[i].adc()) & QIE8_LUT_BITMASK);
578  }
579 }
580 
582  int lutId = getLUTId(HcalDetId(df.id()));
583  const Lut& lut = inputLUT_.at(lutId);
584  for (int i = 0; i < df.samples(); i++) {
585  ics[i] = (lut.at(df[i].adc()) & QIE10_LUT_BITMASK);
586  }
587 }
588 
590  int lutId = getLUTId(HcalDetId(df.id()));
591  const Lut& lut = inputLUT_.at(lutId);
592  for (int i = 0; i < df.samples(); i++) {
593  ics[i] = (lut.at(df[i].adc()) & QIE11_LUT_BITMASK);
594  }
595 }
596 
598  int lutId = getLUTId(id);
599  return ((inputLUT_.at(lutId)).at(sample.adc()) & QIE8_LUT_BITMASK);
600 }
601 
602 std::vector<unsigned short> HcaluLUTTPGCoder::group0FGbits(const QIE11DataFrame& df) const {
603  int lutId = getLUTId(HcalDetId(df.id()));
604  const Lut& lut = inputLUT_.at(lutId);
605  std::vector<unsigned short> group0LLPbits;
606  group0LLPbits.reserve(df.samples());
607  for (int i = 0; i < df.samples(); i++) {
608  group0LLPbits.push_back((lut.at(df[i].adc()) >> 12) &
609  0xF); // four bits (12-15) of LUT used to set 6 finegrain bits from uHTR
610  }
611  return group0LLPbits;
612 }
613 
615  int lutId = getLUTId(id);
616  return ped_.at(lutId);
617 }
618 
620  int lutId = getLUTId(id);
621  return gain_.at(lutId);
622 }
623 
624 std::vector<unsigned short> HcaluLUTTPGCoder::getLinearizationLUT(HcalDetId id) const {
625  int lutId = getLUTId(id);
626  return inputLUT_.at(lutId);
627 }
628 
629 void HcaluLUTTPGCoder::lookupMSB(const HBHEDataFrame& df, std::vector<bool>& msb) const {
630  msb.resize(df.size());
631  for (int i = 0; i < df.size(); ++i)
632  msb[i] = getMSB(df.id(), df.sample(i).adc());
633 }
634 
635 bool HcaluLUTTPGCoder::getMSB(const HcalDetId& id, int adc) const {
636  int lutId = getLUTId(id);
637  const Lut& lut = inputLUT_.at(lutId);
638  return (lut.at(adc) & QIE8_LUT_MSB);
639 }
640 
641 void HcaluLUTTPGCoder::lookupMSB(const QIE10DataFrame& df, std::vector<std::bitset<2>>& msb) const {
642  msb.resize(df.samples());
643  int lutId = getLUTId(HcalDetId(df.id()));
644  const Lut& lut = inputLUT_.at(lutId);
645  for (int i = 0; i < df.samples(); ++i) {
646  msb[i][0] = lut.at(df[i].adc()) & QIE10_LUT_MSB0;
647  msb[i][1] = lut.at(df[i].adc()) & QIE10_LUT_MSB1;
648  }
649 }
650 
651 void HcaluLUTTPGCoder::lookupMSB(const QIE11DataFrame& df, std::vector<std::bitset<2>>& msb) const {
652  int lutId = getLUTId(HcalDetId(df.id()));
653  const Lut& lut = inputLUT_.at(lutId);
654  for (int i = 0; i < df.samples(); ++i) {
655  msb[i][0] = lut.at(df[i].adc()) & QIE11_LUT_MSB0;
656  msb[i][1] = lut.at(df[i].adc()) & QIE11_LUT_MSB1;
657  }
658 }
std::vector< uint32_t > FG_HF_thresholds_
float getRCalib() const
size
Write out results.
std::vector< HcalElectronicsId > allElectronicsIdTrigger() const
uint32_t getFlag() const
static const int nFi_
static constexpr uint32_t kHcalPhiMask2
Definition: HcalDetId.h:15
double cosh_ieta_28_HE_high_depths_
Definition: LutXml.h:27
double linearLSB_QIE11Overlap_
static const int QIE11_LUT_MSB1
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
static const int QIE11_LUT_BITMASK
uint8_t getLutGranularity() const
Definition: HcalQIENum.h:4
bool valid(const DetId &id) const override
int create_lut_map(void)
Definition: LutXml.cc:338
const HcalTopology * topo_
static const int QIE11_LUT_MSB0
static const float lsb_
Definition: weight.py:1
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
std::vector< unsigned short > group0FGbits(const QIE11DataFrame &df) const
double cosh_ieta_28_HE_low_depths_
void init(const HcalTopology *top, const HcalTimeSlew *delay)
bool overrideDBweightsAndFilterHB_
static const int QIE8_LUT_BITMASK
bool getMSB(const HcalDetId &id, int adc) const
assert(be >=bs)
unsigned short LutElement
void update(const HcalDbService &conditions)
void updateXML(const char *filename)
static const int QIE10_LUT_MSB0
int firstHBRing() const
Definition: HcalTopology.h:91
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
static const size_t UPGRADE_LUT_SIZE
float getLUTGain(HcalDetId id) const override
std::vector< Lut > inputLUT_
dictionary corr
std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const override
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
int terminate(void)
HcalTopologyMode::TriggerMode triggerMode() const
Definition: HcalTopology.h:35
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
int lastHBRing() const
Definition: HcalTopology.h:92
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
const HcalTimeSlew * delay_
int maxDepth(void) const
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const float adc2fC[128]
bool overrideDBweightsAndFilterHE_
float getLUTPedestal(HcalDetId id) const override
static const int QIE8_LUT_MSB
uint32_t getValue() const
static constexpr uint32_t kHcalEtaMask2
Definition: HcalDetId.h:19
static const int QIE10_LUT_BITMASK
std::vector< double > cosh_ieta_
std::vector< float > ped_
double cosh_ieta(int ieta, int depth, HcalSubdetector subdet)
constexpr double MaximumFractionalError
std::vector< float > gain_
~HcaluLUTTPGCoder() override
void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const override
std::vector< unsigned int > * getLutFast(uint32_t det_id)
Definition: LutXml.cc:72
static const size_t INPUT_LUT_SIZE
void towerEtaBounds(int ieta, int version, double &eta1, double &eta2) const
where this tower begins and ends in eta
int lastHERing() const
Definition: HcalTopology.h:94
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:164
void compress(const IntegerCaloSamples &ics, const std::vector< bool > &featureBits, HcalTriggerPrimitiveDigi &tp) const override
int lastHFRing() const
Definition: HcalTopology.h:97
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
void make_cosh_ieta_map(void)
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
std::unique_ptr< HcalPulseContainmentManager > pulseCorr_
bool isPlan1(const HcalDetId &id) const
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
static const int QIE10_LUT_MSB1
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134
int firstHFRing() const
Definition: HcalTopology.h:96
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:20
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc
int firstHERing() const
Definition: HcalTopology.h:93
static constexpr uint32_t kHcalDepthMask2
Definition: HcalDetId.h:25
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164