CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Typedefs | Functions | Variables
L1TauEmu Namespace Reference

Typedefs

typedef ap_uint< 5 > count_t
 
typedef ap_fixed< 18, 9 > detaphi2_t
 
typedef ap_fixed< 12, 6 > detaphi_t
 
typedef ap_int< 8 > dxy_t
 
typedef ap_fixed< 10, 4 > etaphi_t
 
typedef ap_uint< 5 > id_t
 
typedef ap_ufixed< 18, -2 > inv_pt_t
 
typedef ap_fixed< 22, 16 > pt_etaphi_t
 
typedef ap_ufixed< 16, 14 > pt_t
 
typedef ap_int< 10 > z0_t
 

Functions

constexpr int ceillog2 (int x)
 
detaphi_t deltaPhi (l1t::PFCandidate a, l1t::PFCandidate b)
 
constexpr int floorlog2 (int x)
 
template<class data_T , int N>
unsigned idx_from_real_val (data_T x)
 
bool inCone (l1t::PFCandidate seed, l1t::PFCandidate part, detaphi_t cone2)
 
template<class data_T , class table_T , int N>
void init_invert_table (table_T table_out[N])
 
template<class in_t , class table_t , int N>
table_t invert_with_shift (in_t in, bool debug=false)
 
constexpr int pow2 (int x)
 
template<class data_T , int N>
float real_val_from_idx (unsigned i)
 

Variables

static constexpr float etaphi_base = 100. / 64
 
static const etaphi_t FIDUCIAL_ETA_PHI = 5.11 * etaphi_base
 
static const detaphi_t HALFPI = 3.14159 / 2 * etaphi_base
 
static constexpr int N_table_inv_pt = 1024
 
static const detaphi_t PI = 3.14159 * etaphi_base
 
static const detaphi_t R2CONE = RCONE * RCONE
 
static const detaphi_t RCONE = 0.4 * 100 / 128
 
static const detaphi_t TWOPI = 3.14159 * 2. * etaphi_base
 

Typedef Documentation

◆ count_t

typedef ap_uint<5> L1TauEmu::count_t

Definition at line 43 of file TauNNIdHW.h.

◆ detaphi2_t

typedef ap_fixed<18, 9> L1TauEmu::detaphi2_t

Definition at line 39 of file TauNNIdHW.h.

◆ detaphi_t

typedef ap_fixed<12, 6> L1TauEmu::detaphi_t

Definition at line 38 of file TauNNIdHW.h.

◆ dxy_t

typedef ap_int<8> L1TauEmu::dxy_t

Definition at line 41 of file TauNNIdHW.h.

◆ etaphi_t

typedef ap_fixed<10, 4> L1TauEmu::etaphi_t

Definition at line 37 of file TauNNIdHW.h.

◆ id_t

typedef ap_uint<5> L1TauEmu::id_t

Definition at line 44 of file TauNNIdHW.h.

◆ inv_pt_t

typedef ap_ufixed<18, -2> L1TauEmu::inv_pt_t

Definition at line 47 of file TauNNIdHW.h.

◆ pt_etaphi_t

typedef ap_fixed<22, 16> L1TauEmu::pt_etaphi_t

Definition at line 40 of file TauNNIdHW.h.

◆ pt_t

typedef ap_ufixed<16, 14> L1TauEmu::pt_t

Definition at line 36 of file TauNNIdHW.h.

◆ z0_t

typedef ap_int<10> L1TauEmu::z0_t

Definition at line 42 of file TauNNIdHW.h.

Function Documentation

◆ ceillog2()

constexpr int L1TauEmu::ceillog2 ( int  x)

Definition at line 57 of file TauNNIdHW.h.

References x.

Referenced by idx_from_real_val(), and real_val_from_idx().

57 { return (x <= 2) ? 1 : 1 + ceillog2((x + 1) / 2); }
constexpr int ceillog2(int x)
Definition: TauNNIdHW.h:57
float x

◆ deltaPhi()

