CMS 3D CMS Logo

L1TkEtMissEmuAlgo.h
Go to the documentation of this file.
1 #ifndef L1Trigger_L1TTrackMatch_L1TkEtMissEmuAlgo_HH
2 #define L1Trigger_L1TTrackMatch_L1TkEtMissEmuAlgo_HH
3 
4 #include <ap_int.h>
5 
6 #include <cmath>
7 #include <cstdint>
8 #include <filesystem>
9 #include <fstream>
10 #include <iostream>
11 #include <iomanip>
12 #include <numeric>
13 
17 
18 // Namespace that defines constants and types used by the EtMiss Emulation
19 // Includes functions for writing LUTs and converting to integer representations
20 namespace l1tmetemu {
21 
22  const unsigned int kInternalPtWidth{14};
23  const unsigned int kPtMagSize{9};
24  const unsigned int kMETSize{16}; // For output Magnitude default 16
25  const unsigned int kMETMagSize{11};
26  const unsigned int kMETPhiSize{13}; // For Output Phi default 13
27  const unsigned int kEtExtra{4};
28  const unsigned int kGlobalPhiExtra{4};
29  const unsigned int kCosLUTSize{10};
30  const unsigned int kCosLUTMagSize{1};
31  const unsigned int kAtanLUTSize{64};
32  const unsigned int kAtanLUTMagSize{2};
33 
34  typedef ap_ufixed<kMETSize, kMETMagSize, AP_RND_CONV, AP_SAT> METWord_t;
35  typedef ap_int<kMETPhiSize> METWordphi_t;
36  typedef ap_int<TTTrack_TrackWord::TrackBitWidths::kPhiSize + kGlobalPhiExtra> global_phi_t;
37  typedef ap_ufixed<kCosLUTSize, kCosLUTMagSize, AP_RND_CONV, AP_SAT> cos_lut_fixed_t;
38  typedef ap_ufixed<kAtanLUTSize, kAtanLUTMagSize, AP_RND_CONV, AP_SAT> atan_lut_fixed_t;
39  typedef ap_fixed<kMETSize + kEtExtra, kMETMagSize + kEtExtra, AP_RND_CONV, AP_SAT> Et_t;
40  typedef ap_fixed<kMETPhiSize + kEtExtra, 4, AP_RND_CONV, AP_SAT> metphi_fixed_t;
41  typedef ap_ufixed<kMETPhiSize + kEtExtra + 7, kMETPhiSize - 2, AP_RND_CONV, AP_SAT> pi_bins_fixed_t;
42 
43  // Output definition as per interface document, only used when creating output format
44  const double kMaxMET = 1 << kMETMagSize; // 2 TeV
45  const double kMaxMETPhi{2 * M_PI};
46 
47  const double kStepMETwordEt = kMaxMET / (1 << kMETSize);
48  const double kStepMETwordPhi = kMaxMETPhi / (1 << kMETPhiSize);
49  const double kBinsInPi = 1.0 / kStepMETwordPhi;
50 
51  // Enough symmetry in cos and sin between 0 and pi/2 to get all possible values
52  // of cos and sin phi
53  const double kMaxCosLUTPhi{M_PI / 2};
54 
55  const unsigned int kNSector{9};
56  const unsigned int kNQuadrants{4};
57 
58  // Simple struct used for ouput of cordic
59  struct EtMiss {
62  };
63 
64  std::vector<cos_lut_fixed_t> generateCosLUT(unsigned int size);
65 
67 
68  std::vector<global_phi_t> generatePhiSliceLUT(unsigned int N);
69 
70  template <typename T>
71  void printLUT(std::vector<T> lut, std::string module = "", std::string name = "") {
73  log << "The " << name << "[" << lut.size() << "] values are ... \n" << std::setprecision(30);
74  for (unsigned int i = 0; i < lut.size(); i++) {
75  log << "\t" << i << "\t" << lut[i] << "\n";
76  }
77  }
78 
79 } // namespace l1tmetemu
80 #endif
size
Write out results.
ap_int< kMETPhiSize > METWordphi_t
ap_fixed< kMETSize+kEtExtra, kMETMagSize+kEtExtra, AP_RND_CONV, AP_SAT > Et_t
const unsigned int kGlobalPhiExtra
ap_int< TTTrack_TrackWord::TrackBitWidths::kPhiSize+kGlobalPhiExtra > global_phi_t
void printLUT(std::vector< T > lut, std::string module="", std::string name="")
ap_ufixed< kAtanLUTSize, kAtanLUTMagSize, AP_RND_CONV, AP_SAT > atan_lut_fixed_t
ap_ufixed< kMETSize, kMETMagSize, AP_RND_CONV, AP_SAT > METWord_t
global_phi_t localToGlobalPhi(TTTrack_TrackWord::phi_t local_phi, global_phi_t sector_shift)
const double kStepMETwordEt
const unsigned int kNQuadrants
const unsigned int kNSector
const unsigned int kCosLUTMagSize
const unsigned int kAtanLUTSize
const unsigned int kAtanLUTMagSize
const double kMaxCosLUTPhi
const double kStepMETwordPhi
const unsigned int kEtExtra
const unsigned int kMETSize
ap_ufixed< kCosLUTSize, kCosLUTMagSize, AP_RND_CONV, AP_SAT > cos_lut_fixed_t
#define M_PI
const unsigned int kInternalPtWidth
#define N
Definition: blowfish.cc:9
const double kMaxMET
ap_fixed< kMETPhiSize+kEtExtra, 4, AP_RND_CONV, AP_SAT > metphi_fixed_t
const unsigned int kMETPhiSize
std::vector< global_phi_t > generatePhiSliceLUT(unsigned int N)
const unsigned int kPtMagSize
std::vector< cos_lut_fixed_t > generateCosLUT(unsigned int size)
const unsigned int kCosLUTSize
const double kMaxMETPhi
const unsigned int kMETMagSize
const double kBinsInPi
ap_uint< TrackBitWidths::kPhiSize > phi_t
ap_ufixed< kMETPhiSize+kEtExtra+7, kMETPhiSize - 2, AP_RND_CONV, AP_SAT > pi_bins_fixed_t