diff --git a/DataFormats/L1TParticleFlow/interface/PFJet.h b/DataFormats/L1TParticleFlow/interface/PFJet.h index e1cfc282659c0..5dd73fdc0bdec 100644 --- a/DataFormats/L1TParticleFlow/interface/PFJet.h +++ b/DataFormats/L1TParticleFlow/interface/PFJet.h @@ -5,6 +5,8 @@ #include "DataFormats/L1Trigger/interface/L1Candidate.h" #include "DataFormats/L1TParticleFlow/interface/PFCandidate.h" #include "DataFormats/Common/interface/Ptr.h" +#include "DataFormats/L1TParticleFlow/interface/jets.h" +#include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h" namespace l1t { @@ -38,13 +40,24 @@ namespace l1t { edm::Ptr daughterPtr(size_type i) const { return constituents_[i]; } // Get and set the encodedJet_ bits. The Jet is encoded in 128 bits as a 2-element array of uint64_t - std::array encodedJet() { return encodedJet_; } - void setEncodedJet(std::array jet) { encodedJet_ = jet; } + // We store encodings both for Correlator internal usage and for Global Trigger + enum class HWEncoding { CT, GT }; + typedef std::array PackedJet; + const PackedJet& encodedJet(const HWEncoding encoding = HWEncoding::GT) const { + return encodedJet_[static_cast(encoding)]; + } + void setEncodedJet(const HWEncoding encoding, const PackedJet jet) { + encodedJet_[static_cast(encoding)] = jet; + } + + // Accessors to HW objects with ap_* types from encoded words + l1gt::Jet getHWJetGT() const { return l1gt::Jet::unpack(encodedJet(HWEncoding::GT)); } + l1ct::Jet getHWJetCT() const { return l1ct::Jet::unpack(encodedJet(HWEncoding::CT)); } private: float rawPt_; Constituents constituents_; - std::array encodedJet_ = {{0, 0}}; + std::array encodedJet_ = {{{{0, 0}}, {{0, 0}}}}; }; typedef std::vector PFJetCollection; diff --git a/DataFormats/L1TParticleFlow/interface/sums.h b/DataFormats/L1TParticleFlow/interface/sums.h index 195566f61afbe..b91aeec3b93d6 100644 --- a/DataFormats/L1TParticleFlow/interface/sums.h +++ b/DataFormats/L1TParticleFlow/interface/sums.h @@ -52,7 +52,7 @@ namespace l1ct { sum.valid = (hwPt != 0) || (hwSumPt != 0); sum.vector_pt = CTtoGT_pt(hwPt); sum.vector_phi = CTtoGT_phi(hwPhi); - sum.scalar_pt = CTtoGT_phi(hwSumPt); + sum.scalar_pt = CTtoGT_pt(hwSumPt); return sum; } }; diff --git a/DataFormats/L1TParticleFlow/src/classes_def.xml b/DataFormats/L1TParticleFlow/src/classes_def.xml index 5f90ab44bb63d..eaf2e1bff560b 100644 --- a/DataFormats/L1TParticleFlow/src/classes_def.xml +++ b/DataFormats/L1TParticleFlow/src/classes_def.xml @@ -33,7 +33,8 @@ - + + diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1MHtPFProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1MHtPFProducer.cc index 741b7a84e550c..1a970da6e8ad0 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1MHtPFProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1MHtPFProducer.cc @@ -65,7 +65,7 @@ void L1MhtPfProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::Even std::vector L1MhtPfProducer::convertEDMToHW(std::vector edmJets) const { std::vector hwJets; std::for_each(edmJets.begin(), edmJets.end(), [&](l1t::PFJet jet) { - l1ct::Jet hwJet = l1ct::Jet::unpack(jet.encodedJet()); + l1ct::Jet hwJet = jet.getHWJetCT(); hwJets.push_back(hwJet); }); return hwJets; @@ -75,17 +75,18 @@ std::vector L1MhtPfProducer::convertHWToEDM(l1ct::Sum hwSums) const std::vector edmSums; reco::Candidate::PolarLorentzVector htVector; - htVector.SetPt(hwSums.hwSumPt.to_double()); + l1gt::Sum gtSum = hwSums.toGT(); + htVector.SetPt(l1gt::Scales::floatPt(gtSum.scalar_pt)); htVector.SetPhi(0); htVector.SetEta(0); reco::Candidate::PolarLorentzVector mhtVector; - mhtVector.SetPt(hwSums.hwPt.to_double()); - mhtVector.SetPhi(l1ct::Scales::floatPhi(hwSums.hwPhi)); + mhtVector.SetPt(l1gt::Scales::floatPt(gtSum.vector_pt)); + mhtVector.SetPhi(l1gt::Scales::floatPhi(gtSum.vector_phi)); mhtVector.SetEta(0); - l1t::EtSum ht(htVector, l1t::EtSum::EtSumType::kTotalHt); - l1t::EtSum mht(mhtVector, l1t::EtSum::EtSumType::kMissingHt); + l1t::EtSum ht(htVector, l1t::EtSum::EtSumType::kTotalHt, gtSum.scalar_pt.bits_to_uint64()); + l1t::EtSum mht(mhtVector, l1t::EtSum::EtSumType::kMissingHt, gtSum.vector_pt.bits_to_uint64(), 0, gtSum.vector_phi); edmSums.push_back(ht); edmSums.push_back(mht); diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1SeedConePFJetProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1SeedConePFJetProducer.cc index 14ad91953db40..32ef0da5e6f0b 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1SeedConePFJetProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1SeedConePFJetProducer.cc @@ -204,7 +204,8 @@ std::vector L1SeedConePFJetProducer::convertHWToEDM( gtJet.v3.pt.V, gtJet.v3.eta.V, gtJet.v3.phi.V); - edmJet.setEncodedJet(jet.toGT().pack()); + edmJet.setEncodedJet(l1t::PFJet::HWEncoding::CT, jet.pack()); + edmJet.setEncodedJet(l1t::PFJet::HWEncoding::GT, jet.toGT().pack()); // get back the references to the constituents std::vector> constituents; std::for_each(jet.constituents.begin(), jet.constituents.end(), [&](auto constituent) { diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1pfJetMet_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1pfJetMet_cff.py index 87328acd0f8b9..1ca27e1cf018f 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1pfJetMet_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1pfJetMet_cff.py @@ -26,7 +26,7 @@ phase2_hgcalV11.toModify(_correctedJets, correctorFile = "L1Trigger/Phase2L1ParticleFlow/data/jecs/jecs_20220308.root") from L1Trigger.Phase2L1ParticleFlow.l1tMHTPFProducer_cfi import l1tMHTPFProducer -l1tSCPFL1PuppiCorrectedEmulatorMHT = l1tMHTPFProducer.clone() +l1tSCPFL1PuppiCorrectedEmulatorMHT = l1tMHTPFProducer.clone(jets = 'l1tSCPFL1PuppiCorrectedEmulator') L1TPFJetsTask = cms.Task( l1tLayer2Deregionizer, l1tSCPFL1PF, l1tSCPFL1Puppi, l1tSCPFL1PuppiEmulator, l1tSCPFL1PuppiCorrectedEmulator, l1tSCPFL1PuppiCorrectedEmulatorMHT