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 {
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 
l1t::Blocks
std::vector< Block > Blocks
Definition: Block.h:99
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
l1t::stage2::RegionalMuonGMTPacker::pack
Blocks pack(const edm::Event &, const PackerTokens *) override
Definition: RegionalMuonGMTPacker.cc:10
RegionalMuonRawDigiTranslator.h
mps_fire.i
i
Definition: mps_fire.py:428
PackerFactory.h
RegionalMuonGMTPacker.h
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm::EDGetTokenT< RegionalMuonCandBxCollection >
edm::Handle
Definition: AssociativeIterator.h:50
l1t::RegionalMuonRawDigiTranslator::generatePackedDataWords
static void generatePackedDataWords(const RegionalMuonCand &mu, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63, bool isKalman)
Definition: RegionalMuonRawDigiTranslator.cc:99
l1t::stage2::RegionalMuonGMTPacker::packTF
void packTF(const edm::Event &, const edm::EDGetTokenT< RegionalMuonCandBxCollection > &, Blocks &)
Definition: RegionalMuonGMTPacker.cc:25
DEFINE_L1T_PACKER
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:23
Event.h
l1t
delete x;
Definition: CaloConfig.h:22
l1t::stage2::RegionalMuonGMTPacker
Definition: RegionalMuonGMTPacker.h:13
l1t::PackerTokens
Definition: PackerTokens.h:10
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::stage2::RegionalMuonGMTPacker::PayloadMap
std::map< unsigned int, std::vector< uint32_t > > PayloadMap
Definition: RegionalMuonGMTPacker.h:16
l1t::stage2::RegionalMuonGMTPacker::isKalman_
bool isKalman_
Definition: RegionalMuonGMTPacker.h:22
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
l1t::Block
Definition: Block.h:70
gather_cfg.blocks
blocks
Definition: gather_cfg.py:90
GMTTokens.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443