Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
void update(const char* filename, bool appendMSB = false);
void updateXML(const char* filename);
void setLUTGenerationMode(bool gen) { LUTGenerationMode_ = gen; };
void setOverrideFGHF(bool overrideFGHF) { overrideFGHF_ = overrideFGHF; };
void setFGHFthresholds(const std::vector<uint32_t>& fgthresholds) { FG_HF_thresholds_ = fgthresholds; };
void setMaskBit(int bit) { bitToMask_ = bit; };
void setAllLinear(bool linear, double lsb8, double lsb11, double lsb11overlap) {
Expand Down Expand Up @@ -114,6 +115,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
const HcalElectronicsMap* emap_;
const HcalTimeSlew* delay_;
bool LUTGenerationMode_;
bool overrideFGHF_ = false;
std::vector<uint32_t> FG_HF_thresholds_;
int bitToMask_;
int firstHBEta_, lastHBEta_, nHBEta_, maxDepthHB_, sizeHB_;
Expand Down
34 changes: 32 additions & 2 deletions CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ HcaluLUTTPGCoder::HcaluLUTTPGCoder()
emap_{},
delay_{},
LUTGenerationMode_{},
overrideFGHF_{},
FG_HF_thresholds_{},
bitToMask_{},
firstHBEta_{},
Expand Down Expand Up @@ -81,6 +82,7 @@ void HcaluLUTTPGCoder::init(const HcalTopology* top, const HcalElectronicsMap* e
emap_ = emap;
delay_ = delay;
LUTGenerationMode_ = true;
overrideFGHF_ = false;
FG_HF_thresholds_ = {0, 0};
bitToMask_ = 0;
allLinear_ = false;
Expand Down Expand Up @@ -381,6 +383,34 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
bool newHBtp = false;
bool newHEtp = false;
std::vector<HcalElectronicsId> vIds = emap_->allElectronicsIdTrigger();

// Access TPParameters to get HF fine-grain thresholds
const HcalTPParameters* tpparameters = conditions.getHcalTPParameters();

// Read thresholds from auxi1 field
// aux1: 32-bit auxiliary word. Currently, only the low 16 bits are used (HF MinBias FG thresholds). The high 16 bits are reserved for future use.
const uint32_t aux1 = tpparameters->getAuxi1();
unsigned fg_hf_lo, fg_hf_hi;

// The first 16 bits of auxi1 are empty OR the switch is open: Read from configuration parameters
const bool zerothresFGHF = (aux1 & 0xFFFFu) == 0u;
if (overrideFGHF_ || zerothresFGHF) {
fg_hf_lo = FG_HF_thresholds_[0];
fg_hf_hi = FG_HF_thresholds_[1];
} else {
// First 8-bits: low threshold
// Second 8-bits: high threshold
fg_hf_lo = aux1 & 0xFFu;
fg_hf_hi = (aux1 >> 8) & 0xFFu;
}

// Sanity check: low less than high
if (fg_hf_hi < fg_hf_lo) {
edm::LogError("HcaluLUTTPGCoder")
<< "ERROR: HF fine-grain thresholds, taken from auxi1 field of HcalTPParameters, are possibly mis-ordered: "
<< "lower threshold (" << fg_hf_lo << ") > high threshold (" << fg_hf_hi << ").";
}

for (std::vector<HcalElectronicsId>::const_iterator eId = vIds.begin(); eId != vIds.end(); eId++) {
// The first HB or HE id is enough to tell whether to use new scheme in HB or HE
if (foundHB and foundHE)
Expand Down Expand Up @@ -577,9 +607,9 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
else {
lut[adc] = std::min(
std::max(0, int((adc2fC(adc) - ped) * gain * rcalib / lsb_ / cosh_ieta_[cell.ietaAbs()])), MASK);
if (adc > FG_HF_thresholds_[0])
if (adc > fg_hf_lo)
lut[adc] |= QIE10_LUT_MSB0;
if (adc > FG_HF_thresholds_[1])
if (adc > fg_hf_hi)
lut[adc] |= QIE10_LUT_MSB1;
}
}
Expand Down
3 changes: 3 additions & 0 deletions CalibCalorimetry/HcalTPGEventSetup/src/HcalTPGCoderULUT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class HcalTPGCoderULUT : public edm::ESProducer {
bool overrideDBweightsAndFilterHB_, overrideDBweightsAndFilterHE_;
double linearLSB_QIE8_, linearLSB_QIE11Overlap_, linearLSB_QIE11_;
int maskBit_;
bool overrideFGHF_;
std::vector<uint32_t> FG_HF_thresholds_;
edm::FileInPath fgfile_, ifilename_;
};
Expand Down Expand Up @@ -107,6 +108,7 @@ HcalTPGCoderULUT::HcalTPGCoderULUT(const edm::ParameterSet& iConfig) {
linearLSB_QIE11_ = scales.getParameter<double>("LSBQIE11");
linearLSB_QIE11Overlap_ = scales.getParameter<double>("LSBQIE11Overlap");
maskBit_ = iConfig.getParameter<int>("MaskBit");
overrideFGHF_ = iConfig.getParameter<bool>("overrideFGHF");
FG_HF_thresholds_ = iConfig.getParameter<std::vector<uint32_t> >("FG_HF_thresholds");
} else {
ifilename_ = iConfig.getParameter<edm::FileInPath>("inputLUTs");
Expand Down Expand Up @@ -146,6 +148,7 @@ void HcalTPGCoderULUT::buildCoder(const HcalTopology* topo,
theCoder->setAllLinear(linearLUTs_, linearLSB_QIE8_, linearLSB_QIE11_, linearLSB_QIE11Overlap_);
theCoder->setLUTGenerationMode(LUTGenerationMode_);
theCoder->setMaskBit(maskBit_);
theCoder->setOverrideFGHF(overrideFGHF_);
theCoder->setFGHFthresholds(FG_HF_thresholds_);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
overrideDBweightsAndFilterHE = cms.bool(False),
tpScales = tpScales,
MaskBit = cms.int32(0x8000),
overrideFGHF = cms.bool(False),
FG_HF_thresholds = cms.vuint32(17, 255),
inputLUTs = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/inputLUTcoder_physics.dat'),
FGLUTs = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/HBHE_FG_LUT.dat'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

latency = cms.int32(1),
FG_threshold = cms.uint32(12), ## threshold for setting fine grain bit
overrideFGHF = cms.bool(False), ## switch: False = read thresholds from TPParameters (default), True = override with FG_HF_thresholds
FG_HF_thresholds = cms.vuint32(17, 255), ## thresholds for setting fine grain bit
ZS_threshold = cms.uint32(1), ## threshold for setting TP zero suppression

Expand Down