CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
71 HcaluLUTTPGCoder::HcaluLUTTPGCoder(const HcalTopology* top, const HcalTimeSlew* delay) { init(top, delay); }
72 
73 void HcaluLUTTPGCoder::init(const HcalTopology* top, const HcalTimeSlew* delay) {
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 
117 int HcaluLUTTPGCoder::getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const {
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();
265  for (int ieta = -HcalDetId::kHcalEtaMask2; ieta <= (int)(HcalDetId::kHcalEtaMask2); ++ieta) {
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 
288 double HcaluLUTTPGCoder::cosh_ieta(int ieta, int depth, HcalSubdetector subdet) {
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 mipMax = 0;
402  unsigned int mipMin = 0;
403  unsigned int bit12_energy =
404  0; // defaults for energy requirement for bits 12-15 are high / low to avoid FG bit 0-4 being set when not intended
405  unsigned int bit13_energy = 0;
406  unsigned int bit14_energy = 999;
407  unsigned int bit15_energy = 999;
408 
409  bool is2018OrLater = topo_->triggerMode() >= HcalTopologyMode::TriggerMode_2018 or
411  if (is2018OrLater or topo_->dddConstants()->isPlan1(cell)) {
412  const HcalTPChannelParameter* channelParameters = conditions.getHcalTPChannelParameter(cell);
413  mipMax = channelParameters->getFGBitInfo() >> 16;
414  mipMin = channelParameters->getFGBitInfo() & 0xFFFF;
415  bit12_energy = 16; // depths 1,2 max energy
416  bit13_energy = 80; // depths 3+ min energy
417  bit14_energy = 64; // prompt min energy
418  bit15_energy = 64; // delayed min energy
419  }
420 
421  int lutId = getLUTId(cell);
422  Lut& lut = inputLUT_[lutId];
423  float ped = 0;
424  float gain = 0;
425  uint32_t status = 0;
426 
427  if (LUTGenerationMode_) {
428  const HcalCalibrations& calibrations = conditions.getHcalCalibrations(cell);
429  for (auto capId : {0, 1, 2, 3}) {
430  ped += calibrations.effpedestal(capId);
431  gain += calibrations.LUTrespcorrgain(capId);
432  }
433  ped /= 4.0;
434  gain /= 4.0;
435 
436  //Get Channel Quality
437  const HcalChannelStatus* channelStatus = conditions.getHcalChannelStatus(cell);
438  status = channelStatus->getValue();
439 
440  } else {
441  const HcalL1TriggerObject* myL1TObj = conditions.getHcalL1TriggerObject(cell);
442  ped = myL1TObj->getPedestal();
443  gain = myL1TObj->getRespGain();
444  status = myL1TObj->getFlag();
445  } // LUTGenerationMode_
446 
447  ped_[lutId] = ped;
448  gain_[lutId] = gain;
449  bool isMasked = ((status & bitToMask_) > 0);
450  float rcalib = meta->getRCalib();
451 
452  auto adc2fC = [channelCoder, shape](unsigned int adc) {
453  float fC = 0;
454  for (auto capId : {0, 1, 2, 3})
455  fC += channelCoder->charge(*shape, adc, capId);
456  return fC / 4;
457  };
458 
459  int qieType = conditions.getHcalQIEType(cell)->getValue();
460 
461  const size_t SIZE = qieType == QIE8 ? INPUT_LUT_SIZE : UPGRADE_LUT_SIZE;
462  const int MASK = qieType == QIE8 ? QIE8_LUT_BITMASK : qieType == QIE10 ? QIE10_LUT_BITMASK : QIE11_LUT_BITMASK;
463  double linearLSB = linearLSB_QIE8_;
464  if (qieType == QIE11 and cell.ietaAbs() == topo_->lastHBRing())
465  linearLSB = linearLSB_QIE11Overlap_;
466  else if (qieType == QIE11)
467  linearLSB = linearLSB_QIE11_;
468 
469  lut.resize(SIZE, 0);
470 
471  // Input LUT for HB/HE/HF
472  if (subdet == HcalBarrel || subdet == HcalEndcap) {
473  int granularity = meta->getLutGranularity();
474 
475  double correctionPhaseNS = conditions.getHcalRecoParam(cell)->correctionPhaseNS();
476 
477  if (qieType == QIE11) {
478  if (overrideDBweightsAndFilterHB_ and cell.ietaAbs() <= lastHBRing)
479  correctionPhaseNS = containPhaseNSHB_;
480  else if (overrideDBweightsAndFilterHE_ and cell.ietaAbs() > lastHBRing)
481  correctionPhaseNS = containPhaseNSHE_;
482  }
483  for (unsigned int adc = 0; adc < SIZE; ++adc) {
484  if (isMasked)
485  lut[adc] = 0;
486  else {
487  double nonlinearityCorrection = 1.0;
488  double containmentCorrection = 1.0;
489  // SiPM nonlinearity was not corrected in 2017
490  // and containment corrections were not
491  // ET-dependent prior to 2018
492  if (is2018OrLater) {
493  double containmentCorrection1TS = pulseCorr_->correction(cell, 1, correctionPhaseNS, adc2fC(adc));
494  // Use the 1-TS containment correction to estimate the charge of the pulse
495  // from the individual samples
496  double correctedCharge = containmentCorrection1TS * adc2fC(adc);
497  double containmentCorrection2TSCorrected =
498  pulseCorr_->correction(cell, 2, correctionPhaseNS, correctedCharge);
499  if (qieType == QIE11) {
500  // When contain1TS_ is set, it should still only apply for QIE11-related things
501  if ((((contain1TSHB_ and overrideDBweightsAndFilterHB_) or newHBtp) and cell.ietaAbs() <= lastHBRing) or
502  (((contain1TSHE_ and overrideDBweightsAndFilterHE_) or newHEtp) and cell.ietaAbs() > lastHBRing)) {
503  containmentCorrection = containmentCorrection1TS;
504  } else {
505  containmentCorrection = containmentCorrection2TSCorrected;
506  }
507 
508  const HcalSiPMParameter& siPMParameter(*conditions.getHcalSiPMParameter(cell));
510  conditions.getHcalSiPMCharacteristics()->getNonLinearities(siPMParameter.getType()));
511  const double fcByPE = siPMParameter.getFCByPE();
512  const double effectivePixelsFired = correctedCharge / fcByPE;
513  nonlinearityCorrection = corr.getRecoCorrectionFactor(effectivePixelsFired);
514  } else {
515  containmentCorrection = containmentCorrection2TSCorrected;
516  }
517  }
518  if (allLinear_)
519  lut[adc] = (LutElement)std::min(
520  std::max(0,
521  int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection * containmentCorrection /
522  linearLSB / cosh_ieta(cell.ietaAbs(), cell.depth(), HcalEndcap))),
523  MASK);
524  else
525  lut[adc] = (LutElement)std::min(std::max(0,
526  int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection *
527  containmentCorrection / nominalgain_ / granularity)),
528  MASK);
529 
530  unsigned int linearizedADC =
531  lut[adc]; // used for bits 12, 13, 14, 15 for Group 0 LUT for LLP time and depth bits that rely on linearized energies
532 
533  if (qieType == QIE11) {
534  if ((linearizedADC < bit12_energy and cell.depth() <= 2) or (cell.depth() >= 3))
535  lut[adc] |= 1 << 12;
536  if (linearizedADC >= bit13_energy and cell.depth() >= 3)
537  lut[adc] |= 1 << 13;
538  if (linearizedADC >= bit14_energy)
539  lut[adc] |= 1 << 14;
540  if (linearizedADC >= bit15_energy)
541  lut[adc] |= 1 << 15;
542  if (adc >= mipMin and adc < mipMax)
543  lut[adc] |= QIE11_LUT_MSB0;
544  else if (adc >= mipMax)
545  lut[adc] |= QIE11_LUT_MSB1;
546  }
547 
548  //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.
549  if (abs(cell.ieta()) == 16 && cell.depth() == 4 &&
551  lut[adc] = 0;
552  }
553  }
554  }
555  } else if (subdet == HcalForward) {
556  for (unsigned int adc = 0; adc < SIZE; ++adc) {
557  if (isMasked)
558  lut[adc] = 0;
559  else {
560  lut[adc] =
561  std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib / lsb_ / cosh_ieta_[cell.ietaAbs()])), MASK);
562  if (adc > FG_HF_thresholds_[0])
563  lut[adc] |= QIE10_LUT_MSB0;
564  if (adc > FG_HF_thresholds_[1])
565  lut[adc] |= QIE10_LUT_MSB1;
566  }
567  }
568  }
569  }
570 }
571 
573  int lutId = getLUTId(df.id());
574  const Lut& lut = inputLUT_.at(lutId);
575  for (int i = 0; i < df.size(); i++) {
576  ics[i] = (lut.at(df[i].adc()) & QIE8_LUT_BITMASK);
577  }
578 }
579 
581  int lutId = getLUTId(df.id());
582  const Lut& lut = inputLUT_.at(lutId);
583  for (int i = 0; i < df.size(); i++) {
584  ics[i] = (lut.at(df[i].adc()) & QIE8_LUT_BITMASK);
585  }
586 }
587 
589  int lutId = getLUTId(HcalDetId(df.id()));
590  const Lut& lut = inputLUT_.at(lutId);
591  for (int i = 0; i < df.samples(); i++) {
592  ics[i] = (lut.at(df[i].adc()) & QIE10_LUT_BITMASK);
593  }
594 }
595 
597  int lutId = getLUTId(HcalDetId(df.id()));
598  const Lut& lut = inputLUT_.at(lutId);
599  for (int i = 0; i < df.samples(); i++) {
600  ics[i] = (lut.at(df[i].adc()) & QIE11_LUT_BITMASK);
601  }
602 }
603 
605  int lutId = getLUTId(id);
606  return ((inputLUT_.at(lutId)).at(sample.adc()) & QIE8_LUT_BITMASK);
607 }
608 
609 std::vector<unsigned short> HcaluLUTTPGCoder::group0FGbits(const QIE11DataFrame& df) const {
610  int lutId = getLUTId(HcalDetId(df.id()));
611  const Lut& lut = inputLUT_.at(lutId);
612  std::vector<unsigned short> group0LLPbits;
613  group0LLPbits.reserve(df.samples());
614  for (int i = 0; i < df.samples(); i++) {
615  group0LLPbits.push_back((lut.at(df[i].adc()) >> 12) &
616  0xF); // four bits (12-15) of LUT used to set 6 finegrain bits from uHTR
617  }
618  return group0LLPbits;
619 }
620 
622  int lutId = getLUTId(id);
623  return ped_.at(lutId);
624 }
625 
627  int lutId = getLUTId(id);
628  return gain_.at(lutId);
629 }
630 
631 std::vector<unsigned short> HcaluLUTTPGCoder::getLinearizationLUT(HcalDetId id) const {
632  int lutId = getLUTId(id);
633  return inputLUT_.at(lutId);
634 }
635 
636 void HcaluLUTTPGCoder::lookupMSB(const HBHEDataFrame& df, std::vector<bool>& msb) const {
637  msb.resize(df.size());
638  for (int i = 0; i < df.size(); ++i)
639  msb[i] = getMSB(df.id(), df.sample(i).adc());
640 }
641 
642 bool HcaluLUTTPGCoder::getMSB(const HcalDetId& id, int adc) const {
643  int lutId = getLUTId(id);
644  const Lut& lut = inputLUT_.at(lutId);
645  return (lut.at(adc) & QIE8_LUT_MSB);
646 }
647 
648 void HcaluLUTTPGCoder::lookupMSB(const QIE10DataFrame& df, std::vector<std::bitset<2>>& msb) const {
649  msb.resize(df.samples());
650  int lutId = getLUTId(HcalDetId(df.id()));
651  const Lut& lut = inputLUT_.at(lutId);
652  for (int i = 0; i < df.samples(); ++i) {
653  msb[i][0] = lut.at(df[i].adc()) & QIE10_LUT_MSB0;
654  msb[i][1] = lut.at(df[i].adc()) & QIE10_LUT_MSB1;
655  }
656 }
657 
658 void HcaluLUTTPGCoder::lookupMSB(const QIE11DataFrame& df, std::vector<std::bitset<2>>& msb) const {
659  int lutId = getLUTId(HcalDetId(df.id()));
660  const Lut& lut = inputLUT_.at(lutId);
661  for (int i = 0; i < df.samples(); ++i) {
662  msb[i][0] = lut.at(df[i].adc()) & QIE11_LUT_MSB0;
663  msb[i][1] = lut.at(df[i].adc()) & QIE11_LUT_MSB1;
664  }
665 }
std::vector< uint32_t > FG_HF_thresholds_
uint32_t getFlag() const
int maxDepth(void) const
int firstHFRing() const
Definition: HcalTopology.h:96
float getPedestal() const
static const int nFi_
static constexpr uint32_t kHcalPhiMask2
Definition: HcalDetId.h:15
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:164
double cosh_ieta_28_HE_high_depths_
int getValue() const
Definition: HcalQIEType.h:19
Definition: LutXml.h:27
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
uint16_t *__restrict__ id
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
double linearLSB_QIE11Overlap_
const HcalRecoParam * getHcalRecoParam(const HcalGenericDetId &fId) const
static const int QIE11_LUT_MSB1
constexpr edm::DataFrame::id_type id() const
static const int QIE11_LUT_BITMASK
const HcalChannelStatus * getHcalChannelStatus(const HcalGenericDetId &fId) const
Definition: HcalQIENum.h:4
bool valid(const DetId &id) const override
int create_lut_map(void)
Definition: LutXml.cc:338
const HcalTopology * topo_
list status
Definition: mps_update.py:107
int firstHBRing() const
Definition: HcalTopology.h:91
int lastHBRing() const
Definition: HcalTopology.h:92
static const int QIE11_LUT_MSB0
static const float lsb_
constexpr const HcalDetId & id() const
Definition: HBHEDataFrame.h:23
tuple correctionPhaseNS
from Configuration.AlCa.GlobalTag import GlobalTag as gtCustomise process.GlobalTag = gtCustomise(pro...
void towerEtaBounds(int ieta, int version, double &eta1, double &eta2) const
where this tower begins and ends in eta
const Item * getValues(DetId fId, bool throwOnFail=true) const
double cosh_ieta_28_HE_low_depths_
void init(const HcalTopology *top, const HcalTimeSlew *delay)
bool overrideDBweightsAndFilterHB_
static const int QIE8_LUT_BITMASK
uint8_t getLutGranularity() const
assert(be >=bs)
std::vector< unsigned short > group0FGbits(const QIE11DataFrame &df) const
HcalTopologyMode::TriggerMode triggerMode() const
Definition: HcalTopology.h:35
unsigned short LutElement
void update(const HcalDbService &conditions)
void updateXML(const char *filename)
std::vector< HcalElectronicsId > allElectronicsIdTrigger() const
static const int QIE10_LUT_MSB0
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_
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const override
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
float getRespGain() const
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int size() const
total number of samples in the digi
Definition: HFDataFrame.h:27
int terminate(void)
std::vector< DetId > getAllChannels() const
constexpr float correctionPhaseNS() const
Definition: HcalRecoParam.h:30
float getNominalGain() const
const HcalTimeSlew * delay_
float getRCalib() const
const HcalL1TriggerObject * getHcalL1TriggerObject(const HcalGenericDetId &fId) const
constexpr double effpedestal(int fCapId) const
get effective pedestal for capid=0..3
int lastHFRing() const
Definition: HcalTopology.h:97
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const float adc2fC[128]
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
const HcalLutMetadata * getHcalLutMetadata() const
constexpr HcalQIESample const & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:40
bool overrideDBweightsAndFilterHE_
float getLUTPedestal(HcalDetId id) const override
static const int QIE8_LUT_MSB
static constexpr uint32_t kHcalEtaMask2
Definition: HcalDetId.h:19
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43
static const int QIE10_LUT_BITMASK
constexpr int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:27
const HcalQIEType * getHcalQIEType(const HcalGenericDetId &fId) const
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_
constexpr int samples() const
total number of samples in the digi
~HcaluLUTTPGCoder() override
void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const override
int firstHERing() const
Definition: HcalTopology.h:93
constexpr double LUTrespcorrgain(int fCapId) const
get LUT corrected and response corrected gain for capid=0..3
const HcalSiPMCharacteristics * getHcalSiPMCharacteristics() const
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
std::vector< float > getNonLinearities(int type) const
get nonlinearity constants
constexpr int samples() const
total number of samples in the digi
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
std::vector< unsigned int > * getLutFast(uint32_t det_id)
Definition: LutXml.cc:72
static const size_t INPUT_LUT_SIZE
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
constexpr edm::DataFrame::id_type id() const
bool getMSB(const HcalDetId &id, int adc) const
tuple filename
Definition: lut2db_cfg.py:20
const HcalElectronicsMap * getHcalMapping() const
uint32_t getFGBitInfo() const
get FG bit information
void compress(const IntegerCaloSamples &ics, const std::vector< bool > &featureBits, HcalTriggerPrimitiveDigi &tp) const override
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
bool isPlan1(const HcalDetId &id) const
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164
int weight
Definition: histoStyle.py:51
void make_cosh_ieta_map(void)
uint32_t getValue() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
std::unique_ptr< HcalPulseContainmentManager > pulseCorr_
const HcalSiPMParameter * getHcalSiPMParameter(const HcalGenericDetId &fId) const
const HcalTPChannelParameter * getHcalTPChannelParameter(const HcalGenericDetId &fId, bool throwOnFail=true) const
tuple size
Write out results.
static const int QIE10_LUT_MSB1
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134
int lastHERing() const
Definition: HcalTopology.h:94
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc
constexpr HcalDetId const & id() const
Definition: HFDataFrame.h:23
static constexpr uint32_t kHcalDepthMask2
Definition: HcalDetId.h:25
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:20