CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Types | Private Attributes | Static Private Attributes
HcaluLUTTPGCoder Class Reference

#include <HcaluLUTTPGCoder.h>

Inheritance diagram for HcaluLUTTPGCoder:
HcalTPGCoder

Public Member Functions

void adc2Linear (const HBHEDataFrame &df, IntegerCaloSamples &ics) const override
 
void adc2Linear (const HFDataFrame &df, IntegerCaloSamples &ics) const override
 
void adc2Linear (const QIE10DataFrame &df, IntegerCaloSamples &ics) const override
 
void adc2Linear (const QIE11DataFrame &df, IntegerCaloSamples &ics) const override
 
unsigned short adc2Linear (HcalQIESample sample, HcalDetId id) const override
 
void compress (const IntegerCaloSamples &ics, const std::vector< bool > &featureBits, HcalTriggerPrimitiveDigi &tp) const override
 
double cosh_ieta (int ieta, int depth, HcalSubdetector subdet)
 
std::vector< unsigned short > getLinearizationLUT (HcalDetId id) const override
 Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all values. More...
 
float getLUTGain (HcalDetId id) const override
 
int getLUTId (HcalSubdetector id, int ieta, int iphi, int depth) const
 
int getLUTId (uint32_t rawid) const
 
int getLUTId (const HcalDetId &detid) const
 
float getLUTPedestal (HcalDetId id) const override
 
bool getMSB (const HcalDetId &id, int adc) const
 
std::vector< unsigned short > group0FGbits (const QIE11DataFrame &df) const
 
 HcaluLUTTPGCoder ()
 
 HcaluLUTTPGCoder (const HcalTopology *topo, const HcalTimeSlew *delay)
 
void init (const HcalTopology *top, const HcalTimeSlew *delay)
 
void lookupMSB (const HBHEDataFrame &df, std::vector< bool > &msb) const
 
void lookupMSB (const QIE10DataFrame &df, std::vector< std::bitset< 2 >> &msb) const
 
void lookupMSB (const QIE11DataFrame &df, std::vector< std::bitset< 2 >> &msb) const
 
void make_cosh_ieta_map (void)
 
void set1TSContainHB (bool contain1TSHB)
 
void set1TSContainHE (bool contain1TSHE)
 
void setAllLinear (bool linear, double lsb8, double lsb11, double lsb11overlap)
 
void setApplyFixPCC (double applyFixPCC)
 
void setContainPhaseHB (double containPhaseNSHB)
 
void setContainPhaseHE (double containPhaseNSHE)
 
void setFGHFthresholds (const std::vector< uint32_t > &fgthresholds)
 
void setLUTGenerationMode (bool gen)
 
void setMaskBit (int bit)
 
void setOverrideDBweightsAndFilterHB (bool overrideDBweightsAndFilterHB)
 
void setOverrideDBweightsAndFilterHE (bool overrideDBweightsAndFilterHE)
 
void update (const HcalDbService &conditions)
 
void update (const char *filename, bool appendMSB=false)
 
void updateXML (const char *filename)
 
 ~HcaluLUTTPGCoder () override
 
- Public Member Functions inherited from HcalTPGCoder
unsigned short adc2Linear (unsigned char adc, HcalDetId id) const
 
virtual ~HcalTPGCoder ()=default
 

Static Public Attributes

static const float lsb_ = 1. / 16
 
static const int QIE10_LUT_BITMASK = 0x7FF
 
static const int QIE11_LUT_BITMASK = 0x3FF
 
static const int QIE8_LUT_BITMASK = 0x3FF
 

Private Types

typedef std::vector< LutElementLut
 
typedef unsigned short LutElement
 

Private Attributes

bool allLinear_
 
bool applyFixPCC_
 
int bitToMask_
 
bool contain1TSHB_
 
bool contain1TSHE_
 
double containPhaseNSHB_ = 6.0
 
double containPhaseNSHE_ = 6.0
 
std::vector< double > cosh_ieta_
 
double cosh_ieta_28_HE_high_depths_
 
double cosh_ieta_28_HE_low_depths_
 
double cosh_ieta_29_HE_
 
const HcalTimeSlewdelay_
 
std::vector< uint32_t > FG_HF_thresholds_
 
int firstHBEta_
 
int firstHEEta_
 
int firstHFEta_
 
std::vector< float > gain_
 
std::vector< LutinputLUT_
 
int lastHBEta_
 
int lastHEEta_
 
int lastHFEta_
 
double linearLSB_QIE11_
 
double linearLSB_QIE11Overlap_
 
double linearLSB_QIE8_
 
bool LUTGenerationMode_
 
int maxDepthHB_
 
int maxDepthHE_
 
int maxDepthHF_
 
int nHBEta_
 
int nHEEta_
 
int nHFEta_
 
bool overrideDBweightsAndFilterHB_ = false
 
bool overrideDBweightsAndFilterHE_ = false
 
std::vector< float > ped_
 
std::unique_ptr< HcalPulseContainmentManagerpulseCorr_
 
int sizeHB_
 
int sizeHE_
 
int sizeHF_
 
const HcalTopologytopo_
 

Static Private Attributes

static const size_t INPUT_LUT_SIZE = 128
 
static const int nFi_ = 72
 
static const int QIE10_LUT_MSB0 = 0x1000
 
static const int QIE10_LUT_MSB1 = 0x2000
 
static const int QIE11_LUT_MSB0 = 0x400
 
static const int QIE11_LUT_MSB1 = 0x800
 
static const int QIE8_LUT_MSB = 0x400
 
