Skip to content

Commit 943faa3

Browse files
committed
Update CICADA unpacker draft to unpack all available BXs
1 parent 4a143f7 commit 943faa3

File tree

5 files changed

+38
-15
lines changed

5 files changed

+38
-15
lines changed

EventFilter/L1TRawToDigi/BuildFile.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<use name="DataFormats/RPCDigi"/>
55
<use name="DataFormats/L1DTTrackFinder"/>
66
<use name="DataFormats/L1TMuon"/>
7+
<use name="DataFormats/L1CaloTrigger"/>
78
<use name="EventFilter/RPCRawToDigi"/>
89
<use name="boost_regex"/>
910
<export>

EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "L1TObjectCollections.h"
77

8+
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"
9+
810
#include "CaloSummaryUnpacker.h"
911
#include "GTSetup.h"
1012

@@ -19,27 +21,45 @@ float l1t::stage2::CaloSummaryUnpacker::processBitsToScore(const unsigned int bi
1921
// i.e. shift bitIndex to max out at half the number of CICADA words (indexed at 0) then count down
2022
//And we shift by 4 bits a time, hence the factor of 4
2123
for (unsigned short bitIndex = 0; bitIndex < numCICADAWords; ++bitIndex) {
22-
constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * (numCICADAWords / 2 - (bitIndex + 1)));
24+
constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * ((numCICADAWords / 2) - (bitIndex + 1)));
2325
}
2426
return constructedScore;
2527
}
2628

2729
bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
2830
LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
29-
//convert to float and then multiply by a factor based on the index?
30-
unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0};
31+
32+
//Just a few things to help us handle the number of BXs
33+
//Strictly, we should generally get five BXs, starting at -2, and going to 2
34+
//With the central BX at 0. The frames count up from -2
35+
int nBX = int(ceil(block.header().getSize() / nFramesPerEvent));
36+
int firstBX = (nBX / 2) - nBX + 1;
37+
int lastBX = nBX / 2;
38+
int processedBXs = 0; //This will just help us keep track of what words we are grabbing
39+
3140

3241
auto res_ = static_cast<L1TObjectCollections*>(coll)->getCICADAScore();
42+
res_ -> setBXRange(firstBX, lastBX);
43+
44+
for (int bx = firstBX; bx <= lastBX; ++bx){
45+
//convert to float and then multiply by a factor based on the index?
46+
unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0};
3347

34-
for (unsigned int wordNum = 0; wordNum < nFrames; ++wordNum) {
35-
uint32_t raw_data = block.payload().at(wordNum);
36-
if (wordNum < numCICADAWords) { // check the first 4 frames for CICADA bits
48+
for (unsigned int wordNum = 0; wordNum < numCICADAWords; ++wordNum) {
49+
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.
50+
//Frame 0 of a bx are the most significant integer bits
51+
//Frame 1 of a bx are the least significant integer bits
52+
//Frame 2 of a bx are the most significant decimal bits
53+
//Frame 3 of a bx are the lest significant decimal bits
54+
//Frames 4&5 are unused (by CICADA), they are reserved.
55+
uint32_t raw_data = block.payload().at(wordLocation);
3756
cicadaBits[wordNum] =
38-
(cicadaBitsPattern & raw_data) >>
39-
28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with
57+
(cicadaBitsPattern & raw_data) >>
58+
28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with later
4059
}
60+
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.
61+
++processedBXs; //index BXs
4162
}
42-
*res_ = processBitsToScore(cicadaBits);
4363

4464
return true;
4565
}

EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace l1t {
1212

1313
bool unpack(const Block& block, UnpackerCollections* coll) override;
1414
float processBitsToScore(const unsigned int[]);
15-
15+
1616
static constexpr unsigned short numCICADAWords = 4; // We have 4 words/frames that contain CICADA bits
17-
static constexpr unsigned int nFrames = 6; //My understanding is that we give 6 32 bit words to uGT
17+
static constexpr unsigned int nFramesPerEvent = 6; //Calo Summary outputs 6 32 bit words (or frames in uGT parlance) per event.
1818
static constexpr unsigned int cicadaBitsPattern =
1919
0xF0000000; //first 4 bits of the first 4 words/frames are CICADA
2020
};

EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "DataFormats/L1Trigger/interface/Jet.h"
77
#include "DataFormats/L1Trigger/interface/Tau.h"
88
#include "DataFormats/L1Trigger/interface/Muon.h"
9+
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"
910

1011
#include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"
1112
#include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"
@@ -19,7 +20,7 @@ namespace l1t {
1920
public:
2021
GTCollections(edm::Event& e)
2122
: L1TObjectCollections(e),
22-
cicadaScore_(std::make_unique<float>(0.0)),
23+
cicadaScore_(std::make_unique<CICADABxCollection>()),
2324
algBlk_(new GlobalAlgBlkBxCollection()),
2425
extBlk_(new GlobalExtBlkBxCollection()) {
2526
std::generate(muons_.begin(), muons_.end(), [] { return std::make_unique<MuonBxCollection>(); });
@@ -43,7 +44,7 @@ namespace l1t {
4344
inline EtSumBxCollection* getZDCSums(const unsigned int copy) override { return zdcsums_[copy].get(); };
4445
inline JetBxCollection* getJets(const unsigned int copy) override { return jets_[copy].get(); };
4546
inline TauBxCollection* getTaus(const unsigned int copy) override { return taus_[copy].get(); };
46-
inline float* getCICADAScore() override { return cicadaScore_.get(); };
47+
inline CICADABxCollection* getCICADAScore() override { return cicadaScore_.get(); };
4748

4849
inline GlobalAlgBlkBxCollection* getAlgs() { return algBlk_.get(); };
4950
inline GlobalExtBlkBxCollection* getExts() { return extBlk_.get(); };
@@ -56,7 +57,7 @@ namespace l1t {
5657
std::array<std::unique_ptr<EtSumBxCollection>, 6> zdcsums_;
5758
std::array<std::unique_ptr<JetBxCollection>, 6> jets_;
5859
std::array<std::unique_ptr<TauBxCollection>, 6> taus_;
59-
std::unique_ptr<float> cicadaScore_;
60+
std::unique_ptr<CICADABxCollection> cicadaScore_;
6061

6162
std::unique_ptr<GlobalAlgBlkBxCollection> algBlk_;
6263
std::unique_ptr<GlobalExtBlkBxCollection> extBlk_;

EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "DataFormats/L1Trigger/interface/Tau.h"
88
#include "DataFormats/L1Trigger/interface/Muon.h"
99
#include "DataFormats/L1Trigger/interface/MuonShower.h"
10+
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"
1011

1112
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
1213

@@ -26,7 +27,7 @@ namespace l1t {
2627
virtual EtSumBxCollection* getZDCSums(const unsigned int copy) { return nullptr; }
2728
virtual JetBxCollection* getJets(const unsigned int copy) { return nullptr; }
2829
virtual TauBxCollection* getTaus(const unsigned int copy) { return nullptr; }
29-
virtual float* getCICADAScore() { return nullptr; }
30+
virtual CICADABxCollection* getCICADAScore() { return nullptr; }
3031

3132
virtual EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) { return nullptr; };
3233
};

0 commit comments

Comments
 (0)