31 typedef ap_ufixed<14, 12, AP_RND, AP_WRAP>
pt_t;
33 const float ptLSB_ = 0.25;
34 const float phiLSB_ =
M_PI / 720;
37 typedef ap_fixed<pt_t::width + 1, pt_t::iwidth + 1, AP_RND, AP_SAT>
pxy_t;
38 typedef ap_fixed<2 * pt_t::width, 2 * pt_t::iwidth, AP_RND, AP_SAT>
pt2_t;
42 const phi_t hwPiOverTwo_ = round(
M_PI / (2 * phiLSB_));
44 typedef ap_ufixed<pt_t::width, 0>
inv_t;
47 const int dropBits_ = 2;
48 const int dropFactor_ = (1 << dropBits_);
49 const int invTableBits_ = 10;
50 const int invTableSize_ = (1 << invTableBits_);
55 void CalcMetHLS(
const std::vector<float>&
pt,
56 const std::vector<float>& phi,
62 maxCands_(
cfg.getParameter<
int>(
"maxCands")) {
63 produces<std::vector<l1t::EtSum>>();
70 std::vector<float>
pt;
71 std::vector<float>
phi;
74 const auto& l1PFCand = l1PFCandidates->at(
i);
75 pt.push_back(l1PFCand.pt());
76 phi.push_back(l1PFCand.phi());
85 std::unique_ptr<std::vector<l1t::EtSum>>
metCollection(
new std::vector<l1t::EtSum>(0));
91 const std::vector<float>&
phi,
102 Project(hw_pt, hw_phi, hw_px,
true);
103 Project(hw_pt, hw_phi, hw_py,
false);
105 hw_sumx = hw_sumx - hw_px;
106 hw_sumy = hw_sumy - hw_py;
110 hw_met =
sqrt(
int(hw_met));
112 phi_t hw_met_phi = 0;
115 metVector.SetPt(hw_met.to_double());
116 metVector.SetPhi(hw_met_phi.to_double() *
phiLSB_);
134 phiQ1 =
hwPi_ - phiQ1;
139 }
else if (phiQ1 < 0) {
144 typedef ap_ufixed<14, 12, AP_RND, AP_WRAP>
pt_t;
158 if (
px == 0 &&
py == 0) {
185 inv_t a_over_b =
a * inv_b;
188 LogDebug(
"L1METPFProducer") <<
" a, b = \n " <<
a.to_double() <<
" , " <<
b.to_double()
189 <<
"; index, inv = " <<
index <<
", " << inv_b.to_double()
190 <<
"; ratio= " << a_over_b.to_double() <<
" \n"
192 LogDebug(
"L1METPFProducer") <<
"bcheck, 1/bc = " << bcheck <<
", " << 1. / bcheck <<
" -- " <<
invTableSize_ <<
" "
197 const int atanTableBits_ = 7;
198 const int atanTableSize_ = (1 << atanTableBits_);
199 index = round(a_over_b.to_double() * atanTableSize_);
203 LogDebug(
"L1METPFProducer") <<
" atan index, phi = " <<
index <<
", " <<
phi.to_double() <<
" ("
205 <<
" rad) real atan(a/b)= " << atan(
a.to_double() /
b.to_double()) <<
" \n"
213 if (px < 0 && py > 0)
215 if (
px > 0 &&
py < 0)
217 if (
px < 0 &&
py < 0)
221 LogDebug(
"L1METPFProducer") <<
" phi hw, float, real = " <<
phi.to_double() <<
", "
223 << atan2(
py.to_double(),
px.to_double()) <<
" rad from x,y = " <<
px.to_double() <<
", "
224 <<
py.to_double() <<
") \n"
231 desc.add<
int>(
"maxCandidates", 128);
233 descriptions.
add(
"L1METPFProducer",
desc);