@@ -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
0 commit comments