static const size_t UPGRADE_LUT_SIZE = 256
 

Detailed Description

The nominal coder uses a user-supplied table to linearize the ADC values.

[number of ieta slices]
[low tower 1] [low tower 2] ...
[high tower 1] [ high tower 2] ...
[LUT 1(0)] [LUT 2(0)] ...
[LUT 1(1)] [LUT 2(1)] ...
. . .
[LUT 1(127)] [LUT 2(127)] ...
Author
M. Weinberger – TAMU
Tulika Bose and Greg Landsberg – Brown

Definition at line 32 of file HcaluLUTTPGCoder.h.

Member Typedef Documentation

◆ Lut

typedef std::vector<LutElement> HcaluLUTTPGCoder::Lut
private

Definition at line 95 of file HcaluLUTTPGCoder.h.

◆ LutElement

typedef unsigned short HcaluLUTTPGCoder::LutElement
private

Definition at line 94 of file HcaluLUTTPGCoder.h.

Constructor & Destructor Documentation

◆ HcaluLUTTPGCoder() [1/2]

HcaluLUTTPGCoder::HcaluLUTTPGCoder ( )

Definition at line 39 of file HcaluLUTTPGCoder.cc.

40  : topo_{},
41  delay_{},
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_{},
63  allLinear_{},
64  contain1TSHB_{},
65  contain1TSHE_{},
66  applyFixPCC_{},
std::vector< uint32_t > FG_HF_thresholds_
double cosh_ieta_28_HE_high_depths_
double linearLSB_QIE11Overlap_
const HcalTopology * topo_
double cosh_ieta_28_HE_low_depths_
const HcalTimeSlew * delay_

◆ HcaluLUTTPGCoder() [2/2]

HcaluLUTTPGCoder::HcaluLUTTPGCoder ( const HcalTopology topo,
const HcalTimeSlew delay 
)

Definition at line 71 of file HcaluLUTTPGCoder.cc.

References phase2TrackerDigitizer_cfi::delay, and init().

71 { init(top, delay); }
void init(const HcalTopology *top, const HcalTimeSlew *delay)

◆ ~HcaluLUTTPGCoder()

HcaluLUTTPGCoder::~HcaluLUTTPGCoder ( )
override

Definition at line 115 of file HcaluLUTTPGCoder.cc.

115 {}

Member Function Documentation

◆ adc2Linear() [1/5]

void HcaluLUTTPGCoder::adc2Linear ( const HBHEDataFrame df,
IntegerCaloSamples ics 
) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 574 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, hgcalPerformanceValidation::df, getLUTId(), mps_fire::i, Ecal07UnpackerData_cfi::ics, inputLUT_, and QIE8_LUT_BITMASK.

Referenced by HcalTriggerPrimitiveAlgo::addSignal(), and HcalTriggerPrimitiveAlgo::addUpgradeTDCFG().

574  {
575  int lutId = getLUTId(df.id());
576  const Lut& lut = inputLUT_.at(lutId);
577  for (int i = 0; i < df.size(); i++) {
578  ics[i] = (lut.at(df[i].adc()) & QIE8_LUT_BITMASK);
579  }
580 }
static const int QIE8_LUT_BITMASK
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ adc2Linear() [2/5]

void HcaluLUTTPGCoder::adc2Linear ( const HFDataFrame df,
IntegerCaloSamples ics 
) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 582 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, hgcalPerformanceValidation::df, getLUTId(), mps_fire::i, Ecal07UnpackerData_cfi::ics, inputLUT_, and QIE8_LUT_BITMASK.

582  {
583  int lutId = getLUTId(df.id());
584  const Lut& lut = inputLUT_.at(lutId);
585  for (int i = 0; i < df.size(); i++) {
586  ics[i] = (lut.at(df[i].adc()) & QIE8_LUT_BITMASK);
587  }
588 }
static const int QIE8_LUT_BITMASK
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ adc2Linear() [3/5]

void HcaluLUTTPGCoder::adc2Linear ( const QIE10DataFrame df,
IntegerCaloSamples ics 
) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 590 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, hgcalPerformanceValidation::df, getLUTId(), mps_fire::i, Ecal07UnpackerData_cfi::ics, inputLUT_, and QIE10_LUT_BITMASK.

590  {
591  int lutId = getLUTId(HcalDetId(df.id()));
592  const Lut& lut = inputLUT_.at(lutId);
593  for (int i = 0; i < df.samples(); i++) {
594  ics[i] = (lut.at(df[i].adc()) & QIE10_LUT_BITMASK);
595  }
596 }
std::vector< Lut > inputLUT_
static const int QIE10_LUT_BITMASK
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ adc2Linear() [4/5]

void HcaluLUTTPGCoder::adc2Linear ( const QIE11DataFrame df,
IntegerCaloSamples ics 
) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 598 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, hgcalPerformanceValidation::df, getLUTId(), mps_fire::i, Ecal07UnpackerData_cfi::ics, inputLUT_, and QIE11_LUT_BITMASK.

598  {
599  int lutId = getLUTId(HcalDetId(df.id()));
600  const Lut& lut = inputLUT_.at(lutId);
601  for (int i = 0; i < df.samples(); i++) {
602  ics[i] = (lut.at(df[i].adc()) & QIE11_LUT_BITMASK);
603  }
604 }
static const int QIE11_LUT_BITMASK
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ adc2Linear() [5/5]

unsigned short HcaluLUTTPGCoder::adc2Linear ( HcalQIESample  sample,
HcalDetId  id 
) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 606 of file HcaluLUTTPGCoder.cc.

