Skip to content

Commit d536c12

Browse files
cerminargpetruc
authored andcommitted
can now use configurable emulator to decode HGC objects (slim or not)
1 parent f003afc commit d536c12

File tree

4 files changed

+89
-43
lines changed

4 files changed

+89
-43
lines changed

L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33

44
#include "DataFormats/L1TParticleFlow/interface/layer1_emulator.h"
55

6+
namespace edm {
7+
class ParameterSet;
8+
}
9+
610
namespace l1ct {
711
class HgcalClusterDecoderEmulator {
12+
bool slim_;
13+
814
public:
9-
HgcalClusterDecoderEmulator(){};
15+
HgcalClusterDecoderEmulator(bool slim = false) : slim_{slim} {};
16+
HgcalClusterDecoderEmulator(const edm::ParameterSet &pset);
17+
1018
~HgcalClusterDecoderEmulator();
1119
l1ct::HadCaloObjEmu decode(const ap_uint<256> &in) const;
1220
};

L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/tkinput_ref.h"
2323
#include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h"
24+
#include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h"
2425
#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h"
2526
#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h"
2627
#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h"
@@ -68,6 +69,7 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> {
6869
l1ct::Event event_;
6970
std::unique_ptr<l1ct::TrackInputEmulator> trackInput_;
7071
std::unique_ptr<l1ct::GMTMuonDecoderEmulator> muonInput_;
72+
std::unique_ptr<l1ct::HgcalClusterDecoderEmulator> hgcalInput_;
7173
std::unique_ptr<l1ct::RegionizerEmulator> regionizer_;
7274
std::unique_ptr<l1ct::PFAlgoEmulatorBase> l1pfalgo_;
7375
std::unique_ptr<l1ct::LinPuppiEmulator> l1pualgo_;
@@ -110,6 +112,38 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> {
110112

111113
void addRawHgcalCluster(l1ct::DetectorSector<ap_uint<256>> &sec, const l1t::PFCluster &c);
112114

115+
template <class T>
116+
void rawHgcalClusterEncode(ap_uint<256> &cwrd, const l1ct::DetectorSector<T> &sec, const l1t::PFCluster &c) const {
117+
cwrd = 0;
118+
ap_ufixed<14, 12, AP_RND_CONV, AP_SAT> w_pt = c.pt();
119+
ap_uint<14> w_empt = round(c.emEt() / 0.25);
120+
constexpr float ETAPHI_LSB = M_PI / 720;
121+
ap_int<9> w_eta = round(sec.region.localEta(c.eta()) / ETAPHI_LSB);
122+
ap_int<9> w_phi = round(sec.region.localPhi(c.phi()) / ETAPHI_LSB);
123+
ap_uint<10> w_qual = c.hwQual();
124+
// NOTE: this is an arbitrary choice to keep the rounding consistent with the "addDecodedHadCalo" one
125+
ap_uint<13> w_srrtot = round(c.sigmaRR() * l1ct::Scales::SRRTOT_SCALE / l1ct::Scales::SRRTOT_LSB);
126+
ap_uint<12> w_meanz = round(c.absZBarycenter());
127+
// NOTE: the calibration can actually make hoe become negative....we add a small protection for now
128+
// We use ap_ufixed to handle saturation and rounding
129+
ap_ufixed<10, 5, AP_RND_CONV, AP_SAT> w_hoe = c.hOverE();
130+
131+
cwrd(13, 0) = w_pt.range();
132+
cwrd(27, 14) = w_empt;
133+
cwrd(72, 64) = w_eta;
134+
cwrd(81, 73) = w_phi;
135+
cwrd(115, 106) = w_qual;
136+
137+
// FIXME: we add the variables use by composite-ID. The definitin will have to be reviewd once the
138+
// hgc format is better defined. For now we use
139+
// hwMeanZ = word 1 bits 30-19
140+
// hwSrrTot = word 3 bits 21 - 9
141+
// hoe = word 1 bits 63-52 (currently spare in the interface)
142+
cwrd(213, 201) = w_srrtot;
143+
cwrd(94, 83) = w_meanz;
144+
cwrd(127, 116) = w_hoe.range();
145+
}
146+
113147
// fetching outputs
114148
std::unique_ptr<l1t::PFCandidateCollection> fetchHadCalo() const;
115149
std::unique_ptr<l1t::PFCandidateCollection> fetchEmCalo() const;
@@ -202,6 +236,13 @@ L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer(const edm::ParameterSet
202236
} else if (muInAlgo != "Ideal")
203237
throw cms::Exception("Configuration", "Unsupported muonInputConversionAlgo");
204238

239+
const std::string &hgcalInAlgo = iConfig.getParameter<std::string>("hgcalInputConversionAlgo");
240+
if (hgcalInAlgo == "Emulator") {
241+
hgcalInput_ = std::make_unique<l1ct::HgcalClusterDecoderEmulator>(
242+
iConfig.getParameter<edm::ParameterSet>("hgcalInputConversionParameters"));
243+
} else if (hgcalInAlgo != "Ideal")
244+
throw cms::Exception("Configuration", "Unsupported hgcalInputConversionAlgo");
245+
205246
const std::string &regalgo = iConfig.getParameter<std::string>("regionizerAlgo");
206247
if (regalgo == "Ideal") {
207248
regionizer_ =
@@ -688,49 +729,28 @@ void L1TCorrelatorLayer1Producer::addDecodedMuon(l1ct::DetectorSector<l1ct::MuOb
688729
void L1TCorrelatorLayer1Producer::addDecodedHadCalo(l1ct::DetectorSector<l1ct::HadCaloObjEmu> &sec,
689730
const l1t::PFCluster &c) {
690731
l1ct::HadCaloObjEmu calo;
691-
calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt());
692-
calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) -
693-
sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
694-
calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi()));
695-
calo.hwEmPt = l1ct::Scales::makePtFromFloat(c.emEt());
696-
calo.hwEmID = c.hwEmID();
697-
calo.hwSrrTot = l1ct::Scales::makeSrrTot(c.sigmaRR());
698-
calo.hwMeanZ = c.absZBarycenter() < 320. ? l1ct::meanz_t(0) : l1ct::Scales::makeMeanZ(c.absZBarycenter());
699-
calo.hwHoe = l1ct::Scales::makeHoe(c.hOverE());
732+
ap_uint<256> word = 0;
733+
rawHgcalClusterEncode(word, sec, c);
734+
if (hgcalInput_) {
735+
calo = hgcalInput_->decode(word);
736+
} else {
737+
calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt());
738+
calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) -
739+
sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
740+
calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi()));
741+
calo.hwEmPt = l1ct::Scales::makePtFromFloat(c.emEt());
742+
calo.hwEmID = c.hwEmID();
743+
calo.hwSrrTot = l1ct::Scales::makeSrrTot(c.sigmaRR());
744+
calo.hwMeanZ = c.absZBarycenter() < 320. ? l1ct::meanz_t(0) : l1ct::Scales::makeMeanZ(c.absZBarycenter());
745+
calo.hwHoe = l1ct::Scales::makeHoe(c.hOverE());
746+
}
700747
calo.src = &c;
701748
sec.obj.push_back(calo);
702749
}
703750

