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

More fixes for displaced tracking in #304 #309

Merged
merged 8 commits into from
Feb 12, 2025
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,203 changes: 2,292 additions & 2,911 deletions L1Trigger/TrackFindingTracklet/data/memorymodules_hourglassExtendedAllCombined.dat

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3,490 changes: 1,787 additions & 1,703 deletions L1Trigger/TrackFindingTracklet/data/wires_hourglassExtendedAllCombined.dat

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ namespace trklet {
int ialphafactinner_[N_DSS_MOD * 2];
int ialphafactouter_[N_DSS_MOD * 2];

//Offset used to index full match memories
unsigned int fmMemOffset_;

//Memory for the full matches
std::vector<FullMatchMemory*> fullmatches_;

Expand Down
24 changes: 7 additions & 17 deletions L1Trigger/TrackFindingTracklet/interface/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ namespace trklet {

constexpr unsigned int N_SECTOR = 9; // # of phi sectors for L1TK processing

constexpr int N_LAYER = 6; // # of barrel layers assumed
constexpr int N_DISK = 5; // # of endcap disks assumed
constexpr unsigned int N_PSLAYER = 3; // # of barrel PS layers assumed
constexpr unsigned int N_SEED = 12; // # of tracklet+triplet seeds
constexpr unsigned int N_SEED_PROMPT = 8; // # of tracklet (prompt) seeds
constexpr unsigned int N_TB = 2; // # of track builders
constexpr int N_LAYER = 6; // # of barrel layers assumed
constexpr int N_DISK = 5; // # of endcap disks assumed
constexpr unsigned int N_PSLAYER = 3; // # of barrel PS layers assumed
constexpr unsigned int N_SEED_PROMPT = 8; // # of tracklet (prompt) seeds
constexpr unsigned int N_SEED_DISPLACED = 4; // # of triplet (displaced) seeds
constexpr unsigned int N_SEED = N_SEED_PROMPT + N_SEED_DISPLACED; // # of tracklet+triplet seeds
constexpr unsigned int N_TB = 2; // # of track builders

constexpr unsigned int N_DSS_MOD = 5; // # of rings with 2S modules per disk

Expand Down Expand Up @@ -199,11 +200,6 @@ namespace trklet {
std::string memPath() const { return memPath_; }
std::string tablePath() const { return tablePath_; }

bool writeVerilog() const { return writeVerilog_; }
bool writeHLS() const { return writeHLS_; }
bool writeInvTable() const { return writeInvTable_; }
bool writeHLSInvTable() const { return writeHLSInvTable_; }

unsigned int writememsect() const { return writememsect_; }

bool enableTripletTables() const { return enableTripletTables_; }
Expand Down Expand Up @@ -932,12 +928,6 @@ namespace trklet {
std::string memPath_{"../data/MemPrints/"}; //path for writing memories
std::string tablePath_{"../data/LUTs/"}; //path for writing LUTs

// Write various lookup tables and autogenerated code (from iMath)
bool writeVerilog_{false}; //Write out auto-generated Verilog mudules used by TCs
bool writeHLS_{false}; //Write out auto-generated HLS mudules used by TCs
bool writeInvTable_{false}; //Write out tables of drinv and invt in tracklet calculator for Verilog module
bool writeHLSInvTable_{false}; //Write out tables of drinv and invt in tracklet calculator for HLS module

unsigned int writememsect_{3}; //writemem only for this sector (note that the files will have _4 extension)

bool enableTripletTables_{false}; //Enable the application of the TED and
Expand Down
36 changes: 0 additions & 36 deletions L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,6 @@ namespace trklet {
double phider[N_DISK - 2],
double rder[N_DISK - 2]);

void exactproj(double rproj,
double rinv,
double phi0,
double t,
double z0,
double& phiproj,
double& zproj,
double& phider,
double& zder);

void exactprojdisk(double zproj,
double rinv,
double phi0,
double t,
double z0,
double& phiproj,
double& rproj,
double& phider,
double& rder);

void projlayer(int ir,
int irinv,
int iphi0,
int it,
int iz0,
int& iz,
int& iphi); // lower case to differentiate from ProjectionCalculator functions

void projdisk(int iz, int irinv, int iphi0, int it, int iz0, int& ir, int& iphi, int& iderphi, int& iderr);

void calcPars(unsigned int idr,
int iphi1,
int ir1,
Expand All @@ -125,12 +95,6 @@ namespace trklet {
int& iz0_new,
int& it_new);

void addDiskProj(Tracklet* tracklet, int disk);
bool addLayerProj(Tracklet* tracklet, int layer);

void addProjection(int layer, int iphi, TrackletProjectionsMemory* trackletprojs, Tracklet* tracklet);
void addProjectionDisk(int disk, int iphi, TrackletProjectionsMemory* trackletprojs, Tracklet* tracklet);

bool goodTrackPars(bool goodrinv, bool goodz0);

bool inSector(int iphi0, int irinv, double phi0approx, double rinvapprox);
Expand Down
42 changes: 32 additions & 10 deletions L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g
rSSinner_(settings),
rSSouter_(settings),
diskRadius_(settings),
fullmatches_(2),
fmMemOffset_(2),
fullmatches_(fmMemOffset_ + N_SEED_DISPLACED),
rinvbendlut_(settings),
luttable_(settings),
inputProjBuffer_(3) {
Expand Down Expand Up @@ -123,18 +124,33 @@ void MatchProcessor::addOutput(MemoryBase* memory, string output) {
edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
<< output;
}
FullMatchMemory* tmp = nullptr;
unsigned int iSeed = N_SEED;
if (output.find("matchout0") != std::string::npos) {
auto* tmp = dynamic_cast<FullMatchMemory*>(memory);
tmp = dynamic_cast<FullMatchMemory*>(memory);
assert(tmp != nullptr);
fullmatches_[0] = tmp;
return;
iSeed = getISeed(tmp->getName());
if (iSeed < N_SEED_PROMPT) {
fullmatches_[0] = tmp;
return;
}
}
if (output.find("matchout1") != std::string::npos) {
auto* tmp = dynamic_cast<FullMatchMemory*>(memory);
tmp = dynamic_cast<FullMatchMemory*>(memory);
assert(tmp != nullptr);
fullmatches_[1] = tmp;
iSeed = getISeed(tmp->getName());
if (iSeed < N_SEED_PROMPT) {
fullmatches_[1] = tmp;
return;
}
}
// Memories for triplet seeds are handled separately for now and placed at
// the end of the fullmatches_ vector
if (tmp != nullptr) {
fullmatches_[fmMemOffset_ + iSeed - N_SEED_PROMPT] = tmp;
return;
}

throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output: " << output;
}

Expand Down Expand Up @@ -749,11 +765,14 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b
edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet;
}

int iSeed = tracklet->getISeed();
unsigned int iSeed = tracklet->getISeed();
int iTB = 0;
if (iSeed == 2 || iSeed == 4 || iSeed == 5 || iSeed == 6) {
if (iSeed == Seed::L3L4 || iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1) {
iTB = 1;
}
if (iSeed >= N_SEED_PROMPT) {
iTB = fmMemOffset_ + iSeed - N_SEED_PROMPT;
}
assert(fullmatches_[iTB] != nullptr);
fullmatches_[iTB]->addMatch(tracklet, fpgastub);

Expand Down Expand Up @@ -941,11 +960,14 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b
edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet;
}

int iSeed = tracklet->getISeed();
unsigned int iSeed = tracklet->getISeed();
int iTB = 0;
if (iSeed == 2 || iSeed == 4 || iSeed == 5 || iSeed == 6) {
if (iSeed == Seed::L3L4 || iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1) {
iTB = 1;
}
if (iSeed >= N_SEED_PROMPT) {
iTB = fmMemOffset_ + iSeed - N_SEED_PROMPT;
}
assert(fullmatches_[iTB] != nullptr);
fullmatches_[iTB]->addMatch(tracklet, fpgastub);

Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/TrackFindingTracklet/src/ProcessBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ unsigned int ProcessBase::getISeed(const std::string& name) {
pos = name1.find('_');
std::string name2 = name1.substr(0, pos);

unordered_map<string, unsigned int> seedmap = {{"AAAA", 0}, {"BBBB", 1}};
unordered_map<string, unsigned int> seedmap = {
{"AAAA", 0}, {"BBBB", 1}, {"L3L4L2", 8}, {"L5L6L4", 9}, {"L2L3D1", 10}, {"D1D2L2", 11}};
auto found = seedmap.find(name2);
if (found != seedmap.end())
return found->second;
Expand Down
18 changes: 18 additions & 0 deletions L1Trigger/TrackFindingTracklet/src/ProjectionCalculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,15 @@ void ProjectionCalculator::execute() {
int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5);
int iphi = iphivmRaw / (32 / settings_.nallstubs(layerdisk));

if (outputproj_[layerdisk][iphi].empty()) {
if (settings_.warnNoMem()) {
edm::LogVerbatim("Tracklet") << "No projection memory exists in " << getName()
<< " for layer = " << layerdisk + 1 << " iphi = " << iphi + 1;
}
return;
}
assert(!outputproj_[layerdisk][iphi].empty());

for (unsigned int i = 0; i < outputproj_[layerdisk][iphi].size(); i++) {
outputproj_[layerdisk][iphi][i]->addProj(
tracklet, projPage); // FIXME write to correct page - though doesn't affect emulation
Expand All @@ -370,6 +379,15 @@ void ProjectionCalculator::execute() {
int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5);
int iphi = iphivmRaw / (32 / settings_.nallstubs(layerdisk)); //>> settings_.nbitsallstubs(layerdisk);

if (outputproj_[layerdisk][iphi].empty()) {
if (settings_.warnNoMem()) {
edm::LogVerbatim("Tracklet") << "No projection memory exists in " << getName()
<< " for disk = " << layerdisk - N_LAYER + 1 << " iphi = " << iphi + 1;
}
return;
}
assert(!outputproj_[layerdisk][iphi].empty());

for (unsigned int i = 0; i < outputproj_[layerdisk][iphi].size(); i++) {
outputproj_[layerdisk][iphi][i]->addProj(tracklet, projPage); // FIXME write to correct page
}
Expand Down
Loading