References getLUTId(), inputLUT_, QIE8_LUT_BITMASK, and ecalGpuTask_cfi::sample.

606  {
607  int lutId = getLUTId(id);
608  return ((inputLUT_.at(lutId)).at(sample.adc()) & QIE8_LUT_BITMASK);
609 }
static const int QIE8_LUT_BITMASK
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const

◆ compress()

void HcaluLUTTPGCoder::compress ( const IntegerCaloSamples ics,
const std::vector< bool > &  featureBits,
HcalTriggerPrimitiveDigi tp 
) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 109 of file HcaluLUTTPGCoder.cc.

References Exception.

111  {
112  throw cms::Exception("PROBLEM: This method should never be invoked!");
113 }

◆ cosh_ieta()

double HcaluLUTTPGCoder::cosh_ieta ( int  ieta,
int  depth,
HcalSubdetector  subdet 
)

Definition at line 288 of file HcaluLUTTPGCoder.cc.

References funct::abs(), allLinear_, cosh_ieta_, cosh_ieta_28_HE_high_depths_, cosh_ieta_28_HE_low_depths_, cosh_ieta_29_HE_, LEDCalibrationChannels::depth, HcalEndcap, and LEDCalibrationChannels::ieta.

Referenced by update().

288  {
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 }
double cosh_ieta_28_HE_high_depths_
double cosh_ieta_28_HE_low_depths_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > cosh_ieta_

◆ getLinearizationLUT()

std::vector< unsigned short > HcaluLUTTPGCoder::getLinearizationLUT ( HcalDetId  id) const
overridevirtual

Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all values.

Reimplemented from HcalTPGCoder.

Definition at line 633 of file HcaluLUTTPGCoder.cc.

References getLUTId(), and inputLUT_.

633  {
634  int lutId = getLUTId(id);
635  return inputLUT_.at(lutId);
636 }
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const

◆ getLUTGain()

float HcaluLUTTPGCoder::getLUTGain ( HcalDetId  id) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 628 of file HcaluLUTTPGCoder.cc.

References gain_, and getLUTId().

628  {
629  int lutId = getLUTId(id);
630  return gain_.at(lutId);
631 }
std::vector< float > gain_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const

◆ getLUTId() [1/3]

int HcaluLUTTPGCoder::getLUTId ( HcalSubdetector  id,
int  ieta,
int  iphi,
int  depth 
) const

Definition at line 117 of file HcaluLUTTPGCoder.cc.

References LEDCalibrationChannels::depth, firstHBEta_, firstHEEta_, firstHFEta_, HcalBarrel, HcalEndcap, HcalForward, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, lastHBEta_, lastHEEta_, lastHFEta_, maxDepthHB_, maxDepthHE_, maxDepthHF_, nFi_, nHBEta_, nHEEta_, nHFEta_, sizeHB_, and sizeHE_.

Referenced by adc2Linear(), getLinearizationLUT(), getLUTGain(), getLUTId(), getLUTPedestal(), getMSB(), group0FGbits(), lookupMSB(), update(), and updateXML().

117  {
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 }
static const int nFi_

◆ getLUTId() [2/3]

int HcaluLUTTPGCoder::getLUTId ( uint32_t  rawid) const

Definition at line 143 of file HcaluLUTTPGCoder.cc.

References HcalDetId::depth(), getLUTId(), HcalDetId::ieta(), HcalDetId::iphi(), and HcalDetId::subdet().

143  {
144  HcalDetId detid(rawid);
145  return getLUTId(detid.subdet(), detid.ieta(), detid.iphi(), detid.depth());
146 }
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const

◆ getLUTId() [3/3]

int HcaluLUTTPGCoder::getLUTId ( const HcalDetId detid) const

Definition at line 148 of file HcaluLUTTPGCoder.cc.

References HcalDetId::depth(), getLUTId(), HcalDetId::ieta(), HcalDetId::iphi(), and HcalDetId::subdet().

148  {
149  return getLUTId(detid.subdet(), detid.ieta(), detid.iphi(), detid.depth());
150 }
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

◆ getLUTPedestal()

float HcaluLUTTPGCoder::getLUTPedestal ( HcalDetId  id) const
overridevirtual

Implements HcalTPGCoder.

Definition at line 623 of file HcaluLUTTPGCoder.cc.

References getLUTId(), and ped_.

623  {
624  int lutId = getLUTId(id);
625  return ped_.at(lutId);
626 }
std::vector< float > ped_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const

◆ getMSB()

bool HcaluLUTTPGCoder::getMSB ( const HcalDetId id,
int  adc 
) const

Definition at line 644 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, getLUTId(), inputLUT_, and QIE8_LUT_MSB.

Referenced by lookupMSB().

644  {
645  int lutId = getLUTId(id);
646  const Lut& lut = inputLUT_.at(lutId);
647  return (lut.at(adc) & QIE8_LUT_MSB);
648 }
std::vector< Lut > inputLUT_
static const int QIE8_LUT_MSB
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ group0FGbits()

std::vector< unsigned short > HcaluLUTTPGCoder::group0FGbits ( const QIE11DataFrame df) const

Definition at line 611 of file HcaluLUTTPGCoder.cc.

References hgcalPerformanceValidation::df, getLUTId(), mps_fire::i, and inputLUT_.

Referenced by HcalTriggerPrimitiveAlgo::addUpgradeTDCFG().

