CMS 3D CMS Logo

l2egencoder_ref.h
Go to the documentation of this file.
1 #ifndef L2EGENCODER_REF_H
2 #define L2EGENCODER_REF_H
3 
7 
8 namespace edm {
9  class ParameterSet;
10 }
11 
12 namespace l1ct {
13 
15  L2EgEncoderEmulator(unsigned int nTKELE_OUT, unsigned int nTKPHO_OUT)
17  assert(nTkEleOut_ % 2 == 0);
18  assert(nTkPhoOut_ % 2 == 0);
19  };
20 
21  L2EgEncoderEmulator(const edm::ParameterSet& iConfig);
22 
23  void toFirmware(const std::vector<ap_uint<64>>& encoded_in, ap_uint<64> encoded_fw[]) const;
24 
25  std::vector<ap_uint<64>> encodeLayer2EgObjs(const std::vector<EGIsoObjEmu>& photons,
26  const std::vector<EGIsoEleObjEmu>& electrons) const {
27  std::vector<ap_uint<64>> ret;
28 
29  auto encoded_photons = encodeLayer2(photons);
30  encoded_photons.resize(nTkPhoOut_, {0});
31  auto encoded_eles = encodeLayer2(electrons);
32  encoded_eles.resize(nTkEleOut_, {0});
33  //
34  encodeLayer2To64bits(encoded_eles, ret);
35  encodeLayer2To64bits(encoded_photons, ret);
36  return ret;
37  }
38 
39  template <class T>
40  std::vector<ap_uint<64>> encodeLayer2EgObjs_trivial(const std::vector<T>& egs, int n) const {
41  std::vector<ap_uint<64>> ret;
42 
43  auto encoded_egs = encodeLayer2_trivial<T>(egs);
44  encoded_egs.resize(n, {0});
45  //
46  encodeLayer2To64bits(encoded_egs, ret);
47 
48  return ret;
49  }
50 
51  private:
52  template <class T>
53  ap_uint<96> encodeLayer2(const T& egiso) const {
54  return egiso.toGT().pack();
55  }
56 
57  template <class T>
58  std::vector<ap_uint<96>> encodeLayer2(const std::vector<T>& egisos) const {
59  std::vector<ap_uint<96>> ret;
60  ret.reserve(egisos.size());
61  for (const auto& egiso : egisos) {
62  ret.push_back(encodeLayer2(egiso));
63  }
64  return ret;
65  }
66  //
67  template <class T>
68  ap_uint<96> encodeLayer2_trivial(const T& egiso) const {
69  ap_uint<96> ret = 0;
70  ret(T::BITWIDTH - 1, 0) = egiso.pack();
71  return ret;
72  }
73 
74  template <class T>
75  std::vector<ap_uint<96>> encodeLayer2_trivial(const std::vector<T>& egisos) const {
76  std::vector<ap_uint<96>> ret;
77  for (const auto& egiso : egisos) {
78  ret.push_back(encodeLayer2_trivial(egiso));
79  }
80  return ret;
81  }
82 
83  void encodeLayer2To64bits(const std::vector<ap_uint<96>>& packed96, std::vector<ap_uint<64>>& packed64) const {
84  for (unsigned int i = 0; i < packed96.size(); i += 2) {
85  packed64.push_back(packed96[i](63, 0));
86  packed64.push_back((ap_uint<32>(packed96[i + 1](95, 64)), ap_uint<32>(packed96[i](95, 64))));
87  packed64.push_back(packed96[i + 1](63, 0));
88  }
89  }
90 
91  unsigned int nTkEleOut_;
92  unsigned int nTkPhoOut_;
93  unsigned int nEncodedWords_;
94  };
95 
96 } // namespace l1ct
97 #endif
std::vector< ap_uint< 64 > > encodeLayer2EgObjs(const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
ret
prodAgent to be discontinued
void encodeLayer2To64bits(const std::vector< ap_uint< 96 >> &packed96, std::vector< ap_uint< 64 >> &packed64) const
ap_uint< 96 > encodeLayer2(const T &egiso) const
ap_uint< 96 > encodeLayer2_trivial(const T &egiso) const
assert(be >=bs)
L2EgEncoderEmulator(unsigned int nTKELE_OUT, unsigned int nTKPHO_OUT)
std::vector< ap_uint< 64 > > encodeLayer2EgObjs_trivial(const std::vector< T > &egs, int n) const
std::vector< ap_uint< 96 > > encodeLayer2_trivial(const std::vector< T > &egisos) const
std::vector< ap_uint< 96 > > encodeLayer2(const std::vector< T > &egisos) const
HLT enums.
void toFirmware(const std::vector< ap_uint< 64 >> &encoded_in, ap_uint< 64 > encoded_fw[]) const
long double T
Definition: datatypes.h:17