-
Notifications
You must be signed in to change notification settings - Fork 4.6k
CICADA-uGT emulator additions #44222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d9d5e0e
CICADA-uGT emulator additions
aloeliger 4fec71b
Add CaloSummary/CICADA Unpacker
aloeliger 4cbf9c4
Update CICADA emulator element pieces to create BX Vectors
aloeliger f0b46d5
Update CICADA model to 2.1.2, the model going online at P5
aloeliger 4a143f7
Apply code format
aloeliger 943faa3
Update CICADA unpacker draft to unpack all available BXs
aloeliger 1699931
code format
aloeliger 2239843
Fix bad "produces" specification
aloeliger e0f3447
Remove CICADA set to 0 from verbosity block
aloeliger 839d7f2
Add empty vector guard to CICADA/uGT emulation
aloeliger 7fdb2c0
Clean L1CaloTrigger classes_def.xml
aloeliger 368f120
Simplify CICADA-uGT unpacker logic
aloeliger bcb0dab
Revert "Merge pull request #45308 from cms-sw/revert-45037-Calo_CICAD…
aloeliger 9243345
Simplify Calo Crate CICADA unpacking logic
aloeliger 3d72abe
Fix mistaken bits convention
aloeliger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #ifndef DataFormats_L1Trigger_CICADA_h | ||
| #define DataFormats_L1Trigger_CICADA_h | ||
|
|
||
| #include "DataFormats/L1Trigger/interface/BXVector.h" | ||
|
|
||
| namespace l1t { | ||
| typedef BXVector<float> CICADABxCollection; | ||
| } | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
| #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h" | ||
|
|
||
| #include "CICADAUnpacker.h" | ||
|
|
||
| #include <cmath> | ||
|
|
||
| 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<CaloLayer1Collections*>(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 { | ||
| const uint32_t* base = block.payload().data(); | ||
| //This differs slightly from uGT, in that we grab the first 4 bits | ||
| //of the last 4 words (still in first to last order) and arrange those | ||
| uint32_t word = (caloCrateCicadaBitsPattern & base[2]) >> 16 | (caloCrateCicadaBitsPattern & base[3]) >> 20 | | ||
| (caloCrateCicadaBitsPattern & base[4]) >> 24 | (caloCrateCicadaBitsPattern & base[5]) >> 28; | ||
| float score = static_cast<float>(word) / 256.f; | ||
| res->push_back(0, score); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| } // namespace stage2 | ||
| } // namespace l1t | ||
|
|
||
| DEFINE_L1T_UNPACKER(l1t::stage2::CICADAUnpacker); |
19 changes: 19 additions & 0 deletions
19
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: | ||
| static constexpr unsigned int caloCrateCicadaBitsPattern = 0xF0000000; //first 4 bits of the words are CICADA | ||
| }; | ||
| } // namespace stage2 | ||
| } // namespace l1t | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
23 changes: 23 additions & 0 deletions
23
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<CICADABxCollection>()){}; | ||
| ~CaloSummaryCollections() override; | ||
| inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); }; | ||
|
|
||
| private: | ||
| std::unique_ptr<CICADABxCollection> cicadaDigis_; | ||
| }; | ||
| } // namespace stage2 | ||
| } // namespace l1t | ||
|
|
||
| #endif |
44 changes: 44 additions & 0 deletions
44
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
| #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h" | ||
|
|
||
| #include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" | ||
|
|
||
| #include "L1TObjectCollections.h" | ||
|
|
||
| #include "DataFormats/L1CaloTrigger/interface/CICADA.h" | ||
|
|
||
| #include "CaloSummaryUnpacker.h" | ||
| #include "GTSetup.h" | ||
|
|
||
| #include <cmath> | ||
|
|
||
| bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) { | ||
| LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize(); | ||
|
|
||
| //Just a few things to help us handle the number of BXs | ||
| //Strictly, we should generally get five BXs, starting at -2, and going to 2 | ||
| //With the central BX at 0. The frames count up from -2 | ||
| int nBX = int(ceil(block.header().getSize() / nFramesPerEvent)); | ||
| int firstBX = (nBX / 2) - nBX + 1; | ||
| int lastBX = nBX / 2; | ||
| int processedBXs = 0; //This will just help us keep track of what words we are grabbing | ||
|
|
||
| auto res_ = static_cast<L1TObjectCollections*>(coll)->getCICADAScore(); | ||
| res_->setBXRange(firstBX, lastBX); | ||
|
|
||
| for (int bx = firstBX; bx <= lastBX; ++bx) { | ||
| unsigned short baseLocation = processedBXs * nFramesPerEvent; | ||
| const uint32_t* base = block.payload().data() + baseLocation; | ||
| //The take the first 4 bits of the first 4 words, and arrange them in order | ||
| uint32_t word = (cicadaBitsPattern & base[0]) >> 16 | (cicadaBitsPattern & base[1]) >> 20 | | ||
| (cicadaBitsPattern & base[2]) >> 24 | (cicadaBitsPattern & base[3]) >> 28; | ||
| //The score needs to be shifted 8 bits over the decimal point | ||
| float score = static_cast<float>(word) / 256.f; | ||
| res_->push_back(bx, score); | ||
| ++processedBXs; //index BXs | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| DEFINE_L1T_UNPACKER(l1t::stage2::CaloSummaryUnpacker); |
21 changes: 21 additions & 0 deletions
21
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #ifndef L1T_PACKER_STAGE2_CaloSummaryUnpacker_H | ||
| #define L1T_PACKER_STAGE2_CaloSummaryUnpacker_H | ||
|
|
||
| #include "EventFilter/L1TRawToDigi/interface/Unpacker.h" | ||
|
|
||
| namespace l1t { | ||
| namespace stage2 { | ||
| class CaloSummaryUnpacker : public Unpacker { | ||
| public: | ||
| CaloSummaryUnpacker() = default; | ||
| ~CaloSummaryUnpacker() override = default; | ||
|
|
||
| bool unpack(const Block& block, UnpackerCollections* coll) override; | ||
| static constexpr unsigned int nFramesPerEvent = | ||
| 6; //Calo Summary outputs 6 32 bit words (or frames in uGT parlance) per event. | ||
| static constexpr unsigned int cicadaBitsPattern = | ||
| 0xF0000000; //first 4 bits of the first 4 words/frames are CICADA | ||
| }; | ||
| } // namespace stage2 | ||
| } // namespace l1t | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming back to this question #44222 (comment), maybe from a different angle, I wonder if
floatis a good long-term choice, as opposed to a dedicatedl1t:CICADAclass (however simple it may currently be).Some points.
l1t::CICADAwould just be something like (in short)class CICADA { float score; };. Is there a possibility that in future one could use the available bits to extract more than a score (e.g. a score with reduced precision plus some different info from other bits) ? If so, a dedicated data format would be more future-proof, and it would minimise changes downstream in the future.l1t:CICADAwould be better, imho. @cms-sw/hlt-l2 can correct me.AXOL1TLScore).I do not know if this (
floatvsl1t:CICADA) needs to be addressed in this PR or not, but it's worth bringing up imho.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the relative difficulty from the engineering perspective of changing what CICADA is, and where it is located means that it is unlikely to ever change from it's current 16 bit fixed point (8 integer bits) interpretation for the L1T side. At least in the time we have left to run the current L1T system. I don't think we need to worry about, for example, float precision not being enough and needing to swap to double.
I can't really speak to future use cases, but admittedly I think the class idea is at least more future proof.
I would just give anything not have to do that in this PR though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this part of a dedicated data type is descoped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be my preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, just had a chat with @eyigitba about the technical reasons for doing this. Strictly, I think it is agreed it is not needed for this PR, but may be more integral for "sophisticated" use at HLT (treating the CICADA score as an object in case we want to do that) than I was giving it credit for. I think there is also desire to centralize with AXO some of these ideas. I can take a look at this with a bit more priority in that case.