CMS 3D CMS Logo

codecs_tkjets.cc
Go to the documentation of this file.
1 
3 
4 namespace l1t::demo::codecs {
5 
6  ap_uint<64> encodeTkJet(const l1t::TkJetWord& j) { return j.tkJetWord(); }
7 
8  // Encodes vertex collection onto 1 output link
9  std::array<std::vector<ap_uint<64>>, 1> encodeTkJets(const edm::View<l1t::TkJetWord>& tkJets) {
10  std::vector<ap_uint<64>> tkJetWords;
11 
12  for (const auto& tkJet : tkJets) {
13  tkJetWords.push_back(encodeTkJet(tkJet));
14  tkJetWords.push_back(ap_uint<64>(0));
15  }
16 
17  std::array<std::vector<ap_uint<64>>, 1> linkData;
18 
19  for (size_t i = 0; i < linkData.size(); i++) {
20  // Pad TkJet vectors -> full packet length (48 frames, but only 12 TkJets max, two words per jet)
21  tkJetWords.resize(24, 0);
22  linkData.at(i) = tkJetWords;
23  }
24 
25  return linkData;
26  }
27 
28  std::vector<l1t::TkJetWord> decodeTkJets(const std::vector<ap_uint<64>>& frames) {
29  std::vector<l1t::TkJetWord> tkJets;
30 
31  for (size_t f = 0; f < frames.size(); f += 2) {
32  // There is no valid bit in the definition right now.
33  // Uncomment the next two lines when this is available.
34  //if (not x.test(TkJetWord::kValidLSB))
35  // break;
36 
37  TkJetWord j(
38  TkJetWord::pt_t(frames[f](TkJetWord::TkJetBitLocations::kPtMSB, TkJetWord::TkJetBitLocations::kPtLSB)),
40  frames[f](TkJetWord::TkJetBitLocations::kGlbPhiMSB, TkJetWord::TkJetBitLocations::kGlbPhiLSB)),
42  frames[f](TkJetWord::TkJetBitLocations::kGlbEtaMSB, TkJetWord::TkJetBitLocations::kGlbEtaLSB)),
43  TkJetWord::z0_t(frames[f](TkJetWord::TkJetBitLocations::kZ0MSB, TkJetWord::TkJetBitLocations::kZ0LSB)),
44  TkJetWord::nt_t(frames[f](TkJetWord::TkJetBitLocations::kNtMSB, TkJetWord::TkJetBitLocations::kNtLSB)),
45  TkJetWord::nx_t(frames[f](TkJetWord::TkJetBitLocations::kXtMSB, TkJetWord::TkJetBitLocations::kXtLSB)),
47  frames[f](TkJetWord::TkJetBitLocations::kDispFlagMSB, TkJetWord::TkJetBitLocations::kDispFlagLSB)),
50  tkJets.push_back(j);
51  }
52 
53  return tkJets;
54  }
55 
56 } // namespace l1t::demo::codecs
ap_int< kGlbEtaSize > glbeta_t
Definition: TkJetWord.h:59
ap_int< kGlbPhiSize > glbphi_t
Definition: TkJetWord.h:60
ap_ufixed< kPtSize, kPtMagSize, AP_TRN, AP_SAT > pt_t
Definition: TkJetWord.h:58
ap_uint< kDispFlagSize > dispflag_t
Definition: TkJetWord.h:64
ap_uint< TkJetBitWidths::kUnassignedSize > tkjetunassigned_t
Definition: TkJetWord.h:65
ap_int< kZ0Size > z0_t
Definition: TkJetWord.h:61
double f[11][100]
ap_uint< kXtSize > nx_t
Definition: TkJetWord.h:63
ap_uint< 64 > encodeTkJet(const l1t::TkJetWord &t)
Definition: codecs_tkjets.cc:6
std::vector< l1t::TkJetWord > decodeTkJets(const std::vector< ap_uint< 64 >> &)
ap_uint< kNtSize > nt_t
Definition: TkJetWord.h:62
std::array< std::vector< ap_uint< 64 > >, 1 > encodeTkJets(const edm::View< l1t::TkJetWord > &)
Definition: codecs_tkjets.cc:9