From a921921361dbafd83698d719ac36f63de45df792 Mon Sep 17 00:00:00 2001 From: aryd Date: Tue, 23 Nov 2021 10:53:39 -0500 Subject: [PATCH] Memory cleanup (#98) * Cleanup of writing leading 0x in memories * Cleanup of obsolote comment * Change order of input links to match VMRouter expectation * Add support for debugging * Remove one pipelining step to match HLS * Determine the PS vs 2S in disks same way as we do in HLS * Some cleanup * Correction to LUT code * Comment out printout * Ran scram build code-format * Update comment about IR steps * Cleanup of obsolote comment * Remove one pipelining step to match HLS * Determine the PS vs 2S in disks same way as we do in HLS * Correction to LUT code * Ran scram build code-format --- .../interface/MatchEngineUnit.h | 9 +- .../interface/MemoryBase.h | 5 +- .../TrackFindingTracklet/interface/Settings.h | 7 +- .../TrackFindingTracklet/interface/Util.h | 4 +- .../interface/VMRouterCM.h | 2 +- .../src/AllInnerStubsMemory.cc | 5 +- .../src/AllProjectionsMemory.cc | 5 +- .../src/AllStubsMemory.cc | 5 +- .../src/CandidateMatchMemory.cc | 5 +- .../src/CleanTrackMemory.cc | 5 +- .../TrackFindingTracklet/src/DTCLinkMemory.cc | 4 +- .../src/FullMatchMemory.cc | 5 +- .../src/InputLinkMemory.cc | 5 +- .../TrackFindingTracklet/src/MatchEngine.cc | 16 +- .../src/MatchEngineUnit.cc | 37 ++-- .../src/MatchProcessor.cc | 11 +- .../TrackFindingTracklet/src/MemoryBase.cc | 7 + L1Trigger/TrackFindingTracklet/src/Sector.cc | 2 +- .../src/StubPairsMemory.cc | 6 +- .../src/StubTripletsMemory.cc | 4 +- .../src/TrackFitMemory.cc | 5 +- .../src/TrackletConfigBuilder.cc | 206 +++++++++--------- .../TrackFindingTracklet/src/TrackletLUT.cc | 4 +- .../src/TrackletParametersMemory.cc | 5 +- .../src/TrackletProjectionsMemory.cc | 5 +- .../src/VMProjectionsMemory.cc | 5 +- .../TrackFindingTracklet/src/VMRouterCM.cc | 5 +- .../src/VMStubsMEMemory.cc | 2 +- .../src/VMStubsTEMemory.cc | 7 +- 29 files changed, 183 insertions(+), 210 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index f4d448f4d9026..8b352d38c9246 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -50,11 +50,10 @@ namespace trklet { bool idle() const { return idle_; } - bool active() const { return !idle_ || goodpair_ || goodpair__ || !empty(); } + bool active() const { return !idle_ || goodpair_ || !empty(); } //needed for consistency with HLS FW version ("_" vs "__" indicating different pipelining stages) bool have_() const { return havepair_; } - bool have__() const { return havepair__; } void reset(); @@ -90,9 +89,9 @@ namespace trklet { const TrackletLUT& luttable_; //Pipeline variables - std::pair tmppair_, tmppair__; - bool goodpair_, goodpair__; - bool havepair_, havepair__; + std::pair tmppair_; + bool goodpair_; + bool havepair_; //save the candidate matches CircularBuffer> candmatches_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h b/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h index ca0280bff8911..9c806137f85ef 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h +++ b/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h @@ -32,13 +32,16 @@ namespace trklet { // extended is the seeding for displaced tracks void initSpecialSeeding(unsigned int pos, bool& overlap, bool& extra, bool& extended); - //Used for a hack below due to MAC OS case sensitiviy problem for files + //Used for a hack below due to MAC OS case insensitiviy problem for files void findAndReplaceAll(std::string& data, std::string toSearch, std::string replaceStr); void openFile(bool first, std::string dirName, std::string filebase); static size_t find_nth(const std::string& haystack, size_t pos, const std::string& needle, size_t nth); + //Format index position in hex + static std::string hexstr(unsigned int index); + protected: std::string name_; unsigned int iSector_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index ea5bc0b131d51..ad1f861e7f5fe 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -412,7 +412,7 @@ namespace trklet { double bendcut(int ibend, int layerdisk, bool isPSmodule) const { if (layerdisk >= N_LAYER && (!isPSmodule)) - layerdisk += (N_LAYER - 1); + layerdisk += N_DISK; double bendcut = bendcut_[layerdisk][ibend]; if (bendcut <= 0.0) std::cout << "bendcut : " << layerdisk << " " << ibend << " " << isPSmodule << std::endl; @@ -429,7 +429,7 @@ namespace trklet { double bendcutte(int ibend, int layerdisk, bool isPSmodule) const { return bendcut(ibend, layerdisk, isPSmodule); } double bendcutme(int ibend, int layerdisk, bool isPSmodule) const { - //FIXME temporary fix until phiprojderdisk bits adjusted. But requires coordinatin with HLS + //Should understand why larger cut needed in disks double fact = (layerdisk < N_LAYER) ? 1.0 : 1.8; return fact * bendcut(ibend, layerdisk, isPSmodule); } @@ -754,9 +754,12 @@ namespace trklet { unsigned int maxstepoffset_{0}; //Number of processing steps for one event (108=18TM*240MHz/40MHz) + //IR should be set to 108 to match the FW for the summer chain, but ultimately should be at 156 std::unordered_map maxstep_{{"IR", 156}, //IR will run at a higher clock speed to handle //input links running at 25 Gbits/s + //Set to 108 to match firmware project 240 MHz clock + {"VMR", 108}, {"TE", 107}, {"TC", 108}, diff --git a/L1Trigger/TrackFindingTracklet/interface/Util.h b/L1Trigger/TrackFindingTracklet/interface/Util.h index 37fe0ba503141..deaf18936d052 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Util.h +++ b/L1Trigger/TrackFindingTracklet/interface/Util.h @@ -47,9 +47,7 @@ namespace trklet { } inline double rinv(double phi1, double phi2, double r1, double r2) { - if (r2 <= r1) { //FIXME can not form tracklet should not call function with r2<=r1 - return 20.0; - } + assert(r1 < r2); //Can not form tracklet should not call function with r2<=r1 double dphi = phi2 - phi1; double dr = r2 - r1; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h b/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h index 2f6a468576361..d6250cc138246 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h @@ -38,7 +38,7 @@ namespace trklet { void addOutput(MemoryBase* memory, std::string output) override; void addInput(MemoryBase* memory, std::string input) override; - void execute(); + void execute(unsigned int iSector); private: //0-5 are the layers and 6-10 are the disks diff --git a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc index 5ee9e5b1cda63..32295dab1fb5e 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc @@ -15,10 +15,7 @@ void AllInnerStubsMemory::writeStubs(bool first, unsigned int iSector) { for (unsigned int j = 0; j < stubs_.size(); j++) { string stub = stubs_[j]->strinner(); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << stub << " " << hexFormat(stub) << endl; + out_ << hexstr(j) << " " << stub << " " << hexFormat(stub) << endl; } out_.close(); } diff --git a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc index d15cb03d753de..409bd8eb7e663 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc @@ -29,10 +29,7 @@ void AllProjectionsMemory::writeAP(bool first, unsigned int iSector) { for (unsigned int j = 0; j < tracklets_.size(); j++) { string proj = (layer_ > 0) ? tracklets_[j]->trackletprojstrlayer(layer_) : tracklets_[j]->trackletprojstrdisk(disk_); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << proj << " " << trklet::hexFormat(proj) << endl; + out_ << hexstr(j) << " " << proj << " " << trklet::hexFormat(proj) << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc index db3993fdd74c5..5861e260feb7a 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc @@ -15,10 +15,7 @@ void AllStubsMemory::writeStubs(bool first, unsigned int iSector) { for (unsigned int j = 0; j < stubs_.size(); j++) { string stub = stubs_[j]->str(); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << stub << " " << hexFormat(stub) << endl; + out_ << hexstr(j) << " " << stub << " " << hexFormat(stub) << endl; } out_.close(); } diff --git a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc index 06092b28350ed..adef2141b7223 100644 --- a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc @@ -48,10 +48,7 @@ void CandidateMatchMemory::writeCM(bool first, unsigned int iSector) { projindex = (1 << 7) - 1; } tmp.set(projindex, 7, true, __LINE__, __FILE__); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << tmp.str() << "|" << stubid << " " << trklet::hexFormat(tmp.str() + stubid) << endl; + out_ << hexstr(j) << " " << tmp.str() << "|" << stubid << " " << trklet::hexFormat(tmp.str() + stubid) << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc index b5adf1859e29c..38fe074aa1622 100644 --- a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc @@ -26,10 +26,7 @@ void CleanTrackMemory::writeCT(bool first, unsigned int iSector) { out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; for (unsigned int j = 0; j < tracks_.size(); j++) { - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec << " "; - out_ << tracks_[j]->trackfitstr() << " " << trklet::hexFormat(tracks_[j]->trackfitstr()); + out_ << hexstr(j) << " " << tracks_[j]->trackfitstr() << " " << trklet::hexFormat(tracks_[j]->trackfitstr()); out_ << "\n"; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc index d80531fa86687..09760a9c44a3a 100644 --- a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc @@ -55,9 +55,7 @@ void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { FPGAWord ldcode(lcode, 2, true); string stub = stubs_[j]->str() + "|" + ldcode.str() + "|1"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << stub << " " << trklet::hexFormat(stub) << endl; + out_ << hexstr(j) << " " << stub << " " << trklet::hexFormat(stub) << endl; } out_.close(); } diff --git a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc index f4bf27d54e5e1..3fba862fcf8e8 100644 --- a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc @@ -52,10 +52,7 @@ void FullMatchMemory::writeMC(bool first, unsigned int iSector) { for (unsigned int j = 0; j < matches_.size(); j++) { string match = (layer_ > 0) ? matches_[j].first->fullmatchstr(layer_) : matches_[j].first->fullmatchdiskstr(disk_); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << match << " " << trklet::hexFormat(match) << endl; + out_ << hexstr(j) << " " << match << " " << trklet::hexFormat(match) << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc index bb34f5c94eaa0..9138831bd147f 100644 --- a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc @@ -23,10 +23,7 @@ void InputLinkMemory::writeStubs(bool first, unsigned int iSector) { for (unsigned int j = 0; j < stubs_.size(); j++) { string stub = stubs_[j]->str(); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << stub << " " << trklet::hexFormat(stub) << endl; + out_ << hexstr(j) << " " << stub << " " << trklet::hexFormat(stub) << endl; } out_.close(); } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index 6d2855a8c0197..a6fff9eb7dc3a 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -222,10 +222,22 @@ void MatchEngine::execute(unsigned int iSector) { //Read vmstub memory and extract data fields const VMStubME& vmstub = vmstubs_->getVMStubMEBin(rzbin, istubtmp); - bool isPSmodule = vmstub.isPSmodule(); - int stubfinerz = vmstub.finerz().value(); + bool isPSmodule = false; + + if (barrel_) { + isPSmodule = layerdisk_ < N_PSLAYER; + } else { + if (layerdisk_ < N_LAYER + 2) { + isPSmodule = ((rzbin & 7) < 3) || ((rzbin & 7) == 3 && stubfinerz <= 3); + } else { + isPSmodule = ((rzbin & 7) < 3) || ((rzbin & 7) == 3 && stubfinerz <= 2); + } + } + + assert(isPSmodule == vmstub.isPSmodule()); + int nbits = isPSmodule ? N_BENDBITS_PS : N_BENDBITS_2S; int deltaphi = projfinephi - vmstub.finephi().value(); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc index 43b3ee79cbe46..028e9317ad0b2 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc @@ -10,9 +10,7 @@ MatchEngineUnit::MatchEngineUnit(bool barrel, unsigned int layerdisk, const Trac barrel_ = barrel; layerdisk_ = layerdisk; goodpair_ = false; - goodpair__ = false; havepair_ = false; - havepair__ = false; } void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, @@ -29,7 +27,7 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, bool usesecondPlus, bool isPSseed, Tracklet* proj, - bool) { + bool print) { vmstubsmemory_ = vmstubsmemory; idle_ = false; nrzbins_ = nrzbins; @@ -61,30 +59,26 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, //Even when you init a new projection you need to process the pipeline //This should be fixed to be done more cleanly - but require synchronizaton //with the HLS code - if (goodpair__) { - candmatches_.store(tmppair__); + if (goodpair_) { + if (print) + std::cout << "Init have pair" << std::endl; + candmatches_.store(tmppair_); } - havepair__ = havepair_; - goodpair__ = goodpair_; - tmppair__ = tmppair_; - havepair_ = false; goodpair_ = false; } -void MatchEngineUnit::step(bool) { +void MatchEngineUnit::step(bool print) { bool almostfull = candmatches_.nearfull(); - if (goodpair__) { - assert(havepair__); - candmatches_.store(tmppair__); + if (goodpair_) { + if (print) + std::cout << "Step have pair" << std::endl; + assert(havepair_); + candmatches_.store(tmppair_); } - havepair__ = havepair_; - goodpair__ = goodpair_; - tmppair__ = tmppair_; - havepair_ = false; goodpair_ = false; @@ -141,7 +135,6 @@ void MatchEngineUnit::step(bool) { } // Detailed printout for comparison with HLS code - bool print = false; if (print) edm::LogVerbatim("Tracklet") << "MEU TrkId stubindex : " << 128 * proj_->TCIndex() + proj_->trackletIndex() << " " << vmstub.stubindex().value() << " " @@ -175,9 +168,7 @@ void MatchEngineUnit::reset() { idle_ = true; istub_ = 0; goodpair_ = false; - goodpair__ = false; havepair_ = false; - havepair__ = false; } int MatchEngineUnit::TCID() const { @@ -185,12 +176,10 @@ int MatchEngineUnit::TCID() const { return peek().first->TCID(); } - if (idle_ && !havepair_ && !havepair__) { + if (idle_ && !havepair_) { return 16383; } - if (havepair__) { - return tmppair__.first->TCID(); - } + if (havepair_) { return tmppair_.first->TCID(); } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 6c0526337f9b4..b4d53b560d0db 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -276,10 +276,10 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { tmpProj.use(1, 1), tmpProj.isPSseed(), tmpProj.proj(), - print && (iME == 0)); + print); addedProjection = true; } else { - matchengines_[iME].step(print && iME == 0); + matchengines_[iME].step(print); } } @@ -343,8 +343,9 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { (proj->proj(layerdisk_).fpgarzproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (proj->proj(layerdisk_).fpgaphiprojder().value() >> - (proj->proj(layerdisk_).fpgaphiprojder().nbits() - nphiderbits_)) & + int phiprojder = proj->proj(layerdisk_).fpgaphiprojder().value(); + + int phiderindex = (phiprojder >> (proj->proj(layerdisk_).fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); int signindex = proj->proj(layerdisk_).fpgarzprojder().value() < 0; @@ -429,7 +430,7 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { } } -bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, bool, unsigned int) { +bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, bool print, unsigned int istep) { const L1TStub* stub = fpgastub->l1tstub(); if (layerdisk_ < N_LAYER) { diff --git a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc index 580dae3a8df7f..f0461f2c20ddd 100644 --- a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc @@ -6,6 +6,7 @@ #include #include +#include using namespace trklet; using namespace std; @@ -106,3 +107,9 @@ size_t MemoryBase::find_nth(const string& haystack, size_t pos, const string& ne return found_pos; return find_nth(haystack, found_pos + 1, needle, nth - 1); } + +std::string MemoryBase::hexstr(unsigned int index) { + std::ostringstream oss; + oss << "0x" << std::setfill('0') << std::setw(2) << hex << index << dec; + return oss.str(); +} diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 8c169f58b125e..0cce2f1508dc9 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -339,7 +339,7 @@ void Sector::executeVMR() { i->execute(); } for (auto& i : VMRCM_) { - i->execute(); + i->execute(isector_); } } diff --git a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc index 40d81f17e3147..ea29fe811d0fd 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc @@ -23,10 +23,8 @@ void StubPairsMemory::writeSP(bool first, unsigned int iSector) { for (unsigned int j = 0; j < stubs_.size(); j++) { string stub1index = stubs_[j].first.stub()->stubindex().str(); string stub2index = stubs_[j].second.stub()->stubindex().str(); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << stub1index << "|" << stub2index << " " << trklet::hexFormat(stub1index + stub2index) << endl; + out_ << hexstr(j) << " " << stub1index << "|" << stub2index << " " << trklet::hexFormat(stub1index + stub2index) + << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc index 73a63404b83c5..5f3307e9d98b7 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc @@ -25,9 +25,7 @@ void StubTripletsMemory::writeST(bool first, unsigned int iSector) { string stub1index = stubs1_[j]->stubindex().str(); string stub2index = stubs2_[j]->stubindex().str(); string stub3index = stubs3_[j]->stubindex().str(); - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << stub1index << "|" << stub2index << "|" << stub3index << endl; + out_ << hexstr(j) << " " << stub1index << "|" << stub2index << "|" << stub3index << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc index 55e95adadf29d..85eb0775a5353 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc @@ -26,10 +26,7 @@ void TrackFitMemory::writeTF(bool first, unsigned int iSector) { out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; for (unsigned int j = 0; j < tracks_.size(); j++) { - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec << " "; - out_ << tracks_[j]->trackfitstr() << " " << trklet::hexFormat(tracks_[j]->trackfitstr()); + out_ << hexstr(j) << " " << tracks_[j]->trackfitstr() << " " << trklet::hexFormat(tracks_[j]->trackfitstr()); out_ << "\n"; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc index 620638aac138d..7180410c4eafa 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc @@ -1130,110 +1130,110 @@ void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memo layerdisk[15] = 9; phimin[15] = -0.0963091; phimax[15] = 0.794441; - dtcname[16] = "2S_1"; - layerdisk[16] = 3; - phimin[16] = -0.0246209; - phimax[16] = 0.763311; - dtcname[17] = "2S_1"; - layerdisk[17] = 4; - phimin[17] = 0.261875; - phimax[17] = 0.403311; - dtcname[18] = "2S_2"; - layerdisk[18] = 4; - phimin[18] = -0.0542445; - phimax[18] = 0.715509; - dtcname[19] = "2S_3"; - layerdisk[19] = 5; - phimin[19] = 0.0410126; - phimax[19] = 0.730605; - dtcname[20] = "2S_4"; - layerdisk[20] = 5; - phimin[20] = -0.0428961; - phimax[20] = 0.693862; - dtcname[21] = "2S_4"; - layerdisk[21] = 8; - phimin[21] = -0.0676705; - phimax[21] = 0.765802; - dtcname[22] = "2S_5"; - layerdisk[22] = 6; - phimin[22] = -0.0648206; - phimax[22] = 0.762952; - dtcname[23] = "2S_5"; - layerdisk[23] = 9; - phimin[23] = -0.0676705; - phimax[23] = 0.765802; - dtcname[24] = "2S_6"; + dtcname[16] = "negPS10G_1"; + layerdisk[16] = 0; + phimin[16] = -0.023281; + phimax[16] = 0.372347; + dtcname[17] = "negPS10G_1"; + layerdisk[17] = 6; + phimin[17] = -0.185672; + phimax[17] = 0.883803; + dtcname[18] = "negPS10G_1"; + layerdisk[18] = 8; + phimin[18] = -0.132414; + phimax[18] = 0.830545; + dtcname[19] = "negPS10G_1"; + layerdisk[19] = 10; + phimin[19] = -0.132414; + phimax[19] = 0.830545; + dtcname[20] = "negPS10G_2"; + layerdisk[20] = 0; + phimin[20] = -0.0133719; + phimax[20] = 0.715599; + dtcname[21] = "negPS10G_2"; + layerdisk[21] = 7; + phimin[21] = -0.110089; + phimax[21] = 0.808221; + dtcname[22] = "negPS10G_2"; + layerdisk[22] = 9; + phimin[22] = -0.132414; + phimax[22] = 0.830545; + dtcname[23] = "negPS10G_3"; + layerdisk[23] = 1; + phimin[23] = -0.115834; + phimax[23] = 0.813823; + dtcname[24] = "negPS10G_3"; layerdisk[24] = 7; - phimin[24] = -0.0648206; - phimax[24] = 0.762952; - dtcname[25] = "2S_6"; - layerdisk[25] = 10; - phimin[25] = -0.0676705; - phimax[25] = 0.765802; - dtcname[26] = "negPS10G_1"; - layerdisk[26] = 0; - phimin[26] = -0.023281; - phimax[26] = 0.372347; - dtcname[27] = "negPS10G_1"; - layerdisk[27] = 6; - phimin[27] = -0.185672; - phimax[27] = 0.883803; - dtcname[28] = "negPS10G_1"; - layerdisk[28] = 8; - phimin[28] = -0.132414; - phimax[28] = 0.830545; - dtcname[29] = "negPS10G_1"; - layerdisk[29] = 10; - phimin[29] = -0.132414; - phimax[29] = 0.830545; - dtcname[30] = "negPS10G_2"; - layerdisk[30] = 0; - phimin[30] = -0.0133719; - phimax[30] = 0.715599; - dtcname[31] = "negPS10G_2"; - layerdisk[31] = 7; - phimin[31] = -0.110089; - phimax[31] = 0.808221; - dtcname[32] = "negPS10G_2"; - layerdisk[32] = 9; - phimin[32] = -0.132414; - phimax[32] = 0.830545; - dtcname[33] = "negPS10G_3"; - layerdisk[33] = 1; - phimin[33] = -0.115834; - phimax[33] = 0.813823; - dtcname[34] = "negPS10G_3"; - layerdisk[34] = 7; - phimin[34] = -0.185672; - phimax[34] = 0.883803; - dtcname[35] = "negPS10G_4"; - layerdisk[35] = 6; - phimin[35] = -0.0823971; - phimax[35] = 0.780529; - dtcname[36] = "negPS10G_4"; - layerdisk[36] = 8; - phimin[36] = -0.0963091; - phimax[36] = 0.794441; - dtcname[37] = "negPS10G_4"; - layerdisk[37] = 10; - phimin[37] = -0.0963091; - phimax[37] = 0.794441; - dtcname[38] = "negPS_1"; - layerdisk[38] = 2; - phimin[38] = -0.0961318; - phimax[38] = 0.445198; - dtcname[39] = "negPS_1"; - layerdisk[39] = 7; - phimin[39] = -0.0823971; - phimax[39] = 0.780529; - dtcname[40] = "negPS_2"; - layerdisk[40] = 2; - phimin[40] = -0.0917521; - phimax[40] = 0.614191; - dtcname[41] = "negPS_2"; - layerdisk[41] = 9; - phimin[41] = -0.0963091; - phimax[41] = 0.794441; + phimin[24] = -0.185672; + phimax[24] = 0.883803; + dtcname[25] = "negPS10G_4"; + layerdisk[25] = 6; + phimin[25] = -0.0823971; + phimax[25] = 0.780529; + dtcname[26] = "negPS10G_4"; + layerdisk[26] = 8; + phimin[26] = -0.0963091; + phimax[26] = 0.794441; + dtcname[27] = "negPS10G_4"; + layerdisk[27] = 10; + phimin[27] = -0.0963091; + phimax[27] = 0.794441; + dtcname[28] = "negPS_1"; + layerdisk[28] = 2; + phimin[28] = -0.0961318; + phimax[28] = 0.445198; + dtcname[29] = "negPS_1"; + layerdisk[29] = 7; + phimin[29] = -0.0823971; + phimax[29] = 0.780529; + dtcname[30] = "negPS_2"; + layerdisk[30] = 2; + phimin[30] = -0.0917521; + phimax[30] = 0.614191; + dtcname[31] = "negPS_2"; + layerdisk[31] = 9; + phimin[31] = -0.0963091; + phimax[31] = 0.794441; + dtcname[32] = "2S_1"; + layerdisk[32] = 3; + phimin[32] = -0.0246209; + phimax[32] = 0.763311; + dtcname[33] = "2S_1"; + layerdisk[33] = 4; + phimin[33] = 0.261875; + phimax[33] = 0.403311; + dtcname[34] = "2S_2"; + layerdisk[34] = 4; + phimin[34] = -0.0542445; + phimax[34] = 0.715509; + dtcname[35] = "2S_3"; + layerdisk[35] = 5; + phimin[35] = 0.0410126; + phimax[35] = 0.730605; + dtcname[36] = "2S_4"; + layerdisk[36] = 5; + phimin[36] = -0.0428961; + phimax[36] = 0.693862; + dtcname[37] = "2S_4"; + layerdisk[37] = 8; + phimin[37] = -0.0676705; + phimax[37] = 0.765802; + dtcname[38] = "2S_5"; + layerdisk[38] = 6; + phimin[38] = -0.0648206; + phimax[38] = 0.762952; + dtcname[39] = "2S_5"; + layerdisk[39] = 9; + phimin[39] = -0.0676705; + phimax[39] = 0.765802; + dtcname[40] = "2S_6"; + layerdisk[40] = 7; + phimin[40] = -0.0648206; + phimax[40] = 0.762952; + dtcname[41] = "2S_6"; + layerdisk[41] = 10; + phimin[41] = -0.0676705; + phimax[41] = 0.765802; dtcname[42] = "neg2S_1"; layerdisk[42] = 3; phimin[42] = -0.0246209; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index a88748b61ab9f..817e72abe0be3 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -124,7 +124,7 @@ void TrackletLUT::initTPlut(bool fillInner, } else { rinner = settings_.rmean(layerdisk1); } - double rinv1 = rinv(0.0, -dphi[i2], rinner, router[i3]); + double rinv1 = (rinner < router[i3]) ? rinv(0.0, -dphi[i2], rinner, router[i3]) : 20.0; double pitchinner = (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); double pitchouter = (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); @@ -312,7 +312,7 @@ void TrackletLUT::initteptlut(bool fillInner, } else { rinner = settings_.rmean(layerdisk1); } - double rinv1 = -rinv(phiinner[i1], phiouter[i2], rinner, router[i3]); + double rinv1 = (rinner < router[i3]) ? -rinv(phiinner[i1], phiouter[i2], rinner, router[i3]) : -20.0; double pitchinner = (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); double pitchouter = diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc index 7667f26038a97..7368391eeff70 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc @@ -33,10 +33,7 @@ void TrackletParametersMemory::writeTPAR(bool first, unsigned int iSector) { for (unsigned int j = 0; j < tracklets_.size(); j++) { string tpar = tracklets_[j]->trackletparstr(); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << tpar << " " << trklet::hexFormat(tpar) << endl; + out_ << hexstr(j) << " " << tpar << " " << trklet::hexFormat(tpar) << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc index 6439581639d9d..2cde8759a71e8 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc @@ -52,10 +52,7 @@ void TrackletProjectionsMemory::writeTPROJ(bool first, unsigned int iSector) { for (unsigned int j = 0; j < tracklets_.size(); j++) { string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_ - 1)) ? tracklets_[j]->trackletprojstrlayer(layer_) : tracklets_[j]->trackletprojstrdisk(disk_); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << proj << " " << trklet::hexFormat(proj) << endl; + out_ << hexstr(j) << " " << proj << " " << trklet::hexFormat(proj) << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc index 3541d9ce522f6..007f865f73db3 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc @@ -41,10 +41,7 @@ void VMProjectionsMemory::writeVMPROJ(bool first, unsigned int iSector) { for (unsigned int j = 0; j < tracklets_.size(); j++) { string vmproj = (layer_ > 0) ? tracklets_[j].first->vmstrlayer(layer_, tracklets_[j].second) : tracklets_[j].first->vmstrdisk(disk_, tracklets_[j].second); - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; - out_ << " " << vmproj << " " << trklet::hexFormat(vmproj) << endl; + out_ << hexstr(j) << " " << vmproj << " " << trklet::hexFormat(vmproj) << endl; } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc index 751c75398a692..8c840b6f8d068 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc @@ -121,9 +121,12 @@ void VMRouterCM::addInput(MemoryBase* memory, string input) { throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; } -void VMRouterCM::execute() { +void VMRouterCM::execute(unsigned int iSector) { unsigned int allStubCounter = 0; + //bool print = getName() == "VMR_D1PHIB" && iSector == 3; + //print = false; + //Loop over the input stubs for (auto& stubinput : stubinputs_) { for (unsigned int i = 0; i < stubinput->nStubs(); i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc index 9ac11723a6fcf..60d437ad2f39f 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc @@ -43,7 +43,7 @@ void VMStubsMEMemory::writeStubs(bool first, unsigned int iSector) { stub += "|" + finephipos.str(); FPGAWord finepos = binnedstubs_[i][j].finerz(); stub += "|" + finepos.str(); - out_ << hex << i << " " << j << dec << " " << stub << " " << trklet::hexFormat(stub) << endl; + out_ << hexstr(i) << " " << hexstr(j) << " " << stub << " " << trklet::hexFormat(stub) << endl; } } out_.close(); diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc index 48e05ece0eaae..77f0a9437840b 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc @@ -227,17 +227,14 @@ void VMStubsTEMemory::writeStubs(bool first, unsigned int iSector) { if (isinner_) { // inner VM for TE purpose for (unsigned int j = 0; j < stubsvm_.size(); j++) { - out_ << "0x"; - out_ << std::setfill('0') << std::setw(2); - out_ << hex << j << dec; string stub = stubsvm_[j].str(); - out_ << " " << stub << " " << trklet::hexFormat(stub) << endl; + out_ << hexstr(j) << " " << stub << " " << trklet::hexFormat(stub) << endl; } } else { // outer VM for TE purpose for (unsigned int i = 0; i < stubsbinnedvm_.size(); i++) { for (unsigned int j = 0; j < stubsbinnedvm_[i].size(); j++) { string stub = stubsbinnedvm_[i][j].str(); - out_ << hex << i << " " << j << dec << " " << stub << " " << trklet::hexFormat(stub) << endl; + out_ << hexstr(i) << " " << hexstr(j) << " " << stub << " " << trklet::hexFormat(stub) << endl; } } }