Skip to content

Commit 9243345

Browse files
committed
Simplify Calo Crate CICADA unpacking logic
1 parent bcb0dab commit 9243345

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,17 @@ namespace l1t {
2626
<< amc_slot << std::endl;
2727
return false;
2828
} else {
29-
std::vector<uint32_t> cicadaWords = {0, 0, 0, 0};
30-
//the last 4 words are CICADA words
31-
for (uint32_t i = 2; i < 6; ++i) {
32-
cicadaWords.at(i - 2) = ((block.payload().at(i)) >> 28);
33-
}
34-
35-
float cicadaScore = convertCICADABitsToFloat(cicadaWords);
36-
res->push_back(0, cicadaScore);
29+
const uint32_t* base = block.payload().data();
30+
//This differs slightly from uGT, in that we grab the first 4 bits
31+
//of the last 4 words (still in first to last order) and arrange those
32+
uint32_t word = (caloCrateCicadaBitsPattern & base[2]) >> 16 | (caloCrateCicadaBitsPattern & base[3]) >> 20 |
33+
(caloCrateCicadaBitsPattern & base[4]) >> 24 | (caloCrateCicadaBitsPattern & base[5]) >> 28;
34+
float score = static_cast<float>(word) / 256.f;
35+
res->push_back(0, score);
3736
return true;
3837
}
3938
}
4039

41-
//convert the 4 CICADA bits/words into a proper number
42-
float CICADAUnpacker::convertCICADABitsToFloat(const std::vector<uint32_t>& cicadaBits) {
43-
uint32_t tempResult = 0;
44-
tempResult |= cicadaBits.at(0) << 12;
45-
tempResult |= cicadaBits.at(1) << 8;
46-
tempResult |= cicadaBits.at(2) << 4;
47-
tempResult |= cicadaBits.at(3);
48-
float result = 0.0;
49-
result = (float)tempResult * pow(2.0, -8);
50-
return result;
51-
}
5240
} // namespace stage2
5341
} // namespace l1t
5442

EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace l1t {
1111
bool unpack(const Block& block, UnpackerCollections* coll) override;
1212

1313
private:
14-
float convertCICADABitsToFloat(const std::vector<uint32_t>&);
14+
static constexpr unsigned int caloCrateCicadaBitsPattern = 0xF0000000; //first 4 bits of the words are CICADA
1515
};
1616
} // namespace stage2
1717
} // namespace l1t

0 commit comments

Comments
 (0)