CMS 3D CMS Logo

codecs_etsums.cc
Go to the documentation of this file.
3 
4 namespace l1t::demo::codecs {
5 
6  ap_uint<64> encodeEtSum(const l1t::EtSum& etSum) {
7  l1tmetemu::EtMiss etMiss;
8  etMiss.Et.V = etSum.hwPt();
9  etMiss.Phi = etSum.hwPhi();
10  ap_uint<1> valid = (etSum.hwQual() > 0);
11  ap_uint<64 - (l1tmetemu::kMETSize + l1tmetemu::kMETPhiSize + 1)> unassigned = 0;
12  ap_uint<64> etSumWord = (unassigned, etMiss.Phi, etMiss.Et.range(), valid);
13  return etSumWord;
14  }
15 
16  // Encodes etsum collection onto 1 output link
17  std::array<std::vector<ap_uint<64>>, 1> encodeEtSums(const edm::View<l1t::EtSum>& etSums) {
18  std::vector<ap_uint<64>> etSumWords;
19 
20  for (const auto& etSum : etSums)
21  etSumWords.push_back(encodeEtSum(etSum));
22 
23  std::array<std::vector<ap_uint<64>>, 1> linkData;
24 
25  for (size_t i = 0; i < linkData.size(); i++) {
26  // Pad etsum vectors -> full packet length (48 frames, but only 1 etsum max)
27  etSumWords.resize(1, 0);
28  linkData.at(i) = etSumWords;
29  }
30 
31  return linkData;
32  }
33 
34  std::vector<l1t::EtSum> decodeEtSums(const std::vector<ap_uint<64>>& frames) {
35  std::vector<l1t::EtSum> etSums;
36 
37  for (const auto& x : frames) {
38  if (not x.test(0))
39  break;
40 
41  math::XYZTLorentzVector v(0, 0, 0, 0);
42  l1t::EtSum s(v,
45  0,
47  0);
48  etSums.push_back(s);
49  }
50 
51  return etSums;
52  }
53 
54 } // namespace l1t::demo::codecs
ap_int< kMETPhiSize > METWordphi_t
ap_uint< 64 > encodeEtSum(const l1t::EtSum &v)
Definition: codecs_etsums.cc:6
int hwPhi() const
Definition: L1Candidate.h:37
ap_ufixed< kMETSize, kMETMagSize, AP_RND_CONV, AP_SAT > METWord_t
int hwQual() const
Definition: L1Candidate.h:38
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const unsigned int kMETSize
int hwPt() const
Definition: L1Candidate.h:35
std::array< std::vector< ap_uint< 64 > >, 1 > encodeEtSums(const edm::View< l1t::EtSum > &)
const unsigned int kMETPhiSize
float x
std::vector< l1t::EtSum > decodeEtSums(const std::vector< ap_uint< 64 >> &)