From d4a1452ab2e91fd8cf1d08c8830570cce61b4da5 Mon Sep 17 00:00:00 2001 From: Dinyar Rabady Date: Mon, 20 Feb 2023 10:56:48 +0100 Subject: [PATCH 1/2] Fix expected version number of uGT with muon shower support --- EventFilter/L1TRawToDigi/python/gtStage2Raw_cfi.py | 4 ++-- L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EventFilter/L1TRawToDigi/python/gtStage2Raw_cfi.py b/EventFilter/L1TRawToDigi/python/gtStage2Raw_cfi.py index e3d126d7ee523..f6a5b15d0122f 100644 --- a/EventFilter/L1TRawToDigi/python/gtStage2Raw_cfi.py +++ b/EventFilter/L1TRawToDigi/python/gtStage2Raw_cfi.py @@ -13,7 +13,7 @@ JetInputTag = cms.InputTag("simCaloStage2Digis"), EtSumInputTag = cms.InputTag("simCaloStage2Digis"), FedId = cms.int32(1404), - FWId = cms.uint32(0x1130), # FW w/ displaced muon info. + FWId = cms.uint32(0x113b), # FW w/ displaced muon info and hadronic showers. lenSlinkHeader = cms.untracked.int32(8), lenSlinkTrailer = cms.untracked.int32(8) ) @@ -32,4 +32,4 @@ ### Era: Run3_2021 from Configuration.Eras.Modifier_stage2L1Trigger_2021_cff import stage2L1Trigger_2021 -stage2L1Trigger_2021.toModify(gtStage2Raw, FWId = cms.uint32(0x10f01)) # FW w/ displaced muon info and hadronic showers. +stage2L1Trigger_2021.toModify(gtStage2Raw, FWId = cms.uint32(0x113b)) # FW w/ displaced muon info and hadronic showers. diff --git a/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc b/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc index 64e75fea6f4e5..9b1e2e7509d28 100644 --- a/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc +++ b/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc @@ -264,7 +264,7 @@ void l1t::MuonRawDigiTranslator::generate64bitDataWord( } bool l1t::MuonRawDigiTranslator::showerFired(uint32_t shower_word, int fedId, unsigned int fwId) { - if ((fedId == 1402 && fwId >= 0x7000000) || (fedId == 1404 && fwId >= 0x00010f01)) { + if ((fedId == 1402 && fwId >= 0x7000000) || (fedId == 1404 && fwId >= 0x113b)) { return ((shower_word >> showerShift_) & 1) == 1; } return false; From 4179ed6d24894007eaea89feaea0e29a9b15304c Mon Sep 17 00:00:00 2001 From: Dinyar Rabady Date: Tue, 21 Feb 2023 20:19:45 +0100 Subject: [PATCH 2/2] Put uG(M)T firmware versions etc. into named constants Also fix overlooked incorrect uGT version from previous commit. --- .../L1TMuon/interface/MuonRawDigiTranslator.h | 20 ++++++--- .../L1TMuon/src/MuonRawDigiTranslator.cc | 45 ++++++++++--------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/L1Trigger/L1TMuon/interface/MuonRawDigiTranslator.h b/L1Trigger/L1TMuon/interface/MuonRawDigiTranslator.h index f0f32df597f9e..c2598f42b77f2 100644 --- a/L1Trigger/L1TMuon/interface/MuonRawDigiTranslator.h +++ b/L1Trigger/L1TMuon/interface/MuonRawDigiTranslator.h @@ -14,11 +14,11 @@ namespace l1t { uint32_t raw_data_00_31, uint32_t raw_data_32_63, int fed, - unsigned int fw, + int fw, int muInBx); - static void fillMuon(Muon& mu, uint32_t raw_data_spare, uint64_t dataword, int fed, unsigned int fw, int muInBx); - static void fillIntermediateMuon(Muon& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, unsigned int fw); - static bool showerFired(uint32_t shower_word, int fedId, unsigned int fwId); + static void fillMuon(Muon& mu, uint32_t raw_data_spare, uint64_t dataword, int fed, int fw, int muInBx); + static void fillIntermediateMuon(Muon& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int fw); + static bool showerFired(uint32_t shower_word, int fedId, int fwId); static void generatePackedMuonDataWords(const Muon& mu, uint32_t& raw_data_spare, uint32_t& raw_data_00_31, @@ -28,7 +28,7 @@ namespace l1t { int muInBx); static void generate64bitDataWord( const Muon& mu, uint32_t& raw_data_spare, uint64_t& dataword, int fedId, int fwId, int muInBx); - static std::array getPackedShowerDataWords(const MuonShower& shower, int fedId, unsigned int fwId); + static std::array getPackedShowerDataWords(const MuonShower& shower, int fedId, int fwId); static int calcHwEta(const uint32_t& raw, unsigned absEtaShift, unsigned etaSignShift); static constexpr unsigned ptMask_ = 0x1FF; @@ -59,6 +59,16 @@ namespace l1t { static constexpr unsigned etaMu1SignShift_ = 21; // For Run-3 static constexpr unsigned absEtaMu2Shift_ = 22; // For Run-3 static constexpr unsigned etaMu2SignShift_ = 30; // For Run-3 + static constexpr int kUgmtFedId = 1402; + static constexpr int kUgtFedId = 1404; + static constexpr int kUgmtFwVersionUntil2016 = 0x4010000; + static constexpr int kUgtFwVersionUntil2016 = 0x10A6; + static constexpr int kUgmtFwVersionUntil2017 = 0x6000000; + static constexpr int kUgtFwVersionUntil2017 = 0x1120; + static constexpr int kUgmtFwVersionRun3Start = 0x6000001; + static constexpr int kUgtFwVersionUntilRun3Start = 0x1130; + static constexpr int kUgmtFwVersionFirstWithShowers = 0x7000000; + static constexpr int kUgtFwVersionFirstWithShowers = 0x113B; private: static void fillMuonStableQuantities(Muon& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63); diff --git a/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc b/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc index 9b1e2e7509d28..48097f98e014c 100644 --- a/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc +++ b/L1Trigger/L1TMuon/src/MuonRawDigiTranslator.cc @@ -2,13 +2,8 @@ #include "TMath.h" #include "L1Trigger/L1TMuon/interface/MuonRawDigiTranslator.h" -void l1t::MuonRawDigiTranslator::fillMuon(Muon& mu, - uint32_t raw_data_spare, - uint32_t raw_data_00_31, - uint32_t raw_data_32_63, - int fed, - unsigned int fw, - int muInBx) { +void l1t::MuonRawDigiTranslator::fillMuon( + Muon& mu, uint32_t raw_data_spare, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int fed, int fw, int muInBx) { // Need the hw charge to properly compute dPhi mu.setHwCharge((raw_data_32_63 >> chargeShift_) & 0x1); @@ -18,11 +13,12 @@ void l1t::MuonRawDigiTranslator::fillMuon(Muon& mu, // In Run-3 we have displacement information. // To make room for these data the raw eta value was moved to the second "spare" word which we will have to treat separately // The uGMT (FED 1402) or uGT (FED 1404) FW versions are used to determine the era. - if ((fed == 1402 && fw < 0x4010000) || (fed == 1404 && fw < 0x10A6)) { + if ((fed == kUgmtFedId && fw < kUgmtFwVersionUntil2016) || (fed == kUgtFedId && fw < kUgtFwVersionUntil2016)) { fillMuonCoordinates2016(mu, raw_data_00_31, raw_data_32_63); - } else if ((fed == 1402 && fw < 0x6000000) || (fed == 1404 && fw < 0x1120)) { + } else if ((fed == kUgmtFedId && fw < kUgmtFwVersionUntil2017) || (fed == kUgtFedId && fw < kUgtFwVersionUntil2017)) { fillMuonCoordinatesFrom2017(mu, raw_data_00_31, raw_data_32_63); - } else if ((fed == 1402 && fw == 0x6000001) || (fed == 1404 && fw < 0x1130)) { + } else if ((fed == kUgmtFedId && fw == kUgmtFwVersionRun3Start) || + (fed == kUgtFedId && fw < kUgtFwVersionUntilRun3Start)) { // We're unpacking data from the November MWGR where the raw eta values were shifted by one bit. fillMuonQuantitiesRun3(mu, raw_data_spare, raw_data_00_31, raw_data_32_63, muInBx, true); } else { @@ -36,13 +32,13 @@ void l1t::MuonRawDigiTranslator::fillMuon(Muon& mu, void l1t::MuonRawDigiTranslator::fillIntermediateMuon(Muon& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, - unsigned int fw) { + int fw) { // Need the hw charge to properly compute dPhi mu.setHwCharge((raw_data_32_63 >> chargeShift_) & 0x1); - if (fw < 0x4010000) { + if (fw < kUgmtFwVersionUntil2016) { fillMuonCoordinates2016(mu, raw_data_00_31, raw_data_32_63); - } else if (fw < 0x6000000) { + } else if (fw < kUgmtFwVersionUntil2017) { fillMuonCoordinatesFrom2017(mu, raw_data_00_31, raw_data_32_63); } else { fillIntermediateMuonQuantitiesRun3(mu, raw_data_00_31, raw_data_32_63); @@ -81,7 +77,7 @@ void l1t::MuonRawDigiTranslator::fillMuonStableQuantities(Muon& mu, uint32_t raw } void l1t::MuonRawDigiTranslator::fillMuon( - Muon& mu, uint32_t raw_data_spare, uint64_t dataword, int fed, unsigned int fw, int muInBx) { + Muon& mu, uint32_t raw_data_spare, uint64_t dataword, int fed, int fw, int muInBx) { fillMuon( mu, raw_data_spare, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF), fed, fw, muInBx); } @@ -192,7 +188,8 @@ void l1t::MuonRawDigiTranslator::generatePackedMuonDataWords(const Muon& mu, if (abs_eta_at_vtx < 0) { abs_eta_at_vtx += (1 << (etaAtVtxSignShift_ - absEtaAtVtxShift_)); } - if ((fedID == 1402 && fwID < 0x4010000) || (fedID == 1404 && fwID < 0x10A6)) { + if ((fedID == kUgmtFedId && fwID < kUgmtFwVersionUntil2016) || + (fedID == kUgtFedId && fwID < kUgtFwVersionUntil2016)) { // For 2016 the non-extrapolated coordiantes were in the place that are now occupied by the extrapolated quantities. raw_data_spare = 0; raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_ | (mu.hwQual() & qualMask_) << qualShift_ | @@ -200,7 +197,8 @@ void l1t::MuonRawDigiTranslator::generatePackedMuonDataWords(const Muon& mu, (mu.hwPhi() & phiMask_) << phiAtVtxShift_; raw_data_32_63 = mu.hwCharge() << chargeShift_ | mu.hwChargeValid() << chargeValidShift_ | (mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (mu.hwIso() & isoMask_) << isoShift_; - } else if ((fedID == 1402 && fwID < 0x6000000) || (fedID == 1404 && fwID < 0x1120)) { + } else if ((fedID == kUgmtFedId && fwID < kUgmtFwVersionUntil2017) || + (fedID == kUgtFedId && fwID < kUgtFwVersionUntil2017)) { raw_data_spare = 0; raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_ | (mu.hwQual() & qualMask_) << qualShift_ | (abs_eta_at_vtx & absEtaMask_) << absEtaAtVtxShift_ | (mu.hwEtaAtVtx() < 0) << etaAtVtxSignShift_ | @@ -210,8 +208,9 @@ void l1t::MuonRawDigiTranslator::generatePackedMuonDataWords(const Muon& mu, (mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (mu.hwIso() & isoMask_) << isoShift_ | (abs_eta & absEtaMask_) << absEtaShift_ | (mu.hwEta() < 0) << etaSignShift_ | (mu.hwPhi() & phiMask_) << phiShift_; - } else if ((fedID == 1402 && fwID == 0x6000001) || - (fedID == 1404 && fwID < 0x1130)) { // This allows us to unpack data taken in the November 2020 MWGR. + } else if ((fedID == kUgmtFedId && fwID == kUgmtFwVersionRun3Start) || + (fedID == kUgtFedId && + fwID < kUgtFwVersionUntilRun3Start)) { // This allows us to unpack data taken in the November 2020 MWGR. generatePackedMuonDataWordsRun3( mu, abs_eta, abs_eta_at_vtx, raw_data_spare, raw_data_00_31, raw_data_32_63, muInBx, true); } else { @@ -263,8 +262,9 @@ void l1t::MuonRawDigiTranslator::generate64bitDataWord( dataword = (((uint64_t)msw) << 32) + lsw; } -bool l1t::MuonRawDigiTranslator::showerFired(uint32_t shower_word, int fedId, unsigned int fwId) { - if ((fedId == 1402 && fwId >= 0x7000000) || (fedId == 1404 && fwId >= 0x113b)) { +bool l1t::MuonRawDigiTranslator::showerFired(uint32_t shower_word, int fedId, int fwId) { + if ((fedId == kUgmtFedId && fwId >= kUgmtFwVersionFirstWithShowers) || + (fedId == kUgtFedId && fwId >= kUgtFwVersionFirstWithShowers)) { return ((shower_word >> showerShift_) & 1) == 1; } return false; @@ -272,9 +272,10 @@ bool l1t::MuonRawDigiTranslator::showerFired(uint32_t shower_word, int fedId, un std::array l1t::MuonRawDigiTranslator::getPackedShowerDataWords(const MuonShower& shower, const int fedId, - const unsigned int fwId) { + const int fwId) { std::array res{}; - if ((fedId == 1402 && fwId >= 0x7000000) || (fedId == 1404 && fwId >= 0x00010f01)) { + if ((fedId == kUgmtFedId && fwId >= kUgmtFwVersionFirstWithShowers) || + (fedId == kUgtFedId && fwId >= kUgtFwVersionFirstWithShowers)) { res.at(0) = shower.isOneNominalInTime() ? (1 << showerShift_) : 0; res.at(1) = shower.isOneTightInTime() ? (1 << showerShift_) : 0; }