From 1004f1c4050a19003f81882a59e0cab1a335d75e Mon Sep 17 00:00:00 2001 From: Christopher McGinn Date: Tue, 1 Aug 2023 22:02:46 +0200 Subject: [PATCH] New L1Trigger/L1TZDC package for ZDC trigger emulation and uGT updates for interfacing Commits defining the new L1Trigger/L1TZDC package in cmssw for L1 ZDC emulation, primarily via plugins/L1TZDCProducer.cc. In addition, the uGT has been fully overhauled by @elfontan to interface with the L1 ZDC emulator with the L1Trigger/L1TGlobal package defining the global trigger. Some additional modifications are made to various DataFormats to include the new ZDCP and ZDCM EtSums and L1Trigger/L1TCalorimeter package modified such that the CaloParamsHelper pickes up commands important for the ZDC emulator. --- .../L1TGlobal/interface/GlobalObject.h | 2 + DataFormats/L1TGlobal/src/GlobalObject.cc | 10 + DataFormats/L1Trigger/interface/EtSum.h | 2 + .../interface/CaloParamsHelper.h | 8 +- .../plugins/L1TCaloStage2ParamsESProducer.cc | 6 + .../L1TCalorimeter/python/caloParams_cfi.py | 3 +- .../interface/EnergySumZdcCondition.h | 86 ++++++ .../interface/EnergySumZdcTemplate.h | 79 ++++++ L1Trigger/L1TGlobal/interface/GlobalBoard.h | 12 +- .../L1TGlobal/interface/GlobalDefinitions.h | 3 + L1Trigger/L1TGlobal/interface/TriggerMenu.h | 11 + .../L1TGlobal/plugins/L1TGlobalProducer.cc | 10 +- .../L1TGlobal/plugins/L1TGlobalProducer.h | 6 +- .../L1TGlobal/plugins/TriggerMenuParser.cc | 163 ++++++++++- .../L1TGlobal/plugins/TriggerMenuParser.h | 11 + .../L1TGlobal/python/simGtStage2Digis_cfi.py | 1 + L1Trigger/L1TGlobal/src/EnergySumCondition.cc | 10 + .../L1TGlobal/src/EnergySumZdcCondition.cc | 183 +++++++++++++ .../L1TGlobal/src/EnergySumZdcTemplate.cc | 105 +++++++ L1Trigger/L1TGlobal/src/GlobalBoard.cc | 93 +++++-- L1Trigger/L1TGlobal/src/GlobalCondition.cc | 8 + L1Trigger/L1TGlobal/src/GlobalDefinitions.cc | 3 + L1Trigger/L1TGlobal/src/TriggerMenu.cc | 28 ++ L1Trigger/L1TGlobal/src/classes_def.xml | 1 + .../interface/L1AnalysisL1Upgrade.h | 7 + .../interface/L1AnalysisL1UpgradeDataFormat.h | 21 +- .../plugins/L1UpgradeTreeProducer.cc | 14 +- .../L1TNtuples/python/L1NtupleEMU_cff.py | 5 + .../L1TNtuples/python/L1NtupleRAW_cff.py | 2 + .../L1TNtuples/python/l1UpgradeTree_cfi.py | 1 + .../L1TNtuples/src/L1AnalysisL1Upgrade.cc | 17 ++ L1Trigger/L1TZDC/BuildFile.xml | 11 + L1Trigger/L1TZDC/README.md | 112 ++++++++ L1Trigger/L1TZDC/plugins/BuildFile.xml | 24 ++ L1Trigger/L1TZDC/plugins/L1TZDCAnalyzer.cc | 139 ++++++++++ L1Trigger/L1TZDC/plugins/L1TZDCProducer.cc | 259 ++++++++++++++++++ L1Trigger/L1TZDC/test/createLUT.C | 151 ++++++++++ L1Trigger/L1TZDC/test/l1ZDCProducerTest.py | 112 ++++++++ L1Trigger/L1TZDC/test/runEmulator-ZDC.py | 190 +++++++++++++ 39 files changed, 1871 insertions(+), 38 deletions(-) create mode 100644 L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h create mode 100644 L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h create mode 100644 L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc create mode 100644 L1Trigger/L1TGlobal/src/EnergySumZdcTemplate.cc create mode 100644 L1Trigger/L1TZDC/BuildFile.xml create mode 100644 L1Trigger/L1TZDC/README.md create mode 100644 L1Trigger/L1TZDC/plugins/BuildFile.xml create mode 100644 L1Trigger/L1TZDC/plugins/L1TZDCAnalyzer.cc create mode 100644 L1Trigger/L1TZDC/plugins/L1TZDCProducer.cc create mode 100644 L1Trigger/L1TZDC/test/createLUT.C create mode 100644 L1Trigger/L1TZDC/test/l1ZDCProducerTest.py create mode 100644 L1Trigger/L1TZDC/test/runEmulator-ZDC.py diff --git a/DataFormats/L1TGlobal/interface/GlobalObject.h b/DataFormats/L1TGlobal/interface/GlobalObject.h index 7a930329ad066..7929f30ba821f 100644 --- a/DataFormats/L1TGlobal/interface/GlobalObject.h +++ b/DataFormats/L1TGlobal/interface/GlobalObject.h @@ -43,6 +43,8 @@ namespace l1t { gtCentrality6, gtCentrality7, gtExternal, + gtZDCP, + gtZDCM, ObjNull }; diff --git a/DataFormats/L1TGlobal/src/GlobalObject.cc b/DataFormats/L1TGlobal/src/GlobalObject.cc index 00341eaf49746..68f63eb098883 100644 --- a/DataFormats/L1TGlobal/src/GlobalObject.cc +++ b/DataFormats/L1TGlobal/src/GlobalObject.cc @@ -53,6 +53,8 @@ l1t::GlobalObject l1TGtObjectStringToEnum(const std::string& label) { {"CENT6", gtCentrality6}, {"CENT7", gtCentrality7}, {"External", gtExternal}, + {"ZDCP", gtZDCP}, + {"ZDCM", gtZDCM}, {"ObjNull", ObjNull}, {nullptr, (GlobalObject)-1}}; @@ -200,6 +202,14 @@ std::string l1t::l1TGtObjectEnumToString(const GlobalObject& gtObject) { gtObjectString = "External"; } break; + case gtZDCP: { + gtObjectString = "ZDCP"; + } break; + + case gtZDCM: { + gtObjectString = "ZDCM"; + } break; + case ObjNull: { gtObjectString = "ObjNull"; edm::LogInfo("L1TGlobal") << "\n ObjNull means no valid GlobalObject defined!"; diff --git a/DataFormats/L1Trigger/interface/EtSum.h b/DataFormats/L1Trigger/interface/EtSum.h index 8885638738d04..09573cf7dada0 100644 --- a/DataFormats/L1Trigger/interface/EtSum.h +++ b/DataFormats/L1Trigger/interface/EtSum.h @@ -52,6 +52,8 @@ namespace l1t { kAsymHt, kAsymEtHF, kAsymHtHF, + kZDCP, + kZDCM, kUninitialized }; diff --git a/L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h b/L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h index f1af2c1594a6c..f448de77092f2 100644 --- a/L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h +++ b/L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h @@ -75,7 +75,8 @@ namespace l1t { metHFPhiCalibration = 49, layer1HCalFBUpper = 50, layer1HCalFBLower = 51, - NUM_CALOPARAMNODES = 52 + hiZDC = 52, + NUM_CALOPARAMNODES = 53 }; CaloParamsHelper() { pnode_.resize(NUM_CALOPARAMNODES); } @@ -525,6 +526,11 @@ namespace l1t { l1t::LUT const* q2LUT() const { return &pnode_[hiQ2].LUT_; } void setQ2LUT(const l1t::LUT& lut) { pnode_[hiQ2].LUT_ = lut; } + // HI ZDC + l1t::LUT* zdcLUT() { return &pnode_[hiZDC].LUT_; } + l1t::LUT const* zdcLUT() const { return &pnode_[hiZDC].LUT_; } + void setZDCLUT(const l1t::LUT& lut) { pnode_[hiZDC].LUT_ = lut; } + // HI parameters double etSumCentLower(unsigned centClass) const { if (pnode_[etSumCentralityLower].dparams_.size() > centClass) diff --git a/L1Trigger/L1TCalorimeter/plugins/L1TCaloStage2ParamsESProducer.cc b/L1Trigger/L1TCalorimeter/plugins/L1TCaloStage2ParamsESProducer.cc index 77d4a54f47306..7ba7ca4e9b388 100644 --- a/L1Trigger/L1TCalorimeter/plugins/L1TCaloStage2ParamsESProducer.cc +++ b/L1Trigger/L1TCalorimeter/plugins/L1TCaloStage2ParamsESProducer.cc @@ -344,6 +344,12 @@ L1TCaloStage2ParamsESProducer::L1TCaloStage2ParamsESProducer(const edm::Paramete std::shared_ptr q2LUT(new LUT(q2LUTStream)); m_params_helper.setQ2LUT(*q2LUT); + // HI ZDC calibration LUT for trigger + edm::FileInPath zdcLUTFile = conf.getParameter("zdcLUTFile"); + std::ifstream zdcLUTStream(zdcLUTFile.fullPath()); + std::shared_ptr zdcLUT(new LUT(zdcLUTStream)); + m_params_helper.setZDCLUT(*zdcLUT); + // Layer 1 LUT specification m_params_helper.setLayer1ECalScaleFactors(conf.getParameter>("layer1ECalScaleFactors")); m_params_helper.setLayer1HCalScaleFactors(conf.getParameter>("layer1HCalScaleFactors")); diff --git a/L1Trigger/L1TCalorimeter/python/caloParams_cfi.py b/L1Trigger/L1TCalorimeter/python/caloParams_cfi.py index 840c01a799cc2..abbab772c6e9b 100644 --- a/L1Trigger/L1TCalorimeter/python/caloParams_cfi.py +++ b/L1Trigger/L1TCalorimeter/python/caloParams_cfi.py @@ -142,7 +142,8 @@ minimumBiasThresholds = cms.vint32(0, 0, 0, 0), centralityLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/centralityLUT_stage1.txt"), q2LUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/q2LUT_stage1.txt"), - + zdcLUTFile = cms.FileInPath("L1Trigger/L1TZDC/data/zdcLUT_HI_v0_1.txt"), + # HCal FB LUT layer1HCalFBLUTUpper = cms.vuint32([ 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, 0xBBBABBBA, diff --git a/L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h b/L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h new file mode 100644 index 0000000000000..c9945e2fe2ebd --- /dev/null +++ b/L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h @@ -0,0 +1,86 @@ +#ifndef L1Trigger_L1TGlobal_EnergySumZdcCondition_h +#define L1Trigger_L1TGlobal_EnergySumZdcCondition_h + +/** + * \class EnergySumZdcCondition + * + * + * Description: evaluation of a CondEnergySumZdc condition. + * + * Implementation: + * + * + * \author: Vasile Mihai Ghete - HEPHY Vienna + * + * + */ + +// system include files +#include +#include + +// user include files +// base classes +#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h" + +// forward declarations +class GlobalCondition; +class EnergySumZdcTemplate; + +namespace l1t { + + class L1Candidate; + + class GlobalBoard; + + // class declaration + class EnergySumZdcCondition : public ConditionEvaluation { + public: + /// constructors + /// default + EnergySumZdcCondition(); + + /// from base template condition (from event setup usually) + EnergySumZdcCondition(const GlobalCondition*, const GlobalBoard*); + + // copy constructor + EnergySumZdcCondition(const EnergySumZdcCondition&); + + // destructor + ~EnergySumZdcCondition() override; + + // assign operator + EnergySumZdcCondition& operator=(const EnergySumZdcCondition&); + + public: + /// the core function to check if the condition matches + const bool evaluateCondition(const int bxEval) const override; + + /// print condition + void print(std::ostream& myCout) const override; + + public: + /// get / set the pointer to a L1GtCondition + inline const EnergySumZdcTemplate* gtEnergySumZdcTemplate() const { return m_gtEnergySumZdcTemplate; } + + void setGtEnergySumZdcTemplate(const EnergySumZdcTemplate*); + + /// get / set the pointer to uGt GlobalBoard + inline const GlobalBoard* getuGtB() const { return m_uGtB; } + + void setuGtB(const GlobalBoard*); + + private: + /// copy function for copy constructor and operator= + void copy(const EnergySumZdcCondition& cp); + + private: + /// pointer to a EnergySumZdcTemplate + const EnergySumZdcTemplate* m_gtEnergySumZdcTemplate; + + /// pointer to uGt GlobalBoard, to be able to get the trigger objects + const GlobalBoard* m_uGtB; + }; + +} // namespace l1t +#endif diff --git a/L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h b/L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h new file mode 100644 index 0000000000000..b22e67094110e --- /dev/null +++ b/L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h @@ -0,0 +1,79 @@ +#ifndef L1Trigger_L1TGlobal_EnergySumZdcTemplate_h +#define L1Trigger_L1TGlobal_EnergySumZdcTemplate_h + +/** + * \class EnergySumZdcTemplate + * + * + * Description: L1 Global Trigger energy-sum template. + * + * Implementation: + * + * + * \author: Vasile Mihai Ghete - HEPHY Vienna + * + * $Date$ + * $Revision$ + * + */ + +// system include files +#include +#include + +// user include files + +// base class +#include "L1Trigger/L1TGlobal/interface/GlobalCondition.h" + +// forward declarations + +// class declaration +class EnergySumZdcTemplate : public GlobalCondition { +public: + // constructor + EnergySumZdcTemplate(); + + // constructor + EnergySumZdcTemplate(const std::string&); + + // constructor + EnergySumZdcTemplate(const std::string&, const l1t::GtConditionType&); + + // copy constructor + EnergySumZdcTemplate(const EnergySumZdcTemplate&); + + // destructor + ~EnergySumZdcTemplate() override; + + // assign operator + EnergySumZdcTemplate& operator=(const EnergySumZdcTemplate&); + +public: + struct ObjectParameter { + unsigned int etLowThreshold; + unsigned int etHighThreshold; + }; + +public: + inline const std::vector* objectParameter() const { return &m_objectParameter; } + + /// set functions + void setConditionParameter(const std::vector&); + + /// print the condition + void print(std::ostream& myCout) const override; + + /// output stream operator + friend std::ostream& operator<<(std::ostream&, const EnergySumZdcTemplate&); + +private: + /// copy function for copy constructor and operator= + void copy(const EnergySumZdcTemplate& cp); + +private: + /// variables containing the parameters + std::vector m_objectParameter; +}; + +#endif diff --git a/L1Trigger/L1TGlobal/interface/GlobalBoard.h b/L1Trigger/L1TGlobal/interface/GlobalBoard.h index cdb391c40c9ca..a6d14a0c8d5a6 100644 --- a/L1Trigger/L1TGlobal/interface/GlobalBoard.h +++ b/L1Trigger/L1TGlobal/interface/GlobalBoard.h @@ -68,13 +68,15 @@ namespace l1t { const edm::EDGetTokenT>&, const edm::EDGetTokenT>&, const edm::EDGetTokenT>&, + const edm::EDGetTokenT>&, const bool receiveEG, const int nrL1EG, const bool receiveTau, const int nrL1Tau, const bool receiveJet, const int nrL1Jet, - const bool receiveEtSums); + const bool receiveEtSums, + const bool receiveEtSumsZdc); void receiveMuonObjectData(const edm::Event&, const edm::EDGetTokenT>&, @@ -161,10 +163,13 @@ namespace l1t { /// pointer to Tau data list inline const BXVector* getCandL1Tau() const { return m_candL1Tau; } - /// pointer to Tau data list + /// pointer to EtSum data list inline const BXVector* getCandL1EtSum() const { return m_candL1EtSum; } - /// pointer to Tau data list + /// pointer to ZDC EtSum data list + inline const BXVector* getCandL1EtSumZdc() const { return m_candL1EtSumZdc; } + + /// pointer to External data list inline const BXVector* getCandL1External() const { return m_candL1External; } /* Drop individual EtSums for Now @@ -226,6 +231,7 @@ namespace l1t { BXVector* m_candL1Tau; BXVector* m_candL1Jet; BXVector* m_candL1EtSum; + BXVector* m_candL1EtSumZdc; BXVector* m_candL1External; // BXVector* m_candETM; diff --git a/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h b/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h index 65d9d8565fbcd..dd5da2d2cd042 100644 --- a/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h +++ b/L1Trigger/L1TGlobal/interface/GlobalDefinitions.h @@ -79,6 +79,8 @@ namespace l1t { TypeAsymHt, TypeAsymEtHF, TypeAsymHtHF, + TypeZDCP, + TypeZDCM, GtConditionTypeInvalid = -1 }; @@ -101,6 +103,7 @@ namespace l1t { CondCorrelationWithOverlapRemoval, CondCorrelationThreeBody, CondMuonShower, + CondEnergySumZdc, GtConditionCategoryInvalid = -1 }; diff --git a/L1Trigger/L1TGlobal/interface/TriggerMenu.h b/L1Trigger/L1TGlobal/interface/TriggerMenu.h index 2a02bb0220c6f..19b6286a796c5 100644 --- a/L1Trigger/L1TGlobal/interface/TriggerMenu.h +++ b/L1Trigger/L1TGlobal/interface/TriggerMenu.h @@ -35,6 +35,7 @@ #include "L1Trigger/L1TGlobal/interface/MuonShowerTemplate.h" #include "L1Trigger/L1TGlobal/interface/CaloTemplate.h" #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h" +#include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" #include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h" @@ -57,6 +58,7 @@ class TriggerMenu { const std::vector >&, const std::vector >&, const std::vector >&, + const std::vector >&, const std::vector >&, const std::vector >&, const std::vector >&, @@ -130,6 +132,14 @@ class TriggerMenu { void setVecEnergySumTemplate(const std::vector >&); + // + inline const std::vector >& vecEnergySumZdcTemplate() const { + return m_vecEnergySumZdcTemplate; + } + + void setVecEnergySumZdcTemplate(const std::vector >&); + + // inline const std::vector >& vecExternalTemplate() const { return m_vecExternalTemplate; } @@ -230,6 +240,7 @@ class TriggerMenu { std::vector > m_vecMuonShowerTemplate; std::vector > m_vecCaloTemplate; std::vector > m_vecEnergySumTemplate; + std::vector > m_vecEnergySumZdcTemplate; std::vector > m_vecExternalTemplate; diff --git a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc index a754919bfa1fa..a4131b688cdff 100644 --- a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc +++ b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc @@ -49,6 +49,8 @@ void L1TGlobalProducer::fillDescriptions(edm::ConfigurationDescriptions& descrip ->setComment("InputTag for Calo Trigger Jet (required parameter: default value is invalid)"); desc.add("EtSumInputTag", edm::InputTag("")) ->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("ExtInputTag", edm::InputTag("")) ->setComment("InputTag for external conditions (not required, but recommend to specify explicitly in config)"); desc.add("AlgoBlkInputTag", edm::InputTag("hltGtStage2Digis")) @@ -103,6 +105,7 @@ L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet) m_tauInputTag(parSet.getParameter("TauInputTag")), m_jetInputTag(parSet.getParameter("JetInputTag")), m_sumInputTag(parSet.getParameter("EtSumInputTag")), + m_sumZdcInputTag(parSet.getParameter("EtSumZdcInputTag")), m_extInputTag(parSet.getParameter("ExtInputTag")), m_produceL1GtDaqRecord(parSet.getParameter("ProduceL1GtDaqRecord")), @@ -132,6 +135,7 @@ L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet) m_tauInputToken = consumes>(m_tauInputTag); m_jetInputToken = consumes>(m_jetInputTag); m_sumInputToken = consumes>(m_sumInputTag); + m_sumZdcInputToken = consumes>(m_sumZdcInputTag); m_muInputToken = consumes>(m_muInputTag); if (m_useMuonShowers) m_muShowerInputToken = consumes>(m_muShowerInputTag); @@ -369,6 +373,7 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet gtParser.vecMuonShowerTemplate(), gtParser.vecCaloTemplate(), gtParser.vecEnergySumTemplate(), + gtParser.vecEnergySumZdcTemplate(), gtParser.vecExternalTemplate(), gtParser.vecCorrelationTemplate(), gtParser.vecCorrelationThreeBodyTemplate(), @@ -513,6 +518,7 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet bool receiveTau = true; bool receiveJet = true; bool receiveEtSums = true; + bool receiveEtSumsZdc = true; bool receiveExt = true; /* *** Boards need redefining ***** @@ -602,13 +608,15 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet m_tauInputToken, m_jetInputToken, m_sumInputToken, + m_sumZdcInputToken, receiveEG, m_nrL1EG, receiveTau, m_nrL1Tau, receiveJet, m_nrL1Jet, - receiveEtSums); + receiveEtSums, + receiveEtSumsZdc); m_uGtBrd->receiveMuonObjectData(iEvent, m_muInputToken, receiveMu, m_nrL1Mu); diff --git a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h index a921a59e3ad7f..2da54f435f6fb 100644 --- a/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h +++ b/L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h @@ -115,21 +115,23 @@ class L1TGlobalProducer : public edm::stream::EDProducer<> { std::unique_ptr m_uGtBrd; - /// input tag for muon collection from GMT + /// input tag for muon collection from the Global Muon Trigger (GMT) edm::InputTag m_muInputTag; edm::InputTag m_muShowerInputTag; edm::EDGetTokenT> m_muInputToken; edm::EDGetTokenT> m_muShowerInputToken; - /// input tag for calorimeter collections from GCT + /// input tag for calorimeter collections from Calo Layer 2 (GCT) or Zero Degree Calorimeter (ZDC) edm::InputTag m_egInputTag; edm::InputTag m_tauInputTag; edm::InputTag m_jetInputTag; edm::InputTag m_sumInputTag; + edm::InputTag m_sumZdcInputTag; edm::EDGetTokenT> m_egInputToken; edm::EDGetTokenT> m_tauInputToken; edm::EDGetTokenT> m_jetInputToken; edm::EDGetTokenT> m_sumInputToken; + edm::EDGetTokenT> m_sumZdcInputToken; /// input tag for external conditions edm::InputTag m_extInputTag; diff --git a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc index 432ab60d49586..8fc1d4c7ff4c1 100644 --- a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc +++ b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc @@ -22,6 +22,8 @@ * \new features: Bernhard Arnold, Elisa Fontanesi * - extended for muon track finder index feature (used for Run 3 muon monitoring seeds) * - checkRangeEta function allows to use up to five eta cuts in L1 algorithms + * \new features: Elisa Fontanesi + * - extended for Zero Degree Calorimeter triggers (used for Run 3 HI data-taking) * * $Date$ * $Revision$ @@ -134,6 +136,11 @@ void l1t::TriggerMenuParser::setVecEnergySumTemplate( m_vecEnergySumTemplate = vecEnergySumTempl; } +void l1t::TriggerMenuParser::setVecEnergySumZdcTemplate( + const std::vector >& vecEnergySumZdcTempl) { + m_vecEnergySumZdcTemplate = vecEnergySumZdcTempl; +} + void l1t::TriggerMenuParser::setVecExternalTemplate( const std::vector >& vecExternalTempl) { m_vecExternalTemplate = vecExternalTempl; @@ -212,6 +219,7 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu) m_vecMuonShowerTemplate.resize(m_numberConditionChips); m_vecCaloTemplate.resize(m_numberConditionChips); m_vecEnergySumTemplate.resize(m_numberConditionChips); + m_vecEnergySumZdcTemplate.resize(m_numberConditionChips); m_vecExternalTemplate.resize(m_numberConditionChips); m_vecCorrelationTemplate.resize(m_numberConditionChips); @@ -275,7 +283,7 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu) condition.getType() == esConditionType::QuadJet) { parseCalo(condition, chipNr, false); - // parse Energy Sums + // parse Energy Sums (and HI trigger objects, treated as energy sums or counters) } else if (condition.getType() == esConditionType::TotalEt || condition.getType() == esConditionType::TotalEtEM || condition.getType() == esConditionType::TotalHt || @@ -301,6 +309,11 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu) condition.getType() == esConditionType::Centrality7) { parseEnergySum(condition, chipNr, false); + // parse ZDC Energy Sums (NOTE: HI trigger objects are treated as energy sums or counters) + } else if (condition.getType() == esConditionType::ZDCPlus || + condition.getType() == esConditionType::ZDCMinus) { + parseEnergySumZdc(condition, chipNr, false); + //parse Muons } else if (condition.getType() == esConditionType::SingleMuon || condition.getType() == esConditionType::DoubleMuon || @@ -555,6 +568,7 @@ bool l1t::TriggerMenuParser::parseScales(std::map::const_iterator cit = scaleMap.begin(); cit != scaleMap.end(); @@ -582,6 +596,8 @@ bool l1t::TriggerMenuParser::parseScales(std::map objParameter(nrObj); + + // Loop over the cuts for this object + int lowerThresholdInd = 0; + int upperThresholdInd = -1; + + int cnt = 0; + + // BLW TO DO: These needs to the added to the object rather than the whole condition. + int relativeBx = 0; + bool gEq = false; + + // l1t::EnergySumsObjectRequirement objPar = condEnergySumZdc.objectRequirement(); + + // Loop over objects and extract the cuts on the objects + const std::vector& objects = condEnergySumZdc.getObjects(); + for (size_t jj = 0; jj < objects.size(); jj++) { + const L1TUtmObject& object = objects.at(jj); + gEq = (object.getComparisonOperator() == esComparisonOperator::GE); + + // BLW TO DO: This needs to be added to the Object Parameters + relativeBx = object.getBxOffset(); + + // Loop over the cuts for this object + 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::Threshold: + lowerThresholdInd = cut.getMinimum().index; + upperThresholdInd = cut.getMaximum().index; + break; + + case esCutType::Count: + lowerThresholdInd = cut.getMinimum().index; + upperThresholdInd = 0xffffff; + break; + + default: + break; + } //end switch + + } //end loop over cuts + + // Fill the object parameters + objParameter[cnt].etLowThreshold = lowerThresholdInd; + objParameter[cnt].etHighThreshold = upperThresholdInd; + + // Output for debugging + std::cout + << "\n EnergySumZdc ET high threshold (hex) for energy sum object " + << cnt + //LogDebug("TriggerMenuParser") << "\n EnergySumZdc ET high threshold (hex) for energy sum object " << cnt + << " = " << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold + << std::dec << std::endl; + + cnt++; + } //end loop over objects + + // object types - all same energySumObjType + std::vector objType(nrObj, energySumObjType); + + // now create a new energySum condition + + EnergySumZdcTemplate energySumCond(name); + + energySumCond.setCondType(cType); + energySumCond.setObjectType(objType); + energySumCond.setCondGEq(gEq); + energySumCond.setCondChipNr(chipNr); + energySumCond.setCondRelativeBx(relativeBx); + + energySumCond.setConditionParameter(objParameter); + + if (edm::isDebugEnabled()) { + std::ostringstream myCoutStream; + energySumCond.print(myCoutStream); + LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl; + } + + // insert condition into the map + if (!insertConditionIntoMap(energySumCond, chipNr)) { + edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl; + + return false; + } else { + (m_vecEnergySumZdcTemplate[chipNr]).push_back(energySumCond); + } + // + return true; +} + +/** + * parseEnergySumCorr Parse an "energy sum" correlation condition and insert an entry to the conditions map * * @param node The corresponding node. * @param name The name of the condition. diff --git a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h index ffdb58ab81755..3f2b993d896de 100644 --- a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h +++ b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h @@ -36,6 +36,7 @@ #include "L1Trigger/L1TGlobal/interface/MuonShowerTemplate.h" #include "L1Trigger/L1TGlobal/interface/CaloTemplate.h" #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h" +#include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationWithOverlapRemovalTemplate.h" @@ -144,6 +145,13 @@ namespace l1t { void setVecEnergySumTemplate(const std::vector >&); + // + inline const std::vector >& vecEnergySumZdcTemplate() const { + return m_vecEnergySumZdcTemplate; + } + + void setVecEnergySumZdcTemplate(const std::vector >&); + // inline const std::vector >& vecExternalTemplate() const { return m_vecExternalTemplate; @@ -292,6 +300,8 @@ namespace l1t { bool parseEnergySum(L1TUtmCondition condEnergySums, unsigned int chipNr = 0, const bool corrFlag = false); + bool parseEnergySumZdc(L1TUtmCondition condEnergySumZdcs, unsigned int chipNr = 0, const bool corrFlag = false); + bool parseEnergySumCorr(const L1TUtmObject* corrESum, unsigned int chipNr = 0); bool parseExternal(L1TUtmCondition condExt, unsigned int chipNr = 0); @@ -397,6 +407,7 @@ namespace l1t { std::vector > m_vecMuonShowerTemplate; std::vector > m_vecCaloTemplate; std::vector > m_vecEnergySumTemplate; + std::vector > m_vecEnergySumZdcTemplate; 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 7b7ff376db73d..1f38f24ab957a 100644 --- a/L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py +++ b/L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py @@ -15,6 +15,7 @@ TauInputTag = cms.InputTag("simCaloStage2Digis"), JetInputTag = cms.InputTag("simCaloStage2Digis"), EtSumInputTag = cms.InputTag("simCaloStage2Digis"), + EtSumZdcInputTag = cms.InputTag("etSumZdcProducer"), AlgorithmTriggersUnmasked = cms.bool(True), AlgorithmTriggersUnprescaled = cms.bool(True), GetPrescaleColumnFromData = cms.bool(False), diff --git a/L1Trigger/L1TGlobal/src/EnergySumCondition.cc b/L1Trigger/L1TGlobal/src/EnergySumCondition.cc index be578e3325dba..2e45dd1985f81 100644 --- a/L1Trigger/L1TGlobal/src/EnergySumCondition.cc +++ b/L1Trigger/L1TGlobal/src/EnergySumCondition.cc @@ -223,6 +223,14 @@ const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const { type = l1t::EtSum::EtSumType::kCentrality; MissingEnergy = false; break; + case gtZDCP: + type = l1t::EtSum::EtSumType::kZDCP; + MissingEnergy = false; + break; + case gtZDCM: + type = l1t::EtSum::EtSumType::kZDCM; + MissingEnergy = false; + break; default: edm::LogError("L1TGlobal") << "\n Error: " @@ -265,6 +273,8 @@ const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const { LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed Centrality bit" << std::endl; return false; } + } else if (type == l1t::EtSum::EtSumType::kZDCP || type == l1t::EtSum::EtSumType::kZDCM) { + return false; } else { // check energy threshold if (!checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candEt, condGEqVal)) { diff --git a/L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc b/L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc new file mode 100644 index 0000000000000..a28bf09eba575 --- /dev/null +++ b/L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc @@ -0,0 +1,183 @@ +/** +\class EnergySumZdcCondition + * + * + * Description: evaluation of a CondEnergySum condition for ZDC objects. + * + * Implementation: This class is built following the EnergySumCondition class + * and is adapted to evaluate a condition on ZDC objects as a threshold on an energy sum value. + * The object types are kZDCP and kZDCM and share the standard EtSum DataFormat. + * + * \author: Elisa Fontanesi and Christopher Mc Ginn + * + */ + +// this class header +#include "L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h" + +// system include files +#include +#include + +#include +#include +#include + +// user include files +// base classes +#include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" +#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h" +#include "DataFormats/L1Trigger/interface/L1Candidate.h" +#include "L1Trigger/L1TGlobal/interface/GlobalBoard.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/MessageLogger/interface/MessageDrop.h" + +// constructors +// default +l1t::EnergySumZdcCondition::EnergySumZdcCondition() : ConditionEvaluation() { + //empty +} + +// from base template condition (from event setup usually) +l1t::EnergySumZdcCondition::EnergySumZdcCondition(const GlobalCondition* eSumTemplate, const GlobalBoard* ptrGTB) + : ConditionEvaluation(), + m_gtEnergySumZdcTemplate(static_cast(eSumTemplate)), + m_uGtB(ptrGTB) + +{ + // maximum number of objects received for the evaluation of the condition + // energy sums are global quantities - one object per event + + m_condMaxNumberObjects = 1; +} + +// copy constructor +void l1t::EnergySumZdcCondition::copy(const l1t::EnergySumZdcCondition& cp) { + m_gtEnergySumZdcTemplate = cp.gtEnergySumZdcTemplate(); + m_uGtB = cp.getuGtB(); + + m_condMaxNumberObjects = cp.condMaxNumberObjects(); + m_condLastResult = cp.condLastResult(); + m_combinationsInCond = cp.getCombinationsInCond(); + + m_verbosity = cp.m_verbosity; +} + +l1t::EnergySumZdcCondition::EnergySumZdcCondition(const l1t::EnergySumZdcCondition& cp) : ConditionEvaluation() { + copy(cp); +} + +// destructor +l1t::EnergySumZdcCondition::~EnergySumZdcCondition() = default; + +// equal operator +l1t::EnergySumZdcCondition& l1t::EnergySumZdcCondition::operator=(const l1t::EnergySumZdcCondition& cp) { + copy(cp); + return *this; +} + +// methods +void l1t::EnergySumZdcCondition::setGtEnergySumZdcTemplate(const EnergySumZdcTemplate* eSumTempl) { + m_gtEnergySumZdcTemplate = eSumTempl; +} + +// set the pointer to uGT GlobalBoard +void l1t::EnergySumZdcCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; } + +// try all object permutations and check spatial correlations, if required +const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const { + // number of trigger objects in the condition: there is only one object + int iCondition = 0; + + // condition result condResult set to true if the energy sum + // passes all requirements + bool condResult = false; + + // store the indices of the calorimeter objects + // from the combination evaluated in the condition + SingleCombInCond objectsInComb; + + // clear the m_combinationsInCond vector + (combinationsInCond()).clear(); + + // clear the indices in the combination + objectsInComb.clear(); + + const BXVector* candVecZdc = m_uGtB->getCandL1EtSumZdc(); + + // Look at objects in bx = bx + relativeBx + int useBx = bxEval + m_gtEnergySumZdcTemplate->condRelativeBx(); + + // Fail condition if attempting to get Bx outside of range + if ((useBx < candVecZdc->getFirstBX()) || (useBx > candVecZdc->getLastBX())) { + return false; + } + + // If no candidates, no use looking any further + int numberObjectsZdc = candVecZdc->size(useBx); + + if (numberObjectsZdc < 1) { + return false; + } + + const EnergySumZdcTemplate::ObjectParameter objPar = (*(m_gtEnergySumZdcTemplate->objectParameter()))[iCondition]; + + // Definition in CondFormats/L1TObjects/interface/L1GtCondition.h: + // condGEqVal indicates the operator used for the condition (>=, =): true for >= + bool condGEqVal = m_gtEnergySumZdcTemplate->condGEq(); + + l1t::EtSum candZdcPlus; + l1t::EtSum candZdcMinus; + unsigned int candZDCPEsum = 0; + unsigned int candZDCMEsum = 0; + bool myres = false; + + for (int iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) { + l1t::EtSum candZdc = *(candVecZdc->at(useBx, iEtSum)); + + if (l1t::EtSum::EtSumType::kZDCP == candZdc.getType()) + candZdcPlus = *(candVecZdc->at(useBx, iEtSum)); + else if (l1t::EtSum::EtSumType::kZDCM == candZdc.getType()) + candZdcMinus = *(candVecZdc->at(useBx, iEtSum)); + + LogDebug("L1TGlobal") << "CANDZdc: " << candZdc.hwPt() << ", " << useBx << ", " << candZdc.getType(); + + if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCP) { + candZDCPEsum = candZdcPlus.hwPt(); + myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCPEsum, condGEqVal); + } else if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCM) { + candZDCMEsum = candZdcMinus.hwPt(); + myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCMEsum, condGEqVal); + } else { + LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed ZDC checkThreshold" << std::endl; + return false; + } + + LogDebug("L1TGlobal") + << "----------------------------------------------> ZDC EtSumType object from EnergySumZdcTemplate" + << "\n objPar.etLowThreshold = " << objPar.etLowThreshold + << "\n objPar.etHighThreshold = " << objPar.etHighThreshold << "\n candZDCPEsum = " << candZDCPEsum + << "\n candZDCMEsum = " << candZDCMEsum << "\n condGEqVal = " << condGEqVal << "\n myres = " << myres + << std::endl; + } + + if (not myres) + return false; + + // index is always zero, as they are global quantities (there is only one object) + int indexObj = 0; + + objectsInComb.push_back(indexObj); + (combinationsInCond()).push_back(objectsInComb); + + // if we get here all checks were successful for this combination + // set the general result for evaluateCondition to "true" + condResult = true; + return condResult; +} + +void l1t::EnergySumZdcCondition::print(std::ostream& myCout) const { + m_gtEnergySumZdcTemplate->print(myCout); + ConditionEvaluation::print(myCout); +} diff --git a/L1Trigger/L1TGlobal/src/EnergySumZdcTemplate.cc b/L1Trigger/L1TGlobal/src/EnergySumZdcTemplate.cc new file mode 100644 index 0000000000000..15371295ae65e --- /dev/null +++ b/L1Trigger/L1TGlobal/src/EnergySumZdcTemplate.cc @@ -0,0 +1,105 @@ +/** + * \class EnergySumZdcTemplate + * + * + * Description: L1 Global Trigger energy-sum template for EtSums from ZDC. + * + * Implementation: + * Effective clone of EnergySumTemplate for use w/ ZDC + * + * \author: Elisa Fontanesi, Boston University, and Christopher Mc Ginn, MIT + * cloned from work of Vasile Mihai Ghete - HEPHY Vienna + * + * 2023.08.31 + * Version 1 + * + */ + +// this class header +#include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" + +// system include files + +#include +#include + +// user include files + +// base class + +// forward declarations + +// constructors +EnergySumZdcTemplate::EnergySumZdcTemplate() : GlobalCondition() { m_condCategory = l1t::CondEnergySumZdc; } + +EnergySumZdcTemplate::EnergySumZdcTemplate(const std::string& cName) : GlobalCondition(cName) { + m_condCategory = l1t::CondEnergySumZdc; +} + +EnergySumZdcTemplate::EnergySumZdcTemplate(const std::string& cName, const l1t::GtConditionType& cType) + : GlobalCondition(cName, l1t::CondEnergySumZdc, cType) { + m_condCategory = l1t::CondEnergySumZdc; + + // should be always 1 - they are global quantities... + int nObjects = nrObjects(); + + if (nObjects > 0) { + m_objectParameter.reserve(nObjects); + m_objectType.reserve(nObjects); + } +} + +// copy constructor +EnergySumZdcTemplate::EnergySumZdcTemplate(const EnergySumZdcTemplate& cp) : GlobalCondition(cp.m_condName) { + copy(cp); +} + +// destructor +EnergySumZdcTemplate::~EnergySumZdcTemplate() = default; + +// assign operator +EnergySumZdcTemplate& EnergySumZdcTemplate::operator=(const EnergySumZdcTemplate& cp) { + copy(cp); + return *this; +} + +// setConditionParameter - set the parameters of the condition +void EnergySumZdcTemplate::setConditionParameter(const std::vector& objParameter) { + m_objectParameter = objParameter; +} + +void EnergySumZdcTemplate::print(std::ostream& myCout) const { + myCout << "\n EnergySumZdcTemplate 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 << " etThreshold = " << std::hex << m_objectParameter[i].etLowThreshold << " - " + << m_objectParameter[i].etHighThreshold << std::endl; + } + + // reset to decimal output + myCout << std::dec << std::endl; +} + +void EnergySumZdcTemplate::copy(const EnergySumZdcTemplate& 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()); +} + +// output stream operator +std::ostream& operator<<(std::ostream& os, const EnergySumZdcTemplate& result) { + result.print(os); + return os; +} diff --git a/L1Trigger/L1TGlobal/src/GlobalBoard.cc b/L1Trigger/L1TGlobal/src/GlobalBoard.cc index f190014d7b271..d5f2583d784a1 100644 --- a/L1Trigger/L1TGlobal/src/GlobalBoard.cc +++ b/L1Trigger/L1TGlobal/src/GlobalBoard.cc @@ -5,7 +5,10 @@ * Description: Global Trigger Logic board, see header file for details. * * Implementation: - * + * Class responsible for receiving the objects from the different subsystems + * and for running the Global Trigger Logic (GTL) and Final Decision Logic (FDL). + * It is directly called by the L1TGlobalProducer. + * The emulator considers a single board for all algorithms. * * \author: M. Fierro - HEPHY Vienna - ORCA version * \author: V. M. Ghete - HEPHY Vienna - CMSSW version @@ -16,7 +19,7 @@ * \author: E. Fontanesi, E. Yigitbasi, A. Loeliger (original implementation by S. Dildick, 2021) * - fix for the muon shower triggers and check on all BXs * \author: E. Fontanesi - added 2Loose HMT for 2023 Run 3 - * + * - added ZDC triggers for 2023 HI data-taking * $Date$ * $Revision$ * @@ -33,6 +36,7 @@ #include "L1Trigger/L1TGlobal/interface/MuonShowerTemplate.h" #include "L1Trigger/L1TGlobal/interface/CaloTemplate.h" #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h" +#include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h" #include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h" #include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h" @@ -48,6 +52,7 @@ #include "L1Trigger/L1TGlobal/interface/MuonShowerCondition.h" #include "L1Trigger/L1TGlobal/interface/CaloCondition.h" #include "L1Trigger/L1TGlobal/interface/EnergySumCondition.h" +#include "L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h" #include "L1Trigger/L1TGlobal/interface/ExternalCondition.h" #include "L1Trigger/L1TGlobal/interface/CorrCondition.h" #include "L1Trigger/L1TGlobal/interface/CorrThreeBodyCondition.h" @@ -64,6 +69,7 @@ l1t::GlobalBoard::GlobalBoard() m_candL1Tau(new BXVector), m_candL1Jet(new BXVector), m_candL1EtSum(new BXVector), + m_candL1EtSumZdc(new BXVector), m_candL1External(new BXVector), m_currentLumi(0), m_isDebugEnabled(edm::isDebugEnabled()) { @@ -89,13 +95,13 @@ l1t::GlobalBoard::GlobalBoard() // Destructor l1t::GlobalBoard::~GlobalBoard() { - //reset(); //why would we need a reset? delete m_candL1Mu; delete m_candL1MuShower; delete m_candL1EG; delete m_candL1Tau; delete m_candL1Jet; delete m_candL1EtSum; + delete m_candL1EtSumZdc; delete m_candL1External; } @@ -121,6 +127,7 @@ void l1t::GlobalBoard::init(const int numberPhysTriggers, m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_); m_candL1Jet->setBXRange(m_bxFirst_, m_bxLast_); m_candL1EtSum->setBXRange(m_bxFirst_, m_bxLast_); + m_candL1EtSumZdc->setBXRange(m_bxFirst_, m_bxLast_); m_candL1External->setBXRange(m_bxFirst_, m_bxLast_); m_uGtAlgBlk.reset(); @@ -134,16 +141,17 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, const edm::EDGetTokenT>& tauInputToken, const edm::EDGetTokenT>& jetInputToken, const edm::EDGetTokenT>& sumInputToken, + const edm::EDGetTokenT>& sumZdcInputToken, const bool receiveEG, const int nrL1EG, const bool receiveTau, const int nrL1Tau, const bool receiveJet, const int nrL1Jet, - const bool receiveEtSums) { + const bool receiveEtSums, + const bool receiveEtSumsZdc) { if (m_verbosity) { LogDebug("L1TGlobal") << "\n**** Board receiving Calo Data "; - //<< "\n from input tag " << caloInputTag << "\n" } resetCalo(); @@ -155,8 +163,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, if (!egData.isValid()) { if (m_verbosity) { - edm::LogWarning("L1TGlobal") << "\nWarning: BXVector with input tag " - //<< caloInputTag + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector collection" << "\nrequested in configuration, but not found in the event.\n"; } } else { @@ -189,8 +196,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, if (!tauData.isValid()) { if (m_verbosity) { - edm::LogWarning("L1TGlobal") << "\nWarning: BXVector with input tag " - //<< caloInputTag + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector collection" << "\nrequested in configuration, but not found in the event.\n"; } } else { @@ -224,8 +230,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, if (!jetData.isValid()) { if (m_verbosity) { - edm::LogWarning("L1TGlobal") << "\nWarning: BXVector with input tag " - //<< caloInputTag + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector collection" << "\nrequested in configuration, but not found in the event.\n"; } } else { @@ -258,8 +263,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, if (!etSumData.isValid()) { if (m_verbosity) { - edm::LogWarning("L1TGlobal") << "\nWarning: BXVector with input tag " - //<< caloInputTag + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector collection" << "\nrequested in configuration, but not found in the event.\n"; } } else { @@ -268,7 +272,7 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, if (i < m_bxFirst_ || i > m_bxLast_) continue; - //Loop over jet in this bx + //Loop over EtSum objects in this bx for (std::vector::const_iterator etsum = etSumData->begin(i); etsum != etSumData->end(i); ++etsum) { (*m_candL1EtSum).push_back(i, &(*etsum)); @@ -310,10 +314,32 @@ void l1t::GlobalBoard::receiveCaloObjectData(const edm::Event& iEvent, } */ - } //end loop over jet in bx + } //end loop over EtSum objects in bx } //end loop over Bx } } + + if (receiveEtSumsZdc) { + edm::Handle> etSumData; + iEvent.getByToken(sumZdcInputToken, etSumData); + + if (!etSumData.isValid()) { + if (m_verbosity) { + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the ZDC Energy Sums collection" + << "\nrequested in configuration, but not found in the event.\n"; + } + } else { + for (int i = etSumData->getFirstBX(); i <= etSumData->getLastBX(); ++i) { + // Prevent from pushing back bx that is outside of allowed range + if (i < m_bxFirst_ || i > m_bxLast_) + continue; + + for (std::vector::const_iterator etsum = etSumData->begin(i); etsum != etSumData->end(i); ++etsum) { + (*m_candL1EtSumZdc).push_back(i, &(*etsum)); + } + } //end loop over Bx + } + } } // receive data from Global Muon Trigger @@ -335,8 +361,7 @@ void l1t::GlobalBoard::receiveMuonObjectData(const edm::Event& iEvent, if (!muonData.isValid()) { if (m_verbosity) { - edm::LogWarning("L1TGlobal") << "\nWarning: BXVector with input tag " - //<< muInputTag + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector collection" << "\nrequested in configuration, but not found in the event.\n"; } } else { @@ -376,7 +401,7 @@ void l1t::GlobalBoard::receiveMuonShowerObjectData(const edm::Event& iEvent, if (!muonData.isValid()) { if (m_verbosity) { - edm::LogWarning("L1TGlobal") << "\nWarning: BXVector with input tag " + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector collection" << "\nrequested in configuration, but not found in the event.\n"; } } else { @@ -446,8 +471,7 @@ void l1t::GlobalBoard::receiveExternalData(const edm::Event& iEvent, if (!extData.isValid()) { if (m_verbosity) { - edm::LogWarning("L1TGlobal") << "\nWarning: BXVector with input tag " - //<< muInputTag + edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector collection" << "\nrequested in configuration, but not found in the event.\n"; } } else { @@ -495,7 +519,6 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, const std::vector>& corrMuon = m_l1GtMenu->corMuonTemplate(); - // Comment out for now const std::vector>& corrCalo = m_l1GtMenu->corCaloTemplate(); const std::vector>& corrEnergySum = m_l1GtMenu->corEnergySumTemplate(); @@ -536,7 +559,6 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, muCondition->evaluateConditionStoreResult(iBxInEvent); - // BLW COmment out for now cMapResults[itCond->first] = muCondition; if (m_verbosity && m_isDebugEnabled) { @@ -604,6 +626,23 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, } // delete eSumCondition; + } break; + case CondEnergySumZdc: { + EnergySumZdcCondition* eSumZdcCondition = new EnergySumZdcCondition(itCond->second, this); + + eSumZdcCondition->setVerbosity(m_verbosity); + eSumZdcCondition->evaluateConditionStoreResult(iBxInEvent); + + cMapResults[itCond->first] = eSumZdcCondition; + + if (m_verbosity && m_isDebugEnabled) { + std::ostringstream myCout; + eSumZdcCondition->print(myCout); + + LogTrace("L1TGlobal") << myCout.str(); + } + // delete eSumZdcCondition; + } break; case CondExternal: { @@ -624,7 +663,7 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, } break; case CondCorrelation: { - // get first the sub-conditions + // get first the subconditions const CorrelationTemplate* corrTemplate = static_cast(itCond->second); const GtConditionCategory cond0Categ = corrTemplate->cond0Category(); const GtConditionCategory cond1Categ = corrTemplate->cond1Category(); @@ -689,7 +728,7 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, } break; case CondCorrelationThreeBody: { - // get first the sub-conditions + // get first the subconditions const CorrelationThreeBodyTemplate* corrTemplate = static_cast(itCond->second); const GtConditionCategory cond0Categ = corrTemplate->cond0Category(); @@ -743,7 +782,7 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, } break; case CondCorrelationWithOverlapRemoval: { - // get first the sub-conditions + // get first the subconditions const CorrelationWithOverlapRemovalTemplate* corrTemplate = static_cast(itCond->second); const GtConditionCategory cond0Categ = corrTemplate->cond0Category(); @@ -762,7 +801,7 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, int cond1NrL1Objects = 0; int cond2NrL1Objects = 0; LogDebug("L1TGlobal") << " cond0NrL1Objects" << cond0NrL1Objects << " cond1NrL1Objects " << cond1NrL1Objects - << " cond2NrL1Objects " << cond2NrL1Objects; + << " cond2NrL1Objects " << cond2NrL1Objects; switch (cond0Categ) { case CondMuon: { @@ -1117,11 +1156,13 @@ void l1t::GlobalBoard::resetCalo() { m_candL1Tau->clear(); m_candL1Jet->clear(); m_candL1EtSum->clear(); + m_candL1EtSumZdc->clear(); m_candL1EG->setBXRange(m_bxFirst_, m_bxLast_); m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_); m_candL1Jet->setBXRange(m_bxFirst_, m_bxLast_); m_candL1EtSum->setBXRange(m_bxFirst_, m_bxLast_); + m_candL1EtSumZdc->setBXRange(m_bxFirst_, m_bxLast_); } void l1t::GlobalBoard::resetExternal() { diff --git a/L1Trigger/L1TGlobal/src/GlobalCondition.cc b/L1Trigger/L1TGlobal/src/GlobalCondition.cc index 3bb8aa22c58aa..93bdd3d3da872 100644 --- a/L1Trigger/L1TGlobal/src/GlobalCondition.cc +++ b/L1Trigger/L1TGlobal/src/GlobalCondition.cc @@ -118,6 +118,8 @@ const int GlobalCondition::nrObjects() const { case l1t::TypeMinBiasHFM0: case l1t::TypeMinBiasHFP1: case l1t::TypeMinBiasHFM1: + case l1t::TypeZDCP: + case l1t::TypeZDCM: case l1t::TypeAsymEt: case l1t::TypeAsymHt: case l1t::TypeAsymEtHF: @@ -197,6 +199,12 @@ void GlobalCondition::print(std::ostream& myCout) const { << "CondEnergySum" << std::endl; } + break; + case l1t::CondEnergySumZdc: { + myCout << " Condition category: " + << "CondEnergySumZdc" << std::endl; + } + break; case l1t::CondCorrelation: { myCout << " Condition category: " diff --git a/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc b/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc index af6fc03e1c44a..f27c1472715bd 100644 --- a/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc +++ b/L1Trigger/L1TGlobal/src/GlobalDefinitions.cc @@ -67,6 +67,8 @@ namespace { {"l1t::TypeMinBiasHFM0", l1t::TypeMinBiasHFM0}, {"l1t::TypeMinBiasHFP1", l1t::TypeMinBiasHFP1}, {"l1t::TypeMinBiasHFM1", l1t::TypeMinBiasHFM1}, + {"l1t::TypeZDCP", l1t::TypeZDCP}, + {"l1t::TypeZDCM", l1t::TypeZDCM}, {"l1t::TypeExternal", l1t::TypeExternal}, {nullptr, (l1t::GtConditionType)-1}, {"l1t::Type2corWithOverlapRemoval", l1t::Type2corWithOverlapRemoval}, @@ -89,6 +91,7 @@ namespace { {"l1t::CondMuon", l1t::CondMuon}, {"l1t::CondCalo", l1t::CondCalo}, {"l1t::CondEnergySum", l1t::CondEnergySum}, + {"l1t::CondEnergySumZdc", l1t::CondEnergySumZdc}, {"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 bb2cac90174a6..818819e05058d 100644 --- a/L1Trigger/L1TGlobal/src/TriggerMenu.cc +++ b/L1Trigger/L1TGlobal/src/TriggerMenu.cc @@ -44,6 +44,7 @@ TriggerMenu::TriggerMenu( const std::vector >& vecMuonShowerTemplateVal, const std::vector >& vecCaloTemplateVal, const std::vector >& vecEnergySumTemplateVal, + const std::vector >& vecEnergySumZdcTemplateVal, const std::vector >& vecExternalTemplateVal, const std::vector >& vecCorrelationTemplateVal, const std::vector >& vecCorrelationThreeBodyTemplateVal, @@ -61,6 +62,7 @@ TriggerMenu::TriggerMenu( m_vecMuonShowerTemplate(vecMuonShowerTemplateVal), m_vecCaloTemplate(vecCaloTemplateVal), m_vecEnergySumTemplate(vecEnergySumTemplateVal), + m_vecEnergySumZdcTemplate(vecEnergySumZdcTemplateVal), m_vecExternalTemplate(vecExternalTemplateVal), m_vecCorrelationTemplate(vecCorrelationTemplateVal), m_vecCorrelationThreeBodyTemplate(vecCorrelationThreeBodyTemplateVal), @@ -86,6 +88,7 @@ TriggerMenu::TriggerMenu(const TriggerMenu& rhs) { m_vecMuonShowerTemplate = rhs.m_vecMuonShowerTemplate; m_vecCaloTemplate = rhs.m_vecCaloTemplate; m_vecEnergySumTemplate = rhs.m_vecEnergySumTemplate; + m_vecEnergySumZdcTemplate = rhs.m_vecEnergySumZdcTemplate; m_vecExternalTemplate = rhs.m_vecExternalTemplate; m_vecCorrelationTemplate = rhs.m_vecCorrelationTemplate; @@ -134,6 +137,7 @@ TriggerMenu& TriggerMenu::operator=(const TriggerMenu& rhs) { m_vecMuonShowerTemplate = rhs.m_vecMuonShowerTemplate; m_vecCaloTemplate = rhs.m_vecCaloTemplate; m_vecEnergySumTemplate = rhs.m_vecEnergySumTemplate; + m_vecEnergySumZdcTemplate = rhs.m_vecEnergySumZdcTemplate; m_vecExternalTemplate = rhs.m_vecExternalTemplate; m_vecCorrelationTemplate = rhs.m_vecCorrelationTemplate; @@ -250,6 +254,25 @@ void TriggerMenu::buildGtConditionMap() { } } + // + size_t vecEnergySumZdcSize = m_vecEnergySumZdcTemplate.size(); + if (condMapSize < vecEnergySumZdcSize) { + m_conditionMap.resize(vecEnergySumZdcSize); + condMapSize = m_conditionMap.size(); + } + + chipNr = -1; + for (std::vector >::iterator itCondOnChip = m_vecEnergySumZdcTemplate.begin(); + itCondOnChip != m_vecEnergySumZdcTemplate.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 // // @@ -365,6 +388,11 @@ void TriggerMenu::setVecEnergySumTemplate(const std::vector >& vecEnergySumZdcTempl) { + m_vecEnergySumZdcTemplate = vecEnergySumZdcTempl; +} + void TriggerMenu::setVecExternalTemplate(const std::vector >& vecExternalTempl) { m_vecExternalTemplate = vecExternalTempl; } diff --git a/L1Trigger/L1TGlobal/src/classes_def.xml b/L1Trigger/L1TGlobal/src/classes_def.xml index 1ea80d258347e..71e5f2ff02322 100644 --- a/L1Trigger/L1TGlobal/src/classes_def.xml +++ b/L1Trigger/L1TGlobal/src/classes_def.xml @@ -26,6 +26,7 @@ + diff --git a/L1Trigger/L1TNtuples/interface/L1AnalysisL1Upgrade.h b/L1Trigger/L1TNtuples/interface/L1AnalysisL1Upgrade.h index c061f18f2ecdb..b86cf223f26a7 100644 --- a/L1Trigger/L1TNtuples/interface/L1AnalysisL1Upgrade.h +++ b/L1Trigger/L1TNtuples/interface/L1AnalysisL1Upgrade.h @@ -34,6 +34,11 @@ namespace L1Analysis { void SetMuonShower(const edm::Handle muonShower, unsigned maxL1Upgrade) { SetMuonShower(*muonShower, maxL1Upgrade); } + + void SetSumZDC(const edm::Handle sumsZDC, unsigned maxL1Upgrade) { + SetSumZDC(*sumsZDC, maxL1Upgrade); + } + void SetEm(const l1t::EGammaBxCollection& em, unsigned maxL1Upgrade); void SetTau(const l1t::TauBxCollection& tau, unsigned maxL1Upgrade); void SetJet(const l1t::JetBxCollection& jet, unsigned maxL1Upgrade); @@ -41,6 +46,8 @@ namespace L1Analysis { void SetMuon(const l1t::MuonBxCollection& muon, unsigned maxL1Upgrade); void SetMuonShower(const l1t::MuonShowerBxCollection& muonShower, unsigned maxL1Upgrade); + void SetSumZDC(const l1t::EtSumBxCollection& sumsZDC, unsigned maxL1Upgrade); + L1AnalysisL1UpgradeDataFormat* getData() { return &l1upgrade_; } private: diff --git a/L1Trigger/L1TNtuples/interface/L1AnalysisL1UpgradeDataFormat.h b/L1Trigger/L1TNtuples/interface/L1AnalysisL1UpgradeDataFormat.h index d222ad9a15105..43b9f84347285 100644 --- a/L1Trigger/L1TNtuples/interface/L1AnalysisL1UpgradeDataFormat.h +++ b/L1Trigger/L1TNtuples/interface/L1AnalysisL1UpgradeDataFormat.h @@ -40,7 +40,9 @@ namespace L1Analysis { kAsymEt, kAsymHt, kAsymEtHF, - kAsymHtHF + kAsymHtHF, + kZDCP, + kZDCM }; struct L1AnalysisL1UpgradeDataFormat { @@ -140,6 +142,15 @@ namespace L1Analysis { sumIEt.clear(); sumIPhi.clear(); sumBx.clear(); + + //CM: Adding additional sum collections for the ZDC + nSumsZDC = 0; + sumZDCType.clear(); + sumZDCEt.clear(); + sumZDCPhi.clear(); + sumZDCIEt.clear(); + sumZDCIPhi.clear(); + sumZDCBx.clear(); } unsigned short int nEGs; @@ -234,6 +245,14 @@ namespace L1Analysis { std::vector sumIEt; std::vector sumIPhi; std::vector sumBx; + + unsigned short int nSumsZDC; + std::vector sumZDCType; + std::vector sumZDCEt; + std::vector sumZDCPhi; + std::vector sumZDCIEt; + std::vector sumZDCIPhi; + std::vector sumZDCBx; }; } // namespace L1Analysis #endif diff --git a/L1Trigger/L1TNtuples/plugins/L1UpgradeTreeProducer.cc b/L1Trigger/L1TNtuples/plugins/L1UpgradeTreeProducer.cc index 0fa9d34a7988e..8ad6491dd8d1c 100644 --- a/L1Trigger/L1TNtuples/plugins/L1UpgradeTreeProducer.cc +++ b/L1Trigger/L1TNtuples/plugins/L1UpgradeTreeProducer.cc @@ -76,6 +76,9 @@ class L1UpgradeTreeProducer : public edm::one::EDAnalyzer sumToken_; const edm::EDGetTokenT muonToken_; const edm::EDGetTokenT muonShowerToken_; + + const edm::EDGetTokenT sumZDCToken_; + std::vector> tauTokens_; }; @@ -85,7 +88,8 @@ L1UpgradeTreeProducer::L1UpgradeTreeProducer(const edm::ParameterSet& iConfig) sumToken_(consumes(iConfig.getUntrackedParameter("sumToken"))), muonToken_(consumes(iConfig.getUntrackedParameter("muonToken"))), muonShowerToken_( - consumes(iConfig.getUntrackedParameter("muonShowerToken"))) { + consumes(iConfig.getUntrackedParameter("muonShowerToken"))), + sumZDCToken_(consumes(iConfig.getUntrackedParameter("sumZDCToken"))) { const auto& taus = iConfig.getUntrackedParameter>("tauTokens"); for (const auto& tau : taus) { tauTokens_.push_back(consumes(tau)); @@ -116,12 +120,14 @@ void L1UpgradeTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSe edm::Handle sums; edm::Handle muon; edm::Handle muonShower; + edm::Handle sumsZDC; iEvent.getByToken(egToken_, eg); iEvent.getByToken(jetToken_, jet); iEvent.getByToken(sumToken_, sums); iEvent.getByToken(muonToken_, muon); iEvent.getByToken(muonShowerToken_, muonShower); + iEvent.getByToken(sumZDCToken_, sumsZDC); if (eg.isValid()) { l1Upgrade->SetEm(eg, maxL1Upgrade_); @@ -152,6 +158,12 @@ void L1UpgradeTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSe edm::LogWarning("MissingProduct") << "L1Upgrade Muon Showers not found. Branch will not be filled" << std::endl; } + if (sumsZDC.isValid()) { + l1Upgrade->SetSumZDC(sumsZDC, maxL1Upgrade_); + } else { + edm::LogWarning("MissingProduct") << "L1Upgrade EtZDCSums not found. Branch will not be filled" << std::endl; + } + for (auto& tautoken : tauTokens_) { edm::Handle tau; iEvent.getByToken(tautoken, tau); diff --git a/L1Trigger/L1TNtuples/python/L1NtupleEMU_cff.py b/L1Trigger/L1TNtuples/python/L1NtupleEMU_cff.py index 91adaa1b0b6ab..981a540c17526 100644 --- a/L1Trigger/L1TNtuples/python/L1NtupleEMU_cff.py +++ b/L1Trigger/L1TNtuples/python/L1NtupleEMU_cff.py @@ -3,6 +3,7 @@ from L1Trigger.L1TNtuples.l1CaloTowerTree_cfi import * from L1Trigger.L1TNtuples.l1UpgradeTfMuonTree_cfi import * +from L1Trigger.L1TNtuples.l1UpgradeTfMuonShowerTree_cfi import * from L1Trigger.L1TNtuples.l1UpgradeTree_cfi import * from L1Trigger.L1TNtuples.l1EventTree_cfi import * from L1Trigger.L1TNtuples.l1uGTTree_cfi import * @@ -14,6 +15,10 @@ l1UpgradeTfMuonEmuTree.emtfMuonToken = cms.untracked.InputTag("simEmtfDigis","EMTF") l1UpgradeTfMuonEmuTree.isEMU = cms.bool(True) +l1UpgradeEmuTree = l1UpgradeTree.clone() +# We have only output of the ZDC emulator available, no info from unpacker: l1UpgradeEmuTree clones from the l1UpgradeTree +l1UpgradeEmuTree.sumZDCToken = cms.untracked.InputTag("etSumZdcProducer") + l1CaloTowerEmuTree = l1CaloTowerTree.clone() l1CaloTowerEmuTree.ecalToken = cms.untracked.InputTag("simEcalTriggerPrimitiveDigis") l1CaloTowerEmuTree.hcalToken = cms.untracked.InputTag("simHcalTriggerPrimitiveDigis") diff --git a/L1Trigger/L1TNtuples/python/L1NtupleRAW_cff.py b/L1Trigger/L1TNtuples/python/L1NtupleRAW_cff.py index 869adcbf473a7..ebf6cb90069f7 100644 --- a/L1Trigger/L1TNtuples/python/L1NtupleRAW_cff.py +++ b/L1Trigger/L1TNtuples/python/L1NtupleRAW_cff.py @@ -14,6 +14,8 @@ l1UpgradeTfMuonTree.omtfMuonToken = cms.untracked.InputTag("gmtStage2Digis","OMTF") # we don't have emtfDigis yet, use unpacked input payloads of GMT l1UpgradeTfMuonTree.emtfMuonToken = cms.untracked.InputTag("gmtStage2Digis","EMTF") +# We have only output of the ZDC emulator available, no info from unpacker +l1UpgradeTree.sumZDCToken = cms.untracked.InputTag("etSumZdcProducer") L1NtupleRAW = cms.Sequence( l1EventTree diff --git a/L1Trigger/L1TNtuples/python/l1UpgradeTree_cfi.py b/L1Trigger/L1TNtuples/python/l1UpgradeTree_cfi.py index c0be4e75a1947..bce1289cec4c6 100644 --- a/L1Trigger/L1TNtuples/python/l1UpgradeTree_cfi.py +++ b/L1Trigger/L1TNtuples/python/l1UpgradeTree_cfi.py @@ -9,6 +9,7 @@ muonShowerToken = cms.untracked.InputTag("simGmtShowerDigis"), muonLegacyToken = cms.untracked.InputTag("muonLegacyInStage2FormatDigis","legacyMuon"), sumToken = cms.untracked.InputTag("caloStage2Digis","EtSum"), + sumZDCToken = cms.untracked.InputTag("etSumZdcProducer"), maxL1Upgrade = cms.uint32(60) ) diff --git a/L1Trigger/L1TNtuples/src/L1AnalysisL1Upgrade.cc b/L1Trigger/L1TNtuples/src/L1AnalysisL1Upgrade.cc index da62a14a601b5..cfe62f48a3191 100644 --- a/L1Trigger/L1TNtuples/src/L1AnalysisL1Upgrade.cc +++ b/L1Trigger/L1TNtuples/src/L1AnalysisL1Upgrade.cc @@ -156,3 +156,20 @@ void L1Analysis::L1AnalysisL1Upgrade::SetSum(const l1t::EtSumBxCollection& sums, } } } + +void L1Analysis::L1AnalysisL1Upgrade::SetSumZDC(const l1t::EtSumBxCollection& sumsZDC, unsigned maxL1Upgrade) { + for (int ibx = sumsZDC.getFirstBX(); ibx <= sumsZDC.getLastBX(); ++ibx) { + for (l1t::EtSumBxCollection::const_iterator it = sumsZDC.begin(ibx); + it != sumsZDC.end(ibx) && l1upgrade_.nSumsZDC < maxL1Upgrade; + it++) { + int type = static_cast(it->getType()); + l1upgrade_.sumZDCType.push_back(type); + l1upgrade_.sumZDCEt.push_back(it->et()); + l1upgrade_.sumZDCPhi.push_back(it->phi()); + l1upgrade_.sumZDCIEt.push_back(it->hwPt()); + l1upgrade_.sumZDCIPhi.push_back(it->hwPhi()); + l1upgrade_.sumZDCBx.push_back(ibx); + l1upgrade_.nSumsZDC++; + } + } +} diff --git a/L1Trigger/L1TZDC/BuildFile.xml b/L1Trigger/L1TZDC/BuildFile.xml new file mode 100644 index 0000000000000..2022333c0a3b4 --- /dev/null +++ b/L1Trigger/L1TZDC/BuildFile.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/L1Trigger/L1TZDC/README.md b/L1Trigger/L1TZDC/README.md new file mode 100644 index 0000000000000..7fe2b4e2c24d7 --- /dev/null +++ b/L1Trigger/L1TZDC/README.md @@ -0,0 +1,112 @@ +Below README for testing prior to CMSSW integration + + +***** COMMON FIXES ON FAIL (Skip to below for build instructions) ***** + +If you see output like the following +``` +----- Begin Fatal Exception 18-Aug-2023 22:34:50 CEST----------------------- +An exception of category 'ProductNotFound' occurred while + [0] Processing Event run: 326295 lumi: 4 event: 32601 stream: 0 + [1] Running path 'zdcEtSum' + [2] Calling method for module L1TZDCProducer/'zdcEtSumProducer' +Exception Message: +Principal::getByToken: Found zero products matching all criteria +Looking for type: HcalDataFrameContainer +Looking for module label: hcalDigis +Looking for productInstanceName: ZDC +Looking for process: reRECO + Additional Info: + [a] If you wish to continue processing events after a ProductNotFound exception, +add "SkipEvent = cms.untracked.vstring('ProductNotFound')" to the "options" PSet in the configuration. + +----- End Fatal Exception ------------------------------------------------- +``` + +The issue is almost certainly the inclusion of "reRECO" as a third argument for the zdcDigis input tag to zDCEtSumProducer (CM note: putting this at the top as I have forgotten this issue twice now) + +*********************************************************************** + + +Basic build instructions, integratable into Molly's L1Emulator instructions with the Run 3 HI menu using CMSSW_13_1_0_pre4 Found here: \ +https://github.com/mitaylor/L1StudiesFramework/tree/main/RunPbPbL1Ntuples + +To build, do +``` +cmsrel CMSSW_13_1_0_pre4 +cd CMSSW_13_1_0_pre4/src +cmsenv +git cms-init +#Insert zdcL1T_v0.0.X +git remote add cfmcginn https://github.com/cfmcginn/cmssw.git +git fetch cfmcginn zdcL1TOnCMSSW_13_1_0_pre4 +git cms-merge-topic -u cfmcginn:zdcL1T_latest +#Note we will do the next line using https instead of Molly's ssh instructions +#git remote add cms-l1t-offline git@github.com:cms-l1t-offline/cmssw.git +git remote add cms-l1t-offline https://github.com/cms-l1t-offline/cmssw.git +git fetch cms-l1t-offline l1t-integration-CMSSW_13_1_0_pre4 +git cms-merge-topic -u cms-l1t-offline:l1t-integration-v161 +git clone https://github.com/cms-l1t-offline/L1Trigger-L1TCalorimeter.git L1Trigger/L1TCalorimeter/data +svn export https://github.com/boundino/HltL1Run2021.git/trunk/L1/ADC + +git cms-checkdeps -A -a + +scram b -j 8 + +wget https://raw.githubusercontent.com/ginnocen/UPCopenHFanalysis/main/zdc_calibration/newZDCAnalyzer/test/files_327524.txt +mv files_327524.txt L1Trigger/L1TZDC/test/ +``` + +To test, do +``` +cd L1Trigger/L1TZDC/test +cmsRun l1ZDCProducerTest.py +``` + +Continuing, but now explicitly using Molly's build instructions directly (Step 2) + +``` +git cms-addpkg L1Trigger/L1TCommon +git cms-addpkg L1Trigger/L1TGlobal +mkdir -p L1Trigger/L1TGlobal/data/Luminosity/startup/ +cd L1Trigger/L1TGlobal/data/Luminosity/startup/ +wget https://raw.githubusercontent.com/mitaylor/HIMenus/main/Menus/L1Menu_CollisionsHeavyIons2023_v0_0_1.xml +cd ../../../../../ +scram b -j 8 +``` +On a good build we need to edit customiseUtils.py per Molly's instructions: + +emacs -nw L1Trigger/Configuration/python/customiseUtils.py + +process.TriggerMenu.L1TriggerMenuFile = cms.string('L1Menu_Collisions2022_v1_2_0.xml') → process.TriggerMenu.L1TriggerMenuFile = cms.string('L1Menu_CollisionsHeavyIons2023_v0_0_1.xml') + +Create the python by grabbing Molly's runCmsDriver for 2018 data +``` +wget https://raw.githubusercontent.com/mitaylor/L1StudiesFramework/main/RunPbPbL1Ntuples/runCmsDriver_2018Data.sh +bash runCmsDriver_2018Data.sh +``` + +We need to modify the output, l1Ntuple_2018Data.py +Towards the end add this block, but before the line + +"MassReplaceInputTag(process, new="rawDataMapperByLabel", old="rawDataCollector")" +**************************** +``` +process.l1UpgradeTree.sumZDCToken = cms.untracked.InputTag("zdcEtSumProducer") + +process.l1UpgradeEmuTree.sumZDCToken = cms.untracked.InputTag("zdcEtSumProducer") + +process.zdcEtSumProducer = cms.EDProducer('L1TZDCProducer', + zdcDigis = cms.InputTag("hcalDigis", "ZDC") +) + +process.zdcEtSum = cms.Path(process.zdcEtSumProducer) +process.schedule.append(process.zdcEtSum) + +#ABOVE CODE BEFORE THIS LINE +MassReplaceInputTag(process, new="rawDataMapperByLabel", old="rawDataCollector") +``` +**************************** + + +This should run out of the box - if it does not please contact me (cfmcginn) or ginnocen @ github \ No newline at end of file diff --git a/L1Trigger/L1TZDC/plugins/BuildFile.xml b/L1Trigger/L1TZDC/plugins/BuildFile.xml new file mode 100644 index 0000000000000..0e934cbf2c4b1 --- /dev/null +++ b/L1Trigger/L1TZDC/plugins/BuildFile.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/L1Trigger/L1TZDC/plugins/L1TZDCAnalyzer.cc b/L1Trigger/L1TZDC/plugins/L1TZDCAnalyzer.cc new file mode 100644 index 0000000000000..ab192412dcc23 --- /dev/null +++ b/L1Trigger/L1TZDC/plugins/L1TZDCAnalyzer.cc @@ -0,0 +1,139 @@ +//Copied from L1TStage2CaloAnalyzer on 2023.08.04 as it exists in CMSSW_13_1_0_pre4 +//Modified by Chris McGinn to instead work for just ZDC etSums +//Contact at christopher.mc.ginn@cern.ch or cfmcginn @ github for bugs + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "CondFormats/L1TObjects/interface/CaloParams.h" +#include "CondFormats/DataRecord/interface/L1TCaloParamsRcd.h" + +#include "DataFormats/L1TCalorimeter/interface/CaloTower.h" +#include "DataFormats/L1TCalorimeter/interface/CaloCluster.h" +#include "DataFormats/L1Trigger/interface/EGamma.h" +#include "DataFormats/L1Trigger/interface/Tau.h" +#include "DataFormats/L1Trigger/interface/Jet.h" +#include "DataFormats/L1Trigger/interface/EtSum.h" + +//For the output +#include "TTree.h" +//string for some branch handling +#include + +// +// class declaration +// + +namespace l1t { + + class L1TZDCAnalyzer : public edm::one::EDAnalyzer { + public: + explicit L1TZDCAnalyzer(const edm::ParameterSet&); + ~L1TZDCAnalyzer() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + //fileservice + edm::Service fs_; + //Declare a tree, member and pointer + TTree* etSumZdcTree_; + //Declare the etSum max and bpx max + //MAX Here is effectively a hardcoded number - you just need to know it from the producer - realistically this is best handled by something passed but for now (2023.08.17) we hardcode + static const int maxBPX_ = 5; + float etSumZdcP_[maxBPX_]; + float etSumZdcM_[maxBPX_]; + + // ----------member data --------------------------- + edm::EDGetToken sumToken_; + + bool doHistos_; + + TFileDirectory evtDispDir_; + }; + + // + // constants, enums and typedefs + // + + // + // static data member definitions + // + + // + // constructors and destructor + // + L1TZDCAnalyzer::L1TZDCAnalyzer(const edm::ParameterSet& iConfig) + : doHistos_(iConfig.getUntrackedParameter("doHistos", true)) { + usesResource(TFileService::kSharedResource); + //now do what ever initialization is needed + + // register what you consume and keep token for later access: + edm::InputTag nullTag("None"); + + edm::InputTag sumTag = iConfig.getParameter("etSumTag"); + sumToken_ = consumes(sumTag); + + edm::LogInfo("L1TZDCAnalyzer") << "Processing " << sumTag.label() << std::endl; + } + + // + // member functions + // + + // ------------ method called for each event ------------ + void L1TZDCAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + + // Handle sums; + Handle > sums; + iEvent.getByToken(sumToken_, sums); + + int startBX = sums->getFirstBX(); + + for (int ibx = startBX; ibx <= sums->getLastBX(); ++ibx) { + for (auto itr = sums->begin(ibx); itr != sums->end(ibx); ++itr) { + if (itr->getType() == l1t::EtSum::EtSumType::kZDCP) + etSumZdcP_[ibx - startBX] = itr->hwPt(); + if (itr->getType() == l1t::EtSum::EtSumType::kZDCM) + etSumZdcM_[ibx - startBX] = itr->hwPt(); + } + } + + etSumZdcTree_->Fill(); + } + + // ------------ method called once each job just before starting event loop ------------ + void L1TZDCAnalyzer::beginJob() { + etSumZdcTree_ = fs_->make("etSumZdcTree", ""); + etSumZdcTree_->Branch("etSumZdcP", etSumZdcP_, ("etSumZdcP[" + std::to_string(maxBPX_) + "]/F").c_str()); + etSumZdcTree_->Branch("etSumZdcM", etSumZdcM_, ("etSumZdcM[" + std::to_string(maxBPX_) + "]/F").c_str()); + } + + // ------------ method called once each job just after ending the event loop ------------ + void L1TZDCAnalyzer::endJob() {} + + // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ + void L1TZDCAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + + desc.add("etSumTag", edm::InputTag("etSumZdcProducer", "")); + descriptions.add("l1tZDCAnalyzer", desc); + } + +} // namespace l1t + +using namespace l1t; + +//define this as a plug-in +DEFINE_FWK_MODULE(L1TZDCAnalyzer); diff --git a/L1Trigger/L1TZDC/plugins/L1TZDCProducer.cc b/L1Trigger/L1TZDC/plugins/L1TZDCProducer.cc new file mode 100644 index 0000000000000..27885f85df2f3 --- /dev/null +++ b/L1Trigger/L1TZDC/plugins/L1TZDCProducer.cc @@ -0,0 +1,259 @@ +// -*- C++ -*- +// +// Package: L1Trigger/L1TZDC +// Class: L1TZDC +// +/**\class L1TZDC L1TZDCProducer.cc L1Trigger/L1TZDC/plugins/L1TZDCProducer.cc + + Description: ZDC Producer for L1 Trigger emulation + + Implementation: + Below text meant to indicate this was largely copied from some original work by James; +modified to be appropriate for producing ZDC Et Sums +*/ +// +// Original Author: James Brooke +// Created: Thu, 05 Dec 2013 17:39:27 GMT +// +// Copied for ZDC by: Chris McGinn +// Copy Made: Wed, 03 Aug 2023 +// Contact: christopher.mc.ginn@cern.ch or +// cfmcginn on github for bugs/issues +// +#include +#include +// user include files + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Utilities/interface/EDPutToken.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TCalorimeter/interface/Stage2Layer2FirmwareFactory.h" +#include "L1Trigger/L1TCalorimeter/interface/Stage2MainProcessor.h" +#include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" + +#include "L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h" +#include "CondFormats/DataRecord/interface/L1TCaloParamsRcd.h" +#include "CondFormats/DataRecord/interface/L1TCaloParamsO2ORcd.h" + +#include "DataFormats/L1TCalorimeter/interface/CaloTower.h" +#include "DataFormats/L1Trigger/interface/EGamma.h" +#include "DataFormats/L1Trigger/interface/Tau.h" +#include "DataFormats/L1Trigger/interface/Jet.h" +#include "DataFormats/L1Trigger/interface/EtSum.h" + +#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" + +// +// class declaration +// + +using namespace l1t; + +class L1TZDCProducer : public edm::stream::EDProducer<> { +public: + explicit L1TZDCProducer(const edm::ParameterSet& ps); + ~L1TZDCProducer() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + + void beginRun(edm::Run const&, edm::EventSetup const&) override; + // void endRun(edm::Run const&, edm::EventSetup const&) override; + + int zdcLUTIndexHelper(int iDetPos, int iBXPos); + + // ----------member data --------------------------- + + // input tokens + //Add the ZDC token, candidateToken for caloParamsHelper + edm::EDGetTokenT zdcToken_; + edm::ESGetToken candidateToken_; + + //input ints + int bxFirst_; + int bxLast_; + int sampleToCenterBX_; + + // put tokens + edm::EDPutTokenT etToken_; + + //Following the L1TStage2Layer2Producer + std::unique_ptr params_; + int scaleFactor_; +}; + +L1TZDCProducer::L1TZDCProducer(const edm::ParameterSet& ps) { + // register what you produce + etToken_ = produces(); + + // register what you consume and keep token for later access: + zdcToken_ = consumes(ps.getParameter("zdcDigis")); + candidateToken_ = esConsumes(); + + bxFirst_ = ps.getParameter("bxFirst"); + bxLast_ = ps.getParameter("bxLast"); + sampleToCenterBX_ = ps.getParameter("sampleToCenterBX"); +} + +// ------------ method called to produce the data ------------ +void L1TZDCProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + using namespace l1t; + + LogDebug("L1TZDCProducer") << "L1TZDCProducer::produce function called..." << std::endl; + + // reduced collection to be emplaced in output + EtSumBxCollection etsumsReduced(0, bxFirst_, bxLast_); + + //inputs + Handle zdcDigiCollection; + iEvent.getByToken(zdcToken_, zdcDigiCollection); + + //Produce ZDC EtSums IF input zdcDigiCollection is valid + if (zdcDigiCollection.isValid()) { + //In lieu of bxFirst, bxLast, use the number of the timeslice samples + const QIE10DataFrame& frametest = (*zdcDigiCollection)[0]; + int nSamples = frametest.samples(); + + //Check if the sample requested as center bx is valid + int sampleToCenterBXChecked = sampleToCenterBX_; + + if (sampleToCenterBXChecked < 0) { + edm::LogWarning("L1TZDCProducer") << "sampleToCenterBX LT 0; Set bx 0 to sample 0 (minimum allowed)" << std::endl; + sampleToCenterBXChecked = 0; + } else if (sampleToCenterBXChecked >= nSamples) { + edm::LogWarning("L1TZDCProducer") + << "sampleToCenterBX GE nsamples; Set bx 0 to sample nsamples-1 (maximum allowed)" << std::endl; + sampleToCenterBXChecked = nSamples - 1; + } + + //rawadc[detector index][time slices] + unsigned short rawadc[18][10]; + + // the loop below loops over all the elements of the QIE10DigiCollection. Each entry corresponds to one channel + for (QIE10DigiCollection::const_iterator it = zdcDigiCollection->begin(); it != zdcDigiCollection->end(); it++) { + const QIE10DataFrame& frame(*it); + HcalZDCDetId cell = frame.id(); + int zside = cell.zside(); + int section = cell.section(); + int channel = cell.channel(); + + if (zside != -1 && zside != 1) + continue; + if (section != 1 && section != 2) + continue; + if (section == 1 && (channel < 1 || channel > 5)) + continue; + if (section == 2 && (channel < 1 || channel > 4)) + continue; + + int ihitid = (zside == 1 ? 9 : 0) + (section == 2 ? 5 : 0) + (channel - 1); + //the loop below iterates over the time slices + for (int iTS = 0; iTS < nSamples; iTS++) { + unsigned short adc = (unsigned short)frame[iTS].adc(); + rawadc[ihitid][iTS] = adc; + } // end of loop over iTS + } //end of loop over channels + + for (int ibx = 0; ibx < nSamples; ibx++) { + double cEMP = 0, cEMM = 0, cHDP = 0, cHDM = 0; + double sumcEMP = 0, sumcEMM = 0, sumcHDP = 0, sumcHDM = 0; + //idet=0-4 correpond to the EM channels + for (int idet = 0; idet < 5; idet++) { + unsigned short EMP = rawadc[idet + 9][ibx]; + unsigned short EMM = rawadc[idet][ibx]; + + int cEMP_LUTIndex = zdcLUTIndexHelper(idet + 9, (int)EMP); + int cEMM_LUTIndex = zdcLUTIndexHelper(idet, (int)EMM); + + cEMP = ((double)params_->zdcLUT()->data(cEMP_LUTIndex)) / ((double)scaleFactor_); + cEMM = ((double)params_->zdcLUT()->data(cEMM_LUTIndex)) / ((double)scaleFactor_); + + sumcEMP = sumcEMP + cEMP; + sumcEMM = sumcEMM + cEMM; + } + //idet=5-8 correspond to HAD channels + for (int idet = 5; idet < 9; idet++) { + unsigned short HDP = rawadc[idet + 9][ibx]; + unsigned short HDM = rawadc[idet][ibx]; + + int cHDP_LUTIndex = zdcLUTIndexHelper(idet + 9, (int)HDP); + int cHDM_LUTIndex = zdcLUTIndexHelper(idet, (int)HDM); + + cHDP = ((double)params_->zdcLUT()->data(cHDP_LUTIndex)) / ((double)scaleFactor_); + cHDM = ((double)params_->zdcLUT()->data(cHDM_LUTIndex)) / ((double)scaleFactor_); + + sumcHDP = sumcHDP + cHDP; + sumcHDM = sumcHDM + cHDM; + } + double sumM = sumcEMM + sumcHDM; + double sumP = sumcEMP + sumcHDP; + + if (ibx == 4) { + edm::LogInfo("L1TZDCProducer") << ", sumM= " << sumM << std::endl; + edm::LogInfo("L1TZDCProducer") << ", sumP= " << sumP << std::endl; + } + l1t::EtSum tempEtM = l1t::EtSum(); + tempEtM.setHwPt(sumM); + tempEtM.setHwEta(-1.); + tempEtM.setHwPhi(0.); + tempEtM.setType(EtSum::EtSumType::kZDCM); + + l1t::EtSum tempEtP = l1t::EtSum(); + tempEtP.setHwPt(sumP); + tempEtP.setHwEta(1.); + tempEtP.setHwPhi(0.); + tempEtP.setType(EtSum::EtSumType::kZDCP); + + if (ibx >= sampleToCenterBXChecked + bxFirst_ && ibx <= sampleToCenterBXChecked + bxLast_) { + etsumsReduced.push_back(ibx - sampleToCenterBXChecked, CaloTools::etSumP4Demux(tempEtP)); + etsumsReduced.push_back(ibx - sampleToCenterBXChecked, CaloTools::etSumP4Demux(tempEtM)); + } + } // end of loop over bunch crossings + } // end if(zdcDigiCollection.isValid()) + else { + // If the collection is not valid issue a warning before putting an empty collection + edm::LogWarning("L1TZDCProducer") << "zdcDigis not valid; return empty ZDC Et Sum BXCollection" << std::endl; + } + + // Emplace even if !zdcDigiCollection.isValid() + // Output in this case will be an empty collection + iEvent.emplace(etToken_, std::move(etsumsReduced)); +} + +// ------------ method called when starting to processes a run ------------ +void L1TZDCProducer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { + edm::ESHandle candidateHandle = iSetup.getHandle(candidateToken_); + + params_ = std::make_unique(*candidateHandle.product()); + scaleFactor_ = params_->zdcLUT()->data(0); //First position is the integer scaling factor + edm::LogInfo("L1TZDCProducer") << "SCALE FACTOR FOR LUT: " << scaleFactor_ << std::endl; +} + +// LUT HELPER METHOD +int L1TZDCProducer::zdcLUTIndexHelper(int iDetPos, int iBxPos) { return 1 + iDetPos * 256 + iBxPos; } + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void L1TZDCProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("zdcDigis", edm::InputTag("hcalDigis", "ZDC")); + desc.add("bxFirst", -2); + desc.add("bxLast", 2); + desc.add("sampleToCenterBX", 4); + descriptions.add("l1tZDCProducer", desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(L1TZDCProducer); diff --git a/L1Trigger/L1TZDC/test/createLUT.C b/L1Trigger/L1TZDC/test/createLUT.C new file mode 100644 index 0000000000000..cc2cd29185663 --- /dev/null +++ b/L1Trigger/L1TZDC/test/createLUT.C @@ -0,0 +1,151 @@ +void createLUT(int capid = 0) { + double const QIE10_regular_fC[256][4] = { + {1.62607, 1.62872, 1.63148, 1.63196}, {4.87821, 4.88615, 4.89444, 4.89588}, {8.13035, 8.14359, 8.1574, 8.1598}, + {11.3825, 11.401, 11.4204, 11.4237}, {14.6346, 14.6585, 14.6833, 14.6876}, {17.8868, 17.9159, 17.9463, 17.9516}, + {21.1389, 21.1733, 21.2093, 21.2155}, {24.391, 24.4308, 24.4722, 24.4794}, {27.6432, 27.6882, 27.7352, 27.7433}, + {30.8953, 30.9456, 30.9981, 31.0072}, {34.1475, 34.2031, 34.2611, 34.2712}, {37.3996, 37.4605, 37.5241, 37.5351}, + {40.6517, 40.7179, 40.787, 40.799}, {43.9039, 43.9754, 44.05, 44.0629}, {47.156, 47.2328, 47.313, 47.3268}, + {50.4081, 50.4902, 50.5759, 50.5908}, {55.2864, 55.3764, 55.4704, 55.4866}, {61.7906, 61.8913, 61.9963, 62.0145}, + {68.2949, 68.4061, 68.5222, 68.5423}, {74.7992, 74.921, 75.0481, 75.0702}, {81.3035, 81.4359, 81.5741, 81.598}, + {87.8077, 87.9507, 88.1, 88.1259}, {94.312, 94.4656, 94.6259, 94.6537}, {100.816, 100.98, 101.152, 101.182}, + {107.321, 107.495, 107.678, 107.709}, {113.825, 114.01, 114.204, 114.237}, {120.329, 120.525, 120.73, 120.765}, + {126.833, 127.04, 127.256, 127.293}, {133.338, 133.555, 133.781, 133.821}, {139.842, 140.07, 140.307, 140.349}, + {146.346, 146.585, 146.833, 146.876}, {152.851, 153.099, 153.359, 153.404}, {159.355, 159.614, 159.885, 159.932}, + {165.859, 166.129, 166.411, 166.46}, {172.363, 172.644, 172.937, 172.988}, {178.868, 179.159, 179.463, 179.516}, + {188.624, 188.931, 189.252, 189.307}, {201.633, 201.961, 202.304, 202.363}, {214.641, 214.991, 215.355, 215.419}, + {227.65, 228.02, 228.407, 228.474}, {240.658, 241.05, 241.459, 241.53}, {253.667, 254.08, 254.511, 254.586}, + {266.675, 267.11, 267.563, 267.641}, {279.684, 280.139, 280.615, 280.697}, {292.692, 293.169, 293.667, 293.753}, + {305.701, 306.199, 306.718, 306.809}, {318.71, 319.229, 319.77, 319.864}, {331.718, 332.258, 332.822, 332.92}, + {344.727, 345.288, 345.874, 345.976}, {357.735, 358.318, 358.926, 359.031}, {370.744, 371.348, 371.978, 372.087}, + {383.752, 384.377, 385.03, 385.143}, {396.761, 397.407, 398.081, 398.198}, {409.769, 410.437, 411.133, 411.254}, + {422.778, 423.467, 424.185, 424.31}, {435.787, 436.496, 437.237, 437.365}, {448.795, 449.526, 450.289, 450.421}, + {468.308, 469.071, 469.867, 470.005}, {494.325, 495.13, 495.97, 496.116}, {520.342, 521.19, 522.074, 522.227}, + {546.359, 547.249, 548.178, 548.339}, {572.376, 573.309, 574.281, 574.45}, {598.393, 599.368, 600.385, 600.561}, + {624.411, 625.428, 626.489, 626.673}, {568.652, 566.063, 566.86, 568.124}, {594.369, 591.816, 592.657, 593.933}, + {620.087, 617.568, 618.453, 619.741}, {645.805, 643.321, 644.25, 645.549}, {671.523, 669.073, 670.046, 671.357}, + {697.24, 694.826, 695.843, 697.165}, {722.958, 720.578, 721.639, 722.973}, {748.676, 746.331, 747.436, 748.781}, + {774.393, 772.083, 773.232, 774.589}, {800.111, 797.836, 799.029, 800.398}, {825.829, 823.588, 824.825, 826.206}, + {851.546, 849.34, 850.622, 852.014}, {877.264, 875.093, 876.418, 877.822}, {902.982, 900.845, 902.214, 903.63}, + {928.699, 926.598, 928.011, 929.438}, {954.417, 952.35, 953.807, 955.246}, {992.994, 990.979, 992.502, 993.958}, + {1044.43, 1042.48, 1044.1, 1045.57}, {1095.86, 1093.99, 1095.69, 1097.19}, {1147.3, 1145.49, 1147.28, 1148.81}, + {1198.73, 1197, 1198.87, 1200.42}, {1250.17, 1248.5, 1250.47, 1252.04}, {1301.61, 1300.01, 1302.06, 1303.66}, + {1353.04, 1351.51, 1353.65, 1355.27}, {1404.48, 1403.02, 1405.25, 1406.89}, {1455.91, 1454.52, 1456.84, 1458.5}, + {1507.35, 1506.03, 1508.43, 1510.12}, {1558.78, 1557.53, 1560.02, 1561.74}, {1610.22, 1609.04, 1611.62, 1613.35}, + {1661.65, 1660.54, 1663.21, 1664.97}, {1713.09, 1712.05, 1714.8, 1716.59}, {1764.52, 1763.55, 1766.4, 1768.2}, + {1815.96, 1815.06, 1817.99, 1819.82}, {1867.39, 1866.56, 1869.58, 1871.43}, {1918.83, 1918.07, 1921.17, 1923.05}, + {1970.27, 1969.57, 1972.77, 1974.67}, {2047.42, 2046.83, 2050.16, 2052.09}, {2150.29, 2149.84, 2153.34, 2155.32}, + {2253.16, 2252.85, 2256.53, 2258.56}, {2356.03, 2355.86, 2359.71, 2361.79}, {2458.9, 2458.87, 2462.9, 2465.02}, + {2561.77, 2561.88, 2566.09, 2568.25}, {2664.64, 2664.89, 2669.27, 2671.49}, {2767.51, 2767.9, 2772.46, 2774.72}, + {2870.38, 2870.91, 2875.64, 2877.95}, {2973.26, 2973.92, 2978.83, 2981.18}, {3076.13, 3076.93, 3082.02, 3084.42}, + {3179, 3179.94, 3185.2, 3187.65}, {3281.87, 3282.95, 3288.39, 3290.88}, {3384.74, 3385.96, 3391.57, 3394.11}, + {3487.61, 3488.97, 3494.76, 3497.35}, {3590.48, 3591.98, 3597.95, 3600.58}, {3693.35, 3694.99, 3701.13, 3703.81}, + {3796.22, 3798, 3804.32, 3807.04}, {3899.09, 3901.01, 3907.5, 3910.28}, {4001.96, 4004.02, 4010.69, 4013.51}, + {4104.83, 4107.03, 4113.88, 4116.74}, {4259.14, 4261.54, 4268.65, 4271.59}, {4464.88, 4467.56, 4475.03, 4478.05}, + {4670.62, 4673.58, 4681.4, 4684.52}, {4876.36, 4879.6, 4887.77, 4890.98}, {5082.11, 5085.62, 5094.14, 5097.45}, + {5287.85, 5291.64, 5300.51, 5303.91}, {5493.59, 5497.66, 5506.88, 5510.38}, {4996.09, 4997.3, 5008.36, 5013.93}, + {5200.82, 5202.38, 5213.76, 5219.46}, {5405.55, 5407.47, 5419.15, 5424.99}, {5610.27, 5612.56, 5624.55, 5630.52}, + {5815, 5817.65, 5829.95, 5836.05}, {6019.73, 6022.74, 6035.35, 6041.58}, {6224.46, 6227.83, 6240.75, 6247.11}, + {6429.19, 6432.92, 6446.14, 6452.64}, {6633.91, 6638, 6651.54, 6658.17}, {6838.64, 6843.09, 6856.94, 6863.7}, + {7043.37, 7048.18, 7062.34, 7069.23}, {7248.1, 7253.27, 7267.74, 7274.76}, {7452.83, 7458.36, 7473.13, 7480.29}, + {7657.55, 7663.45, 7678.53, 7685.82}, {7862.28, 7868.54, 7883.93, 7891.35}, {8067.01, 8073.63, 8089.33, 8096.88}, + {8374.1, 8381.26, 8397.43, 8405.18}, {8783.56, 8791.44, 8808.22, 8816.24}, {9193.01, 9201.61, 9219.02, 9227.3}, + {9602.47, 9611.79, 9629.82, 9638.36}, {10011.9, 10022, 10040.6, 10049.4}, {10421.4, 10432.1, 10451.4, 10460.5}, + {10830.8, 10842.3, 10862.2, 10871.5}, {11240.3, 11252.5, 11273, 11282.6}, {11649.7, 11662.7, 11683.8, 11693.7}, + {12059.2, 12072.9, 12094.6, 12104.7}, {12468.7, 12483, 12505.4, 12515.8}, {12878.1, 12893.2, 12916.2, 12926.8}, + {13287.6, 13303.4, 13327, 13337.9}, {13697, 13713.6, 13737.8, 13749}, {14106.5, 14123.7, 14148.6, 14160}, + {14515.9, 14533.9, 14559.4, 14571.1}, {14925.4, 14944.1, 14970.2, 14982.1}, {15334.9, 15354.3, 15381, 15393.2}, + {15744.3, 15764.5, 15791.8, 15804.3}, {16153.8, 16174.6, 16202.6, 16215.3}, {16767.9, 16789.9, 16818.8, 16831.9}, + {17586.9, 17610.3, 17640.3, 17654}, {18405.8, 18430.6, 18461.9, 18476.2}, {19224.7, 19251, 19283.5, 19298.3}, + {20043.6, 20071.3, 20105.1, 20120.4}, {20862.5, 20891.7, 20926.7, 20942.5}, {21681.4, 21712, 21748.3, 21764.6}, + {22500.3, 22532.4, 22569.9, 22586.8}, {23319.2, 23352.7, 23391.5, 23408.9}, {24138.2, 24173.1, 24213.1, 24231}, + {24957.1, 24993.5, 25034.7, 25053.1}, {25776, 25813.8, 25856.3, 25875.2}, {26594.9, 26634.2, 26677.9, 26697.4}, + {27413.8, 27454.5, 27499.5, 27519.5}, {28232.7, 28274.9, 28321, 28341.6}, {29051.6, 29095.2, 29142.6, 29163.7}, + {29870.5, 29915.6, 29964.2, 29985.8}, {30689.4, 30735.9, 30785.8, 30808}, {31508.4, 31556.3, 31607.4, 31630.1}, + {32327.3, 32376.6, 32429, 32452.2}, {33146.2, 33197, 33250.6, 33274.3}, {34374.6, 34427.5, 34483, 34507.5}, + {36012.4, 36068.2, 36126.2, 36151.7}, {37650.2, 37709, 37769.4, 37796}, {39288, 39349.7, 39412.5, 39440.2}, + {40925.8, 40990.4, 41055.7, 41084.5}, {42563.7, 42631.1, 42698.9, 42728.7}, {44201.5, 44271.8, 44342.1, 44372.9}, + {41124.8, 41187, 41205.1, 41213.7}, {42733.7, 42797.8, 42818.1, 42828.2}, {44342.5, 44408.6, 44431.1, 44442.8}, + {45951.4, 46019.4, 46044.1, 46057.3}, {47560.2, 47630.3, 47657.1, 47671.8}, {49169.1, 49241.1, 49270.1, 49286.4}, + {50777.9, 50851.9, 50883.1, 50900.9}, {52386.8, 52462.7, 52496.1, 52515.4}, {53995.6, 54073.6, 54109.1, 54130}, + {55604.4, 55684.4, 55722.1, 55744.5}, {57213.3, 57295.2, 57335.1, 57359}, {58822.1, 58906, 58948.1, 58973.6}, + {60431, 60516.8, 60561.1, 60588.1}, {62039.8, 62127.7, 62174.1, 62202.6}, {63648.7, 63738.5, 63787.1, 63817.1}, + {65257.5, 65349.3, 65400.1, 65431.7}, {67670.8, 67765.5, 67819.7, 67853.5}, {70888.5, 70987.2, 71045.7, 71082.5}, + {74106.2, 74208.8, 74271.7, 74311.6}, {77323.9, 77430.5, 77497.7, 77540.7}, {80541.6, 80652.1, 80723.7, 80769.7}, + {83759.3, 83873.8, 83949.7, 83998.8}, {86977, 87095.4, 87175.7, 87227.8}, {90194.7, 90317.1, 90401.7, 90456.9}, + {93412.4, 93538.7, 93627.7, 93686}, {96630.1, 96760.4, 96853.7, 96915}, {99847.8, 99982, 100080, 100144}, + {103065, 103204, 103306, 103373}, {106283, 106425, 106532, 106602}, {109501, 109647, 109758, 109831}, + {112719, 112869, 112984, 113060}, {115936, 116090, 116210, 116289}, {119154, 119312, 119436, 119518}, + {122372, 122534, 122662, 122748}, {125589, 125755, 125888, 125977}, {128807, 128977, 129114, 129206}, + {133634, 133809, 133953, 134049}, {140069, 140253, 140405, 140507}, {146504, 146696, 146857, 146965}, + {152940, 153139, 153309, 153424}, {159375, 159582, 159761, 159882}, {165811, 166026, 166213, 166340}, + {172246, 172469, 172665, 172798}, {178681, 178912, 179117, 179256}, {185117, 185356, 185569, 185714}, + {191552, 191799, 192021, 192172}, {197988, 198242, 198473, 198630}, {204423, 204685, 204925, 205089}, + {210858, 211129, 211377, 211547}, {217294, 217572, 217829, 218005}, {223729, 224015, 224281, 224463}, + {230165, 230459, 230733, 230921}, {236600, 236902, 237185, 237379}, {243035, 243345, 243637, 243837}, + {249471, 249789, 250089, 250295}, {255906, 256232, 256541, 256754}, {262342, 262675, 262993, 263212}, + {271995, 272340, 272671, 272899}, {284865, 285227, 285575, 285815}, {297736, 298113, 298479, 298731}, + {310607, 311000, 311383, 311648}, {323478, 323886, 324287, 324564}, {336349, 336773, 337191, 337480}, + {349219, 349660, 350096, 350396}}; + + const float cEMHAD = 0.2; + double calibconst[2][9] = {{0.510403, 1.14888, 1.17357, 0.970406, 0.990911, 1.00, 0.57, 0.37, 0.42}, + {0.670134, 1.18538, 1.07780, 0.925180, 0.659861, 1.00, 0.64, 0.30, 0.28}}; + + // side=0 -> Negative: NEM1, NEM2, NEM3, NEM4, NEM5, NHD1, NHD2, NHD3, NHD4, + // side=1 -> Positive: PEM1, PEM2, PEM3, PEM4, PEM5, PHD1, PHD2, PHD3, PHD4 + + double QIE10_regular_fC_full[256][18]; + for (int ibit = 0; ibit < 256; ibit++) { + for (int idet = 0; idet < 18; idet++) { + if (idet >= 0 && idet < 5) + QIE10_regular_fC_full[ibit][idet] = cEMHAD * calibconst[0][idet] * QIE10_regular_fC[ibit][capid]; + if (idet >= 5 && idet < 9) + QIE10_regular_fC_full[ibit][idet] = calibconst[0][idet] * QIE10_regular_fC[ibit][capid]; + if (idet >= 9 && idet < 14) + QIE10_regular_fC_full[ibit][idet] = cEMHAD * calibconst[1][idet - 9] * QIE10_regular_fC[ibit][capid]; + if (idet >= 14 && idet < 18) + QIE10_regular_fC_full[ibit][idet] = calibconst[1][idet - 9] * QIE10_regular_fC[ibit][capid]; + } + } + + //CM edit 2023.08.16 - switching to a flattened LUT + /* + std::cout<<"double QIE10_regular_fC_full[256][18]={"< int conversion" << std::endl; + std::cout << "#
V1 13 32
" << std::endl; + std::cout << std::endl; + + int index = 0; + //Dump the scaling factor first for instant retrieval + std::cout << index << " " << (int)scalingFactor << " # Scaling Factor" << std::endl; + ++index; + for (int idet = 0; idet < 18; idet++) { + for (int ibit = 0; ibit < 256; ibit++) { + //Line for dummy creation + std::cout << index << " " << 1 << " # [index ibit=" << ibit << "], [index idet=" << idet << "]" << std::endl; + //Line for standard + // std::cout << index << " " << (int)(QIE10_regular_fC_full[ibit][idet]*scalingFactor) << " # [index ibit=" << ibit << "], [index idet=" << idet << "]" << std::endl; + ++index; + } + } + + return; +} diff --git a/L1Trigger/L1TZDC/test/l1ZDCProducerTest.py b/L1Trigger/L1TZDC/test/l1ZDCProducerTest.py new file mode 100644 index 0000000000000..fb9ad9cffcc42 --- /dev/null +++ b/L1Trigger/L1TZDC/test/l1ZDCProducerTest.py @@ -0,0 +1,112 @@ +#Copied rom GM zdcDigiAnalyze.py 2023.08.04 +#Found here https://github.com/ginnocen/UPCopenHFanalysis/blob/zdc_calibrationcode/zdc_calibration/newZDCAnalyzer/test/zdcDigiAnalyze.py +#CMcGinn it modifying to test the l1zdc producer, see comments below +#Bugs, contact christopher.mc.ginn@cern.ch or cfmcginn on github + +import FWCore.ParameterSet.Config as cms +import FWCore.Utilities.FileUtils as FileUtils + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process("Demo",eras.Run2_2018_pp_on_AA) + +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.Geometry.GeometrySimDB_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedNominalCollision2015_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.DigiToRaw_cff') +process.load('HLTrigger.Configuration.HLT_GRun_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') + +#process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff") +#process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) +#process.MessageLogger.cerr.FwkReport.reportEvery = 10000 + +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1000)) +process.MessageLogger.cerr.FwkReport.reportEvery = 10 +#process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10)) +#process.MessageLogger.cerr.FwkReport.reportEvery = 1 + +process.TFileService = cms.Service("TFileService",fileName=cms.string("zdcdigitree_DoDUMMYPyLUT_327524.root")) + +#mylist = FileUtils.loadListFromFile('files_temp.txt') +mylist = FileUtils.loadListFromFile('files_327524.txt') +readFiles = cms.untracked.vstring(*mylist) + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + 'file:/afs/cern.ch/user/m/mcsanad/public/CMSSW_10_3_1/src/zdc/newZDCAnalyzer/test/ED0B7A21-B558-924C-A57E-B1651E8BFFA3.root' +# *mylist + ) +) + +#Try some real basic replacement - producer and analyzer +process.etSumZdcProducer = cms.EDProducer('L1TZDCProducer', + zdcDigis = cms.InputTag("hcalDigis", "ZDC", "reRECO"), + bxFirst = cms.int32(-2), + bxLast = cms.int32(2), + sampleToCenterBX = cms.int32(4) + +) + +process.etSumZdcAnalyzer = cms.EDAnalyzer('L1TZDCAnalyzer', + etSumTag = cms.InputTag("etSumZdcProducer") +) + + +process.skimOutput = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string("comp.root"), + outputCommands = cms.untracked.vstring( + 'keep *' + ), +) + + +#process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +#process.GlobalTag.globaltag = '92X_upgrade2017_realistic_v10' +#process.GlobalTag.globaltag = '103X_dataRun2_Express_v2' +#process.GlobalTag.globaltag = '103X_dataRun2_Prompt_v3' + +#CM Note - below global tag file doesnt appear to exist, swapping in the file from runEmulator-CaloStage2.py for now +#process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff') +#the below is the swap from runEmulator-CaloStage2.py +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.GlobalTag.globaltag = cms.string('103X_dataRun2_v6') + +#For lookup tables +# Automatic addition of the customisation function from L1Trigger.Configuration.customiseSettings +from L1Trigger.Configuration.customiseSettings import L1TSettingsToCaloParams_2018_v1_4_1 +#call to customisation function L1TSettingsToCaloParams_2018_v1_4_1 imported from L1Trigger.Configuration.customiseSettings + +#process.caloStage2Params +#L1TSettingsToCaloParams_2018_v1_4_1.caloStage2Params.zdcLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/zdcLUT_HI_DUMMY.txt"), + +process = L1TSettingsToCaloParams_2018_v1_4_1(process) +#process.caloStage2Params.zdcLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/zdcLUT_HI_DUMMY.txt"), + + +process.produce_step = cms.Path(process.etSumZdcProducer) +process.analyze_step = cms.Path(process.etSumZdcAnalyzer) +process.output_step = cms.EndPath(process.skimOutput) + + +process.schedule = cms.Schedule( + process.produce_step, + process.analyze_step, + process.output_step +) + + +#uncomment the output for debugging/saving the etsums diff --git a/L1Trigger/L1TZDC/test/runEmulator-ZDC.py b/L1Trigger/L1TZDC/test/runEmulator-ZDC.py new file mode 100644 index 0000000000000..8c4800a0df78d --- /dev/null +++ b/L1Trigger/L1TZDC/test/runEmulator-ZDC.py @@ -0,0 +1,190 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: SingleElectronPt10_cfi.py -s GEN,SIM,DIGI,L1 --pileup=NoPileUp --geometry DB --conditions=auto:startup -n 1 --no_exec +import FWCore.ParameterSet.Config as cms + + +# options +import FWCore.ParameterSet.VarParsing as VarParsing +options = VarParsing.VarParsing('analysis') +options.register('skipEvents', + 0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, + "Number of events to skip") +options.register('dump', + False, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.bool, + "Print RAW data") +options.register('doLayer1', + False, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.bool, + "Run layer 1 module") +options.register('doLayer2', + True, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.bool, + "Run layer 2 module") +options.register('selMPBx', + 0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, + "Select MP readout Bx") +options.register('selDemuxBx', + 0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, + "Select Demux readout Bx") +options.register('selAllBx', + False, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.bool, + "Run over all Bx in readout for MP and demux") +options.register('evtDisp', + False, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.bool, + 'Produce histos for individual events') + + +options.parseArguments() + + +process = cms.Process('L1Emulator') + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.Geometry.GeometryDB_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(options.maxEvents) +) + +# Input source +#inFile = 'file:l1tCalo_2016_EDM.root' +process.source = cms.Source("PoolSource", + fileNames=cms.untracked.vstring(options.inputFiles), + skipEvents=cms.untracked.uint32(options.skipEvents) +) + +process.options = cms.untracked.PSet( + SkipEvent = cms.untracked.vstring('ProductNotFound') +) + + +# Output definition +process.output = cms.OutputModule( + "PoolOutputModule", + outputCommands = cms.untracked.vstring("keep *"), + fileName = cms.untracked.string('l1tCalo_2016_simEDM.root') +) + +# Additional output definition +# TTree output file +process.load("CommonTools.UtilAlgos.TFileService_cfi") +process.TFileService.fileName = cms.string('l1tCalo_2016_simHistos.root') + + +# enable debug message logging for our modules +process.MessageLogger = cms.Service( + "MessageLogger", + threshold = cms.untracked.string('DEBUG'), + categories = cms.untracked.vstring('L1T'), + debugModules = cms.untracked.vstring('*') +# 'mp7BufferDumpToRaw', +# 'l1tDigis', +# 'caloStage1Digis' +# ) +) + + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:startup', '') + + +# emulator +process.load('L1Trigger.L1TCalorimeter.simCaloStage2Layer1Digis_cfi') +process.load('L1Trigger.L1TCalorimeter.simCaloStage2Digis_cfi') +process.simCaloStage2Digis.useStaticConfig = True +process.simCaloStage2Layer1Digis.ecalToken = cms.InputTag("ecalDigis:EcalTriggerPrimitives") +process.simCaloStage2Layer1Digis.hcalToken = cms.InputTag("hcalDigis") + +# emulator ES +process.load('L1Trigger.L1TCalorimeter.caloParams_2019_v1_0_cfi') + +# histograms +process.load('L1Trigger.L1TCalorimeter.l1tStage2CaloAnalyzer_cfi') +process.l1tStage2CaloAnalyzer.doEvtDisp = options.evtDisp +process.l1tStage2CaloAnalyzer.mpBx = options.selMPBx +process.l1tStage2CaloAnalyzer.dmxBx = options.selDemuxBx +process.l1tStage2CaloAnalyzer.allBx = options.selAllBx +process.l1tStage2CaloAnalyzer.towerToken = cms.InputTag("simCaloStage2Digis", "MP") +process.l1tStage2CaloAnalyzer.clusterToken = cms.InputTag("None") +process.l1tStage2CaloAnalyzer.mpEGToken = cms.InputTag("simCaloStage2Digis", "MP") +process.l1tStage2CaloAnalyzer.mpTauToken = cms.InputTag("simCaloStage2Digis", "MP") +process.l1tStage2CaloAnalyzer.mpJetToken = cms.InputTag("simCaloStage2Digis", "MP") +process.l1tStage2CaloAnalyzer.mpEtSumToken = cms.InputTag("simCaloStage2Digis", "MP") +process.l1tStage2CaloAnalyzer.egToken = cms.InputTag("simCaloStage2Digis") +process.l1tStage2CaloAnalyzer.tauToken = cms.InputTag("simCaloStage2Digis") +process.l1tStage2CaloAnalyzer.jetToken = cms.InputTag("simCaloStage2Digis") +process.l1tStage2CaloAnalyzer.etSumToken = cms.InputTag("simCaloStage2Digis") + +import L1Trigger.L1TCalorimeter.l1tStage2CaloAnalyzer_cfi +process.l1tCaloStage2HwHistos = L1Trigger.L1TCalorimeter.l1tStage2CaloAnalyzer_cfi.l1tStage2CaloAnalyzer.clone() +process.l1tStage2CaloAnalyzer.doEvtDisp = options.evtDisp +process.l1tStage2CaloAnalyzer.mpBx = options.selMPBx +process.l1tStage2CaloAnalyzer.dmxBx = options.selDemuxBx +process.l1tStage2CaloAnalyzer.allBx = options.selAllBx +process.l1tCaloStage2HwHistos.towerToken = cms.InputTag("caloStage2Digis","CaloTower") +process.l1tCaloStage2HwHistos.clusterToken = cms.InputTag("None") +process.l1tCaloStage2HwHistos.mpEGToken = cms.InputTag("caloStage2Digis", "MP") +process.l1tCaloStage2HwHistos.mpTauToken = cms.InputTag("caloStage2Digis","MP") +process.l1tCaloStage2HwHistos.mpJetToken = cms.InputTag("caloStage2Digis", "MP") +process.l1tCaloStage2HwHistos.mpEtSumToken = cms.InputTag("caloStage2Digis", "MP") +process.l1tCaloStage2HwHistos.egToken = cms.InputTag("caloStage2Digis","EGamma") +process.l1tCaloStage2HwHistos.tauToken = cms.InputTag("caloStage2Digis","Tau") +process.l1tCaloStage2HwHistos.jetToken = cms.InputTag("caloStage2Digis","Jet") +process.l1tCaloStage2HwHistos.etSumToken = cms.InputTag("caloStage2Digis","EtSum") + +# Path and EndPath definitions +process.path = cms.Path( + process.ecalDigis + +process.hcalDigis + +process.simCaloStage2Layer1Digis + +process.simCaloStage2Digis + +process.l1tStage2CaloAnalyzer + +process.l1tCaloStage2HwHistos +) + +if (not options.doLayer1): + process.path.remove(process.ecalDigis) + process.path.remove(process.hcalDigis) + process.path.remove(process.simCaloStage2Layer1Digis) + process.simCaloStage2Digis.towerToken = cms.InputTag("caloStage2Digis","CaloTower") + +if (not options.doLayer2): + process.path.remove(process.simCaloStage2Digis) + + +#if (not options.doMP): +# process.path.remove(process.stage2MPRaw) + +#if (not options.-doDemux): +# process.path.remove(process.stage2DemuxRaw) + +process.out = cms.EndPath( + process.output +) +