From 077e16de136872bdaa077a14340f9f837e021699 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 24 May 2024 04:26:22 -0500 Subject: [PATCH 1/3] Add unpacker for L1T Calo Layer 1 to unpack FED 1356 to retrieve the CICADA score from AMC Slot 7 --- .../implementations_stage2/CICADAUnpacker.cc | 55 +++++++++++++++++++ .../implementations_stage2/CICADAUnpacker.h | 19 +++++++ .../CaloLayer1Collections.cc | 1 + .../CaloLayer1Collections.h | 6 +- .../implementations_stage2/CaloLayer1Setup.cc | 6 ++ .../CaloSummaryCollections.cc | 9 +++ .../CaloSummaryCollections.h | 23 ++++++++ 7 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc create mode 100644 EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc new file mode 100644 index 0000000000000..ee1d613bf6564 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -0,0 +1,55 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h" + +#include "CICADAUnpacker.h" + +#include + +using namespace edm; + +namespace l1t { + namespace stage2 { + bool CICADAUnpacker::unpack(const Block& block, UnpackerCollections* coll) { + LogDebug("L1T") << "Block Size = " << block.header().getSize(); + LogDebug("L1T") << "Board ID = " << block.amc().getBoardID(); + + auto res = static_cast(coll)->getCICADABxCollection(); + // default BX range to trigger standard -2 to 2 + // Even though CICADA will never have BX information + // And everything gets put in BX 0 + res->setBXRange(-2, 2); + + int amc_slot = block.amc().getAMCNumber(); + if (not(amc_slot == 7)) { + throw cms::Exception("CICADAUnpacker") + << "Calo Summary (CICADA) unpacker is unpacking an unexpected AMC. Expected AMC number 7, got AMC number " + << amc_slot << std::endl; + return false; + } else { + std::vector cicadaWords = {0, 0, 0, 0}; + //the first 4 words are CICADA words + for (uint32_t i = 0; i < 4; ++i) { + cicadaWords.at(i) = ((block.payload().at(i)) >> 28); + } + + float cicadaScore = convertCICADABitsToFloat(cicadaWords); + res->push_back(0, cicadaScore); + return true; + } + } + + //convert the 4 CICADA bits/words into a proper number + float CICADAUnpacker::convertCICADABitsToFloat(const std::vector& cicadaBits) { + uint32_t tempResult = 0; + tempResult |= cicadaBits.at(0) << 12; + tempResult |= cicadaBits.at(1) << 8; + tempResult |= cicadaBits.at(2) << 4; + tempResult |= cicadaBits.at(3); + float result = 0.0; + result = (float)tempResult * pow(2.0, -8); + return result; + } + } // namespace stage2 +} // namespace l1t + +DEFINE_L1T_UNPACKER(l1t::stage2::CICADAUnpacker); diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h new file mode 100644 index 0000000000000..8c6927d68700a --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h @@ -0,0 +1,19 @@ +#ifndef EventFilter_L1TRawToDigi_CICADAUnpacker_h +#define EventFilter_L1TRawToDigi_CICADAUnpacker_h + +#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" +#include "CaloLayer1Collections.h" + +namespace l1t { + namespace stage2 { + class CICADAUnpacker : public Unpacker { + public: + bool unpack(const Block& block, UnpackerCollections* coll) override; + + private: + float convertCICADABitsToFloat(const std::vector&); + }; + } // namespace stage2 +} // namespace l1t + +#endif diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc index 2e6ce53fdecab..4ccf20081ee38 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.cc @@ -12,6 +12,7 @@ namespace l1t { for (int i = 0; i < 5; ++i) { event_.put(std::move(ecalDigisBx_[i]), "EcalDigisBx" + std::to_string(i + 1)); } + event_.put(std::move(cicadaDigis_), "CICADAScore"); } } // namespace stage2 } // namespace l1t diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h index a0630d46cb881..ce1be86054b13 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Collections.h @@ -6,6 +6,7 @@ #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" #include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h" #include "L1TObjectCollections.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" namespace l1t { namespace stage2 { @@ -15,7 +16,8 @@ namespace l1t { : L1TObjectCollections(e), ecalDigis_(new EcalTrigPrimDigiCollection()), hcalDigis_(new HcalTrigPrimDigiCollection()), - caloRegions_(new L1CaloRegionCollection()) { + caloRegions_(new L1CaloRegionCollection()), + cicadaDigis_(std::make_unique()) { // Pre-allocate: // 72 iPhi values // 28 iEta values in Ecal, 28 + 12 iEta values in Hcal + HF @@ -37,6 +39,7 @@ namespace l1t { inline EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) override { return ecalDigisBx_[copy].get(); }; + inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); }; private: std::unique_ptr ecalDigis_; @@ -44,6 +47,7 @@ namespace l1t { std::unique_ptr caloRegions_; std::array, 5> ecalDigisBx_; + std::unique_ptr cicadaDigis_; }; } // namespace stage2 } // namespace l1t diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc index 95b1631bcfeda..d0c417d427074 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloLayer1Setup.cc @@ -6,6 +6,8 @@ #include "CaloLayer1Setup.h" +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" + namespace l1t { namespace stage2 { std::unique_ptr CaloLayer1Setup::registerConsumes(const edm::ParameterSet& cfg, @@ -58,6 +60,7 @@ namespace l1t { for (int i = 0; i < 5; ++i) { prod.produces("EcalDigisBx" + std::to_string(i + 1)); } + prod.produces("CICADAScore"); } std::unique_ptr CaloLayer1Setup::getCollections(edm::Event& e) { @@ -72,6 +75,9 @@ namespace l1t { if (board < 18) { res[0] = UnpackerFactory::get()->make("stage2::CaloLayer1Unpacker"); } + if (fed == 1356 && amc == 7) { //calo summary board + res[0] = UnpackerFactory::get()->make("stage2::CICADAUnpacker"); + } } return res; diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc new file mode 100644 index 0000000000000..bedcfb42c9237 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc @@ -0,0 +1,9 @@ +#include "FWCore/Framework/interface/Event.h" + +#include "CaloSummaryCollections.h" + +namespace l1t { + namespace stage2 { + CaloSummaryCollections::~CaloSummaryCollections() { event_.put(std::move(cicadaDigis_)); } + } // namespace stage2 +} // namespace l1t diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h new file mode 100644 index 0000000000000..543d284d16ec7 --- /dev/null +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h @@ -0,0 +1,23 @@ +#ifndef EventFilter_L1TRawToDigi_CaloSummaryCollections_h +#define EventFilter_L1TRawToDigi_CaloSummaryCollections_h + +#include "DataFormats/L1CaloTrigger/interface/CICADA.h" + +#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h" + +namespace l1t { + namespace stage2 { + class CaloSummaryCollections : public UnpackerCollections { + public: + CaloSummaryCollections(edm::Event& e) + : UnpackerCollections(e), cicadaDigis_(std::make_unique()){}; + ~CaloSummaryCollections() override; + inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); }; + + private: + std::unique_ptr cicadaDigis_; + }; + } // namespace stage2 +} // namespace l1t + +#endif From 92c99c1b18f24297cce9c9d13f819b7cba544337 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 21 Jun 2024 10:13:17 -0500 Subject: [PATCH 2/3] Change CICADA unpacker to read the last 4 words instead of first 4 --- .../plugins/implementations_stage2/CICADAUnpacker.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc index ee1d613bf6564..202c112f83b69 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -27,9 +27,9 @@ namespace l1t { return false; } else { std::vector cicadaWords = {0, 0, 0, 0}; - //the first 4 words are CICADA words - for (uint32_t i = 0; i < 4; ++i) { - cicadaWords.at(i) = ((block.payload().at(i)) >> 28); + //the last 4 words are CICADA words + for (uint32_t i = 2; i < 6; ++i) { + cicadaWords.at(i-2) = ((block.payload().at(i)) >> 28); } float cicadaScore = convertCICADABitsToFloat(cicadaWords); From bf7e8381e7b0cf4e951e87de1deacef2adb57f66 Mon Sep 17 00:00:00 2001 From: Andrew Loeliger Date: Fri, 21 Jun 2024 10:33:09 -0500 Subject: [PATCH 3/3] apply formatting --- .../plugins/implementations_stage2/CICADAUnpacker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc index 202c112f83b69..f325e32f2386b 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc @@ -29,7 +29,7 @@ namespace l1t { std::vector cicadaWords = {0, 0, 0, 0}; //the last 4 words are CICADA words for (uint32_t i = 2; i < 6; ++i) { - cicadaWords.at(i-2) = ((block.payload().at(i)) >> 28); + cicadaWords.at(i - 2) = ((block.payload().at(i)) >> 28); } float cicadaScore = convertCICADABitsToFloat(cicadaWords);