611  {
612  int lutId = getLUTId(HcalDetId(df.id()));
613  const Lut& lut = inputLUT_.at(lutId);
614  std::vector<unsigned short> group0LLPbits;
615  group0LLPbits.reserve(df.samples());
616  for (int i = 0; i < df.samples(); i++) {
617  group0LLPbits.push_back((lut.at(df[i].adc()) >> 12) &
618  0xF); // four bits (12-15) of LUT used to set 6 finegrain bits from uHTR
619  }
620  return group0LLPbits;
621 }
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
Definition: Lut.h:31

◆ init()

void HcaluLUTTPGCoder::init ( const HcalTopology top,
const HcalTimeSlew delay 
)

Definition at line 73 of file HcaluLUTTPGCoder.cc.

References allLinear_, applyFixPCC_, bitToMask_, contain1TSHB_, contain1TSHE_, phase2TrackerDigitizer_cfi::delay, delay_, FG_HF_thresholds_, firstHBEta_, HcalTopology::firstHBRing(), firstHEEta_, HcalTopology::firstHERing(), firstHFEta_, HcalTopology::firstHFRing(), gain_, HcalBarrel, HcalEndcap, HcalForward, inputLUT_, lastHBEta_, HcalTopology::lastHBRing(), lastHEEta_, HcalTopology::lastHERing(), lastHFEta_, HcalTopology::lastHFRing(), linearLSB_QIE11_, linearLSB_QIE11Overlap_, linearLSB_QIE8_, LUTGenerationMode_, make_cosh_ieta_map(), HcalTopology::maxDepth(), maxDepthHB_, maxDepthHE_, maxDepthHF_, MaximumFractionalError, nFi_, nHBEta_, nHEEta_, nHFEta_, ped_, pulseCorr_, sizeHB_, sizeHE_, sizeHF_, and topo_.

Referenced by HcalTPGCoderULUT::buildCoder(), and HcaluLUTTPGCoder().

73  {
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 }
std::vector< uint32_t > FG_HF_thresholds_
static const int nFi_
double linearLSB_QIE11Overlap_
const HcalTopology * topo_
int firstHBRing() const
Definition: HcalTopology.h:91
std::vector< Lut > inputLUT_
int lastHBRing() const
Definition: HcalTopology.h:92
const HcalTimeSlew * delay_
int maxDepth(void) const
std::vector< float > ped_
constexpr double MaximumFractionalError
std::vector< float > gain_
int lastHERing() const
Definition: HcalTopology.h:94
int lastHFRing() const
Definition: HcalTopology.h:97
void make_cosh_ieta_map(void)
std::unique_ptr< HcalPulseContainmentManager > pulseCorr_
int firstHFRing() const
Definition: HcalTopology.h:96
int firstHERing() const
Definition: HcalTopology.h:93

◆ lookupMSB() [1/3]

void HcaluLUTTPGCoder::lookupMSB ( const HBHEDataFrame df,
std::vector< bool > &  msb 
) const

Definition at line 638 of file HcaluLUTTPGCoder.cc.

References hgcalPerformanceValidation::df, getMSB(), and mps_fire::i.

Referenced by HcalTriggerPrimitiveAlgo::addSignal().

638  {
639  msb.resize(df.size());
640  for (int i = 0; i < df.size(); ++i)
641  msb[i] = getMSB(df.id(), df.sample(i).adc());
642 }
bool getMSB(const HcalDetId &id, int adc) const

◆ lookupMSB() [2/3]

void HcaluLUTTPGCoder::lookupMSB ( const QIE10DataFrame df,
std::vector< std::bitset< 2 >> &  msb 
) const

Definition at line 650 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, hgcalPerformanceValidation::df, getLUTId(), mps_fire::i, inputLUT_, QIE10_LUT_MSB0, and QIE10_LUT_MSB1.

650  {
651  msb.resize(df.samples());
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()) & QIE10_LUT_MSB0;
656  msb[i][1] = lut.at(df[i].adc()) & QIE10_LUT_MSB1;
657  }
658 }
static const int QIE10_LUT_MSB0
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
static const int QIE10_LUT_MSB1
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ lookupMSB() [3/3]

void HcaluLUTTPGCoder::lookupMSB ( const QIE11DataFrame df,
std::vector< std::bitset< 2 >> &  msb 
) const

Definition at line 660 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, hgcalPerformanceValidation::df, getLUTId(), mps_fire::i, inputLUT_, QIE11_LUT_MSB0, and QIE11_LUT_MSB1.

660  {
661  int lutId = getLUTId(HcalDetId(df.id()));
662  const Lut& lut = inputLUT_.at(lutId);
663  for (int i = 0; i < df.samples(); ++i) {
664  msb[i][0] = lut.at(df[i].adc()) & QIE11_LUT_MSB0;
665  msb[i][1] = lut.at(df[i].adc()) & QIE11_LUT_MSB1;
666  }
667 }
static const int QIE11_LUT_MSB1
static const int QIE11_LUT_MSB0
std::vector< Lut > inputLUT_
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
Definition: Lut.h:31
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ make_cosh_ieta_map()

void HcaluLUTTPGCoder::make_cosh_ieta_map ( void  )

Definition at line 306 of file HcaluLUTTPGCoder.cc.

References cosh_ieta_, cosh_ieta_28_HE_high_depths_, cosh_ieta_28_HE_low_depths_, cosh_ieta_29_HE_, HLT_2022v14_cff::eta1, HLT_2022v14_cff::eta2, HcalTopology::etaRange(), EnergyCorrector::etas, firstHFEta_, HcalEndcap, HcalForward, mps_fire::i, lastHFEta_, topo_, and HcalTrigTowerGeometry::towerEtaBounds().

