Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:18

0001 #include "L1Trigger/L1TTrackMatch/interface/L1TkEtMissEmuAlgo.h"
0002 
0003 using namespace std;
0004 
0005 namespace l1tmetemu {
0006   std::vector<cos_lut_fixed_t> generateCosLUT() {  // Fill cosine LUT with integer values
0007     float phi = 0;
0008     std::vector<cos_lut_fixed_t> cosLUT;
0009     double stepPhi = TTTrack_TrackWord::stepPhi0 * (1 << l1tmetemu::kCosLUTShift);
0010     for (unsigned int LUT_idx = 0; LUT_idx < l1tmetemu::kCosLUTBins; LUT_idx++) {
0011       cosLUT.push_back((cos_lut_fixed_t)(cos(phi)));
0012       phi += stepPhi;
0013       //std::cout << LUT_idx << "," << (cos_lut_fixed_t)(cos(phi)) << std::endl;
0014     }
0015     return cosLUT;
0016   }
0017 
0018   global_phi_t localToGlobalPhi(TTTrack_TrackWord::phi_t local_phi, global_phi_t sector_shift) {
0019     global_phi_t PhiMin = 0;
0020     global_phi_t PhiMax = 2 * M_PI / TTTrack_TrackWord::stepPhi0;
0021 
0022     // The initial word comes in as a uint; the correct bits, but not automatically using 2s compliment format.
0023     global_phi_t globalPhi = local_phi;
0024 
0025     // Once the word is in a larger, signed container, shift it down so that the negative numbers are automatically represented in 2s compliment.
0026     if (local_phi >= (1 << (TTTrack_TrackWord::TrackBitWidths::kPhiSize - 1)))
0027       globalPhi -= (1 << TTTrack_TrackWord::TrackBitWidths::kPhiSize);
0028 
0029     globalPhi += sector_shift;
0030 
0031     if (globalPhi < PhiMin) {
0032       globalPhi = globalPhi + PhiMax;
0033     } else if (globalPhi > PhiMax) {
0034       globalPhi = globalPhi - PhiMax;
0035     }
0036 
0037     return globalPhi;
0038   }
0039 
0040   std::vector<global_phi_t> generatePhiSliceLUT(unsigned int N) {
0041     float sliceCentre = 0.0;
0042     std::vector<global_phi_t> phiLUT;
0043     for (unsigned int q = 0; q <= N; q++) {
0044       phiLUT.push_back((global_phi_t)(sliceCentre / TTTrack_TrackWord::stepPhi0));
0045       sliceCentre += 2 * M_PI / N;
0046     }
0047     return phiLUT;
0048   }
0049 
0050 }  // namespace l1tmetemu