Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement second HF min-bias feature bit #24847

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
9 changes: 5 additions & 4 deletions CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
void update(const char* filename, bool appendMSB = false);
void updateXML(const char* filename);
void setLUTGenerationMode(bool gen){ LUTGenerationMode_ = gen; };
void setFGHFthreshold(unsigned int fgthreshold){ FG_HF_threshold_ = fgthreshold; };
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) { allLinear_ = linear; linearLSB_QIE8_ = lsb8; linearLSB_QIE11_ = lsb11; linearLSB_QIE11Overlap_ = lsb11overlap; };
void lookupMSB(const HBHEDataFrame& df, std::vector<bool>& msb) const;
void lookupMSB(const QIE10DataFrame& 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;
bool getMSB(const HcalDetId& id, int adc) const;
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const;
Expand All @@ -83,13 +83,14 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
static const int QIE8_LUT_MSB = 0x400;
static const int QIE11_LUT_MSB0 = 0x400;
static const int QIE11_LUT_MSB1 = 0x800;
static const int QIE10_LUT_MSB = 0x1000;
static const int QIE10_LUT_MSB0 = 0x1000;
static const int QIE10_LUT_MSB1 = 0x2000;

// member variables
const HcalTopology* topo_;
const HcalTimeSlew* delay_;
bool LUTGenerationMode_;
unsigned int FG_HF_threshold_;
std::vector<uint32_t> FG_HF_thresholds_;
int bitToMask_;
int firstHBEta_, lastHBEta_, nHBEta_, maxDepthHB_, sizeHB_;
int firstHEEta_, lastHEEta_, nHEEta_, maxDepthHE_, sizeHE_;
Expand Down
13 changes: 7 additions & 6 deletions CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ HcaluLUTTPGCoder::HcaluLUTTPGCoder() :
topo_{},
delay_{},
LUTGenerationMode_{},
FG_HF_threshold_{},
FG_HF_thresholds_{},
bitToMask_{},
firstHBEta_{},
lastHBEta_{},
Expand Down Expand Up @@ -75,7 +75,7 @@ void HcaluLUTTPGCoder::init(const HcalTopology* top, const HcalTimeSlew* delay)
topo_ = top;
delay_ = delay;
LUTGenerationMode_ = true;
FG_HF_threshold_ = 0;
FG_HF_thresholds_ = {0, 0};
bitToMask_ = 0;
allLinear_ = false;
linearLSB_QIE8_ = 1.;
Expand Down Expand Up @@ -315,7 +315,6 @@ void HcaluLUTTPGCoder::make_cosh_ieta_map(void) {

void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {

HcalCalibrations calibrations;
const HcalLutMetadata *metadata = conditions.getHcalLutMetadata();
assert(metadata !=nullptr);
float nominalgain_ = metadata->getNominalGain();
Expand Down Expand Up @@ -444,7 +443,8 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
if (isMasked) lut[adc] = 0;
else {
lut[adc] = std::min(std::max(0,int((adc2fC(adc) - ped) * gain * rcalib / lsb_ / cosh_ieta_[cell.ietaAbs()])), MASK);
if(adc>FG_HF_threshold_) lut[adc] |= QIE10_LUT_MSB;
if(adc>FG_HF_thresholds_[0]) lut[adc] |= QIE10_LUT_MSB0;
if(adc>FG_HF_thresholds_[1]) lut[adc] |= QIE10_LUT_MSB1;
}
}
}
Expand Down Expand Up @@ -515,12 +515,13 @@ bool HcaluLUTTPGCoder::getMSB(const HcalDetId& id, int adc) const{
return (lut.at(adc) & QIE8_LUT_MSB);
}

void HcaluLUTTPGCoder::lookupMSB(const QIE10DataFrame& df, std::vector<bool>& msb) const{
void HcaluLUTTPGCoder::lookupMSB(const QIE10DataFrame& df, std::vector<std::bitset<2>>& msb) const{
msb.resize(df.samples());
int lutId = getLUTId(HcalDetId(df.id()));
const Lut& lut = inputLUT_.at(lutId);
for (int i = 0; i < df.samples(); ++i) {
msb[i] = lut.at(df[i].adc()) & QIE10_LUT_MSB;
msb[i][0] = lut.at(df[i].adc()) & QIE10_LUT_MSB0;
msb[i][1] = lut.at(df[i].adc()) & QIE10_LUT_MSB1;
}
}

Expand Down
6 changes: 3 additions & 3 deletions CalibCalorimetry/HcalTPGEventSetup/src/HcalTPGCoderULUT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class HcalTPGCoderULUT : public edm::ESProducer {
bool read_FGLut_, read_Ascii_,read_XML_,LUTGenerationMode_,linearLUTs_;
double linearLSB_QIE8_, linearLSB_QIE11Overlap_, linearLSB_QIE11_;
int maskBit_;
unsigned int FG_HF_threshold_;
std::vector<uint32_t> FG_HF_thresholds_;
edm::FileInPath fgfile_,ifilename_;
};

Expand Down Expand Up @@ -92,7 +92,7 @@ HcalTPGCoderULUT::HcalTPGCoderULUT(const edm::ParameterSet& iConfig)
linearLSB_QIE11_ = scales.getParameter<double>("LSBQIE11");
linearLSB_QIE11Overlap_ = scales.getParameter<double>("LSBQIE11Overlap");
maskBit_ = iConfig.getParameter<int>("MaskBit");
FG_HF_threshold_ = iConfig.getParameter<uint32_t>("FG_HF_threshold");
FG_HF_thresholds_ = iConfig.getParameter<std::vector<uint32_t> >("FG_HF_thresholds");
} else {
ifilename_=iConfig.getParameter<edm::FileInPath>("inputLUTs");
}
Expand All @@ -117,7 +117,7 @@ void HcalTPGCoderULUT::buildCoder(const HcalTopology* topo, const edm::ESHandle<
theCoder->setAllLinear(linearLUTs_, linearLSB_QIE8_, linearLSB_QIE11_, linearLSB_QIE11Overlap_);
theCoder->setLUTGenerationMode(LUTGenerationMode_);
theCoder->setMaskBit(maskBit_);
theCoder->setFGHFthreshold(FG_HF_threshold_);
theCoder->setFGHFthresholds(FG_HF_thresholds_);
}
}