Referenced by init(), and update().

306  {
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 }
double cosh_ieta_28_HE_high_depths_
const HcalTopology * topo_
double cosh_ieta_28_HE_low_depths_
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
std::vector< double > cosh_ieta_

◆ set1TSContainHB()

void HcaluLUTTPGCoder::set1TSContainHB ( bool  contain1TSHB)
inline

◆ set1TSContainHE()

void HcaluLUTTPGCoder::set1TSContainHE ( bool  contain1TSHE)
inline

◆ setAllLinear()

void HcaluLUTTPGCoder::setAllLinear ( bool  linear,
double  lsb8,
double  lsb11,
double  lsb11overlap 
)
inline

Definition at line 63 of file HcaluLUTTPGCoder.h.

References allLinear_, linear(), linearLSB_QIE11_, linearLSB_QIE11Overlap_, and linearLSB_QIE8_.

Referenced by HcalTPGCoderULUT::buildCoder().

63  {
65  linearLSB_QIE8_ = lsb8;
66  linearLSB_QIE11_ = lsb11;
67  linearLSB_QIE11Overlap_ = lsb11overlap;
68  };
double linearLSB_QIE11Overlap_
float linear(float x)

◆ setApplyFixPCC()

void HcaluLUTTPGCoder::setApplyFixPCC ( double  applyFixPCC)
inline

◆ setContainPhaseHB()

void HcaluLUTTPGCoder::setContainPhaseHB ( double  containPhaseNSHB)
inline

◆ setContainPhaseHE()

void HcaluLUTTPGCoder::setContainPhaseHE ( double  containPhaseNSHE)
inline

◆ setFGHFthresholds()

void HcaluLUTTPGCoder::setFGHFthresholds ( const std::vector< uint32_t > &  fgthresholds)
inline

Definition at line 61 of file HcaluLUTTPGCoder.h.

References FG_HF_thresholds_.

Referenced by HcalTPGCoderULUT::buildCoder().

61 { FG_HF_thresholds_ = fgthresholds; };
std::vector< uint32_t > FG_HF_thresholds_

◆ setLUTGenerationMode()

void HcaluLUTTPGCoder::setLUTGenerationMode ( bool  gen)
inline

Definition at line 60 of file HcaluLUTTPGCoder.h.

References relval_steps::gen(), and LUTGenerationMode_.

Referenced by HcalTPGCoderULUT::buildCoder().

60 { LUTGenerationMode_ = gen; };
def gen(fragment, howMuch)
Production test section ####.

◆ setMaskBit()

void HcaluLUTTPGCoder::setMaskBit ( int  bit)
inline

Definition at line 62 of file HcaluLUTTPGCoder.h.

References bitToMask_.

Referenced by HcalTPGCoderULUT::buildCoder().

62 { bitToMask_ = bit; };

◆ setOverrideDBweightsAndFilterHB()

void HcaluLUTTPGCoder::setOverrideDBweightsAndFilterHB ( bool  overrideDBweightsAndFilterHB)
inline

◆ setOverrideDBweightsAndFilterHE()

void HcaluLUTTPGCoder::setOverrideDBweightsAndFilterHE ( bool  overrideDBweightsAndFilterHE)
inline

◆ update() [1/2]

void HcaluLUTTPGCoder::update ( const HcalDbService conditions)

Definition at line 333 of file HcaluLUTTPGCoder.cc.

