diff --git a/L1Trigger/L1TTrackMatch/interface/L1TkEtMissEmuAlgo.h b/L1Trigger/L1TTrackMatch/interface/L1TkEtMissEmuAlgo.h index e427d7942a6fc..9243516fcd04f 100644 --- a/L1Trigger/L1TTrackMatch/interface/L1TkEtMissEmuAlgo.h +++ b/L1Trigger/L1TTrackMatch/interface/L1TkEtMissEmuAlgo.h @@ -28,6 +28,9 @@ namespace l1tmetemu { const unsigned int kGlobalPhiExtra{4}; const unsigned int kCosLUTSize{10}; const unsigned int kCosLUTMagSize{1}; + const unsigned int kCosLUTTableSize{10}; + const unsigned int kCosLUTBins{1 << kCosLUTTableSize}; + const unsigned int kCosLUTShift{TTTrack_TrackWord::TrackBitWidths::kPhiSize - kCosLUTTableSize}; const unsigned int kAtanLUTSize{64}; const unsigned int kAtanLUTMagSize{2}; @@ -61,7 +64,7 @@ namespace l1tmetemu { METWordphi_t Phi; }; - std::vector generateCosLUT(unsigned int size); + std::vector generateCosLUT(); global_phi_t localToGlobalPhi(TTTrack_TrackWord::phi_t local_phi, global_phi_t sector_shift); diff --git a/L1Trigger/L1TTrackMatch/plugins/L1TrackerEtMissEmulatorProducer.cc b/L1Trigger/L1TTrackMatch/plugins/L1TrackerEtMissEmulatorProducer.cc index f9652eeefd365..aa20f48176d57 100644 --- a/L1Trigger/L1TTrackMatch/plugins/L1TrackerEtMissEmulatorProducer.cc +++ b/L1Trigger/L1TTrackMatch/plugins/L1TrackerEtMissEmulatorProducer.cc @@ -82,7 +82,6 @@ L1TrackerEtMissEmulatorProducer::L1TrackerEtMissEmulatorProducer(const edm::Para // Get Emulator config parameters cordicSteps_ = (int)iConfig.getParameter("nCordicSteps"); debug_ = (int)iConfig.getParameter("debug"); - // Name of output ED Product L1MetCollectionName_ = (std::string)iConfig.getParameter("L1MetCollectionName"); @@ -90,12 +89,8 @@ L1TrackerEtMissEmulatorProducer::L1TrackerEtMissEmulatorProducer(const edm::Para cordicDebug_ = true; } - // To have same bin spacing between 0 and pi/2 as between original phi - // granularity - int cosLUTbins = std::floor(l1tmetemu::kMaxCosLUTPhi / TTTrack_TrackWord::stepPhi0); - // Compute LUTs - cosLUT_ = l1tmetemu::generateCosLUT(cosLUTbins); + cosLUT_ = l1tmetemu::generateCosLUT(); // Print LUTs if (debug_ == 1) { @@ -185,45 +180,52 @@ void L1TrackerEtMissEmulatorProducer::produce(edm::Event& iEvent, const edm::Eve // through cosLUT_ gives sin Sum sector Et -ve when cos or sin phi are -ve sector_totals[track->phiSector()] += 1; if (globalPhi >= phiQuadrants_[0] && globalPhi < phiQuadrants_[1]) { - temppx = ((l1tmetemu::Et_t)ptEmulation * cosLUT_[globalPhi]); - temppy = ((l1tmetemu::Et_t)ptEmulation * cosLUT_[phiQuadrants_[1] - 1 - globalPhi]); + temppx = ((l1tmetemu::Et_t)ptEmulation * cosLUT_[(globalPhi) >> l1tmetemu::kCosLUTShift]); + temppy = + ((l1tmetemu::Et_t)ptEmulation * cosLUT_[(phiQuadrants_[1] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift]); if (debug_ == 2) { edm::LogVerbatim("L1TrackerEtMissEmulatorProducer") << "Sector: " << track->phiSector() << " Quadrant: " << 1 << "\n" - << "Emu Phi: " << globalPhi << " Emu Cos(Phi): " << cosLUT_[globalPhi] - << " Emu Sin(Phi): " << cosLUT_[phiQuadrants_[1] - 1 - globalPhi] << "\n"; + << "Emu Phi: " << globalPhi << " Emu Cos(Phi): " << cosLUT_[(globalPhi) >> l1tmetemu::kCosLUTShift] + << " Emu Sin(Phi): " << cosLUT_[(phiQuadrants_[1] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift] << "\n"; } } else if (globalPhi >= phiQuadrants_[1] && globalPhi < phiQuadrants_[2]) { - temppx = -((l1tmetemu::Et_t)ptEmulation * cosLUT_[phiQuadrants_[2] - 1 - globalPhi]); - temppy = ((l1tmetemu::Et_t)ptEmulation * cosLUT_[globalPhi - phiQuadrants_[1]]); + temppx = + -((l1tmetemu::Et_t)ptEmulation * cosLUT_[(phiQuadrants_[2] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift]); + temppy = ((l1tmetemu::Et_t)ptEmulation * cosLUT_[(globalPhi - phiQuadrants_[1]) >> l1tmetemu::kCosLUTShift]); if (debug_ == 2) { edm::LogVerbatim("L1TrackerEtMissEmulatorProducer") << "Sector: " << track->phiSector() << " Quadrant: " << 2 << "\n" - << "Emu Phi: " << globalPhi << " Emu Cos(Phi): -" << cosLUT_[phiQuadrants_[2] - 1 - globalPhi] - << " Emu Sin(Phi): " << cosLUT_[globalPhi - phiQuadrants_[1]] << "\n"; + << "Emu Phi: " << globalPhi << " Emu Cos(Phi): -" + << cosLUT_[(phiQuadrants_[2] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift] + << " Emu Sin(Phi): " << cosLUT_[(globalPhi - phiQuadrants_[1]) >> l1tmetemu::kCosLUTShift] << "\n"; } } else if (globalPhi >= phiQuadrants_[2] && globalPhi < phiQuadrants_[3]) { - temppx = -((l1tmetemu::Et_t)ptEmulation * cosLUT_[globalPhi - phiQuadrants_[2]]); - temppy = -((l1tmetemu::Et_t)ptEmulation * cosLUT_[phiQuadrants_[3] - 1 - globalPhi]); + temppx = -((l1tmetemu::Et_t)ptEmulation * cosLUT_[(globalPhi - phiQuadrants_[2]) >> l1tmetemu::kCosLUTShift]); + temppy = + -((l1tmetemu::Et_t)ptEmulation * cosLUT_[(phiQuadrants_[3] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift]); if (debug_ == 2) { edm::LogVerbatim("L1TrackerEtMissEmulatorProducer") << "Sector: " << track->phiSector() << " Quadrant: " << 3 << "\n" - << "Emu Phi: " << globalPhi << " Emu Cos(Phi): -" << cosLUT_[globalPhi - phiQuadrants_[2]] - << " Emu Sin(Phi): -" << cosLUT_[phiQuadrants_[3] - 1 - globalPhi] << "\n"; + << "Emu Phi: " << globalPhi << " Emu Cos(Phi): -" + << cosLUT_[(globalPhi - phiQuadrants_[2]) >> l1tmetemu::kCosLUTShift] << " Emu Sin(Phi): -" + << cosLUT_[(phiQuadrants_[3] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift] << "\n"; } } else if (globalPhi >= phiQuadrants_[3] && globalPhi < phiQuadrants_[4]) { - temppx = ((l1tmetemu::Et_t)ptEmulation * cosLUT_[phiQuadrants_[4] - 1 - globalPhi]); - temppy = -((l1tmetemu::Et_t)ptEmulation * cosLUT_[globalPhi - phiQuadrants_[3]]); + temppx = + ((l1tmetemu::Et_t)ptEmulation * cosLUT_[(phiQuadrants_[4] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift]); + temppy = -((l1tmetemu::Et_t)ptEmulation * cosLUT_[(globalPhi - phiQuadrants_[3]) >> l1tmetemu::kCosLUTShift]); if (debug_ == 2) { edm::LogVerbatim("L1TrackerEtMissEmulatorProducer") << "Sector: " << track->phiSector() << " Quadrant: " << 4 << "\n" - << " Emu Phi: " << globalPhi << " Emu Cos(Phi): " << cosLUT_[phiQuadrants_[4] - 1 - globalPhi] - << " Emu Sin(Phi): -" << cosLUT_[globalPhi - phiQuadrants_[3]] << "\n"; + << " Emu Phi: " << globalPhi + << " Emu Cos(Phi): " << cosLUT_[(phiQuadrants_[4] - 1 - globalPhi) >> l1tmetemu::kCosLUTShift] + << " Emu Sin(Phi): -" << cosLUT_[(globalPhi - phiQuadrants_[3]) >> l1tmetemu::kCosLUTShift] << "\n"; } } else { temppx = 0; diff --git a/L1Trigger/L1TTrackMatch/src/L1TkEtMissEmuAlgo.cc b/L1Trigger/L1TTrackMatch/src/L1TkEtMissEmuAlgo.cc index 6f82bfd0bef2e..e1ef12f242b08 100644 --- a/L1Trigger/L1TTrackMatch/src/L1TkEtMissEmuAlgo.cc +++ b/L1Trigger/L1TTrackMatch/src/L1TkEtMissEmuAlgo.cc @@ -3,15 +3,16 @@ using namespace std; namespace l1tmetemu { - std::vector generateCosLUT(unsigned int size) { // Fill cosine LUT with integer values + std::vector generateCosLUT() { // Fill cosine LUT with integer values float phi = 0; std::vector cosLUT; - for (unsigned int LUT_idx = 0; LUT_idx < size; LUT_idx++) { + double stepPhi = TTTrack_TrackWord::stepPhi0 * (1 << l1tmetemu::kCosLUTShift); + for (unsigned int LUT_idx = 0; LUT_idx < l1tmetemu::kCosLUTBins; LUT_idx++) { cosLUT.push_back((cos_lut_fixed_t)(cos(phi))); - phi += TTTrack_TrackWord::stepPhi0; + phi += stepPhi; //std::cout << LUT_idx << "," << (cos_lut_fixed_t)(cos(phi)) << std::endl; } - cosLUT.push_back((cos_lut_fixed_t)(0)); //Prevent overflow in last bin + cosLUT[1023] = (cos_lut_fixed_t)(0); //Match F/W for Integration Tests return cosLUT; }