|
21 | 21 |
|
22 | 22 | #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/tkinput_ref.h" |
23 | 23 | #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h" |
| 24 | +#include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h" |
24 | 25 | #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h" |
25 | 26 | #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h" |
26 | 27 | #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h" |
@@ -68,6 +69,7 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { |
68 | 69 | l1ct::Event event_; |
69 | 70 | std::unique_ptr<l1ct::TrackInputEmulator> trackInput_; |
70 | 71 | std::unique_ptr<l1ct::GMTMuonDecoderEmulator> muonInput_; |
| 72 | + std::unique_ptr<l1ct::HgcalClusterDecoderEmulator> hgcalInput_; |
71 | 73 | std::unique_ptr<l1ct::RegionizerEmulator> regionizer_; |
72 | 74 | std::unique_ptr<l1ct::PFAlgoEmulatorBase> l1pfalgo_; |
73 | 75 | std::unique_ptr<l1ct::LinPuppiEmulator> l1pualgo_; |
@@ -110,6 +112,38 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { |
110 | 112 |
|
111 | 113 | void addRawHgcalCluster(l1ct::DetectorSector<ap_uint<256>> &sec, const l1t::PFCluster &c); |
112 | 114 |
|
| 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 | + |
113 | 147 | // fetching outputs |
114 | 148 | std::unique_ptr<l1t::PFCandidateCollection> fetchHadCalo() const; |
115 | 149 | std::unique_ptr<l1t::PFCandidateCollection> fetchEmCalo() const; |
@@ -202,6 +236,13 @@ L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer(const edm::ParameterSet |
202 | 236 | } else if (muInAlgo != "Ideal") |
203 | 237 | throw cms::Exception("Configuration", "Unsupported muonInputConversionAlgo"); |
204 | 238 |
|
| 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 | + |
205 | 246 | const std::string ®algo = iConfig.getParameter<std::string>("regionizerAlgo"); |
206 | 247 | if (regalgo == "Ideal") { |
207 | 248 | regionizer_ = |
@@ -688,49 +729,28 @@ void L1TCorrelatorLayer1Producer::addDecodedMuon(l1ct::DetectorSector<l1ct::MuOb |
688 | 729 | void L1TCorrelatorLayer1Producer::addDecodedHadCalo(l1ct::DetectorSector<l1ct::HadCaloObjEmu> &sec, |
689 | 730 | const l1t::PFCluster &c) { |
690 | 731 | 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 | + } |
700 | 747 | calo.src = &c; |
701 | 748 | sec.obj.push_back(calo); |
702 | 749 | } |
703 | 750 |
|
704 | 751 | void L1TCorrelatorLayer1Producer::addRawHgcalCluster(l1ct::DetectorSector<ap_uint<256>> &sec, const l1t::PFCluster &c) { |
705 | 752 | 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); |
734 | 754 | sec.obj.push_back(cwrd); |
735 | 755 | } |
736 | 756 |
|
|
0 commit comments