From ce61eef371ebc1ccad3419ae1521ce228bbde1c4 Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Fri, 28 Jan 2022 11:20:27 -0500 Subject: [PATCH 1/7] Fixing `zmatchcut_` for L1 and L2 --- L1Trigger/TrackFindingTracklet/interface/Settings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 7c6f48202a295..81d3df1704e94 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -686,8 +686,8 @@ namespace trklet { //z cuts for layers - the column is the seedindex std::array, N_LAYER> zmatchcut_{ - {{{0.0, 0.7, 5.5, 15.0, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 - {{0.0, 0.0, 3.5, 15.0, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 + {{{0.0, 0.7, 5.5, 15.0-0.06, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 + {{0.0, 0.0, 3.5, 15.0-0.06, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 {{0.7, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0}}, //Layer 3 {{3.0, 3.0, 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, //Layer 4 {{3.0, 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.5, 0.0, 0.0, 0.0}}, //Layer 5 From b9bd60a1c34d17a0f2d40a43ff7493cf029fb3df Mon Sep 17 00:00:00 2001 From: Anders Date: Sat, 29 Jan 2022 21:19:52 +0100 Subject: [PATCH 2/7] Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows --- L1Trigger/TrackFindingTracklet/interface/Settings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 81d3df1704e94..7c6f48202a295 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -686,8 +686,8 @@ namespace trklet { //z cuts for layers - the column is the seedindex std::array, N_LAYER> zmatchcut_{ - {{{0.0, 0.7, 5.5, 15.0-0.06, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 - {{0.0, 0.0, 3.5, 15.0-0.06, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 + {{{0.0, 0.7, 5.5, 15.0, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 + {{0.0, 0.0, 3.5, 15.0, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 {{0.7, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0}}, //Layer 3 {{3.0, 3.0, 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, //Layer 4 {{3.0, 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.5, 0.0, 0.0, 0.0}}, //Layer 5 From b55c58d79ff846492b4a874777e76d8c0f7f8740 Mon Sep 17 00:00:00 2001 From: Anders Date: Tue, 1 Feb 2022 18:24:45 +0100 Subject: [PATCH 3/7] Fixes to get agreement with HLS code --- .../interface/MatchEngineUnit.h | 9 ++++++++- .../TrackFindingTracklet/src/MatchEngineUnit.cc | 11 ++++++++--- .../TrackFindingTracklet/src/MatchProcessor.cc | 16 ++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index 8b352d38c9246..f562dc0f24bf1 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -36,7 +36,8 @@ namespace trklet { bool usesecondPlus, bool isPSseed, Tracklet* proj, - bool print); + bool print, + int imeu); bool empty() const { return candmatches_.empty(); } @@ -55,6 +56,8 @@ namespace trklet { //needed for consistency with HLS FW version ("_" vs "__" indicating different pipelining stages) bool have_() const { return havepair_; } + void setAlmostFull(); + void reset(); unsigned int rptr() const { return candmatches_.rptr(); } @@ -69,6 +72,7 @@ namespace trklet { unsigned int rzbin_; unsigned int phibin_; int shift_; + int imeu_; unsigned int istub_; unsigned int iuse_; @@ -85,6 +89,9 @@ namespace trklet { unsigned int layerdisk_; + //Save state at the start of istep + bool almostfullsave_; + //LUT for bend consistency with rinv const TrackletLUT& luttable_; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc index 028e9317ad0b2..83c2d6d3d5aa7 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc @@ -27,9 +27,11 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, bool usesecondPlus, bool isPSseed, Tracklet* proj, - bool print) { + bool print, + int imeu) { vmstubsmemory_ = vmstubsmemory; idle_ = false; + imeu_ = imeu; nrzbins_ = nrzbins; rzbin_ = rzbin; phibin_ = phibin; @@ -69,8 +71,11 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, goodpair_ = false; } +void MatchEngineUnit::setAlmostFull() { + almostfullsave_ = candmatches_.nearfull(); +} + void MatchEngineUnit::step(bool print) { - bool almostfull = candmatches_.nearfull(); if (goodpair_) { if (print) @@ -82,7 +87,7 @@ void MatchEngineUnit::step(bool print) { havepair_ = false; goodpair_ = false; - if (idle() || almostfull) + if (idle() || almostfullsave_) return; unsigned int slot = (phibin_ + use_[iuse_].second) * nrzbins_ + rzbin_ + use_[iuse_].first; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index db02830a02125..d5cfa5fe6a59d 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -135,8 +135,7 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { /* The code is organized in three 'steps' corresponding to the PR, ME, and MC functions. The output from - the PR step is buffered in a 'circular' buffer, and similarly the ME output is put in a circular buffer. - + the PR step is buffered in a 'circular' buffer, and similarly the ME output is put in a circular buffer. The implementation is done in steps, emulating what can be done in firmware. One each step we do: 1) A projection is read and if there is space it is insert into the inputProjBuffer_ @@ -192,7 +191,6 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { for (auto& matchengine : matchengines_) { cout <<" MEU"<ofstream("matchprocessor.txt") << getName() << " " << istep << " " << countall << " " << countsel << " " << countme << " " << countinputproj << endl; From adc785bed3dcab23ddaf2f8f1d846ba02e67287f Mon Sep 17 00:00:00 2001 From: Thomas Schuh Date: Thu, 27 Jan 2022 17:22:12 +0000 Subject: [PATCH 4/7] fixing integer range check in FPGAWord. --- L1Trigger/TrackFindingTracklet/src/FPGAWord.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc b/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc index 3531e4dce243b..0fbcbb9c546e3 100644 --- a/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc +++ b/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc @@ -38,7 +38,7 @@ void FPGAWord::set(int value, int nbits, bool positive, int line, const char* fi } assert(value < (1 << nbits)); } else { - if (value >= (1 << (nbits - 1))) { + if (value > (1 << (nbits - 1)) - 1) { edm::LogProblem("Tracklet") << "value too large:" << value << " " << (1 << (nbits - 1)) - 1 << " (" << file << ":" << line << ")"; } From c6a8c10c01460d5b285e205e5c74308f878f6ca0 Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Fri, 28 Jan 2022 11:20:27 -0500 Subject: [PATCH 5/7] Fixing `zmatchcut_` for L1 and L2 --- L1Trigger/TrackFindingTracklet/interface/Settings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 7c6f48202a295..81d3df1704e94 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -686,8 +686,8 @@ namespace trklet { //z cuts for layers - the column is the seedindex std::array, N_LAYER> zmatchcut_{ - {{{0.0, 0.7, 5.5, 15.0, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 - {{0.0, 0.0, 3.5, 15.0, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 + {{{0.0, 0.7, 5.5, 15.0-0.06, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 + {{0.0, 0.0, 3.5, 15.0-0.06, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 {{0.7, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0}}, //Layer 3 {{3.0, 3.0, 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, //Layer 4 {{3.0, 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.5, 0.0, 0.0, 0.0}}, //Layer 5 From 1f27fde80e03a34d16c0a484f7a174a034f69c82 Mon Sep 17 00:00:00 2001 From: Anders Date: Sat, 29 Jan 2022 21:19:52 +0100 Subject: [PATCH 6/7] Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows --- L1Trigger/TrackFindingTracklet/interface/Settings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 81d3df1704e94..7c6f48202a295 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -686,8 +686,8 @@ namespace trklet { //z cuts for layers - the column is the seedindex std::array, N_LAYER> zmatchcut_{ - {{{0.0, 0.7, 5.5, 15.0-0.06, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 - {{0.0, 0.0, 3.5, 15.0-0.06, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 + {{{0.0, 0.7, 5.5, 15.0, 1.5, 2.0, 0.0, 1.5, 1.0, 8.0, 1.0, 1.5}}, //Layer 1 + {{0.0, 0.0, 3.5, 15.0, 1.25, 0.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0}}, //Layer 2 {{0.7, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0}}, //Layer 3 {{3.0, 3.0, 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, //Layer 4 {{3.0, 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.5, 0.0, 0.0, 0.0}}, //Layer 5 From 7ed72b99d231c9a26cf66644a4ac8c37ca60d6da Mon Sep 17 00:00:00 2001 From: Anders Date: Sat, 29 Jan 2022 21:21:01 +0100 Subject: [PATCH 7/7] Slight rewerite to use <= instead < and not do subtracktion --- L1Trigger/TrackFindingTracklet/src/FPGAWord.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc b/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc index 0fbcbb9c546e3..3531e4dce243b 100644 --- a/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc +++ b/L1Trigger/TrackFindingTracklet/src/FPGAWord.cc @@ -38,7 +38,7 @@ void FPGAWord::set(int value, int nbits, bool positive, int line, const char* fi } assert(value < (1 << nbits)); } else { - if (value > (1 << (nbits - 1)) - 1) { + if (value >= (1 << (nbits - 1))) { edm::LogProblem("Tracklet") << "value too large:" << value << " " << (1 << (nbits - 1)) - 1 << " (" << file << ":" << line << ")"; }