Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase 2 GTT MET cos LUT update (backport) #1154

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion L1Trigger/L1TTrackMatch/interface/L1TkEtMissEmuAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -61,7 +64,7 @@ namespace l1tmetemu {
METWordphi_t Phi;
};

std::vector<cos_lut_fixed_t> generateCosLUT(unsigned int size);
std::vector<cos_lut_fixed_t> generateCosLUT();

global_phi_t localToGlobalPhi(TTTrack_TrackWord::phi_t local_phi, global_phi_t sector_shift);

Expand Down
46 changes: 24 additions & 22 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackerEtMissEmulatorProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,15 @@ L1TrackerEtMissEmulatorProducer::L1TrackerEtMissEmulatorProducer(const edm::Para
// Get Emulator config parameters
cordicSteps_ = (int)iConfig.getParameter<int>("nCordicSteps");
debug_ = (int)iConfig.getParameter<int>("debug");

// Name of output ED Product
L1MetCollectionName_ = (std::string)iConfig.getParameter<std::string>("L1MetCollectionName");

if (debug_ == 5) {
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) {
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions L1Trigger/L1TTrackMatch/src/L1TkEtMissEmuAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
using namespace std;

namespace l1tmetemu {
std::vector<cos_lut_fixed_t> generateCosLUT(unsigned int size) { // Fill cosine LUT with integer values
std::vector<cos_lut_fixed_t> generateCosLUT() { // Fill cosine LUT with integer values
float phi = 0;
std::vector<cos_lut_fixed_t> 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;
}

Expand Down