References funct::abs(), gpuClustering::adc, adc2fC, HcalElectronicsMap::allElectronicsIdTrigger(), allLinear_, applyFixPCC_, cms::cuda::assert(), bitToMask_, AlignmentProducer_cff::calibrations, HcalQIECoder::charge(), submitPVValidationJobs::conditions, contain1TSHB_, contain1TSHE_, containPhaseNSHB_, containPhaseNSHE_, alignCSCRings::corr, castor_dqm_sourceclient-live_cfg::correctionPhaseNS, cosh_ieta(), cosh_ieta_, HcalTopology::dddConstants(), delay_, HcalDetId::depth(), FG_HF_thresholds_, PedestalClient_cfi::gain, gain_, HcalTPChannelParameter::getFGBitInfo(), HcalL1TriggerObject::getFlag(), HcalLutMetadatum::getLutGranularity(), getLUTId(), HcalL1TriggerObject::getPedestal(), HcalLutMetadatum::getRCalib(), HcalL1TriggerObject::getRespGain(), HcalChannelStatus::getValue(), DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalDetId::ieta(), HcalDetId::ietaAbs(), INPUT_LUT_SIZE, inputLUT_, HcalDDDRecConstants::isPlan1(), HcalTopology::lastHBRing(), HcalTopology::lastHERing(), linearLSB_QIE11_, linearLSB_QIE11Overlap_, linearLSB_QIE8_, HcalElectronicsMap::lookupTrigger(), lsb_, LUTGenerationMode_, make_cosh_ieta_map(), SiStripPI::max, MaximumFractionalError, OccupancyTask_cfi::metadata, SiStripPI::min, or, overrideDBweightsAndFilterHB_, overrideDBweightsAndFilterHE_, ped_, pulseCorr_, QIE10, QIE10_LUT_BITMASK, QIE10_LUT_MSB0, QIE10_LUT_MSB1, QIE11, QIE11_LUT_BITMASK, QIE11_LUT_MSB0, QIE11_LUT_MSB1, QIE8, QIE8_LUT_BITMASK, SIZE, mps_update::status, HcalDetId::subdet(), topo_, HcalTopology::triggerMode(), HcalTopologyMode::TriggerMode_2018, HcalTopologyMode::TriggerMode_2018legacy, HcalTopologyMode::TriggerMode_2021, UPGRADE_LUT_SIZE, and HcalTopology::valid().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), HcalTPGCoderULUT::buildCoder(), dqm-mbProfile.Profile::finish(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

333  {
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)
480  else if (overrideDBweightsAndFilterHE_ and cell.ietaAbs() > lastHBRing)
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 (subdet == HcalBarrel) { // edit since bits 12-15 not supported in HE yet
535  if ((linearizedADC < bit12_energy and cell.depth() <= 2) or (cell.depth() >= 3))
536  lut[adc] |= 1 << 12;
537  if (linearizedADC >= bit13_energy and cell.depth() >= 3)
538  lut[adc] |= 1 << 13;
539  if (linearizedADC >= bit14_energy)
540  lut[adc] |= 1 << 14;
541  if (linearizedADC >= bit15_energy)
542  lut[adc] |= 1 << 15;
543  }
544  if (adc >= mipMin and adc < mipMax)
545  lut[adc] |= QIE11_LUT_MSB0;
546  else if (adc >= mipMax)
547  lut[adc] |= QIE11_LUT_MSB1;
548  }
549 
550  //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.
551  if (abs(cell.ieta()) == 16 && cell.depth() == 4 &&
553  lut[adc] = 0;
554  }
555  }
556  }
557  } else if (subdet == HcalForward) {
558  for (unsigned int adc = 0; adc < SIZE; ++adc) {
559  if (isMasked)
560  lut[adc] = 0;
561  else {
562  lut[adc] =
563  std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib / lsb_ / cosh_ieta_[cell.ietaAbs()])), MASK);
564  if (adc > FG_HF_thresholds_[0])
565  lut[adc] |= QIE10_LUT_MSB0;
566  if (adc > FG_HF_thresholds_[1])
567  lut[adc] |= QIE10_LUT_MSB1;
568  }
569  }
570  }
571  }
572 }
std::vector< uint32_t > FG_HF_thresholds_
float getRCalib() const
std::vector< HcalElectronicsId > allElectronicsIdTrigger() const
uint32_t getFlag() const
double linearLSB_QIE11Overlap_
static const int QIE11_LUT_MSB1
static const int QIE11_LUT_BITMASK
uint8_t getLutGranularity() const
Definition: HcalQIENum.h:4
bool valid(const DetId &id) const override
const HcalTopology * topo_
static const int QIE11_LUT_MSB0
static const float lsb_
Definition: weight.py:1
bool overrideDBweightsAndFilterHB_
static const int QIE8_LUT_BITMASK
assert(be >=bs)
unsigned short LutElement
static const int QIE10_LUT_MSB0
static const size_t UPGRADE_LUT_SIZE
std::vector< Lut > inputLUT_
dictionary corr
HcalTopologyMode::TriggerMode triggerMode() const
Definition: HcalTopology.h:35
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
const HcalTimeSlew * delay_
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const float adc2fC[128]
bool overrideDBweightsAndFilterHE_
uint32_t getValue() const
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_
static const size_t INPUT_LUT_SIZE
int lastHERing() const
Definition: HcalTopology.h:94
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:164
uint32_t getFGBitInfo() const
get FG bit information
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
static const int QIE10_LUT_MSB1
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

◆ update() [2/2]

void HcaluLUTTPGCoder::update ( const char *  filename,
bool  appendMSB = false 
)

Definition at line 152 of file HcaluLUTTPGCoder.cc.