704751
void L1TCorrelatorLayer1Producer::addRawHgcalCluster(l1ct::DetectorSector<ap_uint<256>> &sec, const l1t::PFCluster &c) {
705752
ap_uint<256> cwrd = 0;
706-
ap_ufixed<14, 12, AP_RND_CONV, AP_SAT> w_pt = c.pt();
707-
ap_uint<14> w_empt = round(c.emEt() / 0.25);
708-
constexpr float ETAPHI_LSB = M_PI / 720;
709-
ap_int<9> w_eta = round(sec.region.localEta(c.eta()) / ETAPHI_LSB);
710-
ap_int<9> w_phi = round(sec.region.localPhi(c.phi()) / ETAPHI_LSB);
711-
ap_uint<10> w_qual = c.hwQual();
712-
// NOTE: this is an arbitrary choice to keep the rounding consistent with the "addDecodedHadCalo" one
713-
ap_uint<13> w_srrtot = round(c.sigmaRR() * l1ct::Scales::SRRTOT_SCALE / l1ct::Scales::SRRTOT_LSB);
714-
ap_uint<12> w_meanz = round(c.absZBarycenter());
715-
// NOTE: the calibration can actually make hoe become negative....we add a small protection for now
716-
// We use ap_ufixed to handle saturation and rounding
717-
ap_ufixed<10, 5, AP_RND_CONV, AP_SAT> w_hoe = c.hOverE();
718-
719-
cwrd(13, 0) = w_pt.range();
720-
cwrd(27, 14) = w_empt;
721-
cwrd(72, 64) = w_eta;
722-
cwrd(81, 73) = w_phi;
723-
cwrd(115, 106) = w_qual;
724-
725-
// FIXME: we add the variables use by composite-ID. The definitin will have to be reviewd once the
726-
// hgc format is better defined. For now we use
727-
// hwMeanZ = word 1 bits 30-19
728-
// hwSrrTot = word 3 bits 21 - 9
729-
// hoe = word 1 bits 63-52 (currently spare in the interface)
730-
cwrd(213, 201) = w_srrtot;
731-
cwrd(94, 83) = w_meanz;
732-
cwrd(127, 116) = w_hoe.range();
733-
753+
rawHgcalClusterEncode(cwrd, sec, c);
734754
sec.obj.push_back(cwrd);
735755
}
736756

