File indexing completed on 2024-04-06 12:21:16
0001 #ifndef L1Trigger_L1TTrackMatch_L1TkEtMissEmuAlgo_HH
0002 #define L1Trigger_L1TTrackMatch_L1TkEtMissEmuAlgo_HH
0003
0004 #include <ap_int.h>
0005
0006 #include <cmath>
0007 #include <cstdint>
0008 #include <filesystem>
0009 #include <fstream>
0010 #include <iostream>
0011 #include <iomanip>
0012 #include <numeric>
0013
0014 #include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h"
0015 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017
0018
0019
0020 namespace l1tmetemu {
0021
0022 const unsigned int kInternalPtWidth{14};
0023 const unsigned int kPtMagSize{9};
0024 const unsigned int kMETSize{16};
0025 const unsigned int kMETMagSize{11};
0026 const unsigned int kMETPhiSize{13};
0027 const unsigned int kEtExtra{4};
0028 const unsigned int kGlobalPhiExtra{4};
0029 const unsigned int kCosLUTSize{10};
0030 const unsigned int kCosLUTMagSize{1};
0031 const unsigned int kCosLUTTableSize{10};
0032 const unsigned int kCosLUTBins{(1 << kCosLUTTableSize) + 1};
0033 const unsigned int kCosLUTShift{TTTrack_TrackWord::TrackBitWidths::kPhiSize - kCosLUTTableSize};
0034 const unsigned int kAtanLUTSize{64};
0035 const unsigned int kAtanLUTMagSize{2};
0036
0037 typedef ap_ufixed<kMETSize, kMETMagSize, AP_RND_CONV, AP_SAT> METWord_t;
0038 typedef ap_int<kMETPhiSize> METWordphi_t;
0039 typedef ap_int<TTTrack_TrackWord::TrackBitWidths::kPhiSize + kGlobalPhiExtra> global_phi_t;
0040 typedef ap_ufixed<kCosLUTSize, kCosLUTMagSize, AP_RND_CONV, AP_SAT> cos_lut_fixed_t;
0041 typedef ap_ufixed<kAtanLUTSize, kAtanLUTMagSize, AP_RND_CONV, AP_SAT> atan_lut_fixed_t;
0042 typedef ap_fixed<kMETSize + kEtExtra, kMETMagSize + kEtExtra, AP_RND_CONV, AP_SAT> Et_t;
0043 typedef ap_fixed<kMETPhiSize + kEtExtra, 4, AP_RND_CONV, AP_SAT> metphi_fixed_t;
0044 typedef ap_ufixed<kMETPhiSize + kEtExtra + 7, kMETPhiSize - 2, AP_RND_CONV, AP_SAT> pi_bins_fixed_t;
0045
0046
0047 const double kMaxMET = 1 << kMETMagSize;
0048 const double kMaxMETPhi{2 * M_PI};
0049
0050 const double kStepMETwordEt = kMaxMET / (1 << kMETSize);
0051 const double kStepMETwordPhi = kMaxMETPhi / (1 << kMETPhiSize);
0052 const double kBinsInPi = 1.0 / kStepMETwordPhi;
0053
0054
0055
0056 const double kMaxCosLUTPhi{M_PI / 2};
0057
0058 const unsigned int kNSector{9};
0059 const unsigned int kNQuadrants{4};
0060
0061
0062 struct EtMiss {
0063 METWord_t Et;
0064 METWordphi_t Phi;
0065 };
0066
0067 std::vector<cos_lut_fixed_t> generateCosLUT();
0068
0069 global_phi_t localToGlobalPhi(TTTrack_TrackWord::phi_t local_phi, global_phi_t sector_shift);
0070
0071 std::vector<global_phi_t> generatePhiSliceLUT(unsigned int N);
0072
0073 template <typename T>
0074 void printLUT(std::vector<T> lut, std::string module = "", std::string name = "") {
0075 edm::LogVerbatim log(module);
0076 log << "The " << name << "[" << lut.size() << "] values are ... \n" << std::setprecision(30);
0077 for (unsigned int i = 0; i < lut.size(); i++) {
0078 log << "\t" << i << "\t" << lut[i] << "\n";
0079 }
0080 }
0081
0082 }
0083 #endif