References gpuClustering::adc, cms::cuda::assert(), edmScanValgrind::buffer, LEDCalibrationChannels::depth, geometryDiff::file, corrVsCorr::filename, getLUTId(), HcalBarrel, HcalEndcap, HcalForward, mps_fire::i, l1ctLayer2EG_cff::id, LEDCalibrationChannels::ieta, recoMuon::in, INPUT_LUT_SIZE, inputLUT_, LEDCalibrationChannels::iphi, QIE8_LUT_BITMASK, QIE8_LUT_MSB, findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, topo_, and HcalTopology::valid().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), dqm-mbProfile.Profile::finish(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

152  {
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 }
size
Write out results.
bool valid(const DetId &id) const override
const HcalTopology * topo_
static const int QIE8_LUT_BITMASK
assert(be >=bs)
unsigned short LutElement
std::vector< Lut > inputLUT_
static const int QIE8_LUT_MSB
static const size_t INPUT_LUT_SIZE
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ updateXML()

void HcaluLUTTPGCoder::updateXML ( const char *  filename)

Definition at line 261 of file HcaluLUTTPGCoder.cc.

References LutXml::create_lut_map(), LEDCalibrationChannels::depth, Exception, corrVsCorr::filename, XMLProcessor::getInstance(), LutXml::getLutFast(), getLUTId(), HcalBarrel, HcalEndcap, HcalForward, mps_fire::i, LEDCalibrationChannels::ieta, INPUT_LUT_SIZE, inputLUT_, createfilelist::int, LEDCalibrationChannels::iphi, HcalDetId::kHcalDepthMask2, HcalDetId::kHcalEtaMask2, HcalDetId::kHcalPhiMask2, XMLProcessor::terminate(), topo_, and HcalTopology::valid().

Referenced by HcalTPGCoderULUT::buildCoder().

261  {
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 }
static constexpr uint32_t kHcalPhiMask2
Definition: HcalDetId.h:15
Definition: LutXml.h:27
bool valid(const DetId &id) const override
int create_lut_map(void)
Definition: LutXml.cc:338
const HcalTopology * topo_
unsigned short LutElement
std::vector< Lut > inputLUT_
int terminate(void)
HcalSubdetector
Definition: HcalAssistant.h:31
static constexpr uint32_t kHcalEtaMask2
Definition: HcalDetId.h:19
std::vector< unsigned int > * getLutFast(uint32_t det_id)
Definition: LutXml.cc:72
static const size_t INPUT_LUT_SIZE
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134
static constexpr uint32_t kHcalDepthMask2
Definition: HcalDetId.h:25

Member Data Documentation

◆ allLinear_

bool HcaluLUTTPGCoder::allLinear_
private

Definition at line 123 of file HcaluLUTTPGCoder.h.

Referenced by cosh_ieta(), init(), setAllLinear(), and update().

◆ applyFixPCC_

bool HcaluLUTTPGCoder::applyFixPCC_
private

Definition at line 127 of file HcaluLUTTPGCoder.h.

Referenced by init(), setApplyFixPCC(), and update().

◆ bitToMask_

int HcaluLUTTPGCoder::bitToMask_
private

Definition at line 113 of file HcaluLUTTPGCoder.h.

Referenced by init(), setMaskBit(), and update().

◆ contain1TSHB_

bool HcaluLUTTPGCoder::contain1TSHB_
private

Definition at line 124 of file HcaluLUTTPGCoder.h.

Referenced by init(), set1TSContainHB(), and update().

◆ contain1TSHE_

bool HcaluLUTTPGCoder::contain1TSHE_
private

Definition at line 124 of file HcaluLUTTPGCoder.h.

Referenced by init(), set1TSContainHE(), and update().

◆ containPhaseNSHB_

double HcaluLUTTPGCoder::containPhaseNSHB_ = 6.0
private

Definition at line 125 of file HcaluLUTTPGCoder.h.

Referenced by setContainPhaseHB(), and update().

◆ containPhaseNSHE_

double HcaluLUTTPGCoder::containPhaseNSHE_ = 6.0
private

Definition at line 126 of file HcaluLUTTPGCoder.h.

Referenced by setContainPhaseHE(), and update().

◆ cosh_ieta_

std::vector<double> HcaluLUTTPGCoder::cosh_ieta_
private

Definition at line 120 of file HcaluLUTTPGCoder.h.

Referenced by cosh_ieta(), make_cosh_ieta_map(), and update().

◆ cosh_ieta_28_HE_high_depths_

double HcaluLUTTPGCoder::cosh_ieta_28_HE_high_depths_
private

Definition at line 122 of file HcaluLUTTPGCoder.h.

Referenced by cosh_ieta(), and make_cosh_ieta_map().

◆ cosh_ieta_28_HE_low_depths_

double HcaluLUTTPGCoder::cosh_ieta_28_HE_low_depths_
private

Definition at line 122 of file HcaluLUTTPGCoder.h.

Referenced by cosh_ieta(), and make_cosh_ieta_map().

◆ cosh_ieta_29_HE_

double HcaluLUTTPGCoder::cosh_ieta_29_HE_
private

Definition at line 122 of file HcaluLUTTPGCoder.h.

Referenced by cosh_ieta(), and make_cosh_ieta_map().

◆ delay_

const HcalTimeSlew* HcaluLUTTPGCoder::delay_
private

Definition at line 110 of file HcaluLUTTPGCoder.h.

Referenced by init(), and update().

◆ FG_HF_thresholds_

std::vector<uint32_t> HcaluLUTTPGCoder::FG_HF_thresholds_
private

Definition at line 112 of file HcaluLUTTPGCoder.h.

Referenced by init(), setFGHFthresholds(), and update().

◆ firstHBEta_

int HcaluLUTTPGCoder::firstHBEta_
private

Definition at line 114 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ firstHEEta_

int HcaluLUTTPGCoder::firstHEEta_
private

Definition at line 115 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ firstHFEta_

int HcaluLUTTPGCoder::firstHFEta_
private

Definition at line 116 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), init(), and make_cosh_ieta_map().

◆ gain_

std::vector<float> HcaluLUTTPGCoder::gain_
private

Definition at line 118 of file HcaluLUTTPGCoder.h.

Referenced by getLUTGain(), init(), and update().

◆ INPUT_LUT_SIZE

const size_t HcaluLUTTPGCoder::INPUT_LUT_SIZE = 128
staticprivate

Definition at line 98 of file HcaluLUTTPGCoder.h.

Referenced by update(), and updateXML().

◆ inputLUT_

std::vector<Lut> HcaluLUTTPGCoder::inputLUT_
private

◆ lastHBEta_

int HcaluLUTTPGCoder::lastHBEta_
private

Definition at line 114 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ lastHEEta_

int HcaluLUTTPGCoder::lastHEEta_
private

Definition at line 115 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ lastHFEta_

int HcaluLUTTPGCoder::lastHFEta_
private

Definition at line 116 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), init(), and make_cosh_ieta_map().

◆ linearLSB_QIE11_

double HcaluLUTTPGCoder::linearLSB_QIE11_
private

Definition at line 128 of file HcaluLUTTPGCoder.h.

Referenced by init(), setAllLinear(), and update().

◆ linearLSB_QIE11Overlap_

double HcaluLUTTPGCoder::linearLSB_QIE11Overlap_
private

Definition at line 128 of file HcaluLUTTPGCoder.h.

