CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MuonPacker.cc
Go to the documentation of this file.
2 
3 #include "GMTTokens.h"
4 #include "MuonPacker.h"
5 
6 namespace l1t {
7  namespace stage2 {
10  event.getByToken(static_cast<const CommonTokens*>(toks)->getMuonToken(), muons);
11 
12  PayloadMap payloadMap;
13 
14  for (int bx = muons->getFirstBX(); bx <= muons->getLastBX(); ++bx) {
15  packBx(payloadMap, muons, bx);
16  }
17 
18  Blocks blocks;
19  // push everything in the blocks vector
20  for (auto& kv : payloadMap) {
21  blocks.push_back(Block(kv.first, kv.second));
22  }
23  return blocks;
24  }
25 
27  // the first word in every BX and every block id is 0
28  for (unsigned int blkId = b1_; blkId < b1_ + 7; blkId += 2) {
29  payloadMap[blkId].push_back(0);
30  }
31 
32  unsigned int blkId = b1_;
33  auto mu{muons->begin(bx)};
34  uint32_t mu1_shared_word{0};
35  uint32_t mu2_shared_word{0};
36  uint32_t mu1_msw{0};
37  uint32_t mu2_msw{0};
38  uint32_t mu1_lsw{0};
39  uint32_t mu2_lsw{0};
40  // Slightly convoluted logic to account for the Run-3 muon readout record:
41  // To make space for displacement information we moved the raw
42  // (i.e. non-extrapolated) eta value to the second "spare" word
43  // in the block which we call "shared word". So the logic below
44  // needs to be aware if it is operating on the first or second
45  // muon in the block in order to place the eta value in the right
46  // place in the shared word. Additionally the logic needs to
47  // wait for the second muon in the block before filling the
48  // payload map because the shared word goes in first.
49  for (int muCtr = 1; muCtr <= 8; ++muCtr) {
50  if (mu != muons->end(bx)) {
52  *mu, mu2_shared_word, mu2_lsw, mu2_msw, fedId_, fwId_, 2 - (muCtr % 2));
53  ++mu;
54  }
55 
56  // If we're remaining in the current block the muon we just packed is the first one in the block.
57  // If not we add both muons to the payload map and go to the next block.
58  if (muCtr % 2 == 1) {
59  mu1_shared_word = mu2_shared_word;
60  mu1_lsw = mu2_lsw;
61  mu1_msw = mu2_msw;
62  } else {
63  payloadMap[blkId].push_back(mu1_shared_word | mu2_shared_word);
64  payloadMap[blkId].push_back(mu1_lsw);
65  payloadMap[blkId].push_back(mu1_msw);
66  payloadMap[blkId].push_back(mu2_lsw);
67  payloadMap[blkId].push_back(mu2_msw);
68 
69  blkId += 2;
70 
71  mu1_shared_word = 0;
72  mu1_lsw = 0;
73  mu1_msw = 0;
74  }
75  mu2_shared_word = 0;
76  mu2_lsw = 0;
77  mu2_msw = 0;
78  }
79  }
80  } // namespace stage2
81 } // namespace l1t
82 
tuple blocks
Definition: gather_cfg.py:90
std::map< unsigned int, std::vector< uint32_t > > PayloadMap
Definition: MuonPacker.h:18
void packBx(PayloadMap &payloadMap, const edm::Handle< MuonBxCollection > &muons, int bx)
Definition: MuonPacker.cc:26
Blocks pack(const edm::Event &, const PackerTokens *) override
Definition: MuonPacker.cc:8
std::vector< Block > Blocks
Definition: Block.h:99
static void generatePackedDataWords(const Muon &mu, uint32_t &raw_data_spare, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63, int fedId, int fwId, int muInBx)
const int mu
Definition: Constants.h:22
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:23
tuple muons
Definition: patZpeak.py:39