CMS 3D CMS Logo

codecs_htsums.cc
Go to the documentation of this file.
3 
4 namespace l1t::demo::codecs {
5 
6  ap_uint<64> encodeHtSum(const l1t::EtSum& htSum) {
7  l1tmhtemu::EtMiss htMiss;
8  htMiss.Et = htSum.p4().energy();
9  htMiss.Phi = htSum.hwPhi();
10  ap_uint<l1tmhtemu::kMHTSize> HT = htSum.hwPt();
11  ap_uint<l1tmhtemu::kValidSize> valid = (htSum.hwQual() > 0);
12  ap_uint<l1tmhtemu::kUnassignedSize> unassigned = 0;
13  ap_uint<64> htSumWord = (unassigned, HT, htMiss.Phi, htMiss.Et.range(), valid);
14  return htSumWord;
15  }
16 
17  // Encodes htsum collection onto 1 output link
18  std::array<std::vector<ap_uint<64>>, 1> encodeHtSums(const edm::View<l1t::EtSum>& htSums) {
19  std::vector<ap_uint<64>> htSumWords;
20 
21  for (const auto& htSum : htSums)
22  htSumWords.push_back(encodeHtSum(htSum));
23 
24  std::array<std::vector<ap_uint<64>>, 1> linkData;
25 
26  for (size_t i = 0; i < linkData.size(); i++) {
27  // Pad etsum vectors -> full packet length (48 frames, but only 1 htsum max)
28  htSumWords.resize(1, 0);
29  linkData.at(i) = htSumWords;
30  }
31 
32  return linkData;
33  }
34 
35  std::vector<l1t::EtSum> decodeHtSums(const std::vector<ap_uint<64>>& frames) {
36  std::vector<l1t::EtSum> htSums;
37 
38  for (const auto& x : frames) {
39  if (not x.test(0))
40  break;
41 
43  l1t::EtSum s(v,
46  0,
48  0);
49  htSums.push_back(s);
50  }
51 
52  return htSums;
53  }
54 
55 } // namespace l1t::demo::codecs
std::array< std::vector< ap_uint< 64 > >, 1 > encodeHtSums(const edm::View< l1t::EtSum > &)
int hwPhi() const
Definition: L1Candidate.h:37
ap_uint< kMHTPhiSize > MHTphi_t
ap_uint< 64 > encodeHtSum(const l1t::EtSum &v)
Definition: codecs_htsums.cc:6
const LorentzVector & p4() const final
four-momentum Lorentz vector
int hwQual() const
Definition: L1Candidate.h:38
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
ap_ufixed< kMHTSize, kMHTIntSize > MHT_t
int hwPt() const
Definition: L1Candidate.h:35
std::vector< l1t::EtSum > decodeHtSums(const std::vector< ap_uint< 64 >> &)
float x
Definition: HT.h:21