Skip to content

Commit 368f120

Browse files
committed
Simplify CICADA-uGT unpacker logic
1 parent 7fdb2c0 commit 368f120

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.cc

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@
1212

1313
#include <cmath>
1414

15-
float l1t::stage2::CaloSummaryUnpacker::processBitsToScore(const unsigned int bitsArray[]) {
16-
float constructedScore = 0.0;
17-
//All bits have been shifted to just left of the decimal point
18-
//We need to convert them to float, shift them back to their proper position
19-
//And then add them into the total
20-
//The proper power is 4(-(bitIndex+1) + numCICADAWords/2)
21-
// i.e. shift bitIndex to max out at half the number of CICADA words (indexed at 0) then count down
22-
//And we shift by 4 bits a time, hence the factor of 4
23-
for (unsigned short bitIndex = 0; bitIndex < numCICADAWords; ++bitIndex) {
24-
constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * ((numCICADAWords / 2) - (bitIndex + 1)));
25-
}
26-
return constructedScore;
27-
}
28-
2915
bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
3016
LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
3117

@@ -41,27 +27,14 @@ bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollec
4127
res_->setBXRange(firstBX, lastBX);
4228

4329
for (int bx = firstBX; bx <= lastBX; ++bx) {
44-
//convert to float and then multiply by a factor based on the index?
45-
unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0};
46-
47-
for (unsigned int wordNum = 0; wordNum < numCICADAWords; ++wordNum) {
48-
unsigned short wordLocation =
49-
processedBXs * nFramesPerEvent +
50-
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.
51-
//Frame 0 of a bx are the most significant integer bits
52-
//Frame 1 of a bx are the least significant integer bits
53-
//Frame 2 of a bx are the most significant decimal bits
54-
//Frame 3 of a bx are the lest significant decimal bits
55-
//Frames 4&5 are unused (by CICADA), they are reserved.
56-
uint32_t raw_data = block.payload().at(wordLocation);
57-
cicadaBits[wordNum] =
58-
(cicadaBitsPattern & raw_data) >>
59-
28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with later
60-
}
61-
res_->push_back(
62-
bx,
63-
processBitsToScore(
64-
cicadaBits)); //Now we insert CICADA into the proper BX, after a quick utility constructs a number from the 4 sets of bits.
30+
unsigned short baseLocation = processedBXs * nFramesPerEvent;
31+
const uint32_t* base = block.payload().data() + baseLocation;
32+
//The take the first 4 bits of the first 4 words, and arrange them in order
33+
uint32_t word = (cicadaBitsPattern & base[0]) >> 16 | (cicadaBitsPattern & base[1]) >> 20 |
34+
(cicadaBitsPattern & base[2]) >> 24 | (cicadaBitsPattern & base[3]) >> 28;
35+
//The score needs to be shifted 8 bits over the decimal point
36+
float score = static_cast<float>(word) / 256.f;
37+
res_->push_back(bx, score);
6538
++processedBXs; //index BXs
6639
}
6740

EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ namespace l1t {
1111
~CaloSummaryUnpacker() override = default;
1212

1313
bool unpack(const Block& block, UnpackerCollections* coll) override;
14-
float processBitsToScore(const unsigned int[]);
15-
16-
static constexpr unsigned short numCICADAWords = 4; // We have 4 words/frames that contain CICADA bits
1714
static constexpr unsigned int nFramesPerEvent =
1815
6; //Calo Summary outputs 6 32 bit words (or frames in uGT parlance) per event.
1916
static constexpr unsigned int cicadaBitsPattern =

0 commit comments

Comments
 (0)