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() { // Fill cosine LUT with integer values
7  float phi = 0;
8  std::vector<cos_lut_fixed_t> cosLUT;
10  for (unsigned int LUT_idx = 0; LUT_idx < l1tmetemu::kCosLUTBins; LUT_idx++) {
11  cosLUT.push_back((cos_lut_fixed_t)(cos(phi)));
12  phi += stepPhi;
13  //std::cout << LUT_idx << "," << (cos_lut_fixed_t)(cos(phi)) << std::endl;
14  }
15  cosLUT[1023] = (cos_lut_fixed_t)(0); //Match F/W for Integration Tests
16  return cosLUT;
17  }
18 
20  global_phi_t PhiMin = 0;
22 
23  // The initial word comes in as a uint; the correct bits, but not automatically using 2s compliment format.
24  global_phi_t globalPhi = local_phi;
25 
26  // Once the word is in a larger, signed container, shift it down so that the negative numbers are automatically represented in 2s compliment.
27  if (local_phi >= (1 << (TTTrack_TrackWord::TrackBitWidths::kPhiSize - 1)))
28  globalPhi -= (1 << TTTrack_TrackWord::TrackBitWidths::kPhiSize);
29 
30  globalPhi += sector_shift;
31 
32  if (globalPhi < PhiMin) {
33  globalPhi = globalPhi + PhiMax;
34  } else if (globalPhi > PhiMax) {
35  globalPhi = globalPhi - PhiMax;
36  }
37 
38  return globalPhi;
39  }
40 
41  std::vector<global_phi_t> generatePhiSliceLUT(unsigned int N) {
42  float sliceCentre = 0.0;
43  std::vector<global_phi_t> phiLUT;
44  for (unsigned int q = 0; q <= N; q++) {
45  phiLUT.push_back((global_phi_t)(sliceCentre / TTTrack_TrackWord::stepPhi0));
46  sliceCentre += 2 * M_PI / N;
47  }
48  return phiLUT;
49  }
50 
51 } // namespace l1tmetemu
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
const unsigned int kCosLUTBins
ap_ufixed< kCosLUTSize, kCosLUTMagSize, AP_RND_CONV, AP_SAT > cos_lut_fixed_t
#define M_PI
#define N
Definition: blowfish.cc:9
const unsigned int kCosLUTShift
static constexpr double stepPhi0
std::vector< global_phi_t > generatePhiSliceLUT(unsigned int N)
std::vector< cos_lut_fixed_t > generateCosLUT()
ap_uint< TrackBitWidths::kPhiSize > phi_t