L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
),
5050
muonInputConversionAlgo = cms.string("Emulator"),
5151
muonInputConversionParameters = muonInputConversionParameters.clone(),
52+
hgcalInputConversionAlgo = cms.string("Ideal"),
5253
regionizerAlgo = cms.string("Ideal"),
5354
pfAlgo = cms.string("PFAlgo3"),
5455
puAlgo = cms.string("LinearizedPuppi"),
@@ -196,6 +197,10 @@
196197
),
197198
muonInputConversionAlgo = cms.string("Emulator"),
198199
muonInputConversionParameters = muonInputConversionParameters.clone(),
200+
hgcalInputConversionAlgo = cms.string("Emulator"),
201+
hgcalInputConversionParameters = cms.PSet(
202+
slim = cms.bool(False)
203+
),
199204
regionizerAlgo = cms.string("Multififo"),
200205
regionizerAlgoParameters = cms.PSet(
201206
useAlsoVtxCoords = cms.bool(True),
@@ -318,6 +323,10 @@
318323
trkPtCut = cms.double(2.0),
319324
muonInputConversionAlgo = cms.string("Emulator"),
320325
muonInputConversionParameters = muonInputConversionParameters.clone(),
326+
hgcalInputConversionAlgo = cms.string("Emulator"),
327+
hgcalInputConversionParameters = cms.PSet(
328+
slim = cms.bool(True)
329+
),
321330
regionizerAlgo = cms.string("Multififo"),
322331
regionizerAlgoParameters = cms.PSet(
323332
useAlsoVtxCoords = cms.bool(True),
@@ -418,6 +427,7 @@
418427
trkPtCut = cms.double(2.0),
419428
muonInputConversionAlgo = cms.string("Ideal"),
420429
muonInputConversionParameters = muonInputConversionParameters.clone(),
430+
hgcalInputConversionAlgo = cms.string("Ideal"),
421431
regionizerAlgo = cms.string("Ideal"),
422432
pfAlgo = cms.string("PFAlgoDummy"),
423433
puAlgo = cms.string("LinearizedPuppi"),

L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h"
22

3+
#ifdef CMSSW_GIT_HASH
4+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
5+
l1ct::HgcalClusterDecoderEmulator::HgcalClusterDecoderEmulator(const edm::ParameterSet &pset)
6+
: slim_(pset.getParameter<bool>("slim")) {}
7+
8+
#endif
9+
310
l1ct::HgcalClusterDecoderEmulator::~HgcalClusterDecoderEmulator() {}
411

512
l1ct::HadCaloObjEmu l1ct::HgcalClusterDecoderEmulator::decode(const ap_uint<256> &in) const {
@@ -20,10 +27,11 @@ l1ct::HadCaloObjEmu l1ct::HgcalClusterDecoderEmulator::decode(const ap_uint<256>
2027
out.hwPhi = w_phi; // relative to the region center, at calo
2128
out.hwEmPt = w_empt * l1ct::pt_t(l1ct::Scales::INTPT_LSB);
2229
out.hwEmID = w_qual;
23-
24-
out.hwSrrTot = w_srrtot * l1ct::srrtot_t(l1ct::Scales::SRRTOT_LSB);
25-
out.hwMeanZ = (w_meanz == 0) ? l1ct::meanz_t(0) : l1ct::meanz_t(w_meanz - l1ct::meanz_t(l1ct::Scales::MEANZ_OFFSET));
26-
out.hwHoe = w_hoe * l1ct::hoe_t(l1ct::Scales::HOE_LSB);
27-
30+
if (!slim_) {
31+
out.hwSrrTot = w_srrtot * l1ct::srrtot_t(l1ct::Scales::SRRTOT_LSB);
32+
out.hwMeanZ =
33+
(w_meanz == 0) ? l1ct::meanz_t(0) : l1ct::meanz_t(w_meanz - l1ct::meanz_t(l1ct::Scales::MEANZ_OFFSET));
34+
out.hwHoe = w_hoe * l1ct::hoe_t(l1ct::Scales::HOE_LSB);
35+
}
2836
return out;
2937
}

0 commit comments

Comments
 (0)