detaphi_t L1TauEmu::deltaPhi ( l1t::PFCandidate  a,
l1t::PFCandidate  b 
)
inline

Definition at line 115 of file TauNNIdHW.h.

References a, b, bphi, etaphi_base, l1ct::Scales::INTPHI_PI, and l1ct::Scales::INTPHI_TWOPI.

Referenced by inCone().

115  {
116  // scale the particle eta, phi to hardware units
117  etaphi_t aphi = etaphi_t(a.phi() * etaphi_base);
118  etaphi_t bphi = etaphi_t(b.phi() * etaphi_base);
119  detaphi_t dphi = detaphi_t(aphi) - detaphi_t(bphi);
120  // phi wrap
121  detaphi_t dphi0 =
123  detaphi_t dphi1 =
125  //dphi > PI ? detaphi_t(TWOPI - dphi) : detaphi_t(dphi);
126  //dphi < -PI ? detaphi_t(TWOPI + dphi) : detaphi_t(dphi);
127  detaphi_t dphiw = dphi > detaphi_t(0) ? dphi0 : dphi1;
128  return dphiw;
129  }
constexpr int INTPHI_PI
Definition: datatypes.h:149
static constexpr float etaphi_base
Definition: TauNNIdHW.h:35
ap_fixed< 12, 6 > detaphi_t
Definition: TauNNIdHW.h:38
const float bphi
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
constexpr int INTPHI_TWOPI
Definition: datatypes.h:150
ap_fixed< 10, 4 > etaphi_t
Definition: TauNNIdHW.h:28

◆ floorlog2()

constexpr int L1TauEmu::floorlog2 ( int  x)

Definition at line 58 of file TauNNIdHW.h.

References x.

58 { return (x < 2) ? 0 : 1 + floorlog2(x / 2); }
float x
constexpr int floorlog2(int x)
Definition: TauNNIdHW.h:58

◆ idx_from_real_val()

template<class data_T , int N>
unsigned L1TauEmu::idx_from_real_val ( data_T  x)
inline

Definition at line 74 of file TauNNIdHW.h.

References ceillog2(), N, and x.

74  {
75  // Slice the top N bits to get an index into the table
76  static constexpr int NB = ceillog2(N); // number of address bits for table
77  // Slice the top-1 NB bits of the value
78  // the MSB of '1' is implicit, so only slice below that
79  ap_uint<NB> y = x(x.width - 2, x.width - NB - 1);
80  return (unsigned)y(NB - 1, 0);
81  }
constexpr int ceillog2(int x)
Definition: TauNNIdHW.h:57
#define N
Definition: blowfish.cc:9
float x

◆ inCone()

bool L1TauEmu::inCone ( l1t::PFCandidate  seed,
l1t::PFCandidate  part,
detaphi_t  cone2 
)
inline

Definition at line 131 of file TauNNIdHW.h.

References deltaPhi(), etaphi_base, runTheMatrix::ret, and fileCollector::seed.

Referenced by L1NNTauProducer::makeTau_HW(), and L1NNTauProducer::process_HW().

131  {
132  // scale the particle eta, phi to hardware units
133  etaphi_t seta = etaphi_t(seed.eta() * etaphi_base);
134  etaphi_t peta = etaphi_t(part.eta() * etaphi_base);
135  detaphi_t deta = detaphi_t(seta) - detaphi_t(peta);
136  detaphi_t dphi = deltaPhi(seed, part);
137  bool ret = (deta * deta + dphi * dphi) < cone2;
138  return ret;
139  }
detaphi_t deltaPhi(l1t::PFCandidate a, l1t::PFCandidate b)
Definition: TauNNIdHW.h:115
static constexpr float etaphi_base
Definition: TauNNIdHW.h:35
ret
prodAgent to be discontinued
ap_fixed< 12, 6 > detaphi_t
Definition: TauNNIdHW.h:38
part
Definition: HCALResponse.h:20
ap_fixed< 10, 4 > etaphi_t
Definition: TauNNIdHW.h:28

◆ init_invert_table()

