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 
14  //auto bmtfToken = static_cast<const GMTTokens*>(toks)->getRegionalMuonCandTokenBMTF();
15  //auto omtfToken = static_cast<const GMTTokens*>(toks)->getRegionalMuonCandTokenOMTF();
16  //auto emtfToken = static_cast<const GMTTokens*>(toks)->getRegionalMuonCandTokenEMTF();
17 
18  Blocks blocks;
19 
20  // link ids for the different TFs
21  //std::vector<unsigned int> bmtfLinks {48,49,50,51,52,53,54,55,56,57,58,59};
22  //std::vector<unsigned int> omtfLinks {42,43,44,45,46,47,60,61,62,63,64,65};
23  //std::vector<unsigned int> emtfLinks {36,37,38,39,40,41,66,67,68,69,70,71};
24 
25  // pack the muons for each TF in blocks
26  //packTF(event, bmtfToken, blocks, bmtfLinks);
27  //packTF(event, omtfToken, blocks, omtfLinks);
28  //packTF(event, emtfToken, blocks, emtfLinks);
29 
30  return blocks;
31  }
32 
33  void
34  RegionalMuonGMTPacker::packTF(const edm::Event& event, const edm::EDGetTokenT<RegionalMuonCandBxCollection>& tfToken, Blocks &blocks, const std::vector<unsigned int>& links)
35  {
37  event.getByToken(tfToken, muons);
38 
39  PayloadMap payloadMap;
40 
41  unsigned bxCtr = 0;
42  for (int i = muons->getFirstBX(); i <= muons->getLastBX(); ++i, ++bxCtr) {
43  for (auto mu = muons->begin(i); mu != muons->end(i); ++mu) {
44  uint32_t msw = 0;
45  uint32_t lsw = 0;
46 
48 
49  payloadMap[mu->link()*2].push_back(lsw);
50  payloadMap[mu->link()*2].push_back(msw);
51  }
52 
53  // muons are expected to come on a range of links depending on the the TF
54  // but even if there was no muon coming from a processor the block should be generated
55  // so add these links without muons to the map as well so that they will be filled with zeros
56  for (const auto &link : links) {
57  if (payloadMap.count(link*2) == 0) {
58  payloadMap[link*2].push_back(0);
59  } else {
60  // if the key was already created in a previous BX then seed an entry for the padding if nothing was filled in this bx
61  if (payloadMap[link*2].size() == bxCtr * 6) {
62  payloadMap[link*2].push_back(0);
63  }
64  }
65  }
66 
67  // padding to 3 muons per block id (link) per BX
68  for (auto &kv : payloadMap) {
69  while (kv.second.size() % 6 != 0) {
70  kv.second.push_back(0);
71  }
72  }
73  }
74 
75  // push everything in the blocks vector
76  for (auto &kv : payloadMap) {
77  blocks.push_back(Block(kv.first, kv.second));
78  }
79  }
80  }
81 }
82 
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
std::vector< Block > Blocks
Definition: Block.h:72
const int mu
Definition: Constants.h:22
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:22
virtual Blocks pack(const edm::Event &, const PackerTokens *) override
void packTF(const edm::Event &, const edm::EDGetTokenT< RegionalMuonCandBxCollection > &, Blocks &, const std::vector< unsigned int > &)
Definition: event.py:1