-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45293 from aloeliger/CICADA_uGT_Emulator_14_0
[14_0] CICADA-uGT emulator additions
- Loading branch information
Showing
36 changed files
with
652 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
42 changes: 42 additions & 0 deletions
42
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc
This file contains 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,42 @@ | ||
#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(); | ||
//First 4 bits of the first 4 words are CICADA bits | ||
uint32_t word = (caloCrateCicadaBitsPattern & base[0]) >> 16 | (caloCrateCicadaBitsPattern & base[1]) >> 20 | | ||
(caloCrateCicadaBitsPattern & base[2]) >> 24 | (caloCrateCicadaBitsPattern & base[3]) >> 28; | ||
float score = static_cast<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 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 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 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 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 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 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 |
71 changes: 71 additions & 0 deletions
71
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc
This file contains 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,71 @@ | ||
#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> | ||
|
||
float l1t::stage2::CaloSummaryUnpacker::processBitsToScore(const unsigned int bitsArray[]) { | ||
float constructedScore = 0.0; | ||
//All bits have been shifted to just left of the decimal point | ||
//We need to convert them to float, shift them back to their proper position | ||
//And then add them into the total | ||
//The proper power is 4(-(bitIndex+1) + numCICADAWords/2) | ||
// i.e. shift bitIndex to max out at half the number of CICADA words (indexed at 0) then count down | ||
//And we shift by 4 bits a time, hence the factor of 4 | ||
for (unsigned short bitIndex = 0; bitIndex < numCICADAWords; ++bitIndex) { | ||
constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * ((numCICADAWords / 2) - (bitIndex + 1))); | ||
} | ||
return constructedScore; | ||
} | ||
|
||
bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) { | ||
LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize(); | ||
|
||
//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) { | ||
//convert to float and then multiply by a factor based on the index? | ||
unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0}; | ||
|
||
for (unsigned int wordNum = 0; wordNum < numCICADAWords; ++wordNum) { | ||
unsigned short wordLocation = | ||
processedBXs * nFramesPerEvent + | ||
wordNum; //Calculate the location of the needed CICADA word based on how many BXs we have already handled, and how many words of CICADA we have already grabbed. | ||
//Frame 0 of a bx are the most significant integer bits | ||
//Frame 1 of a bx are the least significant integer bits | ||
//Frame 2 of a bx are the most significant decimal bits | ||
//Frame 3 of a bx are the lest significant decimal bits | ||
//Frames 4&5 are unused (by CICADA), they are reserved. | ||
uint32_t raw_data = block.payload().at(wordLocation); | ||
cicadaBits[wordNum] = | ||
(cicadaBitsPattern & raw_data) >> | ||
28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with later | ||
} | ||
res_->push_back( | ||
bx, | ||
processBitsToScore( | ||
cicadaBits)); //Now we insert CICADA into the proper BX, after a quick utility constructs a number from the 4 sets of bits. | ||
++processedBXs; //index BXs | ||
} | ||
|
||
return true; | ||
} | ||
|
||
DEFINE_L1T_UNPACKER(l1t::stage2::CaloSummaryUnpacker); |
24 changes: 24 additions & 0 deletions
24
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h
This file contains 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,24 @@ | ||
#ifndef L1T_PACKER_STAGE2_CaloSummaryUnpacker_H | ||
#define L1T_PACKER_STAGE2_CaloSummaryUnpacker_H | ||
|
||
#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
class CaloSummaryUnpacker : public Unpacker { | ||
public: | ||
CaloSummaryUnpacker() = default; | ||
~CaloSummaryUnpacker() override = default; | ||
|
||
bool unpack(const Block& block, UnpackerCollections* coll) override; | ||
float processBitsToScore(const unsigned int[]); | ||
|
||
static constexpr unsigned short numCICADAWords = 4; // We have 4 words/frames that contain CICADA bits | ||
static constexpr unsigned int 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 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 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 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 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.