CMS 3D CMS Logo

CaloSummaryPacker.cc
Go to the documentation of this file.
3 
4 #include "GTTokens.h"
5 
6 #include "CaloSummaryPacker.h"
7 
8 namespace l1t {
9  namespace stage2 {
11  //Shift the score up by 8 bits, and turn it into an integer for easy working with
12  //the bits
13  uint32_t cicadaBits = static_cast<uint32_t>(score * 256.f);
14  //CICADA word goes from most significant bits, to least significant
15  //But always at the start of the word, so the resultant words need to be adjusted upwards
16  uint32_t firstWord = (cicadaBits & 0xF000) << 16;
17  uint32_t secondWord = (cicadaBits & 0x0F00) << 20;
18  uint32_t thirdWord = (cicadaBits & 0x00F0) << 24;
19  uint32_t fourthWord = (cicadaBits & 0x000F) << 28;
20 
21  return {firstWord, secondWord, thirdWord, fourthWord};
22  }
23 
26  event.getByToken(static_cast<const GTTokens*>(toks)->getCICADAToken(), cicadaScores);
27 
28  std::vector<uint32_t> payload;
29 
30  for (int i = cicadaScores->getFirstBX(); i <= cicadaScores->getLastBX(); ++i) {
31  //check if we _have_ a CICADA score to work with, the emulator does not
32  //guarantee 5 BX worth of CICADA, but unpacked data from uGT does
33  //If we do not have a CICADA score for a BX, we can simply treat that as
34  //a zero score.
35  //otherwise, once we have a CICADA score, we can simply construct the 6
36  //words (4 with CICADA bits, 2 without), from the score
37  float CICADAScore = 0.0;
38  if (cicadaScores->size(i) != 0) {
39  CICADAScore = cicadaScores->at(
40  i, 0); //Shouldn't ever have more than one score per BX, so this should be safe if the size is not 0
41  }
42  //Make the CICADA words
43  std::vector<uint32_t> bxWords = generateCICADAWordsFromScore(CICADAScore);
44  payload.insert(payload.end(), bxWords.begin(), bxWords.end());
45  //Remaining two 32 bit words of CICADA are unused
46  payload.push_back(0);
47  payload.push_back(0);
48  }
49 
50  return {Block(22, payload)};
51  }
52  } // namespace stage2
53 } // namespace l1t
54 
delete x;
Definition: CaloConfig.h:22
std::vector< Block > Blocks
Definition: Block.h:99
Blocks pack(const edm::Event &, const PackerTokens *) override
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:23
std::vector< uint32_t > generateCICADAWordsFromScore(float)
Definition: event.py:1