1 #ifndef L1Trigger_Phase2L1ParticleFlow_L1SeedConePFJetEmulator_h 2 #define L1Trigger_Phase2L1ParticleFlow_L1SeedConePFJetEmulator_h 52 static constexpr
int pow(
int x) {
53 return x == 0 ? 1 :
B * pow<B>(
x - 1);
56 static constexpr
int pow2(
int x) {
return pow<2>(
x); }
66 template <
class T,
class Op>
74 return op(
x.at(0),
x.at(1));
76 std::vector<T> left(
x.begin(),
x.begin() + leftN);
77 std::vector<T> right(
x.begin() + leftN,
x.end());
78 return op(reduce<T, Op>(left, op), reduce<T, Op>(right, op));
89 template <
class data_T,
int N>
97 x(
x.width - 2,
x.width - NB - 1) =
i;
101 template <
class data_T,
int N>
107 ap_uint<NB>
y =
x(
x.width - 2,
x.width - NB - 1);
108 return (
unsigned)
y(NB - 1, 0);
111 template <
class data_T,
class table_T,
int N>
114 for (
unsigned i = 0;
i <
N;
i++) {
115 float x = real_val_from_idx<data_T, N>(
i);
116 table_T inv_x = 1 /
x;
117 table_out[
i] = inv_x;
121 template <
class in_t,
class table_t,
int N>
125 for (
int b = 0;
b <
in.width;
b++) {
130 in_t in_shifted =
in << (
in.width - msb - 1);
132 int idx = idx_from_real_val<in_t, N>(in_shifted);
133 table_t inv_in = inv_table[
idx];
135 table_t
out = inv_in << (
in.width - msb - 1);
137 dbgCout() <<
" x " <<
in <<
", msb = " << msb <<
", shift = " << (
in.width - msb) <<
", idx = " <<
idx 139 dbgCout() <<
" pre 1 / " << in_shifted <<
" = " << inv_in <<
"(" << 1 / (
float)in_shifted <<
")" << std::endl;
140 dbgCout() <<
" post 1 / " <<
in <<
" = " <<
out <<
"(" << 1 / (
float)
in <<
")" << std::endl;
static T reduce(std::vector< T > x, Op op)
static void init_invert_table(table_T table_out[N])
static constexpr int pow(int x)
static constexpr int pow2(int x)
static float real_val_from_idx(unsigned i)
L1SCJetEmu(bool debug, float coneSize, unsigned nJets)
Particle operator()(Particle a, Particle b)
static unsigned idx_from_real_val(data_T x)
ap_fixed< 18, 23 > detaphi2_t
ap_ufixed< 18, -2 > inv_pt_t
l1ct::PuppiObjEmu Particle
std::vector< Jet > emulateEvent(std::vector< Particle > &parts) const
static constexpr int floorlog2(int x)
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
static constexpr int ceillog2(int x)
static table_t invert_with_shift(const in_t in, const table_t inv_table[N], bool debug=false)
static detaphi_t deltaPhi(Particle a, Particle b)
Jet makeJet_HW(const std::vector< Particle > &parts) const
inv_pt_t inv_pt_table_[N_table_inv_pt]
bool inCone(Particle seed, Particle part) const
static OpPuppiObjMax op_max
static constexpr int N_table_inv_pt
ap_fixed< 22, 22 > pt_etaphi_t
std::vector< l1ct::PuppiObjEmu > constituents