From baf69eebe3fb19c1aa8bece194e3fa25f31cb42b Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 26 Jan 2024 09:31:53 -0600 Subject: [PATCH 01/17] Update CICADA emulator templates and update model version to pattern testing model --- .../L1TCaloLayer1/plugins/L1TCaloSummary.cc | 21 ++++++++++++++----- .../python/simCaloStage2Layer1Summary_cfi.py | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc index d8ec5cbffa7c7..e70edf2751201 100644 --- a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc +++ b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc @@ -336,8 +336,19 @@ void L1TCaloSummary::fillDescriptions(edm::ConfigurationDescripti descriptions.addDefault(desc); } -typedef L1TCaloSummary, ap_fixed<11, 5>> L1TCaloSummaryCICADAv1; -typedef L1TCaloSummary, ap_ufixed<16, 8>> L1TCaloSummaryCICADAv2; -//define type version plugins -DEFINE_FWK_MODULE(L1TCaloSummaryCICADAv1); -DEFINE_FWK_MODULE(L1TCaloSummaryCICADAv2); +// Initial version, X.0.0, input/output typing +typedef L1TCaloSummary, ap_fixed<11, 5>> L1TCaloSummary_CICADA_v1p0p0; +typedef L1TCaloSummary, ap_ufixed<16, 8>> L1TCaloSummary_CICADA_v2p0p0; +DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v1p0p0); +DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v2p0p0); +// X.1.0 version input.output typing +typedef L1TCaloSummary, ap_fixed<11,5>> L1TCaloSummary_CICADA_v1p1p0; +typedef L1TCaloSummary, ap_ufixed<16,8>> L1TCaloSummary_CICADA_v2p1p0; +DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v1p1p0); +DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v2p1p0); +// X.1.1 version input/output typing +typedef L1TCaloSummary, ap_ufixed<16,8,AP_RND,AP_SAT,AP_SAT>> L1TCaloSummary_CICADA_vXp1p1; +DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_vXp1p1); +// X.1.2 version input/output typing +typedef L1TCaloSummary, ap_ufixed<16,8,AP_RND_CONV,AP_SAT>> L1TCaloSummary_CICADA_vXp1p2; +DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_vXp1p2); diff --git a/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py b/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py index 91fd111a33b27..4d7c51e0c4f99 100644 --- a/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py +++ b/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py @@ -2,7 +2,7 @@ from L1Trigger.L1TCaloLayer1.CICADATestPatterns import standardCICADATestPatterns -simCaloStage2Layer1Summary = cms.EDProducer('L1TCaloSummaryCICADAv2', +simCaloStage2Layer1Summary = cms.EDProducer('L1TCaloSummary_CICADA_vXp1p1', nPumBins = cms.uint32(18), pumLUT00n= cms.vdouble(0.43, 0.32, 0.29, 0.36, 0.33, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25), pumLUT00p= cms.vdouble(0.45, 0.32, 0.29, 0.35, 0.31, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25), @@ -50,7 +50,7 @@ verbose = cms.bool(False), # See UCTLayer1.hh for firmware version firmwareVersion = cms.int32(1), - CICADAModelVersion = cms.string("CICADAModel_v2p1"), + CICADAModelVersion = cms.string("CICADA_v1p1p1"), useTestPatterns = cms.bool(False), testPatterns = standardCICADATestPatterns ) From 7c84bbf05586af2d270ac11e7fa74e1d0dfc2213 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 26 Jan 2024 10:02:06 -0600 Subject: [PATCH 02/17] fix format --- L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc index e70edf2751201..4237afee3dcb8 100644 --- a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc +++ b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc @@ -342,13 +342,13 @@ typedef L1TCaloSummary, ap_ufixed<16, 8>> L1TCaloSummary_CICADA_v2p0 DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v1p0p0); DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v2p0p0); // X.1.0 version input.output typing -typedef L1TCaloSummary, ap_fixed<11,5>> L1TCaloSummary_CICADA_v1p1p0; -typedef L1TCaloSummary, ap_ufixed<16,8>> L1TCaloSummary_CICADA_v2p1p0; +typedef L1TCaloSummary, ap_fixed<11, 5>> L1TCaloSummary_CICADA_v1p1p0; +typedef L1TCaloSummary, ap_ufixed<16, 8>> L1TCaloSummary_CICADA_v2p1p0; DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v1p1p0); DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_v2p1p0); // X.1.1 version input/output typing -typedef L1TCaloSummary, ap_ufixed<16,8,AP_RND,AP_SAT,AP_SAT>> L1TCaloSummary_CICADA_vXp1p1; +typedef L1TCaloSummary, ap_ufixed<16, 8, AP_RND, AP_SAT, AP_SAT>> L1TCaloSummary_CICADA_vXp1p1; DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_vXp1p1); // X.1.2 version input/output typing -typedef L1TCaloSummary, ap_ufixed<16,8,AP_RND_CONV,AP_SAT>> L1TCaloSummary_CICADA_vXp1p2; +typedef L1TCaloSummary, ap_ufixed<16, 8, AP_RND_CONV, AP_SAT>> L1TCaloSummary_CICADA_vXp1p2; DEFINE_FWK_MODULE(L1TCaloSummary_CICADA_vXp1p2); From e1a92b0ee47c2e14ad6a4ef361a29851c134bf40 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Tue, 27 Feb 2024 04:30:31 -0600 Subject: [PATCH 03/17] CICADA-uGT emulator additions --- .../L1TGlobal/interface/CICADACondition.h | 44 +++++++++++ .../L1TGlobal/interface/CICADATemplate.h | 36 +++++++++ L1Trigger/L1TGlobal/interface/GlobalBoard.h | 10 ++- .../L1TGlobal/interface/GlobalDefinitions.h | 2 + L1Trigger/L1TGlobal/interface/TriggerMenu.h | 8 ++ .../L1TGlobal/plugins/L1TGlobalProducer.cc | 10 ++- .../L1TGlobal/plugins/L1TGlobalProducer.h | 2 + .../L1TGlobal/plugins/TriggerMenuParser.cc | 77 +++++++++++++++++++ .../L1TGlobal/plugins/TriggerMenuParser.h | 8 ++ .../L1TGlobal/python/simGtStage2Digis_cfi.py | 1 + L1Trigger/L1TGlobal/src/CICADACondition.cc | 65 ++++++++++++++++ L1Trigger/L1TGlobal/src/CICADATemplate.cc | 60 +++++++++++++++ L1Trigger/L1TGlobal/src/GlobalBoard.cc | 35 ++++++++- L1Trigger/L1TGlobal/src/GlobalDefinitions.cc | 2 + L1Trigger/L1TGlobal/src/TriggerMenu.cc | 28 +++++++ L1Trigger/L1TGlobal/src/classes.h | 1 + L1Trigger/L1TGlobal/src/classes_def.xml | 1 + 17 files changed, 387 insertions(+), 3 deletions(-) create mode 100644 L1Trigger/L1TGlobal/interface/CICADACondition.h create mode 100644 L1Trigger/L1TGlobal/interface/CICADATemplate.h create mode 100644 L1Trigger/L1TGlobal/src/CICADACondition.cc create mode 100644 L1Trigger/L1TGlobal/src/CICADATemplate.cc diff --git a/L1Trigger/L1TGlobal/interface/CICADACondition.h b/L1Trigger/L1TGlobal/interface/CICADACondition.h new file mode 100644 index 0000000000000..b14e4f6593eae --- /dev/null +++ b/L1Trigger/L1TGlobal/interface/CICADACondition.h @@ -0,0 +1,44 @@ +#ifndef L1Trigger_L1TGlobal_CICADACondition_h +#define L1Trigger_L1TGlobal_CICADACondition_h + +#include +#include + +#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h" + +class GlobalCondition; +class CICADATemplate; + +namespace l1t { + class GlobalBoard; + + class CICADACondition : public ConditionEvaluation { + public: + CICADACondition(); + CICADACondition(const GlobalCondition*, const GlobalBoard*); + CICADACondition(const CICADACondition&); + ~CICADACondition() override = default; + + CICADACondition& operator=(const CICADACondition&); + + const bool evaluateCondition(const int bxEval) const override; + + void print(std::ostream& myCout) const override; + + inline const CICADATemplate* gtCICADATemplate() const { return m_gtCICADATemplate; } + + void setGtCICADATemplate(const CICADATemplate* cicadaTemplate) { m_gtCICADATemplate = cicadaTemplate; } + + inline const GlobalBoard* getuGtB() const { return m_uGtB; } + + void setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; } + + private: + void copy(const CICADACondition& cp); + + const CICADATemplate* m_gtCICADATemplate; + + const GlobalBoard* m_uGtB; + }; +} // namespace l1t +#endif diff --git a/L1Trigger/L1TGlobal/interface/CICADATemplate.h b/L1Trigger/L1TGlobal/interface/CICADATemplate.h new file mode 100644 index 0000000000000..c34574fde3f3d --- /dev/null +++ b/L1Trigger/L1TGlobal/interface/CICADATemplate.h @@ -0,0 +1,36 @@ +#ifndef L1Trigger_L1TGlobal_CICADATemplate_h +#define L1Trigger_L1TGlobal_CICADATemplate_h + +#include +#include + +#include "L1Trigger/L1TGlobal/interface/GlobalCondition.h" + +class CICADATemplate : public GlobalCondition { +public: + CICADATemplate(); + CICADATemplate(const std::string&); + CICADATemplate(const std::string&, const l1t::GtConditionType&); + CICADATemplate(const CICADATemplate&); + ~CICADATemplate() = default; + + CICADATemplate& operator=(const CICADATemplate&); + + struct ObjectParameter { + float minCICADAThreshold; + float maxCICADAThreshold; + }; + inline const std::vector* objectParameter() const { return &m_objectParameter; } + + void setConditionParameter(const std::vector& objParameter) { m_objectParameter = objParameter; } + + void print(std::ostream& myCout) const override; + + friend std::ostream& operator<<(std::ostream&, const CICADATemplate&); + +private: + void copy(const CICADATemplate& cp); + std::vector m_objectParameter; +}; + +#endif diff --git a/L1Trigger/L1TGlobal/interface/GlobalBoard.h b/L1Trigger/L1TGlobal/interface/GlobalBoard.h index a6d14a0c8d5a6..7bb6266a57e6b 100644 --- a/L1Trigger/L1TGlobal/interface/GlobalBoard.h +++ b/L1Trigger/L1TGlobal/interface/GlobalBoard.h @@ -69,6 +69,7 @@ namespace l1t { const edm::EDGetTokenT>&, const edm::EDGetTokenT>&, const edm::EDGetTokenT>&, + const edm::EDGetTokenT&, const bool receiveEG, const int nrL1EG, const bool receiveTau, @@ -76,7 +77,8 @@ namespace l1t { const bool receiveJet, const int nrL1Jet, const bool receiveEtSums, - const bool receiveEtSumsZdc); + const bool receiveEtSumsZdc, + const bool receiveCICADA); void receiveMuonObjectData(const edm::Event&, const edm::EDGetTokenT>&, @@ -172,6 +174,8 @@ namespace l1t { /// pointer to External data list inline const BXVector* getCandL1External() const { return m_candL1External; } + inline const float getCICADAScore() const { return m_cicadaScore; } + /* Drop individual EtSums for Now /// pointer to ETM data list inline const l1t::EtSum* getCandL1ETM() const @@ -204,6 +208,8 @@ namespace l1t { void setResetPSCountersEachLumiSec(bool val) { m_resetPSCountersEachLumiSec = val; } void setSemiRandomInitialPSCounters(bool val) { m_semiRandomInitialPSCounters = val; } + void setCICADAScore(float val) { m_cicadaScore = val; } + public: inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; } @@ -242,6 +248,8 @@ namespace l1t { int m_bxFirst_; int m_bxLast_; + float m_cicadaScore = 0.0; + std::bitset m_gtlAlgorithmOR; std::bitset m_gtlDecisionWord; diff --git a/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h b/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h index 8162cf921af32..6306afe93c4da 100644 --- a/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h +++ b/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h @@ -82,6 +82,7 @@ namespace l1t { TypeZDCP, TypeZDCM, TypeAXOL1TL, + TypeCICADA, GtConditionTypeInvalid = -1 }; @@ -106,6 +107,7 @@ namespace l1t { CondMuonShower, CondEnergySumZdc, CondAXOL1TL, + CondCICADA, GtConditionCategoryInvalid = -1 }; diff --git a/L1Trigger/L1TGlobal/interface/TriggerMenu.h b/L1Trigger/L1TGlobal/interface/TriggerMenu.h index 85fc746839578..2053edf64ce9e 100644 --- a/L1Trigger/L1TGlobal/interface/TriggerMenu.h +++ b/L1Trigger/L1TGlobal/interface/TriggerMenu.h @@ -37,6 +37,7 @@ #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h" #include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" #include "L1Trigger/L1TGlobal/interface/AXOL1TLTemplate.h" +#include "L1Trigger/L1TGlobal/interface/CICADATemplate.h" #include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h" @@ -61,6 +62,7 @@ class TriggerMenu { const std::vector >&, const std::vector >&, const std::vector >&, + const std::vector >&, const std::vector >&, const std::vector >&, const std::vector >&, @@ -146,6 +148,11 @@ class TriggerMenu { void setVecAXOL1TLTemplate(const std::vector >&); + // + inline const std::vector >& vecCICADATemplate() const { return m_vecCICADATemplate; } + + void setVecCICADATemplate(const std::vector >&); + // inline const std::vector >& vecExternalTemplate() const { return m_vecExternalTemplate; @@ -249,6 +256,7 @@ class TriggerMenu { std::vector > m_vecEnergySumTemplate; std::vector > m_vecEnergySumZdcTemplate; std::vector > m_vecAXOL1TLTemplate; + std::vector > m_vecCICADATemplate; std::vector > m_vecExternalTemplate; diff --git a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc index 81a51738e67c5..2ad9a5b7be06f 100644 --- a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc +++ b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc @@ -51,6 +51,8 @@ void L1TGlobalProducer::fillDescriptions(edm::ConfigurationDescriptions& descrip ->setComment("InputTag for Calo Trigger EtSum (required parameter: default value is invalid)"); desc.add("EtSumZdcInputTag", edm::InputTag("")) ->setComment("InputTag for ZDC EtSums Plus and Minus (required parameter: default value is invalid)"); + desc.add("CICADAInputTag", edm::InputTag("")) + ->setComment("InputTag for CICADA Anomaly Detection (required parameter: default value is invalid)"); desc.add("ExtInputTag", edm::InputTag("")) ->setComment("InputTag for external conditions (not required, but recommend to specify explicitly in config)"); desc.add("AlgoBlkInputTag", edm::InputTag("hltGtStage2Digis")) @@ -106,6 +108,7 @@ L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet) m_jetInputTag(parSet.getParameter("JetInputTag")), m_sumInputTag(parSet.getParameter("EtSumInputTag")), m_sumZdcInputTag(parSet.getParameter("EtSumZdcInputTag")), + m_CICADAInputTag(parSet.getParameter("CICADAInputTag")), m_extInputTag(parSet.getParameter("ExtInputTag")), m_produceL1GtDaqRecord(parSet.getParameter("ProduceL1GtDaqRecord")), @@ -136,6 +139,7 @@ L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet) m_jetInputToken = consumes>(m_jetInputTag); m_sumInputToken = consumes>(m_sumInputTag); m_sumZdcInputToken = consumes>(m_sumZdcInputTag); + m_CICADAInputToken = consumes(m_CICADAInputTag); m_muInputToken = consumes>(m_muInputTag); if (m_useMuonShowers) m_muShowerInputToken = consumes>(m_muShowerInputTag); @@ -375,6 +379,7 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet gtParser.vecEnergySumTemplate(), gtParser.vecEnergySumZdcTemplate(), gtParser.vecAXOL1TLTemplate(), + gtParser.vecCICADATemplate(), gtParser.vecExternalTemplate(), gtParser.vecCorrelationTemplate(), gtParser.vecCorrelationThreeBodyTemplate(), @@ -520,6 +525,7 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet bool receiveJet = true; bool receiveEtSums = true; bool receiveEtSumsZdc = true; + bool receiveCICADA = true; bool receiveExt = true; /* *** Boards need redefining ***** @@ -610,6 +616,7 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet m_jetInputToken, m_sumInputToken, m_sumZdcInputToken, + m_CICADAInputToken, receiveEG, m_nrL1EG, receiveTau, @@ -617,7 +624,8 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet receiveJet, m_nrL1Jet, receiveEtSums, - receiveEtSumsZdc); + receiveEtSumsZdc, + receiveCICADA); m_uGtBrd->receiveMuonObjectData(iEvent, m_muInputToken, receiveMu, m_nrL1Mu); diff --git a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h index 2da54f435f6fb..65260298bab22 100644 --- a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h +++ b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h @@ -127,11 +127,13 @@ class L1TGlobalProducer : public edm::stream::EDProducer<> { edm::InputTag m_jetInputTag; edm::InputTag m_sumInputTag; edm::InputTag m_sumZdcInputTag; + edm::InputTag m_CICADAInputTag; edm::EDGetTokenT> m_egInputToken; edm::EDGetTokenT> m_tauInputToken; edm::EDGetTokenT> m_jetInputToken; edm::EDGetTokenT> m_sumInputToken; edm::EDGetTokenT> m_sumZdcInputToken; + edm::EDGetTokenT m_CICADAInputToken; /// input tag for external conditions edm::InputTag m_extInputTag; diff --git a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc index 81fb9afa080e2..cc8bb3ccb584f 100644 --- a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc +++ b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc @@ -147,6 +147,10 @@ void l1t::TriggerMenuParser::setVecAXOL1TLTemplate(const std::vector >& vecCICADATempl) { + m_vecCICADATemplate = vecCICADATempl; +} + void l1t::TriggerMenuParser::setVecExternalTemplate( const std::vector >& vecExternalTempl) { m_vecExternalTemplate = vecExternalTempl; @@ -227,6 +231,7 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu) m_vecEnergySumTemplate.resize(m_numberConditionChips); m_vecEnergySumZdcTemplate.resize(m_numberConditionChips); m_vecAXOL1TLTemplate.resize(m_numberConditionChips); + m_vecCICADATemplate.resize(m_numberConditionChips); m_vecExternalTemplate.resize(m_numberConditionChips); m_vecCorrelationTemplate.resize(m_numberConditionChips); @@ -326,6 +331,9 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu) condition.getType() == esConditionType::AnomalyDetectionTrigger) { parseAXOL1TL(condition, chipNr); + //parse CICADA + } else if (condition.getType() == esConditionType::CicadaTrigger) { + parseCICADA(condition, chipNr); //parse Muons } else if (condition.getType() == esConditionType::SingleMuon || condition.getType() == esConditionType::DoubleMuon || @@ -2903,6 +2911,75 @@ bool l1t::TriggerMenuParser::parseExternal(L1TUtmCondition condExt, unsigned int return true; } +// Parse the CICADA condition and insert the entry into the conditions mapping +bool l1t::TriggerMenuParser::parseCICADA(L1TUtmCondition condCICADA, unsigned int chipNr) { + using namespace tmeventsetup; + + std::string condition = "cicada"; + std::string type = l1t2string(condCICADA.getType()); + std::string name = l1t2string(condCICADA.getName()); + + LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl + << " (in parseCICADA) " << std::endl + << " condition = " << condition << std::endl + << " type = " << type << std::endl + << " name = " << name << std::endl; + const int nrObj = 1; + GtConditionType cType = TypeCICADA; + + std::vector objParameter(nrObj); + + if (int(condCICADA.getObjects().size()) != nrObj) { + edm::LogError("TriggerMenuParser") << " condCICADA objects: nrObj = " << nrObj + << "condCICADA.getObjects().size() = " << condCICADA.getObjects().size() + << std::endl; + return false; + } + + L1TUtmObject object = condCICADA.getObjects().at(0); + int relativeBx = object.getBxOffset(); + bool gEq = (object.getComparisonOperator() == esComparisonOperator::GE); + + float lowerThresholdInd = 0; //May need to be float to match CICADA? + float upperThresholdInd = -1; + + const std::vector& cuts = object.getCuts(); + for (size_t kk = 0; kk < cuts.size(); kk++) { + const L1TUtmCut& cut = cuts.at(kk); + + switch (cut.getCutType()) { + case esCutType::CicadaScore: + lowerThresholdInd = cut.getMinimum().value; + upperThresholdInd = cut.getMaximum().value; + } + } + + objParameter[0].minCICADAThreshold = lowerThresholdInd; + objParameter[0].maxCICADAThreshold = upperThresholdInd; + + CICADATemplate cicadaCond(name); + cicadaCond.setCondType(cType); + cicadaCond.setCondGEq(gEq); + cicadaCond.setCondChipNr(chipNr); + cicadaCond.setCondRelativeBx(relativeBx); + cicadaCond.setConditionParameter(objParameter); + + if (edm::isDebugEnabled()) { + std::ostringstream myCoutStream; + cicadaCond.print(myCoutStream); + LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl; + } + + if (!insertConditionIntoMap(cicadaCond, chipNr)) { + edm::LogError("TriggerMenuParser") << " Error: duplicate CICADA condition (" << name << ")" << std::endl; + return false; + } + + (m_vecCICADATemplate[chipNr]).push_back(cicadaCond); + + return true; +} + /** * parseCorrelation Parse a correlation condition and * insert an entry to the conditions map diff --git a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h index 74551d0a2012b..e934ba96353f0 100644 --- a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h +++ b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h @@ -38,6 +38,7 @@ #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h" #include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" #include "L1Trigger/L1TGlobal/interface/AXOL1TLTemplate.h" +#include "L1Trigger/L1TGlobal/interface/CICADATemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationWithOverlapRemovalTemplate.h" @@ -157,6 +158,10 @@ namespace l1t { inline const std::vector >& vecAXOL1TLTemplate() const { return m_vecAXOL1TLTemplate; } void setVecAXOL1TLTemplate(const std::vector >&); + // + inline const std::vector >& vecCICADATemplate() const { return m_vecCICADATemplate; } + void setVecCICADATemplate(const std::vector >&); + // inline const std::vector >& vecExternalTemplate() const { return m_vecExternalTemplate; @@ -309,6 +314,8 @@ namespace l1t { bool parseAXOL1TL(L1TUtmCondition condAXOL1TL, unsigned int chipNr = 0); + bool parseCICADA(L1TUtmCondition condCICADA, unsigned int chipNr = 0); + bool parseEnergySumCorr(const L1TUtmObject* corrESum, unsigned int chipNr = 0); bool parseExternal(L1TUtmCondition condExt, unsigned int chipNr = 0); @@ -416,6 +423,7 @@ namespace l1t { std::vector > m_vecEnergySumTemplate; std::vector > m_vecEnergySumZdcTemplate; std::vector > m_vecAXOL1TLTemplate; + std::vector > m_vecCICADATemplate; std::vector > m_vecExternalTemplate; std::vector > m_vecCorrelationTemplate; diff --git a/L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py b/L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py index 1f38f24ab957a..4916c8647d018 100644 --- a/L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py +++ b/L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py @@ -16,6 +16,7 @@ JetInputTag = cms.InputTag("simCaloStage2Digis"), EtSumInputTag = cms.InputTag("simCaloStage2Digis"), EtSumZdcInputTag = cms.InputTag("etSumZdcProducer"), + CICADAInputTag = cms.InputTag("simCaloStage2Layer1Summary", "CICADAScore"), AlgorithmTriggersUnmasked = cms.bool(True), AlgorithmTriggersUnprescaled = cms.bool(True), GetPrescaleColumnFromData = cms.bool(False), diff --git a/L1Trigger/L1TGlobal/src/CICADACondition.cc b/L1Trigger/L1TGlobal/src/CICADACondition.cc new file mode 100644 index 0000000000000..169aa1dba1964 --- /dev/null +++ b/L1Trigger/L1TGlobal/src/CICADACondition.cc @@ -0,0 +1,65 @@ +#include "L1Trigger/L1TGlobal/interface/CICADACondition.h" + +#include +#include + +#include +#include +#include + +#include "L1Trigger/L1TGlobal/interface/CICADATemplate.h" +#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h" +#include "L1Trigger/L1TGlobal/interface/GlobalBoard.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/MessageLogger/interface/MessageDrop.h" + +l1t::CICADACondition::CICADACondition() : ConditionEvaluation() {} + +l1t::CICADACondition::CICADACondition(const GlobalCondition* cicadaTemplate, const GlobalBoard* ptrGTB) + : ConditionEvaluation(), m_gtCICADATemplate(static_cast(cicadaTemplate)), m_uGtB(ptrGTB) { + m_condMaxNumberObjects = 1; //necessary? +} + +void l1t::CICADACondition::copy(const l1t::CICADACondition& cp) { + m_gtCICADATemplate = cp.gtCICADATemplate(); + m_uGtB = cp.getuGtB(); + + m_condMaxNumberObjects = cp.condMaxNumberObjects(); + m_condLastResult = cp.condLastResult(); + m_combinationsInCond = cp.getCombinationsInCond(); + + m_verbosity = cp.m_verbosity; +} + +l1t::CICADACondition::CICADACondition(const l1t::CICADACondition& cp) : ConditionEvaluation() { copy(cp); } + +l1t::CICADACondition& l1t::CICADACondition::operator=(const l1t::CICADACondition& cp) { + copy(cp); + return *this; +} + +const bool l1t::CICADACondition::evaluateCondition(const int bxEval) const { + bool condResult = false; + const float cicadaScore = m_uGtB->getCICADAScore(); //needs to be implemented + + // This gets rid of a GT emulator convention "iCondition". + // This usually indexes the next line, which is somewhat concerning + // AXOL1TL operates this way, but it should be checked + const CICADATemplate::ObjectParameter objPar = (*(m_gtCICADATemplate->objectParameter()))[0]; + + bool condGEqVal = m_gtCICADATemplate->condGEq(); + bool passCondition = false; + + passCondition = checkCut(objPar.minCICADAThreshold, cicadaScore, condGEqVal); + + condResult |= passCondition; + + return condResult; +} + +void l1t::CICADACondition::print(std::ostream& myCout) const { + myCout << "CICADA Condition Print: " << std::endl; + m_gtCICADATemplate->print(myCout); + ConditionEvaluation::print(myCout); +} diff --git a/L1Trigger/L1TGlobal/src/CICADATemplate.cc b/L1Trigger/L1TGlobal/src/CICADATemplate.cc new file mode 100644 index 0000000000000..a33b30502f8a0 --- /dev/null +++ b/L1Trigger/L1TGlobal/src/CICADATemplate.cc @@ -0,0 +1,60 @@ +#include "L1Trigger/L1TGlobal/interface/CICADATemplate.h" + +#include +#include + +//TODO: Check the actual conditions name: "CondCICADA" +CICADATemplate::CICADATemplate() : GlobalCondition() { m_condCategory = l1t::CondCICADA; } + +CICADATemplate::CICADATemplate(const std::string& cName) : GlobalCondition(cName) { m_condCategory = l1t::CondCICADA; } + +CICADATemplate::CICADATemplate(const std::string& cName, const l1t::GtConditionType& cType) + : GlobalCondition(cName, l1t::CondCICADA, cType) { + m_condCategory = l1t::CondCICADA; + + int nObjects = nrObjects(); + + if (nObjects > 0) { + m_objectType.reserve(nObjects); + } +} + +CICADATemplate::CICADATemplate(const CICADATemplate& cp) : GlobalCondition(cp.m_condName) { copy(cp); } + +CICADATemplate& CICADATemplate::operator=(const CICADATemplate& cp) { + copy(cp); + return *this; +} + +void CICADATemplate::print(std::ostream& myCout) const { + myCout << "\n CICADATemplate print..." << std::endl; + + GlobalCondition::print(myCout); + + int nObjects = nrObjects(); + + for (int i = 0; i < nObjects; ++i) { + myCout << std::endl; + myCout << " Template for object " << i << " [ hex ]" << std::endl; + myCout << " CICADAThreshold = " << std::hex << m_objectParameter[i].minCICADAThreshold << std::endl; + } + + myCout << std::dec << std::endl; +} + +void CICADATemplate::copy(const CICADATemplate& cp) { + m_condName = cp.condName(); + m_condCategory = cp.condCategory(); + m_condType = cp.condType(); + m_objectType = cp.objectType(); + m_condGEq = cp.condGEq(); + m_condChipNr = cp.condChipNr(); + m_condRelativeBx = cp.condRelativeBx(); + + m_objectParameter = *(cp.objectParameter()); +} + +std::ostream& operator<<(std::ostream& os, const CICADATemplate& result) { + result.print(os); + return os; +} diff --git a/L1Trigger/L1TGlobal/src/GlobalBoard.cc b/L1Trigger/L1TGlobal/src/GlobalBoard.cc index b026a2fd1af68..0b727a923b4f0 100644 --- a/L1Trigger/L1TGlobal/src/GlobalBoard.cc +++ b/L1Trigger/L1TGlobal/src/GlobalBoard.cc @@ -38,6 +38,7 @@ #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h" #include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" #include "L1Trigger/L1TGlobal/interface/AXOL1TLTemplate.h" +#include "L1Trigger/L1TGlobal/interface/CICADATemplate.h" #include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h" @@ -55,6 +56,7 @@ #include "L1Trigger/L1TGlobal/interface/EnergySumCondition.h" #include "L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h" #include "L1Trigger/L1TGlobal/interface/AXOL1TLCondition.h" +#include "L1Trigger/L1TGlobal/interface/CICADACondition.h" #include "L1Trigger/L1TGlobal/interface/ExternalCondition.h" #include "L1Trigger/L1TGlobal/interface/CorrCondition.h" #include "L1Trigger/L1TGlobal/interface/CorrThreeBodyCondition.h" @@ -144,6 +146,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, const edm::EDGetTokenT>& jetInputToken, const edm::EDGetTokenT>& sumInputToken, const edm::EDGetTokenT>& sumZdcInputToken, + const edm::EDGetTokenT& CICADAInputToken, const bool receiveEG, const int nrL1EG, const bool receiveTau, @@ -151,7 +154,8 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, const bool receiveJet, const int nrL1Jet, const bool receiveEtSums, - const bool receiveEtSumsZdc) { + const bool receiveEtSumsZdc, + const bool receiveCICADA) { if (m_verbosity) { LogDebug("L1TGlobal") << "\n**** Board receiving Calo Data "; } @@ -342,6 +346,19 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, } //end loop over Bx } } + if (receiveCICADA) { + edm::Handle cicadaScoreHandle; + iEvent.getByToken(CICADAInputToken, cicadaScoreHandle); + if (not cicadaScoreHandle.isValid()) { + if (m_verbosity) { + edm::LogWarning("L1Tglobal") << "\nWarning: Input tag for the CICADA score" + << "\nrequested in configuration, but not found in the event.\n" + << "\nSetting score to 0.0"; + setCICADAScore(0.0); + } + } else + setCICADAScore(*cicadaScoreHandle); + } } // receive data from Global Muon Trigger @@ -664,6 +681,21 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, //delete axol1tlCCondition; } break; + case CondCICADA: { + CICADACondition* cicadaCondition = new CICADACondition(itCond->second, this); + + cicadaCondition->setVerbosity(m_verbosity); + cicadaCondition->evaluateConditionStoreResult(iBxInEvent); + + cMapResults[itCond->first] = cicadaCondition; + + if (m_verbosity && m_isDebugEnabled) { + std::ostringstream myCout; + cicadaCondition->print(myCout); + + edm::LogWarning("L1TGlobal") << "cicadaCondition " << myCout.str(); + } + } break; case CondExternal: { ExternalCondition* extCondition = new ExternalCondition(itCond->second, this); @@ -1177,6 +1209,7 @@ void l1t::GlobalBoard::resetCalo() { m_candL1Jet->clear(); m_candL1EtSum->clear(); m_candL1EtSumZdc->clear(); + m_cicadaScore = 0.0; m_candL1EG->setBXRange(m_bxFirst_, m_bxLast_); m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_); diff --git a/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc b/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc index 64ff03b9fff8c..d6e7293445221 100644 --- a/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc +++ b/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc @@ -70,6 +70,7 @@ namespace { {"l1t::TypeZDCP", l1t::TypeZDCP}, {"l1t::TypeZDCM", l1t::TypeZDCM}, {"l1t::TypeAXOL1TL", l1t::TypeAXOL1TL}, + {"l1t::TypeCICADA", l1t::TypeCICADA}, {"l1t::TypeExternal", l1t::TypeExternal}, {nullptr, (l1t::GtConditionType)-1}, {"l1t::Type2corWithOverlapRemoval", l1t::Type2corWithOverlapRemoval}, @@ -94,6 +95,7 @@ namespace { {"l1t::CondEnergySum", l1t::CondEnergySum}, {"l1t::CondEnergySumZdc", l1t::CondEnergySumZdc}, {"l1t::CondAXOL1TL", l1t::CondAXOL1TL}, + {"l1t::CondCICADA", l1t::CondCICADA}, {"l1t::CondCorrelation", l1t::CondCorrelation}, {"l1t::CondCorrelationThreeBody", l1t::CondCorrelationThreeBody}, {"l1t::CondCorrelationWithOverlapRemoval", l1t::CondCorrelationWithOverlapRemoval}, diff --git a/L1Trigger/L1TGlobal/src/TriggerMenu.cc b/L1Trigger/L1TGlobal/src/TriggerMenu.cc index bcfa91ef80021..f1cbb108374ec 100644 --- a/L1Trigger/L1TGlobal/src/TriggerMenu.cc +++ b/L1Trigger/L1TGlobal/src/TriggerMenu.cc @@ -46,6 +46,7 @@ TriggerMenu::TriggerMenu( const std::vector >& vecEnergySumTemplateVal, const std::vector >& vecEnergySumZdcTemplateVal, const std::vector >& vecAXOL1TLTemplateVal, + const std::vector >& vecCICADATemplateVal, const std::vector >& vecExternalTemplateVal, const std::vector >& vecCorrelationTemplateVal, const std::vector >& vecCorrelationThreeBodyTemplateVal, @@ -65,6 +66,7 @@ TriggerMenu::TriggerMenu( m_vecEnergySumTemplate(vecEnergySumTemplateVal), m_vecEnergySumZdcTemplate(vecEnergySumZdcTemplateVal), m_vecAXOL1TLTemplate(vecAXOL1TLTemplateVal), + m_vecCICADATemplate(vecCICADATemplateVal), m_vecExternalTemplate(vecExternalTemplateVal), m_vecCorrelationTemplate(vecCorrelationTemplateVal), m_vecCorrelationThreeBodyTemplate(vecCorrelationThreeBodyTemplateVal), @@ -92,6 +94,7 @@ TriggerMenu::TriggerMenu(const TriggerMenu& rhs) { m_vecEnergySumTemplate = rhs.m_vecEnergySumTemplate; m_vecEnergySumZdcTemplate = rhs.m_vecEnergySumZdcTemplate; m_vecAXOL1TLTemplate = rhs.m_vecAXOL1TLTemplate; + m_vecCICADATemplate = rhs.m_vecCICADATemplate; m_vecExternalTemplate = rhs.m_vecExternalTemplate; m_vecCorrelationTemplate = rhs.m_vecCorrelationTemplate; @@ -142,6 +145,7 @@ TriggerMenu& TriggerMenu::operator=(const TriggerMenu& rhs) { m_vecEnergySumTemplate = rhs.m_vecEnergySumTemplate; m_vecEnergySumZdcTemplate = rhs.m_vecEnergySumZdcTemplate; m_vecAXOL1TLTemplate = rhs.m_vecAXOL1TLTemplate; + m_vecCICADATemplate = rhs.m_vecCICADATemplate; m_vecExternalTemplate = rhs.m_vecExternalTemplate; m_vecCorrelationTemplate = rhs.m_vecCorrelationTemplate; @@ -297,6 +301,26 @@ void TriggerMenu::buildGtConditionMap() { } } + // + size_t vecCICADASize = m_vecCICADATemplate.size(); + if (condMapSize < vecCICADASize) { + m_conditionMap.resize(vecCICADASize); + condMapSize = m_conditionMap.size(); + } + + chipNr = -1; + + for (std::vector >::iterator itCondOnChip = m_vecCICADATemplate.begin(); + itCondOnChip != m_vecCICADATemplate.end(); + itCondOnChip++) { + chipNr++; + + for (std::vector::iterator itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); + itCond++) { + (m_conditionMap.at(chipNr))[itCond->condName()] = &(*itCond); + } + } + /// DMP: Comment out unused templates for now // // @@ -421,6 +445,10 @@ void TriggerMenu::setVecAXOL1TLTemplate(const std::vector >& vecCICADATempl) { + m_vecCICADATemplate = vecCICADATempl; +} + void TriggerMenu::setVecExternalTemplate(const std::vector >& vecExternalTempl) { m_vecExternalTemplate = vecExternalTempl; } diff --git a/L1Trigger/L1TGlobal/src/classes.h b/L1Trigger/L1TGlobal/src/classes.h index 712f74571932e..678c9c91f72f0 100644 --- a/L1Trigger/L1TGlobal/src/classes.h +++ b/L1Trigger/L1TGlobal/src/classes.h @@ -10,5 +10,6 @@ namespace L1Trigger_L1TGlobal { std::vector dummy5; std::vector dummy6; std::vector dummy7; + std::vector dummy8; }; } // namespace L1Trigger_L1TGlobal diff --git a/L1Trigger/L1TGlobal/src/classes_def.xml b/L1Trigger/L1TGlobal/src/classes_def.xml index a8c49d4ce4456..f0e8bb1489161 100644 --- a/L1Trigger/L1TGlobal/src/classes_def.xml +++ b/L1Trigger/L1TGlobal/src/classes_def.xml @@ -28,6 +28,7 @@ + From a592e46b3b8e543354846b9cd6feebb9934f63f1 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Wed, 6 Mar 2024 09:01:03 -0600 Subject: [PATCH 04/17] Add CaloSummary/CICADA Unpacker Fix format Remove debug statement --- .../CaloSummaryUnpacker.cc | 47 +++++++++++++++++++ .../CaloSummaryUnpacker.h | 23 +++++++++ .../implementations_stage2/GTCollections.cc | 1 + .../implementations_stage2/GTCollections.h | 7 ++- .../plugins/implementations_stage2/GTSetup.cc | 5 ++ .../L1TObjectCollections.h | 1 + 6 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc new file mode 100644 index 0000000000000..42ca66e108f81 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc @@ -0,0 +1,47 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h" + +#include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" + +#include "L1TObjectCollections.h" + +#include "CaloSummaryUnpacker.h" +#include "GTSetup.h" + +#include + +float l1t::stage2::CaloSummaryUnpacker::processBitsToScore(const unsigned int bitsArray[]) { + float constructedScore = 0.0; + //All bits have been shifted to just left of the decimal point + //We need to convert them to float, shift them back to their proper position + //And then add them into the total + //The proper power is 4(-(bitIndex+1) + numCICADAWords/2) + // i.e. shift bitIndex to max out at half the number of CICADA words (indexed at 0) then count down + //And we shift by 4 bits a time, hence the factor of 4 + for (unsigned short bitIndex = 0; bitIndex < numCICADAWords; ++bitIndex) { + constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * (numCICADAWords / 2 - (bitIndex + 1))); + } + return constructedScore; +} + +bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) { + LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize(); + //convert to float and then multiply by a factor based on the index? + unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0}; + + auto res_ = static_cast(coll)->getCICADAScore(); + + for (unsigned int wordNum = 0; wordNum < nFrames; ++wordNum) { + uint32_t raw_data = block.payload().at(wordNum); + if (wordNum < numCICADAWords) { // check the first 4 frames for CICADA bits + cicadaBits[wordNum] = + (cicadaBitsPattern & raw_data) >> + 28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with + } + } + *res_ = processBitsToScore(cicadaBits); + + return true; +} + +DEFINE_L1T_UNPACKER(l1t::stage2::CaloSummaryUnpacker); diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h new file mode 100644 index 0000000000000..6c893bb8cee51 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h @@ -0,0 +1,23 @@ +#ifndef L1T_PACKER_STAGE2_CaloSummaryUnpacker_H +#define L1T_PACKER_STAGE2_CaloSummaryUnpacker_H + +#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" + +namespace l1t { + namespace stage2 { + class CaloSummaryUnpacker : public Unpacker { + public: + CaloSummaryUnpacker() = default; + ~CaloSummaryUnpacker() override = default; + + bool unpack(const Block& block, UnpackerCollections* coll) override; + float processBitsToScore(const unsigned int[]); + + static constexpr unsigned short numCICADAWords = 4; // We have 4 words/frames that contain CICADA bits + static constexpr unsigned int nFrames = 6; //My understanding is that we give 6 32 bit words to uGT + static constexpr unsigned int cicadaBitsPattern = + 0xF0000000; //first 4 bits of the first 4 words/frames are CICADA + }; + } // namespace stage2 +} // namespace l1t +#endif diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc index 8977b3c15907b..06386f96f2fb4 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc @@ -12,6 +12,7 @@ namespace l1t { event_.put(std::move(zdcsums_[0]), "EtSumZDC"); event_.put(std::move(jets_[0]), "Jet"); event_.put(std::move(taus_[0]), "Tau"); + event_.put(std::move(cicadaScore_), "CICADAScore"); for (int i = 1; i < 6; ++i) { event_.put(std::move(muons_[i]), "Muon" + std::to_string(i + 1)); event_.put(std::move(muonShowers_[i]), "MuonShower" + std::to_string(i + 1)); diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h index d27530a744dfb..01924c3ceeb41 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h @@ -18,7 +18,10 @@ namespace l1t { class GTCollections : public L1TObjectCollections { public: GTCollections(edm::Event& e) - : L1TObjectCollections(e), algBlk_(new GlobalAlgBlkBxCollection()), extBlk_(new GlobalExtBlkBxCollection()) { + : L1TObjectCollections(e), + cicadaScore_(std::make_unique(0.0)), + algBlk_(new GlobalAlgBlkBxCollection()), + extBlk_(new GlobalExtBlkBxCollection()) { std::generate(muons_.begin(), muons_.end(), [] { return std::make_unique(); }); std::generate( muonShowers_.begin(), muonShowers_.end(), [] { return std::make_unique(); }); @@ -40,6 +43,7 @@ namespace l1t { inline EtSumBxCollection* getZDCSums(const unsigned int copy) override { return zdcsums_[copy].get(); }; inline JetBxCollection* getJets(const unsigned int copy) override { return jets_[copy].get(); }; inline TauBxCollection* getTaus(const unsigned int copy) override { return taus_[copy].get(); }; + inline float* getCICADAScore() override { return cicadaScore_.get(); }; inline GlobalAlgBlkBxCollection* getAlgs() { return algBlk_.get(); }; inline GlobalExtBlkBxCollection* getExts() { return extBlk_.get(); }; @@ -52,6 +56,7 @@ namespace l1t { std::array, 6> zdcsums_; std::array, 6> jets_; std::array, 6> taus_; + std::unique_ptr cicadaScore_; std::unique_ptr algBlk_; std::unique_ptr extBlk_; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc index e48c229a6994b..89f43d95b8c5c 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc @@ -9,6 +9,7 @@ #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.h" #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/JetUnpacker.h" #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/TauUnpacker.h" +#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h" #include "GTSetup.h" @@ -62,6 +63,7 @@ namespace l1t { prod.produces("EtSumZDC"); prod.produces("Jet"); prod.produces("Tau"); + prod.produces("CICADAScore"); prod.produces(); prod.produces(); for (int i = 2; i < 7; ++i) { // Collections from boards 2-6 @@ -89,6 +91,8 @@ namespace l1t { auto zdc_unp = static_pointer_cast(UnpackerFactory::get()->make("stage2::ZDCUnpacker")); auto jet_unp = static_pointer_cast(UnpackerFactory::get()->make("stage2::JetUnpacker")); auto tau_unp = static_pointer_cast(UnpackerFactory::get()->make("stage2::TauUnpacker")); + auto caloSummary_unp = static_pointer_cast( + UnpackerFactory::get()->make("stage2::CaloSummaryUnpacker")); if (fw >= 0x10f2) { etsum_unp = static_pointer_cast( @@ -124,6 +128,7 @@ namespace l1t { res[16] = tau_unp; res[18] = tau_unp; res[20] = etsum_unp; + res[22] = caloSummary_unp; if (amc == 1) { // only unpack first uGT board for the external signal inputs (single copy) res[24] = ext_unp; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h index 69f5892f09aaf..3f6fd11600f56 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h @@ -26,6 +26,7 @@ namespace l1t { virtual EtSumBxCollection* getZDCSums(const unsigned int copy) { return nullptr; } virtual JetBxCollection* getJets(const unsigned int copy) { return nullptr; } virtual TauBxCollection* getTaus(const unsigned int copy) { return nullptr; } + virtual float* getCICADAScore() { return nullptr; } virtual EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) { return nullptr; }; }; From 79cdad4df7851a392aa36a405016fd64a05b53a2 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Sun, 14 Apr 2024 08:54:22 -0500 Subject: [PATCH 05/17] Update CICADA emulator element pieces to create BX Vectors This change is done in preparation for updating the unpacker to handle multiple BX's worth of CICADA information --- DataFormats/L1CaloTrigger/interface/CICADA.h | 10 ++++++++++ DataFormats/L1CaloTrigger/src/classes.h | 1 + DataFormats/L1CaloTrigger/src/classes_def.xml | 4 ++++ L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc | 10 ++++++---- L1Trigger/L1TGlobal/interface/GlobalBoard.h | 2 +- L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc | 2 +- L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h | 2 +- L1Trigger/L1TGlobal/src/CICADACondition.cc | 2 +- L1Trigger/L1TGlobal/src/GlobalBoard.cc | 6 +++--- 9 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 DataFormats/L1CaloTrigger/interface/CICADA.h diff --git a/DataFormats/L1CaloTrigger/interface/CICADA.h b/DataFormats/L1CaloTrigger/interface/CICADA.h new file mode 100644 index 0000000000000..692975df2f3e0 --- /dev/null +++ b/DataFormats/L1CaloTrigger/interface/CICADA.h @@ -0,0 +1,10 @@ +#ifndef DataFormats_L1Trigger_CICADA_h +#define DataFormats_L1Trigger_CICADA_h + +#include "DataFormats/L1Trigger/interface/BXVector.h" + +namespace l1t { + typedef BXVector CICADABxCollection; +} + +#endif diff --git a/DataFormats/L1CaloTrigger/src/classes.h b/DataFormats/L1CaloTrigger/src/classes.h index 69b17d865a4b1..c26cbf160df7f 100644 --- a/DataFormats/L1CaloTrigger/src/classes.h +++ b/DataFormats/L1CaloTrigger/src/classes.h @@ -2,3 +2,4 @@ #include #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "DataFormats/Common/interface/Wrapper.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" diff --git a/DataFormats/L1CaloTrigger/src/classes_def.xml b/DataFormats/L1CaloTrigger/src/classes_def.xml index 3793915652f34..832f2b50b57ff 100644 --- a/DataFormats/L1CaloTrigger/src/classes_def.xml +++ b/DataFormats/L1CaloTrigger/src/classes_def.xml @@ -13,4 +13,8 @@ + + + + diff --git a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc index 4237afee3dcb8..bf8ce9f0abc42 100644 --- a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc +++ b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc @@ -51,6 +51,7 @@ #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" #include "DataFormats/Math/interface/LorentzVector.h" @@ -166,7 +167,7 @@ L1TCaloSummary::L1TCaloSummary(const edm::ParameterSet& iConfig) //anomaly trigger loading model = loader.load_model(); - produces("CICADAScore"); + produces("CICADAScore"); } // @@ -180,7 +181,8 @@ void L1TCaloSummary::produce(edm::Event& iEvent, const edm::Event std::unique_ptr bJetCands(new L1JetParticleCollection); - std::unique_ptr CICADAScore = std::make_unique(); + std::unique_ptr CICADAScore = std::make_unique(); + CICADAScore->setBXRange(-2,2); UCTGeometry g; @@ -254,10 +256,10 @@ void L1TCaloSummary::produce(edm::Event& iEvent, const edm::Event model->predict(); model->read_result(modelResult); - *CICADAScore = modelResult[0].to_float(); + CICADAScore->push_back(0, modelResult[0].to_float()); if (overwriteWithTestPatterns) - edm::LogInfo("L1TCaloSummary") << "Test Pattern Output: " << *CICADAScore; + edm::LogInfo("L1TCaloSummary") << "Test Pattern Output: " << CICADAScore->at(0, 0); summaryCard.setRegionData(inputRegions); diff --git a/L1Trigger/L1TGlobal/interface/GlobalBoard.h b/L1Trigger/L1TGlobal/interface/GlobalBoard.h index 7bb6266a57e6b..f44c485f629df 100644 --- a/L1Trigger/L1TGlobal/interface/GlobalBoard.h +++ b/L1Trigger/L1TGlobal/interface/GlobalBoard.h @@ -69,7 +69,7 @@ namespace l1t { const edm::EDGetTokenT>&, const edm::EDGetTokenT>&, const edm::EDGetTokenT>&, - const edm::EDGetTokenT&, + const edm::EDGetTokenT>&, const bool receiveEG, const int nrL1EG, const bool receiveTau, diff --git a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc index 2ad9a5b7be06f..b082df516787d 100644 --- a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc +++ b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc @@ -139,7 +139,7 @@ L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet) m_jetInputToken = consumes>(m_jetInputTag); m_sumInputToken = consumes>(m_sumInputTag); m_sumZdcInputToken = consumes>(m_sumZdcInputTag); - m_CICADAInputToken = consumes(m_CICADAInputTag); + m_CICADAInputToken = consumes>(m_CICADAInputTag); m_muInputToken = consumes>(m_muInputTag); if (m_useMuonShowers) m_muShowerInputToken = consumes>(m_muShowerInputTag); diff --git a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h index 65260298bab22..1b6928c521e58 100644 --- a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h +++ b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h @@ -133,7 +133,7 @@ class L1TGlobalProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> m_jetInputToken; edm::EDGetTokenT> m_sumInputToken; edm::EDGetTokenT> m_sumZdcInputToken; - edm::EDGetTokenT m_CICADAInputToken; + edm::EDGetTokenT> m_CICADAInputToken; /// input tag for external conditions edm::InputTag m_extInputTag; diff --git a/L1Trigger/L1TGlobal/src/CICADACondition.cc b/L1Trigger/L1TGlobal/src/CICADACondition.cc index 169aa1dba1964..2fec836454ad6 100644 --- a/L1Trigger/L1TGlobal/src/CICADACondition.cc +++ b/L1Trigger/L1TGlobal/src/CICADACondition.cc @@ -41,7 +41,7 @@ l1t::CICADACondition& l1t::CICADACondition::operator=(const l1t::CICADACondition const bool l1t::CICADACondition::evaluateCondition(const int bxEval) const { bool condResult = false; - const float cicadaScore = m_uGtB->getCICADAScore(); //needs to be implemented + const float cicadaScore = m_uGtB->getCICADAScore(); // This gets rid of a GT emulator convention "iCondition". // This usually indexes the next line, which is somewhat concerning diff --git a/L1Trigger/L1TGlobal/src/GlobalBoard.cc b/L1Trigger/L1TGlobal/src/GlobalBoard.cc index 0b727a923b4f0..ce15910a3b4f8 100644 --- a/L1Trigger/L1TGlobal/src/GlobalBoard.cc +++ b/L1Trigger/L1TGlobal/src/GlobalBoard.cc @@ -146,7 +146,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, const edm::EDGetTokenT>& jetInputToken, const edm::EDGetTokenT>& sumInputToken, const edm::EDGetTokenT>& sumZdcInputToken, - const edm::EDGetTokenT& CICADAInputToken, + const edm::EDGetTokenT>& CICADAInputToken, const bool receiveEG, const int nrL1EG, const bool receiveTau, @@ -347,7 +347,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, } } if (receiveCICADA) { - edm::Handle cicadaScoreHandle; + edm::Handle> cicadaScoreHandle; iEvent.getByToken(CICADAInputToken, cicadaScoreHandle); if (not cicadaScoreHandle.isValid()) { if (m_verbosity) { @@ -357,7 +357,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, setCICADAScore(0.0); } } else - setCICADAScore(*cicadaScoreHandle); + setCICADAScore(cicadaScoreHandle->at(0, 0)); //CICADA emulation will only provide a central BX, and one value. Unpacking may have more values, but that can't be guaranteed. } } From 022f03bb7c12be460b941ed28eeb040a90713345 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Sun, 14 Apr 2024 08:54:48 -0500 Subject: [PATCH 06/17] Update CICADA model to 2.1.2, the model going online at P5 --- .../L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py b/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py index 4d7c51e0c4f99..6ee4753fc5d73 100644 --- a/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py +++ b/L1Trigger/L1TCaloLayer1/python/simCaloStage2Layer1Summary_cfi.py @@ -2,7 +2,7 @@ from L1Trigger.L1TCaloLayer1.CICADATestPatterns import standardCICADATestPatterns -simCaloStage2Layer1Summary = cms.EDProducer('L1TCaloSummary_CICADA_vXp1p1', +simCaloStage2Layer1Summary = cms.EDProducer('L1TCaloSummary_CICADA_vXp1p2', nPumBins = cms.uint32(18), pumLUT00n= cms.vdouble(0.43, 0.32, 0.29, 0.36, 0.33, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25), pumLUT00p= cms.vdouble(0.45, 0.32, 0.29, 0.35, 0.31, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25), @@ -50,7 +50,7 @@ verbose = cms.bool(False), # See UCTLayer1.hh for firmware version firmwareVersion = cms.int32(1), - CICADAModelVersion = cms.string("CICADA_v1p1p1"), + CICADAModelVersion = cms.string("CICADAModel_v2p1p2"), useTestPatterns = cms.bool(False), testPatterns = standardCICADATestPatterns ) From 77dd1b45fb96c157389cfe0daac10c204e03fe75 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Sun, 14 Apr 2024 08:56:25 -0500 Subject: [PATCH 07/17] Apply code format --- L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc | 2 +- L1Trigger/L1TGlobal/src/GlobalBoard.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc index bf8ce9f0abc42..324a6f99a362a 100644 --- a/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc +++ b/L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc @@ -182,7 +182,7 @@ void L1TCaloSummary::produce(edm::Event& iEvent, const edm::Event std::unique_ptr bJetCands(new L1JetParticleCollection); std::unique_ptr CICADAScore = std::make_unique(); - CICADAScore->setBXRange(-2,2); + CICADAScore->setBXRange(-2, 2); UCTGeometry g; diff --git a/L1Trigger/L1TGlobal/src/GlobalBoard.cc b/L1Trigger/L1TGlobal/src/GlobalBoard.cc index ce15910a3b4f8..523bcee2873d1 100644 --- a/L1Trigger/L1TGlobal/src/GlobalBoard.cc +++ b/L1Trigger/L1TGlobal/src/GlobalBoard.cc @@ -357,7 +357,9 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, setCICADAScore(0.0); } } else - setCICADAScore(cicadaScoreHandle->at(0, 0)); //CICADA emulation will only provide a central BX, and one value. Unpacking may have more values, but that can't be guaranteed. + setCICADAScore(cicadaScoreHandle->at( + 0, + 0)); //CICADA emulation will only provide a central BX, and one value. Unpacking may have more values, but that can't be guaranteed. } } From e045296498cd13e40cb19344c23854987df82134 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Sun, 14 Apr 2024 13:13:43 -0500 Subject: [PATCH 08/17] Update CICADA unpacker draft to unpack all available BXs --- EventFilter/L1TRawToDigi/BuildFile.xml | 1 + .../CaloSummaryUnpacker.cc | 38 ++++++++++++++----- .../CaloSummaryUnpacker.h | 4 +- .../implementations_stage2/GTCollections.h | 7 ++-- .../L1TObjectCollections.h | 3 +- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/EventFilter/L1TRawToDigi/BuildFile.xml b/EventFilter/L1TRawToDigi/BuildFile.xml index 1f7ab7c054201..f69ff72d87fb7 100644 --- a/EventFilter/L1TRawToDigi/BuildFile.xml +++ b/EventFilter/L1TRawToDigi/BuildFile.xml @@ -4,6 +4,7 @@ + diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc index 42ca66e108f81..3b500e1c7a5f8 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc @@ -5,6 +5,8 @@ #include "L1TObjectCollections.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" + #include "CaloSummaryUnpacker.h" #include "GTSetup.h" @@ -19,27 +21,45 @@ float l1t::stage2::CaloSummaryUnpacker::processBitsToScore(const unsigned int bi // i.e. shift bitIndex to max out at half the number of CICADA words (indexed at 0) then count down //And we shift by 4 bits a time, hence the factor of 4 for (unsigned short bitIndex = 0; bitIndex < numCICADAWords; ++bitIndex) { - constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * (numCICADAWords / 2 - (bitIndex + 1))); + constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * ((numCICADAWords / 2) - (bitIndex + 1))); } return constructedScore; } bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) { LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize(); - //convert to float and then multiply by a factor based on the index? - unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0}; + + //Just a few things to help us handle the number of BXs + //Strictly, we should generally get five BXs, starting at -2, and going to 2 + //With the central BX at 0. The frames count up from -2 + int nBX = int(ceil(block.header().getSize() / nFramesPerEvent)); + int firstBX = (nBX / 2) - nBX + 1; + int lastBX = nBX / 2; + int processedBXs = 0; //This will just help us keep track of what words we are grabbing + auto res_ = static_cast(coll)->getCICADAScore(); + res_ -> setBXRange(firstBX, lastBX); + + for (int bx = firstBX; bx <= lastBX; ++bx){ + //convert to float and then multiply by a factor based on the index? + unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0}; - for (unsigned int wordNum = 0; wordNum < nFrames; ++wordNum) { - uint32_t raw_data = block.payload().at(wordNum); - if (wordNum < numCICADAWords) { // check the first 4 frames for CICADA bits + for (unsigned int wordNum = 0; wordNum < numCICADAWords; ++wordNum) { + unsigned short wordLocation = processedBXs*nFramesPerEvent + wordNum; //Calculate the location of the needed CICADA word based on how many BXs we have already handled, and how many words of CICADA we have already grabbed. + //Frame 0 of a bx are the most significant integer bits + //Frame 1 of a bx are the least significant integer bits + //Frame 2 of a bx are the most significant decimal bits + //Frame 3 of a bx are the lest significant decimal bits + //Frames 4&5 are unused (by CICADA), they are reserved. + uint32_t raw_data = block.payload().at(wordLocation); cicadaBits[wordNum] = - (cicadaBitsPattern & raw_data) >> - 28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with + (cicadaBitsPattern & raw_data) >> + 28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with later } + res_->push_back(bx, processBitsToScore(cicadaBits)); //Now we insert CICADA into the proper BX, after a quick utility constructs a number from the 4 sets of bits. + ++processedBXs; //index BXs } - *res_ = processBitsToScore(cicadaBits); return true; } diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h index 6c893bb8cee51..ab631b70ed99d 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h @@ -12,9 +12,9 @@ namespace l1t { bool unpack(const Block& block, UnpackerCollections* coll) override; float processBitsToScore(const unsigned int[]); - + static constexpr unsigned short numCICADAWords = 4; // We have 4 words/frames that contain CICADA bits - static constexpr unsigned int nFrames = 6; //My understanding is that we give 6 32 bit words to uGT + static constexpr unsigned int nFramesPerEvent = 6; //Calo Summary outputs 6 32 bit words (or frames in uGT parlance) per event. static constexpr unsigned int cicadaBitsPattern = 0xF0000000; //first 4 bits of the first 4 words/frames are CICADA }; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h index 01924c3ceeb41..547019e4fa55f 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h @@ -6,6 +6,7 @@ #include "DataFormats/L1Trigger/interface/Jet.h" #include "DataFormats/L1Trigger/interface/Tau.h" #include "DataFormats/L1Trigger/interface/Muon.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" #include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h" #include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h" @@ -19,7 +20,7 @@ namespace l1t { public: GTCollections(edm::Event& e) : L1TObjectCollections(e), - cicadaScore_(std::make_unique(0.0)), + cicadaScore_(std::make_unique()), algBlk_(new GlobalAlgBlkBxCollection()), extBlk_(new GlobalExtBlkBxCollection()) { std::generate(muons_.begin(), muons_.end(), [] { return std::make_unique(); }); @@ -43,7 +44,7 @@ namespace l1t { inline EtSumBxCollection* getZDCSums(const unsigned int copy) override { return zdcsums_[copy].get(); }; inline JetBxCollection* getJets(const unsigned int copy) override { return jets_[copy].get(); }; inline TauBxCollection* getTaus(const unsigned int copy) override { return taus_[copy].get(); }; - inline float* getCICADAScore() override { return cicadaScore_.get(); }; + inline CICADABxCollection* getCICADAScore() override { return cicadaScore_.get(); }; inline GlobalAlgBlkBxCollection* getAlgs() { return algBlk_.get(); }; inline GlobalExtBlkBxCollection* getExts() { return extBlk_.get(); }; @@ -56,7 +57,7 @@ namespace l1t { std::array, 6> zdcsums_; std::array, 6> jets_; std::array, 6> taus_; - std::unique_ptr cicadaScore_; + std::unique_ptr cicadaScore_; std::unique_ptr algBlk_; std::unique_ptr extBlk_; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h index 3f6fd11600f56..40ed4d5b244b2 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h @@ -7,6 +7,7 @@ #include "DataFormats/L1Trigger/interface/Tau.h" #include "DataFormats/L1Trigger/interface/Muon.h" #include "DataFormats/L1Trigger/interface/MuonShower.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" @@ -26,7 +27,7 @@ namespace l1t { virtual EtSumBxCollection* getZDCSums(const unsigned int copy) { return nullptr; } virtual JetBxCollection* getJets(const unsigned int copy) { return nullptr; } virtual TauBxCollection* getTaus(const unsigned int copy) { return nullptr; } - virtual float* getCICADAScore() { return nullptr; } + virtual CICADABxCollection* getCICADAScore() { return nullptr; } virtual EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) { return nullptr; }; }; From 8d28d38eb04c9b7c90ab53faeb8109783eaf7c44 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Sun, 14 Apr 2024 13:15:23 -0500 Subject: [PATCH 09/17] code format --- .../CaloSummaryUnpacker.cc | 22 +++++++++++-------- .../CaloSummaryUnpacker.h | 5 +++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc index 3b500e1c7a5f8..faf694e411d98 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc @@ -35,18 +35,19 @@ bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollec int nBX = int(ceil(block.header().getSize() / nFramesPerEvent)); int firstBX = (nBX / 2) - nBX + 1; int lastBX = nBX / 2; - int processedBXs = 0; //This will just help us keep track of what words we are grabbing - + int processedBXs = 0; //This will just help us keep track of what words we are grabbing auto res_ = static_cast(coll)->getCICADAScore(); - res_ -> setBXRange(firstBX, lastBX); + res_->setBXRange(firstBX, lastBX); - for (int bx = firstBX; bx <= lastBX; ++bx){ + for (int bx = firstBX; bx <= lastBX; ++bx) { //convert to float and then multiply by a factor based on the index? unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0}; for (unsigned int wordNum = 0; wordNum < numCICADAWords; ++wordNum) { - unsigned short wordLocation = processedBXs*nFramesPerEvent + wordNum; //Calculate the location of the needed CICADA word based on how many BXs we have already handled, and how many words of CICADA we have already grabbed. + unsigned short wordLocation = + processedBXs * nFramesPerEvent + + wordNum; //Calculate the location of the needed CICADA word based on how many BXs we have already handled, and how many words of CICADA we have already grabbed. //Frame 0 of a bx are the most significant integer bits //Frame 1 of a bx are the least significant integer bits //Frame 2 of a bx are the most significant decimal bits @@ -54,11 +55,14 @@ bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollec //Frames 4&5 are unused (by CICADA), they are reserved. uint32_t raw_data = block.payload().at(wordLocation); cicadaBits[wordNum] = - (cicadaBitsPattern & raw_data) >> - 28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with later + (cicadaBitsPattern & raw_data) >> + 28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with later } - res_->push_back(bx, processBitsToScore(cicadaBits)); //Now we insert CICADA into the proper BX, after a quick utility constructs a number from the 4 sets of bits. - ++processedBXs; //index BXs + res_->push_back( + bx, + processBitsToScore( + cicadaBits)); //Now we insert CICADA into the proper BX, after a quick utility constructs a number from the 4 sets of bits. + ++processedBXs; //index BXs } return true; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h index ab631b70ed99d..384e5e4494889 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h @@ -12,9 +12,10 @@ namespace l1t { bool unpack(const Block& block, UnpackerCollections* coll) override; float processBitsToScore(const unsigned int[]); - + static constexpr unsigned short numCICADAWords = 4; // We have 4 words/frames that contain CICADA bits - static constexpr unsigned int nFramesPerEvent = 6; //Calo Summary outputs 6 32 bit words (or frames in uGT parlance) per event. + static constexpr unsigned int nFramesPerEvent = + 6; //Calo Summary outputs 6 32 bit words (or frames in uGT parlance) per event. static constexpr unsigned int cicadaBitsPattern = 0xF0000000; //first 4 bits of the first 4 words/frames are CICADA }; From 1e4041d259564700548169cb380e92b50854e9ca Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Sun, 14 Apr 2024 17:10:58 -0500 Subject: [PATCH 10/17] Fix bad "produces" specification --- .../L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc index 89f43d95b8c5c..7c569b515a9c2 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc @@ -63,7 +63,7 @@ namespace l1t { prod.produces("EtSumZDC"); prod.produces("Jet"); prod.produces("Tau"); - prod.produces("CICADAScore"); + prod.produces("CICADAScore"); prod.produces(); prod.produces(); for (int i = 2; i < 7; ++i) { // Collections from boards 2-6 From 98984f36a0a403105e4972b56882368db57a9d8a Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Tue, 25 Jun 2024 01:10:58 -0500 Subject: [PATCH 11/17] Remove CICADA set to 0 from verbosity block --- L1Trigger/L1TGlobal/src/GlobalBoard.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/L1TGlobal/src/GlobalBoard.cc b/L1Trigger/L1TGlobal/src/GlobalBoard.cc index 523bcee2873d1..b358bc10bf41a 100644 --- a/L1Trigger/L1TGlobal/src/GlobalBoard.cc +++ b/L1Trigger/L1TGlobal/src/GlobalBoard.cc @@ -354,8 +354,8 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, edm::LogWarning("L1Tglobal") << "\nWarning: Input tag for the CICADA score" << "\nrequested in configuration, but not found in the event.\n" << "\nSetting score to 0.0"; - setCICADAScore(0.0); } + setCICADAScore(0.0); } else setCICADAScore(cicadaScoreHandle->at( 0, From 6d68034b7f9c4fd9d36c880cf951fd63413778d2 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Tue, 25 Jun 2024 07:36:33 -0500 Subject: [PATCH 12/17] Add empty vector guard to CICADA/uGT emulation --- L1Trigger/L1TGlobal/src/GlobalBoard.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/L1Trigger/L1TGlobal/src/GlobalBoard.cc b/L1Trigger/L1TGlobal/src/GlobalBoard.cc index b358bc10bf41a..fb6a1159cbbf7 100644 --- a/L1Trigger/L1TGlobal/src/GlobalBoard.cc +++ b/L1Trigger/L1TGlobal/src/GlobalBoard.cc @@ -356,10 +356,18 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, << "\nSetting score to 0.0"; } setCICADAScore(0.0); - } else + } else if (cicadaScoreHandle->isEmpty(0)) { + if (m_verbosity) { + edm::LogWarning("L1Tglobal") + << "\nWarning: CICADA score had a valid input tag, but an empty BX collection" + << "\nThe CICADA score will be filled with 0.0 to prevent any failure of uGT emulation"; + } + setCICADAScore(0.0); + } else { setCICADAScore(cicadaScoreHandle->at( 0, 0)); //CICADA emulation will only provide a central BX, and one value. Unpacking may have more values, but that can't be guaranteed. + } } } From fb600f7f6e1582681b05780034e3e2a7cde38f19 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 24 May 2024 04:26:22 -0500 Subject: [PATCH 13/17] Add unpacker for L1T Calo Layer 1 to unpack FED 1356 to retrieve the CICADA score from AMC Slot 7 --- .../implementations_stage2/CICADAUnpacker.cc | 55 +++++++++++++++++++ .../implementations_stage2/CICADAUnpacker.h | 19 +++++++ .../CaloLayer1Collections.cc | 1 + .../CaloLayer1Collections.h | 6 +- .../implementations_stage2/CaloLayer1Setup.cc | 6 ++ .../CaloSummaryCollections.cc | 9 +++ .../CaloSummaryCollections.h | 23 ++++++++ 7 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc new file mode 100644 index 0000000000000..ee1d613bf6564 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -0,0 +1,55 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h" + +#include "CICADAUnpacker.h" + +#include + +using namespace edm; + +namespace l1t { + namespace stage2 { + bool CICADAUnpacker::unpack(const Block& block, UnpackerCollections* coll) { + LogDebug("L1T") << "Block Size = " << block.header().getSize(); + LogDebug("L1T") << "Board ID = " << block.amc().getBoardID(); + + auto res = static_cast(coll)->getCICADABxCollection(); + // default BX range to trigger standard -2 to 2 + // Even though CICADA will never have BX information + // And everything gets put in BX 0 + res->setBXRange(-2, 2); + + int amc_slot = block.amc().getAMCNumber(); + if (not(amc_slot == 7)) { + throw cms::Exception("CICADAUnpacker") + << "Calo Summary (CICADA) unpacker is unpacking an unexpected AMC. Expected AMC number 7, got AMC number " + << amc_slot << std::endl; + return false; + } else { + std::vector cicadaWords = {0, 0, 0, 0}; + //the first 4 words are CICADA words + for (uint32_t i = 0; i < 4; ++i) { + cicadaWords.at(i) = ((block.payload().at(i)) >> 28); + } + + float cicadaScore = convertCICADABitsToFloat(cicadaWords); + res->push_back(0, cicadaScore); + return true; + } + } + + //convert the 4 CICADA bits/words into a proper number + float CICADAUnpacker::convertCICADABitsToFloat(const std::vector& cicadaBits) { + uint32_t tempResult = 0; + tempResult |= cicadaBits.at(0) << 12; + tempResult |= cicadaBits.at(1) << 8; + tempResult |= cicadaBits.at(2) << 4; + tempResult |= cicadaBits.at(3); + float result = 0.0; + result = (float)tempResult * pow(2.0, -8); + return result; + } + } // namespace stage2 +} // namespace l1t + +DEFINE_L1T_UNPACKER(l1t::stage2::CICADAUnpacker); diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h new file mode 100644 index 0000000000000..8c6927d68700a --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h @@ -0,0 +1,19 @@ +#ifndef EventFilter_L1TRawToDigi_CICADAUnpacker_h +#define EventFilter_L1TRawToDigi_CICADAUnpacker_h + +#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" +#include "CaloLayer1Collections.h" + +namespace l1t { + namespace stage2 { + class CICADAUnpacker : public Unpacker { + public: + bool unpack(const Block& block, UnpackerCollections* coll) override; + + private: + float convertCICADABitsToFloat(const std::vector&); + }; + } // namespace stage2 +} // namespace l1t + +#endif diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc index 2e6ce53fdecab..4ccf20081ee38 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc @@ -12,6 +12,7 @@ namespace l1t { for (int i = 0; i < 5; ++i) { event_.put(std::move(ecalDigisBx_[i]), "EcalDigisBx" + std::to_string(i + 1)); } + event_.put(std::move(cicadaDigis_), "CICADAScore"); } } // namespace stage2 } // namespace l1t diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h index a0630d46cb881..ce1be86054b13 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h @@ -6,6 +6,7 @@ #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h" #include "L1TObjectCollections.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" namespace l1t { namespace stage2 { @@ -15,7 +16,8 @@ namespace l1t { : L1TObjectCollections(e), ecalDigis_(new EcalTrigPrimDigiCollection()), hcalDigis_(new HcalTrigPrimDigiCollection()), - caloRegions_(new L1CaloRegionCollection()) { + caloRegions_(new L1CaloRegionCollection()), + cicadaDigis_(std::make_unique()) { // Pre-allocate: // 72 iPhi values // 28 iEta values in Ecal, 28 + 12 iEta values in Hcal + HF @@ -37,6 +39,7 @@ namespace l1t { inline EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) override { return ecalDigisBx_[copy].get(); }; + inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); }; private: std::unique_ptr ecalDigis_; @@ -44,6 +47,7 @@ namespace l1t { std::unique_ptr caloRegions_; std::array, 5> ecalDigisBx_; + std::unique_ptr cicadaDigis_; }; } // namespace stage2 } // namespace l1t diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc index 95b1631bcfeda..d0c417d427074 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc @@ -6,6 +6,8 @@ #include "CaloLayer1Setup.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" + namespace l1t { namespace stage2 { std::unique_ptr CaloLayer1Setup::registerConsumes(const edm::ParameterSet& cfg, @@ -58,6 +60,7 @@ namespace l1t { for (int i = 0; i < 5; ++i) { prod.produces("EcalDigisBx" + std::to_string(i + 1)); } + prod.produces("CICADAScore"); } std::unique_ptr CaloLayer1Setup::getCollections(edm::Event& e) { @@ -72,6 +75,9 @@ namespace l1t { if (board < 18) { res[0] = UnpackerFactory::get()->make("stage2::CaloLayer1Unpacker"); } + if (fed == 1356 && amc == 7) { //calo summary board + res[0] = UnpackerFactory::get()->make("stage2::CICADAUnpacker"); + } } return res; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc new file mode 100644 index 0000000000000..bedcfb42c9237 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc @@ -0,0 +1,9 @@ +#include "FWCore/Framework/interface/Event.h" + +#include "CaloSummaryCollections.h" + +namespace l1t { + namespace stage2 { + CaloSummaryCollections::~CaloSummaryCollections() { event_.put(std::move(cicadaDigis_)); } + } // namespace stage2 +} // namespace l1t diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h new file mode 100644 index 0000000000000..543d284d16ec7 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h @@ -0,0 +1,23 @@ +#ifndef EventFilter_L1TRawToDigi_CaloSummaryCollections_h +#define EventFilter_L1TRawToDigi_CaloSummaryCollections_h + +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" + +#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h" + +namespace l1t { + namespace stage2 { + class CaloSummaryCollections : public UnpackerCollections { + public: + CaloSummaryCollections(edm::Event& e) + : UnpackerCollections(e), cicadaDigis_(std::make_unique()){}; + ~CaloSummaryCollections() override; + inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); }; + + private: + std::unique_ptr cicadaDigis_; + }; + } // namespace stage2 +} // namespace l1t + +#endif From f67febb42dcb3f057caa7b5ab1da709d2acee819 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 21 Jun 2024 10:13:17 -0500 Subject: [PATCH 14/17] Change CICADA unpacker to read the last 4 words instead of first 4 --- .../plugins/implementations_stage2/CICADAUnpacker.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc index ee1d613bf6564..202c112f83b69 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -27,9 +27,9 @@ namespace l1t { return false; } else { std::vector cicadaWords = {0, 0, 0, 0}; - //the first 4 words are CICADA words - for (uint32_t i = 0; i < 4; ++i) { - cicadaWords.at(i) = ((block.payload().at(i)) >> 28); + //the last 4 words are CICADA words + for (uint32_t i = 2; i < 6; ++i) { + cicadaWords.at(i-2) = ((block.payload().at(i)) >> 28); } float cicadaScore = convertCICADABitsToFloat(cicadaWords); From 81c3d4f7cb26cc23bc700f9bbb4be89b0b5ea05e Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 21 Jun 2024 10:33:09 -0500 Subject: [PATCH 15/17] apply formatting --- .../plugins/implementations_stage2/CICADAUnpacker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc index 202c112f83b69..f325e32f2386b 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -29,7 +29,7 @@ namespace l1t { std::vector cicadaWords = {0, 0, 0, 0}; //the last 4 words are CICADA words for (uint32_t i = 2; i < 6; ++i) { - cicadaWords.at(i-2) = ((block.payload().at(i)) >> 28); + cicadaWords.at(i - 2) = ((block.payload().at(i)) >> 28); } float cicadaScore = convertCICADABitsToFloat(cicadaWords); From 57dace053439c517c695312870d316759b396ee9 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Wed, 26 Jun 2024 08:38:19 -0500 Subject: [PATCH 16/17] Simplify Calo Crate CICADA unpacking logic --- .../implementations_stage2/CICADAUnpacker.cc | 26 +++++-------------- .../implementations_stage2/CICADAUnpacker.h | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc index f325e32f2386b..f3a52e754c522 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -26,29 +26,17 @@ namespace l1t { << amc_slot << std::endl; return false; } else { - std::vector cicadaWords = {0, 0, 0, 0}; - //the last 4 words are CICADA words - for (uint32_t i = 2; i < 6; ++i) { - cicadaWords.at(i - 2) = ((block.payload().at(i)) >> 28); - } - - float cicadaScore = convertCICADABitsToFloat(cicadaWords); - res->push_back(0, cicadaScore); + const uint32_t* base = block.payload().data(); + //This differs slightly from uGT, in that we grab the first 4 bits + //of the last 4 words (still in first to last order) and arrange those + uint32_t word = (caloCrateCicadaBitsPattern & base[2]) >> 16 | (caloCrateCicadaBitsPattern & base[3]) >> 20 | + (caloCrateCicadaBitsPattern & base[4]) >> 24 | (caloCrateCicadaBitsPattern & base[5]) >> 28; + float score = static_cast(word) / 256.f; + res->push_back(0, score); return true; } } - //convert the 4 CICADA bits/words into a proper number - float CICADAUnpacker::convertCICADABitsToFloat(const std::vector& cicadaBits) { - uint32_t tempResult = 0; - tempResult |= cicadaBits.at(0) << 12; - tempResult |= cicadaBits.at(1) << 8; - tempResult |= cicadaBits.at(2) << 4; - tempResult |= cicadaBits.at(3); - float result = 0.0; - result = (float)tempResult * pow(2.0, -8); - return result; - } } // namespace stage2 } // namespace l1t diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h index 8c6927d68700a..a23c5440d1bea 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h @@ -11,7 +11,7 @@ namespace l1t { bool unpack(const Block& block, UnpackerCollections* coll) override; private: - float convertCICADABitsToFloat(const std::vector&); + static constexpr unsigned int caloCrateCicadaBitsPattern = 0xF0000000; //first 4 bits of the words are CICADA }; } // namespace stage2 } // namespace l1t From 594bb31dd9d1410f95e402e12c9d5d00c68884a9 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Wed, 26 Jun 2024 11:29:49 -0500 Subject: [PATCH 17/17] Fix mistaken bits convention --- .../plugins/implementations_stage2/CICADAUnpacker.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc index f3a52e754c522..a34e5156ee339 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -27,10 +27,9 @@ namespace l1t { return false; } else { const uint32_t* base = block.payload().data(); - //This differs slightly from uGT, in that we grab the first 4 bits - //of the last 4 words (still in first to last order) and arrange those - uint32_t word = (caloCrateCicadaBitsPattern & base[2]) >> 16 | (caloCrateCicadaBitsPattern & base[3]) >> 20 | - (caloCrateCicadaBitsPattern & base[4]) >> 24 | (caloCrateCicadaBitsPattern & base[5]) >> 28; + //First 4 bits of the first 4 words are CICADA bits + uint32_t word = (caloCrateCicadaBitsPattern & base[0]) >> 16 | (caloCrateCicadaBitsPattern & base[1]) >> 20 | + (caloCrateCicadaBitsPattern & base[2]) >> 24 | (caloCrateCicadaBitsPattern & base[3]) >> 28; float score = static_cast(word) / 256.f; res->push_back(0, score); return true;