Referenced by init(), setAllLinear(), and update().

◆ linearLSB_QIE8_

double HcaluLUTTPGCoder::linearLSB_QIE8_
private

Definition at line 128 of file HcaluLUTTPGCoder.h.

Referenced by init(), setAllLinear(), and update().

◆ lsb_

const float HcaluLUTTPGCoder::lsb_ = 1. / 16
static

Definition at line 34 of file HcaluLUTTPGCoder.h.

Referenced by CaloTPGTranscoderULUT::setup(), and update().

◆ LUTGenerationMode_

bool HcaluLUTTPGCoder::LUTGenerationMode_
private

Definition at line 111 of file HcaluLUTTPGCoder.h.

Referenced by init(), setLUTGenerationMode(), and update().

◆ maxDepthHB_

int HcaluLUTTPGCoder::maxDepthHB_
private

Definition at line 114 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ maxDepthHE_

int HcaluLUTTPGCoder::maxDepthHE_
private

Definition at line 115 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ maxDepthHF_

int HcaluLUTTPGCoder::maxDepthHF_
private

Definition at line 116 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ nFi_

const int HcaluLUTTPGCoder::nFi_ = 72
staticprivate

Definition at line 100 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ nHBEta_

int HcaluLUTTPGCoder::nHBEta_
private

Definition at line 114 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ nHEEta_

int HcaluLUTTPGCoder::nHEEta_
private

Definition at line 115 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ nHFEta_

int HcaluLUTTPGCoder::nHFEta_
private

Definition at line 116 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ overrideDBweightsAndFilterHB_

bool HcaluLUTTPGCoder::overrideDBweightsAndFilterHB_ = false
private

Definition at line 130 of file HcaluLUTTPGCoder.h.

Referenced by setOverrideDBweightsAndFilterHB(), and update().

◆ overrideDBweightsAndFilterHE_

bool HcaluLUTTPGCoder::overrideDBweightsAndFilterHE_ = false
private

Definition at line 131 of file HcaluLUTTPGCoder.h.

Referenced by setOverrideDBweightsAndFilterHE(), and update().

◆ ped_

std::vector<float> HcaluLUTTPGCoder::ped_
private

Definition at line 119 of file HcaluLUTTPGCoder.h.

Referenced by getLUTPedestal(), init(), and update().

◆ pulseCorr_

std::unique_ptr<HcalPulseContainmentManager> HcaluLUTTPGCoder::pulseCorr_
private

Definition at line 129 of file HcaluLUTTPGCoder.h.

Referenced by init(), and update().

◆ QIE10_LUT_BITMASK

const int HcaluLUTTPGCoder::QIE10_LUT_BITMASK = 0x7FF
static

Definition at line 89 of file HcaluLUTTPGCoder.h.

Referenced by adc2Linear(), and update().

◆ QIE10_LUT_MSB0

const int HcaluLUTTPGCoder::QIE10_LUT_MSB0 = 0x1000
staticprivate

Definition at line 105 of file HcaluLUTTPGCoder.h.

Referenced by lookupMSB(), and update().

◆ QIE10_LUT_MSB1

const int HcaluLUTTPGCoder::QIE10_LUT_MSB1 = 0x2000
staticprivate

Definition at line 106 of file HcaluLUTTPGCoder.h.

Referenced by lookupMSB(), and update().

◆ QIE11_LUT_BITMASK

const int HcaluLUTTPGCoder::QIE11_LUT_BITMASK = 0x3FF
static

Definition at line 90 of file HcaluLUTTPGCoder.h.

Referenced by adc2Linear(), and update().

◆ QIE11_LUT_MSB0

const int HcaluLUTTPGCoder::QIE11_LUT_MSB0 = 0x400
staticprivate

Definition at line 103 of file HcaluLUTTPGCoder.h.

Referenced by lookupMSB(), and update().

◆ QIE11_LUT_MSB1

const int HcaluLUTTPGCoder::QIE11_LUT_MSB1 = 0x800
staticprivate

Definition at line 104 of file HcaluLUTTPGCoder.h.

Referenced by lookupMSB(), and update().

◆ QIE8_LUT_BITMASK

const int HcaluLUTTPGCoder::QIE8_LUT_BITMASK = 0x3FF
static

Definition at line 88 of file HcaluLUTTPGCoder.h.

Referenced by adc2Linear(), and update().

◆ QIE8_LUT_MSB

const int HcaluLUTTPGCoder::QIE8_LUT_MSB = 0x400
staticprivate

Definition at line 102 of file HcaluLUTTPGCoder.h.

Referenced by getMSB(), and update().

◆ sizeHB_

int HcaluLUTTPGCoder::sizeHB_
private

Definition at line 114 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ sizeHE_

int HcaluLUTTPGCoder::sizeHE_
private

Definition at line 115 of file HcaluLUTTPGCoder.h.

Referenced by getLUTId(), and init().

◆ sizeHF_

int HcaluLUTTPGCoder::sizeHF_
private

Definition at line 116 of file HcaluLUTTPGCoder.h.

Referenced by init().

◆ topo_

const HcalTopology* HcaluLUTTPGCoder::topo_
private

Definition at line 109 of file HcaluLUTTPGCoder.h.

Referenced by init(), make_cosh_ieta_map(), update(), and updateXML().

◆ UPGRADE_LUT_SIZE

const size_t HcaluLUTTPGCoder::UPGRADE_LUT_SIZE = 256
staticprivate

Definition at line 99 of file HcaluLUTTPGCoder.h.

Referenced by update().