Expand Down
4 changes: 1 addition & 3 deletions CaloOnlineTools/HcalOnlineDb/test/template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")
process = cms.Process("TEST", eras.Run2_2018)

process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.categories.append('LUT')
Expand All @@ -20,8 +20,6 @@

process.HcalTPGCoderULUT.LUTGenerationMode = cms.bool(True)

process.CaloTPGTranscoder.HFTPScaleShift.NCT=2;

process.HcalTPGCoderULUT.DumpL1TriggerObjects = cms.bool(True)
process.HcalTPGCoderULUT.TagName = cms.string('__LUTtag__')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IntegerCaloSamples;
class HcalTriggerPrimitiveAlgo {
public:
HcalTriggerPrimitiveAlgo(bool pf, const std::vector<double>& w, int latency,
uint32_t FG_threshold, uint32_t FG_HF_threshold, uint32_t ZS_threshold,
uint32_t FG_threshold, const std::vector<uint32_t>& FG_HF_thresholds, uint32_t ZS_threshold,
int numberOfSamples, int numberOfPresamples,
int numberOfSamplesHF, int numberOfPresamplesHF, bool useTDCInMinBiasBits,
uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0);
Expand Down Expand Up @@ -118,7 +118,7 @@ class HcalTriggerPrimitiveAlgo {
std::vector<double> weights_;
int latency_;
uint32_t FG_threshold_;
uint32_t FG_HF_threshold_;
std::vector<uint32_t> FG_HF_thresholds_;
uint32_t ZS_threshold_;
int ZS_threshold_I_;
int numberOfSamples_;
Expand Down Expand Up @@ -158,7 +158,7 @@ class HcalTriggerPrimitiveAlgo {
IntegerCaloSamples samples;
QIE10DataFrame digi;
std::vector<bool> validity;
std::vector<bool> fgbit;
std::vector<std::bitset<2>> fgbits;
std::vector<bool> passTDC;
};
typedef std::map<HcalTrigTowerDetId, std::map<uint32_t, std::array<HFUpgradeDetails, 4>>> HFUpgradeDetailMap;
Expand Down
18 changes: 11 additions & 7 deletions SimCalorimetry/HcalTrigPrimAlgos/src/HcalTriggerPrimitiveAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
using namespace std;

HcalTriggerPrimitiveAlgo::HcalTriggerPrimitiveAlgo( bool pf, const std::vector<double>& w, int latency,
uint32_t FG_threshold, uint32_t FG_HF_threshold, uint32_t ZS_threshold,
uint32_t FG_threshold, const std::vector<uint32_t>& FG_HF_thresholds, uint32_t ZS_threshold,
int numberOfSamples, int numberOfPresamples,
int numberOfSamplesHF, int numberOfPresamplesHF, bool useTDCInMinBiasBits,
uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold
)
: incoder_(nullptr), outcoder_(nullptr),
theThreshold(0), peakfind_(pf), weights_(w), latency_(latency),
FG_threshold_(FG_threshold), FG_HF_threshold_(FG_HF_threshold), ZS_threshold_(ZS_threshold),
FG_threshold_(FG_threshold), FG_HF_thresholds_(FG_HF_thresholds), ZS_threshold_(ZS_threshold),
numberOfSamples_(numberOfSamples),
numberOfPresamples_(numberOfPresamples),
numberOfSamplesHF_(numberOfSamplesHF),
Expand Down Expand Up @@ -228,7 +228,7 @@ HcalTriggerPrimitiveAlgo::addSignal(const QIE10DataFrame& frame)
detail.digi = frame;
detail.validity.resize(nsamples);
detail.passTDC.resize(nsamples);
incoder_->lookupMSB(frame, detail.fgbit);
incoder_->lookupMSB(frame, detail.fgbits);
for (int idx = 0; idx < nsamples; ++idx){
detail.validity[idx] = validChannel(frame, idx);
detail.passTDC[idx] = passTDC(frame, idx);
Expand Down Expand Up @@ -522,7 +522,7 @@ void HcalTriggerPrimitiveAlgo::analyzeHF2016(
uint32_t ADCShort = details.ShortDigi[ibin].adc();

if (details.LongDigi.id().ietaAbs() >= FIRST_FINEGRAIN_TOWER) {
finegrain[ibin][1] = (ADCLong > FG_HF_threshold_ || ADCShort > FG_HF_threshold_);
finegrain[ibin][1] = (ADCLong > FG_HF_thresholds_[0] || ADCShort > FG_HF_thresholds_[0]);

if (embit != nullptr)
finegrain[ibin][0] = embit->fineGrainbit(details.ShortDigi, details.LongDigi, ibin);
Expand Down Expand Up @@ -645,11 +645,15 @@ void HcalTriggerPrimitiveAlgo::analyzeHFQIE10(
for (const auto& detail: details) {
if (idx < int(detail.digi.size()) and detail.validity[idx] and HcalDetId(detail.digi.id()).ietaAbs() >= FIRST_FINEGRAIN_TOWER) {
if(useTDCInMinBiasBits_ && !detail.passTDC[idx]) continue;
finegrain[ibin][1] = finegrain[ibin][1] or detail.fgbit[idx];
finegrain[ibin][1] = finegrain[ibin][1] or detail.fgbits[idx][0];
// what is commonly called the "second" HF min-bias bit is
// actually the 0-th bit, which can also be used instead for the EM bit
// (called finegrain[ibin][0] below) in non-HI running
finegrain[ibin][0] = finegrain[ibin][0] or detail.fgbits[idx][1];
}
}

if (embit != nullptr) {
// the EM bit is only used if the "second" FG bit is disabled
if (embit != nullptr and FG_HF_thresholds_.at(1) != 255) {
finegrain[ibin][0] = embit->fineGrainbit(
details[1].digi, details[3].digi,
details[0].digi, details[2].digi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Modifier_run2_HCAL_2018_cff import run2_HCAL_2018
from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018

from SimCalorimetry.HcalTrigPrimProducers.hcaltpdigi_cfi import *
from CalibCalorimetry.CaloTPG.CaloTPGTranscoder_cfi import *
Expand All @@ -16,7 +17,7 @@
linearLUTs = cms.bool(False),
tpScales = tpScales,
MaskBit = cms.int32(0x8000),
FG_HF_threshold = cms.uint32(17),
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'),
RCalibFile = cms.FileInPath('CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat')
Expand All @@ -26,3 +27,5 @@

run2_HCAL_2018.toModify(CaloTPGTranscoder, linearLUTs=cms.bool(True))
run2_HCAL_2018.toModify(HcalTPGCoderULUT, linearLUTs=cms.bool(True))
pp_on_AA_2018.toModify(CaloTPGTranscoder, FG_HF_thresholds = cms.vuint32(15, 19))
pp_on_AA_2018.toModify(HcalTPGCoderULUT, FG_HF_thresholds = cms.vuint32(15, 19))
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
weights = cms.vdouble(1.0, 1.0), ##hardware algo
latency = cms.int32(1),
FG_threshold = cms.uint32(12), ## threshold for setting fine grain bit
FG_HF_threshold = cms.uint32(17), ## threshold for setting fine grain bit
FG_HF_thresholds = cms.vuint32(17, 255), ## thresholds for setting fine grain bit
ZS_threshold = cms.uint32(1), ## threshold for setting TP zero suppression
numberOfSamples = cms.int32(4),
numberOfPresamples = cms.int32(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ HcalTrigPrimDigiProducer::HcalTrigPrimDigiProducer(const edm::ParameterSet& ps)
ps.getParameter<std::vector<double> >("weights"),
ps.getParameter<int>("latency"),
ps.getParameter<uint32_t>("FG_threshold"),
ps.getParameter<uint32_t>("FG_HF_threshold"),
ps.getParameter<std::vector<uint32_t> >("FG_HF_thresholds"),
ps.getParameter<uint32_t>("ZS_threshold"),
ps.getParameter<int>("numberOfSamples"),
ps.getParameter<int>("numberOfPresamples"),
Expand Down