diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h index aa99831c369ba..5fd80ba3954d7 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h @@ -3,10 +3,18 @@ #include "DataFormats/L1TParticleFlow/interface/layer1_emulator.h" +namespace edm { + class ParameterSet; +} + namespace l1ct { class HgcalClusterDecoderEmulator { + bool slim_; + public: - HgcalClusterDecoderEmulator(){}; + HgcalClusterDecoderEmulator(bool slim = false) : slim_{slim} {}; + HgcalClusterDecoderEmulator(const edm::ParameterSet &pset); + ~HgcalClusterDecoderEmulator(); l1ct::HadCaloObjEmu decode(const ap_uint<256> &in) const; }; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 2776584a7c60c..6d3779404c679 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -21,6 +21,7 @@ #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/tkinput_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h" +#include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h" @@ -68,6 +69,7 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { l1ct::Event event_; std::unique_ptr trackInput_; std::unique_ptr muonInput_; + std::unique_ptr hgcalInput_; std::unique_ptr regionizer_; std::unique_ptr l1pfalgo_; std::unique_ptr l1pualgo_; @@ -110,6 +112,38 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { void addRawHgcalCluster(l1ct::DetectorSector> &sec, const l1t::PFCluster &c); + template + void rawHgcalClusterEncode(ap_uint<256> &cwrd, const l1ct::DetectorSector &sec, const l1t::PFCluster &c) const { + cwrd = 0; + ap_ufixed<14, 12, AP_RND_CONV, AP_SAT> w_pt = c.pt(); + ap_uint<14> w_empt = round(c.emEt() / 0.25); + constexpr float ETAPHI_LSB = M_PI / 720; + ap_int<9> w_eta = round(sec.region.localEta(c.eta()) / ETAPHI_LSB); + ap_int<9> w_phi = round(sec.region.localPhi(c.phi()) / ETAPHI_LSB); + ap_uint<10> w_qual = c.hwQual(); + // NOTE: this is an arbitrary choice to keep the rounding consistent with the "addDecodedHadCalo" one + ap_uint<13> w_srrtot = round(c.sigmaRR() * l1ct::Scales::SRRTOT_SCALE / l1ct::Scales::SRRTOT_LSB); + ap_uint<12> w_meanz = round(c.absZBarycenter()); + // NOTE: the calibration can actually make hoe become negative....we add a small protection for now + // We use ap_ufixed to handle saturation and rounding + ap_ufixed<10, 5, AP_RND_CONV, AP_SAT> w_hoe = c.hOverE(); + + cwrd(13, 0) = w_pt.range(); + cwrd(27, 14) = w_empt; + cwrd(72, 64) = w_eta; + cwrd(81, 73) = w_phi; + cwrd(115, 106) = w_qual; + + // FIXME: we add the variables use by composite-ID. The definitin will have to be reviewd once the + // hgc format is better defined. For now we use + // hwMeanZ = word 1 bits 30-19 + // hwSrrTot = word 3 bits 21 - 9 + // hoe = word 1 bits 63-52 (currently spare in the interface) + cwrd(213, 201) = w_srrtot; + cwrd(94, 83) = w_meanz; + cwrd(127, 116) = w_hoe.range(); + } + // fetching outputs std::unique_ptr fetchHadCalo() const; std::unique_ptr fetchEmCalo() const; @@ -202,6 +236,13 @@ L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer(const edm::ParameterSet } else if (muInAlgo != "Ideal") throw cms::Exception("Configuration", "Unsupported muonInputConversionAlgo"); + const std::string &hgcalInAlgo = iConfig.getParameter("hgcalInputConversionAlgo"); + if (hgcalInAlgo == "Emulator") { + hgcalInput_ = std::make_unique( + iConfig.getParameter("hgcalInputConversionParameters")); + } else if (hgcalInAlgo != "Ideal") + throw cms::Exception("Configuration", "Unsupported hgcalInputConversionAlgo"); + const std::string ®algo = iConfig.getParameter("regionizerAlgo"); if (regalgo == "Ideal") { regionizer_ = @@ -688,49 +729,28 @@ void L1TCorrelatorLayer1Producer::addDecodedMuon(l1ct::DetectorSector &sec, const l1t::PFCluster &c) { l1ct::HadCaloObjEmu calo; - calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt()); - calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) - - sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value - calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi())); - calo.hwEmPt = l1ct::Scales::makePtFromFloat(c.emEt()); - calo.hwEmID = c.hwEmID(); - calo.hwSrrTot = l1ct::Scales::makeSrrTot(c.sigmaRR()); - calo.hwMeanZ = c.absZBarycenter() < 320. ? l1ct::meanz_t(0) : l1ct::Scales::makeMeanZ(c.absZBarycenter()); - calo.hwHoe = l1ct::Scales::makeHoe(c.hOverE()); + ap_uint<256> word = 0; + rawHgcalClusterEncode(word, sec, c); + if (hgcalInput_) { + calo = hgcalInput_->decode(word); + } else { + calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt()); + calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) - + sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value + calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi())); + calo.hwEmPt = l1ct::Scales::makePtFromFloat(c.emEt()); + calo.hwEmID = c.hwEmID(); + calo.hwSrrTot = l1ct::Scales::makeSrrTot(c.sigmaRR()); + calo.hwMeanZ = c.absZBarycenter() < 320. ? l1ct::meanz_t(0) : l1ct::Scales::makeMeanZ(c.absZBarycenter()); + calo.hwHoe = l1ct::Scales::makeHoe(c.hOverE()); + } calo.src = &c; sec.obj.push_back(calo); } void L1TCorrelatorLayer1Producer::addRawHgcalCluster(l1ct::DetectorSector> &sec, const l1t::PFCluster &c) { ap_uint<256> cwrd = 0; - ap_ufixed<14, 12, AP_RND_CONV, AP_SAT> w_pt = c.pt(); - ap_uint<14> w_empt = round(c.emEt() / 0.25); - constexpr float ETAPHI_LSB = M_PI / 720; - ap_int<9> w_eta = round(sec.region.localEta(c.eta()) / ETAPHI_LSB); - ap_int<9> w_phi = round(sec.region.localPhi(c.phi()) / ETAPHI_LSB); - ap_uint<10> w_qual = c.hwQual(); - // NOTE: this is an arbitrary choice to keep the rounding consistent with the "addDecodedHadCalo" one - ap_uint<13> w_srrtot = round(c.sigmaRR() * l1ct::Scales::SRRTOT_SCALE / l1ct::Scales::SRRTOT_LSB); - ap_uint<12> w_meanz = round(c.absZBarycenter()); - // NOTE: the calibration can actually make hoe become negative....we add a small protection for now - // We use ap_ufixed to handle saturation and rounding - ap_ufixed<10, 5, AP_RND_CONV, AP_SAT> w_hoe = c.hOverE(); - - cwrd(13, 0) = w_pt.range(); - cwrd(27, 14) = w_empt; - cwrd(72, 64) = w_eta; - cwrd(81, 73) = w_phi; - cwrd(115, 106) = w_qual; - - // FIXME: we add the variables use by composite-ID. The definitin will have to be reviewd once the - // hgc format is better defined. For now we use - // hwMeanZ = word 1 bits 30-19 - // hwSrrTot = word 3 bits 21 - 9 - // hoe = word 1 bits 63-52 (currently spare in the interface) - cwrd(213, 201) = w_srrtot; - cwrd(94, 83) = w_meanz; - cwrd(127, 116) = w_hoe.range(); - + rawHgcalClusterEncode(cwrd, sec, c); sec.obj.push_back(cwrd); } diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py index 15e62ff10d5e4..c4665a0207076 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py @@ -49,6 +49,7 @@ ), muonInputConversionAlgo = cms.string("Emulator"), muonInputConversionParameters = muonInputConversionParameters.clone(), + hgcalInputConversionAlgo = cms.string("Ideal"), regionizerAlgo = cms.string("Ideal"), pfAlgo = cms.string("PFAlgo3"), puAlgo = cms.string("LinearizedPuppi"), @@ -196,6 +197,10 @@ ), muonInputConversionAlgo = cms.string("Emulator"), muonInputConversionParameters = muonInputConversionParameters.clone(), + hgcalInputConversionAlgo = cms.string("Emulator"), + hgcalInputConversionParameters = cms.PSet( + slim = cms.bool(False) + ), regionizerAlgo = cms.string("Multififo"), regionizerAlgoParameters = cms.PSet( useAlsoVtxCoords = cms.bool(True), @@ -318,6 +323,10 @@ trkPtCut = cms.double(2.0), muonInputConversionAlgo = cms.string("Emulator"), muonInputConversionParameters = muonInputConversionParameters.clone(), + hgcalInputConversionAlgo = cms.string("Emulator"), + hgcalInputConversionParameters = cms.PSet( + slim = cms.bool(True) + ), regionizerAlgo = cms.string("Multififo"), regionizerAlgoParameters = cms.PSet( useAlsoVtxCoords = cms.bool(True), @@ -418,6 +427,7 @@ trkPtCut = cms.double(2.0), muonInputConversionAlgo = cms.string("Ideal"), muonInputConversionParameters = muonInputConversionParameters.clone(), + hgcalInputConversionAlgo = cms.string("Ideal"), regionizerAlgo = cms.string("Ideal"), pfAlgo = cms.string("PFAlgoDummy"), puAlgo = cms.string("LinearizedPuppi"), diff --git a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp index 4851eccc06b71..e4713944edf02 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp @@ -1,5 +1,12 @@ #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h" +#ifdef CMSSW_GIT_HASH +#include "FWCore/ParameterSet/interface/ParameterSet.h" +l1ct::HgcalClusterDecoderEmulator::HgcalClusterDecoderEmulator(const edm::ParameterSet &pset) + : slim_(pset.getParameter("slim")) {} + +#endif + l1ct::HgcalClusterDecoderEmulator::~HgcalClusterDecoderEmulator() {} l1ct::HadCaloObjEmu l1ct::HgcalClusterDecoderEmulator::decode(const ap_uint<256> &in) const { @@ -20,10 +27,11 @@ l1ct::HadCaloObjEmu l1ct::HgcalClusterDecoderEmulator::decode(const ap_uint<256> out.hwPhi = w_phi; // relative to the region center, at calo out.hwEmPt = w_empt * l1ct::pt_t(l1ct::Scales::INTPT_LSB); out.hwEmID = w_qual; - - out.hwSrrTot = w_srrtot * l1ct::srrtot_t(l1ct::Scales::SRRTOT_LSB); - out.hwMeanZ = (w_meanz == 0) ? l1ct::meanz_t(0) : l1ct::meanz_t(w_meanz - l1ct::meanz_t(l1ct::Scales::MEANZ_OFFSET)); - out.hwHoe = w_hoe * l1ct::hoe_t(l1ct::Scales::HOE_LSB); - + if (!slim_) { + out.hwSrrTot = w_srrtot * l1ct::srrtot_t(l1ct::Scales::SRRTOT_LSB); + out.hwMeanZ = + (w_meanz == 0) ? l1ct::meanz_t(0) : l1ct::meanz_t(w_meanz - l1ct::meanz_t(l1ct::Scales::MEANZ_OFFSET)); + out.hwHoe = w_hoe * l1ct::hoe_t(l1ct::Scales::HOE_LSB); + } return out; }