CMS 3D CMS Logo

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