diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc index c033551330b57..8977b3c15907b 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc @@ -9,6 +9,7 @@ namespace l1t { event_.put(std::move(muonShowers_[0]), "MuonShower"); event_.put(std::move(egammas_[0]), "EGamma"); event_.put(std::move(etsums_[0]), "EtSum"); + event_.put(std::move(zdcsums_[0]), "EtSumZDC"); event_.put(std::move(jets_[0]), "Jet"); event_.put(std::move(taus_[0]), "Tau"); for (int i = 1; i < 6; ++i) { @@ -16,6 +17,7 @@ namespace l1t { event_.put(std::move(muonShowers_[i]), "MuonShower" + std::to_string(i + 1)); event_.put(std::move(egammas_[i]), "EGamma" + std::to_string(i + 1)); event_.put(std::move(etsums_[i]), "EtSum" + std::to_string(i + 1)); + event_.put(std::move(zdcsums_[i]), "EtSumZDC" + std::to_string(i + 1)); event_.put(std::move(jets_[i]), "Jet" + std::to_string(i + 1)); event_.put(std::move(taus_[i]), "Tau" + std::to_string(i + 1)); } diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h index 36dcba98f2507..d27530a744dfb 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h @@ -24,6 +24,7 @@ namespace l1t { muonShowers_.begin(), muonShowers_.end(), [] { return std::make_unique(); }); std::generate(egammas_.begin(), egammas_.end(), [] { return std::make_unique(); }); std::generate(etsums_.begin(), etsums_.end(), [] { return std::make_unique(); }); + std::generate(zdcsums_.begin(), zdcsums_.end(), [] { return std::make_unique(); }); std::generate(jets_.begin(), jets_.end(), [] { return std::make_unique(); }); std::generate(taus_.begin(), taus_.end(), [] { return std::make_unique(); }); }; @@ -36,6 +37,7 @@ namespace l1t { }; inline EGammaBxCollection* getEGammas(const unsigned int copy) override { return egammas_[copy].get(); }; inline EtSumBxCollection* getEtSums(const unsigned int copy) override { return etsums_[copy].get(); }; + inline EtSumBxCollection* getZDCSums(const unsigned int copy) override { return zdcsums_[copy].get(); }; inline JetBxCollection* getJets(const unsigned int copy) override { return jets_[copy].get(); }; inline TauBxCollection* getTaus(const unsigned int copy) override { return taus_[copy].get(); }; @@ -47,6 +49,7 @@ namespace l1t { std::array, 6> muonShowers_; std::array, 6> egammas_; std::array, 6> etsums_; + std::array, 6> zdcsums_; std::array, 6> jets_; std::array, 6> taus_; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc index 0787ae413c632..e48c229a6994b 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc @@ -6,13 +6,17 @@ #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/MuonUnpacker.h" #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/EGammaUnpacker.h" #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h" +#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.h" #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/JetUnpacker.h" #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/TauUnpacker.h" #include "GTSetup.h" +const unsigned int l1t::stage2::zdc::nOutputFramePerBX = 6; + namespace l1t { namespace stage2 { + std::unique_ptr GTSetup::registerConsumes(const edm::ParameterSet& cfg, edm::ConsumesCollector& cc) { return std::unique_ptr(new GTTokens(cfg, cc)); } @@ -55,6 +59,7 @@ namespace l1t { prod.produces("MuonShower"); prod.produces("EGamma"); prod.produces("EtSum"); + prod.produces("EtSumZDC"); prod.produces("Jet"); prod.produces("Tau"); prod.produces(); @@ -64,6 +69,7 @@ namespace l1t { prod.produces("MuonShower" + std::to_string(i)); prod.produces("EGamma" + std::to_string(i)); prod.produces("EtSum" + std::to_string(i)); + prod.produces("EtSumZDC" + std::to_string(i)); prod.produces("Jet" + std::to_string(i)); prod.produces("Tau" + std::to_string(i)); } @@ -80,6 +86,7 @@ namespace l1t { static_pointer_cast(UnpackerFactory::get()->make("stage2::EGammaUnpacker")); auto etsum_unp = static_pointer_cast(UnpackerFactory::get()->make("stage2::EtSumUnpacker")); + auto zdc_unp = static_pointer_cast(UnpackerFactory::get()->make("stage2::ZDCUnpacker")); auto jet_unp = static_pointer_cast(UnpackerFactory::get()->make("stage2::JetUnpacker")); auto tau_unp = static_pointer_cast(UnpackerFactory::get()->make("stage2::TauUnpacker")); @@ -97,6 +104,7 @@ namespace l1t { muon_unp->setMuonCopy(amc - 1); egamma_unp->setEGammaCopy(amc - 1); etsum_unp->setEtSumCopy(amc - 1); + zdc_unp->setEtSumZDCCopy(amc - 1); jet_unp->setJetCopy(amc - 1); tau_unp->setTauCopy(amc - 1); @@ -135,6 +143,8 @@ namespace l1t { res[45] = alg_unp; res[47] = alg_unp; res[49] = alg_unp; + + res[142] = zdc_unp; } return res; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.h index 078fc31084683..a0f6b9cb97d83 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.h @@ -12,6 +12,11 @@ namespace l1t { namespace stage2 { + + namespace zdc { + extern const unsigned int nOutputFramePerBX; + } // namespace zdc + class GTSetup : public PackingSetup { public: ~GTSetup() override{}; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h index 1650face93738..69f5892f09aaf 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h @@ -23,6 +23,7 @@ namespace l1t { virtual MuonShowerBxCollection* getMuonShowers(const unsigned int copy) { return nullptr; } virtual EGammaBxCollection* getEGammas(const unsigned int copy) { return nullptr; } //= 0; virtual EtSumBxCollection* getEtSums(const unsigned int copy) { return nullptr; } + virtual EtSumBxCollection* getZDCSums(const unsigned int copy) { return nullptr; } virtual JetBxCollection* getJets(const unsigned int copy) { return nullptr; } virtual TauBxCollection* getTaus(const unsigned int copy) { return nullptr; } diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.cc new file mode 100644 index 0000000000000..f1302cc76d0e8 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.cc @@ -0,0 +1,65 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h" + +#include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" + +#include "L1TObjectCollections.h" + +// #include "L1TStage2Layer2Constants.h" +#include "ZDCUnpacker.h" +#include "GTSetup.h" + +namespace l1t { + namespace stage2 { + ZDCUnpacker::ZDCUnpacker() : EtSumZDCCopy_(0) {} + + bool ZDCUnpacker::unpack(const Block& block, UnpackerCollections* coll) { + using namespace l1t::stage2; + uint32_t zdc_mask = 0x3FF; + LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize(); + + int nBX = int(ceil(block.header().getSize() / zdc::nOutputFramePerBX)); + // expect the first four frames to be the first 4 EtSum objects reported per event (see CMS IN-2013/005) + + // Find the central, first and last BXs + int firstBX = (nBX / 2) - nBX + 1; + int lastBX = nBX / 2; + + auto res_ = static_cast(coll)->getZDCSums(EtSumZDCCopy_); + res_->setBXRange(firstBX, lastBX); + + LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX; + + // Loop over multiple BX and fill EtSums collection + for (int bx = firstBX; bx <= lastBX; bx++) { + // ZDC - + int iFrame = (bx - firstBX) * zdc::nOutputFramePerBX; + + uint32_t raw_data = block.payload().at(iFrame + 1); // ZDC - info is found on frame 1 of each bx + + l1t::EtSum zdcm{l1t::EtSum::kZDCM}; + zdcm.setHwPt(raw_data & zdc_mask); + zdcm.setP4(l1t::CaloTools::p4Demux(&zdcm)); + + LogDebug("L1T") << "ZDC -: pT " << zdcm.hwPt() << " bx " << bx; + + res_->push_back(bx, zdcm); + + // ZDC + + raw_data = block.payload().at(iFrame + 2); // ZDC + info is found on frame 2 of each bx + + l1t::EtSum zdcp{l1t::EtSum::kZDCP}; + zdcp.setHwPt(raw_data & zdc_mask); + zdcp.setP4(l1t::CaloTools::p4Demux(&zdcp)); + + LogDebug("L1T") << "ZDC +: pT " << zdcp.hwPt() << " bx " << bx; + + res_->push_back(bx, zdcp); + } + + return true; + } + } // namespace stage2 +} // namespace l1t + +DEFINE_L1T_UNPACKER(l1t::stage2::ZDCUnpacker); diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.h new file mode 100644 index 0000000000000..85cd622b8d313 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.h @@ -0,0 +1,23 @@ +#ifndef L1T_PACKER_STAGE2_ZDCUnpacker_H +#define L1T_PACKER_STAGE2_ZDCUnpacker_H + +#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" + +namespace l1t { + namespace stage2 { + class ZDCUnpacker : public Unpacker { + public: + ZDCUnpacker(); + ~ZDCUnpacker() override = default; + + bool unpack(const Block& block, UnpackerCollections* coll) override; + + inline void setEtSumZDCCopy(const unsigned int copy) { EtSumZDCCopy_ = copy; }; + + private: + unsigned int EtSumZDCCopy_; + }; + } // namespace stage2 +} // namespace l1t + +#endif