CMS 3D CMS Logo

RegionalMuonGMTPacker.cc
Go to the documentation of this file.
3 
5 #include "GMTTokens.h"
7 
8 namespace l1t {
9  namespace stage2 {
10  Blocks
12  {
13  auto bmtfToken = static_cast<const GMTTokens*>(toks)->getRegionalMuonCandTokenBMTF();
14  auto omtfToken = static_cast<const GMTTokens*>(toks)->getRegionalMuonCandTokenOMTF();
15  auto emtfToken = static_cast<const GMTTokens*>(toks)->getRegionalMuonCandTokenEMTF();
16 
17  Blocks blocks;
18 
19  // pack the muons for each TF in blocks
20  packTF(event, bmtfToken, blocks);
21  packTF(event, omtfToken, blocks);
22  packTF(event, emtfToken, blocks);
23 
24  return blocks;
25  }
26 
27  void
29  {
31  event.getByToken(tfToken, muons);
32 
33  constexpr unsigned wordsPerBx = 6; // number of 32 bit words per BX
34 
35  PayloadMap payloadMap;
36 
37  const auto nBx = muons->getLastBX() - muons->getFirstBX() + 1;
38  unsigned bxCtr = 0;
39  for (int i = muons->getFirstBX(); i <= muons->getLastBX(); ++i, ++bxCtr) {
40  for (auto mu = muons->begin(i); mu != muons->end(i); ++mu) {
41  const auto linkTimes2 = mu->link() * 2;
42 
43  // If the map key is new reserve the payload size.
44  if (payloadMap.count(linkTimes2) == 0) {
45  payloadMap[linkTimes2].reserve(wordsPerBx * nBx);
46  // If there was no muon on the link of this muon in previous
47  // BX the payload up to this BX must be filled with zeros.
48  if (bxCtr > 0) {
49  while (payloadMap[linkTimes2].size() < bxCtr * wordsPerBx) {
50  payloadMap[linkTimes2].push_back(0);
51  }
52  }
53  }
54 
55  // Fill the muon in the payload for this link.
56  uint32_t msw = 0;
57  uint32_t lsw = 0;
58 
60 
61  payloadMap[linkTimes2].push_back(lsw);
62  payloadMap[linkTimes2].push_back(msw);
63  }
64 
65  // padding to 3 muons per block id (link) per BX
66  // This can be empty muons as well.
67  for (auto &kv : payloadMap) {
68  while (kv.second.size() < (bxCtr + 1) * wordsPerBx) {
69  kv.second.push_back(0);
70  }
71  }
72  }
73 
74  // push everything in the blocks vector
75  for (auto &kv : payloadMap) {
76  blocks.push_back(Block(kv.first, kv.second));
77  }
78  }
79  }
80 }
81 
size
Write out results.
std::map< unsigned int, std::vector< uint32_t > > PayloadMap
static void generatePackedDataWords(const RegionalMuonCand &, uint32_t &, uint32_t &)
delete x;
Definition: CaloConfig.h:22
#define constexpr
std::vector< Block > Blocks
Definition: Block.h:72
const int mu
Definition: Constants.h:22
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:22
Blocks pack(const edm::Event &, const PackerTokens *) override
void packTF(const edm::Event &, const edm::EDGetTokenT< RegionalMuonCandBxCollection > &, Blocks &)
Definition: event.py:1