CMS 3D CMS Logo

L1TkEtMissEmuAlgo.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
5 namespace l1tmetemu {
6  std::vector<cos_lut_fixed_t> generateCosLUT(unsigned int size) { // Fill cosine LUT with integer values
7  float phi = 0;
8  std::vector<cos_lut_fixed_t> cosLUT;
9  for (unsigned int LUT_idx = 0; LUT_idx < size; LUT_idx++) {
10  cosLUT.push_back((cos_lut_fixed_t)(cos(phi)));
12  //std::cout << LUT_idx << "," << (cos_lut_fixed_t)(cos(phi)) << std::endl;
13  }
14  cosLUT.push_back((cos_lut_fixed_t)(0)); //Prevent overflow in last bin
15  return cosLUT;
16  }
17 
19  global_phi_t PhiMin = 0;
21 
22  // The initial word comes in as a uint; the correct bits, but not automatically using 2s compliment format.
23  global_phi_t globalPhi = local_phi;
24 
25  // Once the word is in a larger, signed container, shift it down so that the negative numbers are automatically represented in 2s compliment.
26  if (local_phi >= (1 << (TTTrack_TrackWord::TrackBitWidths::kPhiSize - 1)))
27  globalPhi -= (1 << TTTrack_TrackWord::TrackBitWidths::kPhiSize);
28 
29  globalPhi += sector_shift;
30 
31  if (globalPhi < PhiMin) {
32  globalPhi = globalPhi + PhiMax;
33  } else if (globalPhi > PhiMax) {
34  globalPhi = globalPhi - PhiMax;
35  }
36 
37  return globalPhi;
38  }
39 
40  std::vector<global_phi_t> generatePhiSliceLUT(unsigned int N) {
41  float sliceCentre = 0.0;
42  std::vector<global_phi_t> phiLUT;
43  for (unsigned int q = 0; q <= N; q++) {
44  phiLUT.push_back((global_phi_t)(sliceCentre / TTTrack_TrackWord::stepPhi0));
45  sliceCentre += 2 * M_PI / N;
46  }
47  return phiLUT;
48  }
49 
50 } // namespace l1tmetemu
size
Write out results.
ap_int< TTTrack_TrackWord::TrackBitWidths::kPhiSize+kGlobalPhiExtra > global_phi_t
global_phi_t localToGlobalPhi(TTTrack_TrackWord::phi_t local_phi, global_phi_t sector_shift)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
ap_ufixed< kCosLUTSize, kCosLUTMagSize, AP_RND_CONV, AP_SAT > cos_lut_fixed_t
#define M_PI
#define N
Definition: blowfish.cc:9
static constexpr double stepPhi0
std::vector< global_phi_t > generatePhiSliceLUT(unsigned int N)
std::vector< cos_lut_fixed_t > generateCosLUT(unsigned int size)
ap_uint< TrackBitWidths::kPhiSize > phi_t