template<class data_T , class table_T , int N>
void L1TauEmu::init_invert_table ( table_T  table_out[N])

Definition at line 84 of file TauNNIdHW.h.

References mps_fire::i, N, and x.

84  {
85  // The template data_T is the data type used to address the table
86  for (unsigned i = 0; i < N; i++) {
87  float x = real_val_from_idx<data_T, N>(i);
88  table_T inv_x = 1 / x;
89  table_out[i] = inv_x;
90  }
91  }
#define N
Definition: blowfish.cc:9
float x

◆ invert_with_shift()

template<class in_t , class table_t , int N>
table_t L1TauEmu::invert_with_shift ( in_t  in,
bool  debug = false 
)

Definition at line 94 of file TauNNIdHW.h.

References b, heavyIonCSV_trainingSettings::idx, recoMuon::in, N, and MillePedeFileConverter_cfg::out.

94  {
95  table_t inv_table[N];
96  init_invert_table<in_t, table_t, N>(inv_table);
97 
98  // find the first '1' in the denominator
99  int msb = 0;
100  for (int b = 0; b < in.width; b++) {
101  if (in[b])
102  msb = b;
103  }
104  // shift up the denominator such that the left-most bit (msb) is '1'
105  in_t in_shifted = in << (in.width - msb - 1);
106  // lookup the inverse of the shifted input
107  int idx = idx_from_real_val<in_t, N>(in_shifted);
108  table_t inv_in = inv_table[idx];
109  // shift the output back
110  table_t out = inv_in << (in.width - msb - 1);
111 
112  return out;
113  }
#define N
Definition: blowfish.cc:9
double b
Definition: hdecay.h:120

◆ pow2()

constexpr int L1TauEmu::pow2 ( int  x)

Definition at line 59 of file TauNNIdHW.h.

References x.

59 { return x == 0 ? 1 : 2 * pow2(x - 1); }
constexpr int pow2(int x)
Definition: TauNNIdHW.h:59
float x

◆ real_val_from_idx()

template<class data_T , int N>
float L1TauEmu::real_val_from_idx ( unsigned  i)
inline

Definition at line 62 of file TauNNIdHW.h.

References ceillog2(), mps_fire::i, N, and x.

62  {
63  // Treat the index as the top N bits
64  static constexpr int NB = ceillog2(N); // number of address bits for table
65  data_T x(0);
66  // The MSB of 1 is implicit in the table
67  x[x.width - 1] = 1;
68  // So we can use the next NB bits for real data
69  x(x.width - 2, x.width - NB - 1) = i;
70  return (float)x;
71  }
constexpr int ceillog2(int x)
Definition: TauNNIdHW.h:57
#define N
Definition: blowfish.cc:9
float x

Variable Documentation

◆ etaphi_base

constexpr float L1TauEmu::etaphi_base = 100. / 64
static

◆ FIDUCIAL_ETA_PHI

const etaphi_t L1TauEmu::FIDUCIAL_ETA_PHI = 5.11 * etaphi_base
static

Definition at line 55 of file TauNNIdHW.h.

◆ HALFPI

const detaphi_t L1TauEmu::HALFPI = 3.14159 / 2 * etaphi_base
static

Definition at line 51 of file TauNNIdHW.h.

◆ N_table_inv_pt

constexpr int L1TauEmu::N_table_inv_pt = 1024
static

Definition at line 48 of file TauNNIdHW.h.

◆ PI

const detaphi_t L1TauEmu::PI = 3.14159 * etaphi_base
static

Definition at line 50 of file TauNNIdHW.h.

◆ R2CONE

const detaphi_t L1TauEmu::R2CONE = RCONE * RCONE
static

Definition at line 53 of file TauNNIdHW.h.

◆ RCONE

const detaphi_t L1TauEmu::RCONE = 0.4 * 100 / 128
static

Definition at line 52 of file TauNNIdHW.h.

◆ TWOPI

const detaphi_t L1TauEmu::TWOPI = 3.14159 * 2. * etaphi_base
static

Definition at line 49 of file TauNNIdHW.h.