From 3a634da84edfd68697dd93938a6f48229c6481ae Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Wed, 22 Jun 2022 11:47:26 -0400 Subject: [PATCH 01/30] Find best MC match (#174) * Find best match (matches HLS for all barrel layers and some disks) * Fixed comment * Removed extra table init calls * code-format * Added descriptive comments --- .../src/MatchCalculator.cc | 121 +++++++++++------- 1 file changed, 77 insertions(+), 44 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index bda660edffddc..bc619e6556661 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -1,3 +1,13 @@ +////////////////////////////////////////////////////////////////// +// MatchCalculator +// This class loads pairs for tracklet/stubs and looks for the +// best possible match. +// Variables such as `best_ideltaphi_barrel` store the "global" +// best value for delta phi, r, z, and r*phi, for instances +// where the same tracklet has multiple stub pairs. This allows +// us to find the truly best match +////////////////////////////////////////////////////////////////// + #include "L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h" #include "L1Trigger/TrackFindingTracklet/interface/Globals.h" #include "L1Trigger/TrackFindingTracklet/interface/Util.h" @@ -122,14 +132,23 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { Tracklet* oldTracklet = nullptr; + // Get all tracklet/stub pairs std::vector, const Stub*> > mergedMatches = mergeMatches(matches_); // Number of clock cycles the pipeline in HLS takes to process the projection merging to - // produce the first projectio + // produce the first projection unsigned int mergedepth = 3; unsigned int maxProc = std::min(settings_.maxStep("MC") - mergedepth, (unsigned int)mergedMatches.size()); + // Pick some initial large values + int best_ideltaphi_barrel = 0xFFFF; + int best_ideltaz_barrel = 0xFFFF; + int best_ideltaphi_disk = 0xFFFF; + int best_ideltar_disk = 0xFFFF; + unsigned int curr_projid = -1; + unsigned int next_projid = -1; + for (unsigned int j = 0; j < maxProc; j++) { if (settings_.debugTracklet() && j == 0) { edm::LogVerbatim("Tracklet") << getName() << " has " << mergedMatches.size() << " candidate matches"; @@ -141,8 +160,8 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { Tracklet* tracklet = mergedMatches[j].first.first; const L1TStub* stub = fpgastub->l1tstub(); - //check that the matches are orderd correctly - //allow equal here since we can have more than one cadidate match per tracklet projection + //check that the matches are ordered correctly + //allow equal here since we can have more than one candidate match per tracklet projection if (oldTracklet != nullptr) { assert(oldTracklet->TCID() <= tracklet->TCID()); } @@ -194,6 +213,19 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { double dzapprox = z - (proj.rzprojapprox() + dr * proj.rzprojderapprox()); int seedindex = tracklet->getISeed(); + unsigned int projindex = mergedMatches[j].first.second; // Allproj index + curr_projid = next_projid; + next_projid = projindex; + + // Do we have a new tracklet? + bool newtracklet = (j == 0 || projindex != curr_projid); + if (j == 0) + best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible + // If so, replace the "best" values with the cut tables + if (newtracklet) { + best_ideltaphi_barrel = (int)phimatchcuttable_.lookup(seedindex); + best_ideltaz_barrel = (int)zmatchcuttable_.lookup(seedindex); + } assert(phimatchcuttable_.lookup(seedindex) > 0); assert(zmatchcuttable_.lookup(seedindex) > 0); @@ -229,33 +261,24 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { << zmatchcuttable_.lookup(seedindex) * settings_.kz() << endl; } - bool imatch = (std::abs(ideltaphi) <= (int)phimatchcuttable_.lookup(seedindex)) && - (ideltaz * fact_ < (int)zmatchcuttable_.lookup(seedindex)) && - (ideltaz * fact_ >= -(int)zmatchcuttable_.lookup(seedindex)); - - bool keep = true; - if (!settings_.doKF() || !settings_.doMultipleMatches()) { - // Case of allowing only one stub per track per layer (or no KF which implies the same). - if (imatch && tracklet->match(layerdisk_)) { - // Veto match if is not the best one for this tracklet (in given layer) - auto res = tracklet->resid(layerdisk_); - keep = abs(ideltaphi) < abs(res.fpgaphiresid().value()); - imatch = keep; - } + // integer match + bool imatch = (std::abs(ideltaphi) <= best_ideltaphi_barrel) && (ideltaz * fact_ < best_ideltaz_barrel) && + (ideltaz * fact_ >= -best_ideltaz_barrel); + // Update the "best" values + if (imatch) { + best_ideltaphi_barrel = std::abs(ideltaphi); + best_ideltaz_barrel = std::abs(ideltaz * fact_); } if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " keep = " << keep << " ideltaphi cut " - << ideltaphi << " " << phimatchcuttable_.lookup(seedindex) << " ideltaz*fact cut " - << ideltaz * fact_ << " " << zmatchcuttable_.lookup(seedindex); + edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " ideltaphi cut " << ideltaphi << " " + << phimatchcuttable_.lookup(seedindex) << " ideltaz*fact cut " << ideltaz * fact_ + << " " << zmatchcuttable_.lookup(seedindex); } if (imatch) { countsel++; - // TO DO: storing the matches in both FullMatchMemory & Tracklet is ugly. - // Should clean this up, to avoid the need to store them in Tracklet. - tracklet->addMatch(layerdisk_, ideltaphi, ideltaz, @@ -273,7 +296,6 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { fullMatches_[seedindex]->addMatch(tracklet, mergedMatches[j].second); } } else { //disk matches - //check that stubs and projections in same half of detector assert(stub->z() * tracklet->t() > 0.0); @@ -288,7 +310,7 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { int iz = fpgastub->z().value(); int iphi = proj.fpgaphiproj().value(); - //TODO - need to express interms of constants + //TODO - need to express in terms of constants int shifttmp = 6; int iphicorr = (iz * proj.fpgaphiprojder().value()) >> shifttmp; @@ -296,13 +318,14 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { int ir = proj.fpgarzproj().value(); - //TODO - need to express interms of constants + //TODO - need to express in terms of constants int shifttmp2 = 7; int ircorr = (iz * proj.fpgarzprojder().value()) >> shifttmp2; ir += ircorr; int ideltaphi = fpgastub->phi().value() * settings_.kphi() / settings_.kphi() - iphi; + int irstub = fpgastub->r().value(); int ialphafact = 0; if (!stub->isPSmodule()) { @@ -384,6 +407,23 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { idrcut = rcut2Stable_.lookup(seedindex); } + unsigned int projindex = mergedMatches[j].first.second; // Allproj index + curr_projid = next_projid; + next_projid = projindex; + // Do we have a new tracklet? + bool newtracklet = (j == 0 || projindex != curr_projid); + if (j == 0) + best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible + // If so, replace the "best" values with the cut tables + if (newtracklet) { + best_ideltaphi_disk = idrphicut; + best_ideltar_disk = idrcut; + } + + // Update the cut vales (cut table if new tracklet, otherwise current best) + idrphicut = newtracklet ? idrphicut : best_ideltaphi_disk; + idrcut = newtracklet ? idrcut : best_ideltar_disk; + double drphicut = idrphicut * settings_.kphi() * settings_.kr(); double drcut = idrcut * settings_.krprojshiftdisk(); @@ -399,34 +439,26 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { << ideltar * settings_.krprojshiftdisk() << " " << deltar << " " << drcut << " " << endl; } + // floating point match match = (std::abs(drphi) < drphicut) && (std::abs(deltar) < drcut); - imatch = (std::abs(ideltaphi * irstub) < idrphicut) && (std::abs(ideltar) < idrcut); + // integer match + imatch = (std::abs(ideltaphi) * irstub < best_ideltaphi_disk) && (std::abs(ideltar) < best_ideltar_disk); + // Update the "best" values + if (imatch) { + best_ideltaphi_disk = std::abs(ideltaphi) * irstub; + best_ideltar_disk = std::abs(ideltar); + } } else { edm::LogProblem("Tracklet") << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox << "dphi " << dphi << " Seed / ISeed " << tracklet->getISeed() << endl; match = false; imatch = false; } - - bool keep = true; - if (!settings_.doKF() || !settings_.doMultipleMatches()) { - // Case of allowing only one stub per track per layer (or no KF which implies the same). - if (imatch && tracklet->match(layerdisk_)) { - // Veto match if is not the best one for this tracklet (in given layer) - auto res = tracklet->resid(layerdisk_); - keep = abs(ideltaphi) < abs(res.fpgaphiresid().value()); - imatch = keep; - } - } - if (not keep) - match = false; // FIX: should calc keep with float point here. - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "imatch match disk: " << imatch << " " << match << " keep = " << keep << " " - << std::abs(ideltaphi) << " " << drphicut / (settings_.kphi() * stub->r()) << " " - << std::abs(ideltar) << " " << drcut / settings_.krprojshiftdisk() - << " r = " << stub->r(); + edm::LogVerbatim("Tracklet") << "imatch match disk: " << imatch << " " << match << " " << std::abs(ideltaphi) + << " " << drphicut / (settings_.kphi() * stub->r()) << " " << std::abs(ideltar) + << " " << drcut / settings_.krprojshiftdisk() << " r = " << stub->r(); } if (imatch) { @@ -462,6 +494,7 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { } } +// Combines all tracklet/stub pairs into a vector std::vector, const Stub*> > MatchCalculator::mergeMatches( vector& candmatch) { std::vector, const Stub*> > tmp; From 295a73e188cff86cfaa972edd602b791c1d7d427 Mon Sep 17 00:00:00 2001 From: sarafiorendi Date: Fri, 24 Jun 2022 14:13:30 +0200 Subject: [PATCH 02/30] Add possibility to invent seeding stubs coordinates before DR (#170) * add possibility to invent stubs * fix missing index in l1tstub * apply code format * updated function names and description,update invent l1tstub creation * apply code format * remove parameter from tracklet_cfi * change default invent option to true * code format --- .../TrackFindingTracklet/interface/L1TStub.h | 8 + .../interface/PurgeDuplicate.h | 15 ++ .../interface/SLHCEvent.h | 3 +- .../TrackFindingTracklet/interface/Settings.h | 3 + .../plugins/L1FPGATrackProducer.cc | 19 +- L1Trigger/TrackFindingTracklet/src/L1TStub.cc | 1 + .../src/PurgeDuplicate.cc | 196 ++++++++++++++++-- .../TrackFindingTracklet/src/SLHCEvent.cc | 4 +- 8 files changed, 228 insertions(+), 21 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h index 2a5f0e01732ee..6a7b987512a87 100644 --- a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h +++ b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h @@ -81,8 +81,15 @@ namespace trklet { std::vector tps() const { return tps_; } void setAllStubIndex(unsigned int index) { allstubindex_ = index; } + void setUniqueIndex(unsigned int index) { uniqueindex_ = index; } + void setCoords(double x, double y, double z) { + x_ = x; + y_ = y; + z_ = z; + } unsigned int allStubIndex() const { return allstubindex_; } + unsigned int uniqueIndex() const { return uniqueindex_; } unsigned int strip() const { return strip_; } @@ -134,6 +141,7 @@ namespace trklet { double pt_; double bend_; unsigned int allstubindex_; + unsigned int uniqueindex_; unsigned int isPSmodule_; unsigned int isFlipped_; bool tiltedBarrel_; diff --git a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h index 7909efdbeb72d..614cd396fe22c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h +++ b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h @@ -37,6 +37,21 @@ namespace trklet { private: double getPhiRes(Tracklet* curTracklet, const Stub* curStub); + bool isSeedingStub(int, int, int); + std::string l1tinfo(const L1TStub*, std::string); + std::pair findLayerDisk(const Stub*); + std::vector getInventedCoords( + unsigned int, + const Stub*, + Tracklet*); // calculate stub coordinates based on tracklet trajectory for prompt tracking + std::vector getInventedCoordsExtended( + unsigned int, + const Stub*, + Tracklet*); // calculate stub coordinates based on tracklet trajectory for extended tracking + std::vector getInventedSeedingStub( + unsigned int, + Tracklet*, + std::vector); // return stub with invented x,y,z coords, if it's a seeding one for this tracklet std::vector inputtracks_; std::vector> inputstublists_; diff --git a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h index 444767154ffc6..80baa5a535c00 100644 --- a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h +++ b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h @@ -46,7 +46,8 @@ namespace trklet { double z, double bend, double strip, - std::vector tpstt); + std::vector tpstt, + int stubindex); const L1TStub& lastStub() const { return stubs_.back(); } diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 41fe380fac2c8..5b161dac26e05 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -259,6 +259,8 @@ namespace trklet { void setCombined(bool combined) { combined_ = combined; } bool reduced() const { return reduced_; } void setReduced(bool reduced) { reduced_ = reduced; } + bool inventStubs() const { return inventStubs_; } + void setInventStubs(bool inventStubs) { inventStubs_ = inventStubs; } double bfield() const { return bfield_; } void setBfield(double bfield) { bfield_ = bfield; } @@ -945,6 +947,7 @@ namespace trklet { unsigned int nHelixPar_{4}; // 4 or 5 param helix fit bool extended_{false}; // turn on displaced tracking bool reduced_{false}; // use reduced (Summer Chain) config + bool inventStubs_{true}; // invent seeding stub coordinates based on tracklet traj // Use combined TP (TE+TC) and MP (PR+ME+MC) configuration (with prompt tracking) bool combined_{false}; diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 13fdc79169296..5c8ec8d51df34 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -366,6 +366,9 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe edm::Ref>, TTStub>, L1TStubCompare> stubMapType; + typedef std::map>, TTStub>> + stubIndexMapType; typedef edm::Ref>, TTCluster> TTClusterRef; @@ -373,6 +376,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe auto L1TkTracksForOutput = std::make_unique>>(); stubMapType stubMap; + stubIndexMapType stubIndexMap; //////////// // GET BS // @@ -454,6 +458,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe ///////////////////////////////// // Process stubs in each region and channel within that tracking region + unsigned int theStubIndex = 0; for (const int& region : handleDTC->tfpRegions()) { for (const int& channel : handleDTC->tfpChannels()) { // Get the DTC name & ID from the channel @@ -612,10 +617,13 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe ttPos.z(), stubbend, stubRef->innerClusterPosition(), - assocTPs); + assocTPs, + theStubIndex); const trklet::L1TStub& lastStub = ev.lastStub(); stubMap[lastStub] = stubRef; + stubIndexMap[lastStub.uniqueIndex()] = stub.first; + theStubIndex++; } } } @@ -690,11 +698,14 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe stubs.push_back(stubptr); } + int countStubs = 0; stubMapType::const_iterator it; + stubIndexMapType::const_iterator itIndex; for (const auto& itstubs : stubs) { - it = stubMap.find(itstubs); - if (it != stubMap.end()) { - aTrack.addStubRef(it->second); + itIndex = stubIndexMap.find(itstubs.uniqueIndex()); + if (itIndex != stubIndexMap.end()) { + aTrack.addStubRef(itIndex->second); + countStubs = countStubs + 1; } else { // could not find stub in stub map } diff --git a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc index d2078be8d95cd..07bef9c923e35 100644 --- a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc +++ b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc @@ -52,6 +52,7 @@ L1TStub::L1TStub(std::string DTClink, detId_ = detId; allstubindex_ = 999; + uniqueindex_ = 99999; } void L1TStub::write(ofstream& out) { diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index b186cde0ab151..87cbb261ac73a 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -173,6 +173,12 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe return; unsigned int numStublists = inputstublists_.size(); + if (settings_.inventStubs()) { + for (unsigned int itrk = 0; itrk < numStublists; itrk++) { + inputstublists_[itrk] = getInventedSeedingStub(iSector, inputtracklets_[itrk], inputstublists_[itrk]); + } + } + // Initialize all-false 2D array of tracks being duplicates to other tracks bool dupMap[numStublists][numStublists]; // Ends up symmetric for (unsigned int itrk = 0; itrk < numStublists; itrk++) { @@ -292,23 +298,34 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe // Get a merged stub list std::vector newStubList; - std::vector stubsTrk1 = inputstublists_[rejetrk]; - std::vector stubsTrk2 = inputstublists_[preftrk]; + std::vector stubsTrk1 = inputstublists_[preftrk]; + std::vector stubsTrk2 = inputstublists_[rejetrk]; + std::vector stubsTrk1indices; + std::vector stubsTrk2indices; + for (unsigned int stub1it = 0; stub1it < stubsTrk1.size(); stub1it++) { + stubsTrk1indices.push_back(stubsTrk1[stub1it]->l1tstub()->uniqueIndex()); + } + for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { + stubsTrk2indices.push_back(stubsTrk2[stub2it]->l1tstub()->uniqueIndex()); + } newStubList = stubsTrk1; for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { - if (find(stubsTrk1.begin(), stubsTrk1.end(), stubsTrk2[stub2it]) == stubsTrk1.end()) { + if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) == + stubsTrk1indices.end()) { newStubList.push_back(stubsTrk2[stub2it]); } } - // Overwrite stublist of preferred track with merged list + // Overwrite stublist of preferred track with merged list inputstublists_[preftrk] = newStubList; std::vector> newStubidsList; - std::vector> stubidsTrk1 = mergedstubidslists_[rejetrk]; - std::vector> stubidsTrk2 = mergedstubidslists_[preftrk]; + std::vector> stubidsTrk1 = mergedstubidslists_[preftrk]; + std::vector> stubidsTrk2 = mergedstubidslists_[rejetrk]; newStubidsList = stubidsTrk1; - for (unsigned int stub2it = 0; stub2it < stubidsTrk2.size(); stub2it++) { - if (find(stubidsTrk1.begin(), stubidsTrk1.end(), stubidsTrk2[stub2it]) == stubidsTrk1.end()) { + + for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { + if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) == + stubsTrk1indices.end()) { newStubidsList.push_back(stubidsTrk2[stub2it]); } } @@ -497,6 +514,18 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { // Get phi projection of tracklet int seedindex = curTracklet->seedIndex(); // If this stub is a seed stub, set projection=phi, so that res=0 + if (isSeedingStub(seedindex, Layer, Disk)) { + phiproj = stubphi; + // Otherwise, get projection of tracklet + } else { + phiproj = curTracklet->proj(curStub->layerdisk()).phiproj(); + } + // Calculate residual + phires = std::abs(stubphi - phiproj); + return phires; +} + +bool PurgeDuplicate::isSeedingStub(int seedindex, int Layer, int Disk) { if ((seedindex == 0 && (Layer == 1 || Layer == 2)) || (seedindex == 1 && (Layer == 2 || Layer == 3)) || (seedindex == 2 && (Layer == 3 || Layer == 4)) || (seedindex == 3 && (Layer == 5 || Layer == 6)) || (seedindex == 4 && (abs(Disk) == 1 || abs(Disk) == 2)) || @@ -505,13 +534,150 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { (seedindex == 8 && (Layer == 2 || Layer == 3 || Layer == 4)) || (seedindex == 9 && (Layer == 4 || Layer == 5 || Layer == 6)) || (seedindex == 10 && (Layer == 2 || Layer == 3 || abs(Disk) == 1)) || - (seedindex == 11 && (Layer == 2 || abs(Disk) == 1 || abs(Disk) == 2))) { - phiproj = stubphi; - // Otherwise, get projection of tracklet + (seedindex == 11 && (Layer == 2 || abs(Disk) == 1 || abs(Disk) == 2))) + return true; + + return false; +} + +std::pair PurgeDuplicate::findLayerDisk(const Stub* st) { + std::pair layer_disk; + layer_disk.first = st->layerdisk() + 1; + if (layer_disk.first > N_LAYER) { + layer_disk.first = 0; + } + layer_disk.second = st->layerdisk() - (N_LAYER - 1); + if (layer_disk.second < 0) { + layer_disk.second = 0; + } + return layer_disk; +} + +std::string PurgeDuplicate::l1tinfo(const L1TStub* l1stub, std::string str = "") { + std::string thestr = Form("\t %s stub info: r/z/phi:\t%f\t%f\t%f\t%d\t%f\t%d", + str.c_str(), + l1stub->r(), + l1stub->z(), + l1stub->phi(), + l1stub->iphi(), + l1stub->bend(), + l1stub->layerdisk()); + return thestr; +} + +std::vector PurgeDuplicate::getInventedCoords(unsigned int iSector, const Stub* st, Tracklet* tracklet) { + int stubLayer = (findLayerDisk(st)).first; + int stubDisk = (findLayerDisk(st)).second; + + double stub_phi = -99; + double stub_z = -99; + double stub_r = -99; + + double tracklet_rinv = tracklet->rinv(); + + if (st->isBarrel()) { + stub_r = settings_.rmean(stubLayer - 1); + stub_phi = tracklet->phi0() - std::asin(stub_r * tracklet_rinv / 2); + stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG(); + stub_phi = reco::reduceRange(stub_phi); + stub_z = tracklet->z0() + 2 * tracklet->t() * 1 / tracklet_rinv * std::asin(stub_r * tracklet_rinv / 2); } else { - phiproj = curTracklet->proj(curStub->layerdisk()).phiproj(); + stub_z = settings_.zmean(stubDisk - 1) * tracklet->disk() / abs(tracklet->disk()); + stub_phi = tracklet->phi0() - (stub_z - tracklet->z0()) * tracklet_rinv / 2 / tracklet->t(); + stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG(); + stub_phi = reco::reduceRange(stub_phi); + stub_r = 2 / tracklet_rinv * std::sin((stub_z - tracklet->z0()) * tracklet_rinv / 2 / tracklet->t()); } - // Calculate residual - phires = std::abs(stubphi - phiproj); - return phires; + + std::vector invented_coords{stub_r, stub_z, stub_phi}; + return invented_coords; +} + +std::vector PurgeDuplicate::getInventedCoordsExtended(unsigned int iSector, + const Stub* st, + Tracklet* tracklet) { + int stubLayer = (findLayerDisk(st)).first; + int stubDisk = (findLayerDisk(st)).second; + + double stub_phi = -99; + double stub_z = -99; + double stub_r = -99; + + double rho = 1 / tracklet->rinv(); + double rho_minus_d0 = rho + tracklet->d0(); // should be -, but otherwise does not work + + // exact helix + if (st->isBarrel()) { + stub_r = settings_.rmean(stubLayer - 1); + + double sin_val = (stub_r * stub_r + rho_minus_d0 * rho_minus_d0 - rho * rho) / (2 * stub_r * rho_minus_d0); + stub_phi = tracklet->phi0() - std::asin(sin_val); + stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG(); + stub_phi = reco::reduceRange(stub_phi); + + double beta = std::acos((rho * rho + rho_minus_d0 * rho_minus_d0 - stub_r * stub_r) / (2 * rho * rho_minus_d0)); + stub_z = tracklet->z0() + tracklet->t() * std::abs(rho * beta); + } else { + stub_z = settings_.zmean(stubDisk - 1) * tracklet->disk() / abs(tracklet->disk()); + + double beta = (stub_z - tracklet->z0()) / (tracklet->t() * std::abs(rho)); // maybe rho should be abs value + double r_square = -2 * rho * rho_minus_d0 * std::cos(beta) + rho * rho + rho_minus_d0 * rho_minus_d0; + stub_r = sqrt(r_square); + + double sin_val = (stub_r * stub_r + rho_minus_d0 * rho_minus_d0 - rho * rho) / (2 * stub_r * rho_minus_d0); + stub_phi = tracklet->phi0() - std::asin(sin_val); + stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG(); + stub_phi = reco::reduceRange(stub_phi); + } + + // TMP: for displaced tracking, exclude one of the 3 seeding stubs + // to be discussed + int seed = tracklet->seedIndex(); + if ((seed == 8 && stubLayer == 4) || (seed == 9 && stubLayer == 5) || (seed == 10 && stubLayer == 3) || + (seed == 11 && abs(stubDisk) == 1)) { + stub_phi = st->l1tstub()->phi(); + stub_z = st->l1tstub()->z(); + stub_r = st->l1tstub()->r(); + } + + std::vector invented_coords{stub_r, stub_z, stub_phi}; + return invented_coords; +} + +std::vector PurgeDuplicate::getInventedSeedingStub(unsigned int iSector, + Tracklet* tracklet, + std::vector originalStubsList) { + std::vector newStubList; + + for (unsigned int stubit = 0; stubit < originalStubsList.size(); stubit++) { + const Stub* thisStub = originalStubsList[stubit]; + + if (isSeedingStub(tracklet->seedIndex(), (findLayerDisk(thisStub)).first, (findLayerDisk(thisStub)).second)) { + // get a vector containing r, z, phi + std::vector inv_r_z_phi; + if (!settings_.extended()) + inv_r_z_phi = getInventedCoords(iSector, thisStub, tracklet); + else { + inv_r_z_phi = getInventedCoordsExtended(iSector, thisStub, tracklet); + } + double stub_x_invent = inv_r_z_phi[0] * std::cos(inv_r_z_phi[2]); + double stub_y_invent = inv_r_z_phi[0] * std::sin(inv_r_z_phi[2]); + double stub_z_invent = inv_r_z_phi[1]; + + Stub* invent_stub_ptr = new Stub(*thisStub); + const L1TStub* l1stub = thisStub->l1tstub(); + L1TStub invent_l1stub = *l1stub; + invent_l1stub.setCoords(stub_x_invent, stub_y_invent, stub_z_invent); + + invent_stub_ptr->setl1tstub(new L1TStub(invent_l1stub)); + invent_stub_ptr->l1tstub()->setAllStubIndex(l1stub->allStubIndex()); + invent_stub_ptr->l1tstub()->setUniqueIndex(l1stub->uniqueIndex()); + + newStubList.push_back(invent_stub_ptr); + + } else { + newStubList.push_back(thisStub); + } + } + return newStubList; } diff --git a/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc b/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc index 1c0e0f1e9427b..8b206afd34cb7 100644 --- a/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc +++ b/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc @@ -25,7 +25,8 @@ bool SLHCEvent::addStub(string DTClink, double z, double bend, double strip, - vector tps) { + vector tps, + int stubindex) { L1TStub stub(DTClink, region, layerdisk, @@ -43,6 +44,7 @@ bool SLHCEvent::addStub(string DTClink, strip, tps); + stub.setUniqueIndex(stubindex); stubs_.push_back(stub); return true; } From a2849c8c872a6cc5a7e246bf21b3b74f98c78a29 Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Mon, 15 Aug 2022 11:07:55 -0400 Subject: [PATCH 03/30] MC/MP LUTs (#176) * Add disk cut tables * Removed debug lines * code-format * Fixed LUTs * Disk LUTs for MP * Initialize LUTs * Added comments to TrackletLUT.h * code-format --- .../interface/MatchCalculator.h | 4 +++ .../interface/MatchProcessor.h | 4 +++ .../interface/TrackletLUT.h | 18 +++++++++- .../src/MatchCalculator.cc | 10 +++++- .../src/MatchProcessor.cc | 8 +++++ .../TrackFindingTracklet/src/TrackletLUT.cc | 36 +++++++++++++++++++ 6 files changed, 78 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h b/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h index 82459b8c3925f..3f4865598b388 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h @@ -49,6 +49,10 @@ namespace trklet { TrackletLUT rphicut2Stable_; TrackletLUT rcutPStable_; TrackletLUT rcut2Stable_; + TrackletLUT alphainner_; + TrackletLUT alphaouter_; + TrackletLUT rSSinner_; + TrackletLUT rSSouter_; int ialphafactinner_[N_DSS_MOD * 2]; int ialphafactouter_[N_DSS_MOD * 2]; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index 78b9573734922..d60f09080322f 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -58,6 +58,10 @@ namespace trklet { TrackletLUT rphicut2Stable_; TrackletLUT rcutPStable_; TrackletLUT rcut2Stable_; + TrackletLUT alphainner_; + TrackletLUT alphaouter_; + TrackletLUT rSSinner_; + TrackletLUT rSSouter_; int nrbits_; int nphiderbits_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h index f37b8a909d498..b6438428adaec 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h @@ -1,3 +1,8 @@ +////////////////////////////////////////////////////////////////// +// TrackletLUT +// This class writes out the variuos look up tables +// for all modules. +////////////////////////////////////////////////////////////////// #ifndef L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h #define L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h @@ -24,7 +29,18 @@ namespace trklet { ~TrackletLUT() = default; - enum MatchType { barrelphi, barrelz, disk2Sphi, disk2Sr, diskPSphi, diskPSr }; + enum MatchType { + barrelphi, // write LUT for barrel phi + barrelz, // write LUT for barrel z + disk2Sphi, // write LUT for disk 2S phi + disk2Sr, // write LUT for disk 2S r + diskPSphi, // write LUT for disk PS phi + diskPSr, // write LUT for disk PS r + alphainner, // write alpha corrections LUT for 2S (inner) + alphaouter, // write alpha corrections LUT for 2S (outer) + rSSinner, // write r LUT for 2S (inner) + rSSouter // write r LUT for 2S (inner) + }; //region only used for name - should be removed void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index bc619e6556661..43631168503fe 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -36,7 +36,11 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* rphicutPStable_(settings), rphicut2Stable_(settings), rcutPStable_(settings), - rcut2Stable_(settings) { + rcut2Stable_(settings), + alphainner_(settings), + alphaouter_(settings), + rSSinner_(settings), + rSSouter_(settings) { phiregion_ = name[8] - 'A'; layerdisk_ = initLayerDisk(3); @@ -71,6 +75,10 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* rphicut2Stable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::disk2Sphi, region); rcutPStable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::diskPSr, region); rcut2Stable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::disk2Sr, region); + alphainner_.initmatchcut(layerdisk_, TrackletLUT::MatchType::alphainner, region); + alphaouter_.initmatchcut(layerdisk_, TrackletLUT::MatchType::alphaouter, region); + rSSinner_.initmatchcut(layerdisk_, TrackletLUT::MatchType::rSSinner, region); + rSSouter_.initmatchcut(layerdisk_, TrackletLUT::MatchType::rSSouter, region); } for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 204c9d9d0d4d0..6b28d13246951 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -21,6 +21,10 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g rphicut2Stable_(settings), rcutPStable_(settings), rcut2Stable_(settings), + alphainner_(settings), + alphaouter_(settings), + rSSinner_(settings), + rSSouter_(settings), fullmatches_(12), rinvbendlut_(settings), luttable_(settings), @@ -65,6 +69,10 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g rphicut2Stable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::disk2Sphi, region); rcutPStable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::diskPSr, region); rcut2Stable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::disk2Sr, region); + alphainner_.initmatchcut(layerdisk_, TrackletLUT::MatchType::alphainner, region); + alphaouter_.initmatchcut(layerdisk_, TrackletLUT::MatchType::alphaouter, region); + rSSinner_.initmatchcut(layerdisk_, TrackletLUT::MatchType::rSSinner, region); + rSSouter_.initmatchcut(layerdisk_, TrackletLUT::MatchType::rSSouter, region); } for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index 4f969a2e80cd2..a07bd4694a24d 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -34,6 +34,30 @@ void TrackletLUT::initmatchcut(unsigned int layerdisk, MatchType type, unsigned table_.push_back(settings_.rcutPS(iSeed, layerdisk - N_LAYER) / settings_.krprojshiftdisk()); } } + if (type == alphainner) { + for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { + table_.push_back((1 << settings_.alphashift()) * settings_.krprojshiftdisk() * settings_.half2SmoduleWidth() / + (1 << (settings_.nbitsalpha() - 1)) / (settings_.rDSSinner(i) * settings_.rDSSinner(i)) / + settings_.kphi()); + } + } + if (type == alphaouter) { + for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { + table_.push_back((1 << settings_.alphashift()) * settings_.krprojshiftdisk() * settings_.half2SmoduleWidth() / + (1 << (settings_.nbitsalpha() - 1)) / (settings_.rDSSouter(i) * settings_.rDSSouter(i)) / + settings_.kphi()); + } + } + if (type == rSSinner) { + for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { + table_.push_back(settings_.rDSSinner(i) / settings_.kr()); + } + } + if (type == rSSouter) { + for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { + table_.push_back(settings_.rDSSouter(i) / settings_.kr()); + } + } name_ = settings_.combined() ? "MP_" : "MC_"; @@ -55,6 +79,18 @@ void TrackletLUT::initmatchcut(unsigned int layerdisk, MatchType type, unsigned if (type == diskPSr) { name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_PSrcut.tab"; } + if (type == alphainner) { + name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_alphainner.tab"; + } + if (type == alphaouter) { + name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_alphaouter.tab"; + } + if (type == rSSinner) { + name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_rDSSinner.tab"; + } + if (type == rSSouter) { + name_ += TrackletConfigBuilder::LayerName(layerdisk) + "PHI" + cregion + "_rDSSouter.tab"; + } positive_ = false; From c7c8339a9ea4db3253d443c284a98b6c693702cc Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Mon, 15 Aug 2022 11:08:26 -0400 Subject: [PATCH 04/30] MP best match (#180) * Trying best cut values * Added header, clang-format --- .../interface/MatchProcessor.h | 7 +++ .../src/MatchProcessor.cc | 63 +++++++++++++++++-- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index d60f09080322f..624de1af99743 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -87,6 +87,13 @@ namespace trklet { unsigned int nMatchEngines_; std::vector matchengines_; + int best_ideltaphi_barrel; + int best_ideltaz_barrel; + int best_ideltaphi_disk; + int best_ideltar_disk; + Tracklet* curr_tracklet; + Tracklet* next_tracklet; + CircularBuffer inputProjBuffer_; }; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 6b28d13246951..9efde018a66b8 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -1,3 +1,15 @@ +////////////////////////////////////////////////////////////////// +// MatchProcessor +// +// This module is the combined version of the PR+ME+MC +// See more in execute() +// +// Variables such as `best_ideltaphi_barrel` store the "global" +// best value for delta phi, r, z, and r*phi, for instances +// where the same tracklet has multiple stub pairs. This allows +// us to find the truly best match +////////////////////////////////////////////////////////////////// + #include "L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h" #include "L1Trigger/TrackFindingTracklet/interface/Globals.h" #include "L1Trigger/TrackFindingTracklet/interface/Util.h" @@ -94,6 +106,14 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g tmpME.setimeu(iME); matchengines_.push_back(tmpME); } + + // Pick some initial large values + best_ideltaphi_barrel = 0xFFFF; + best_ideltaz_barrel = 0xFFFF; + best_ideltaphi_disk = 0xFFFF; + best_ideltar_disk = 0xFFFF; + curr_tracklet = nullptr; + next_tracklet = nullptr; } void MatchProcessor::addOutput(MemoryBase* memory, string output) { @@ -448,7 +468,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, unsigned int istep) { const L1TStub* stub = fpgastub->l1tstub(); if (layerdisk_ < N_LAYER) { @@ -495,6 +515,18 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b double dzapprox = z - (proj.rzprojapprox() + dr * proj.rzprojderapprox()); int seedindex = tracklet->getISeed(); + curr_tracklet = next_tracklet; + next_tracklet = tracklet; + + // Do we have a new tracklet? + bool newtracklet = (istep == 0 || tracklet != curr_tracklet); + if (istep == 0) + best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible + // If so, replace the "best" values with the cut tables + if (newtracklet) { + best_ideltaphi_barrel = (int)phimatchcuttable_.lookup(seedindex); + best_ideltaz_barrel = (int)zmatchcuttable_.lookup(seedindex); + } assert(phimatchcuttable_.lookup(seedindex) > 0); assert(zmatchcuttable_.lookup(seedindex) > 0); @@ -524,9 +556,13 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b << zmatchcuttable_.lookup(seedindex) * settings_.kz() << endl; } - bool imatch = (std::abs(ideltaphi) <= phimatchcuttable_.lookup(seedindex)) && - (ideltaz << dzshift_ < zmatchcuttable_.lookup(seedindex)) && - (ideltaz << dzshift_ >= -zmatchcuttable_.lookup(seedindex)); + bool imatch = (std::abs(ideltaphi) <= best_ideltaphi_barrel && (ideltaz << dzshift_ < best_ideltaz_barrel) && + (ideltaz << dzshift_ >= -best_ideltaz_barrel)); + // Update the "best" values + if (imatch) { + best_ideltaphi_barrel = std::abs(ideltaphi); + best_ideltaz_barrel = std::abs(ideltaz); + } if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " ideltaphi cut " << ideltaphi << " " @@ -680,6 +716,18 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b idrcut = rcut2Stable_.lookup(seedindex); } + curr_tracklet = next_tracklet; + next_tracklet = tracklet; + // Do we have a new tracklet? + bool newtracklet = (istep == 0 || tracklet != curr_tracklet); + if (istep == 0) + best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible + // If so, replace the "best" values with the cut tables + if (newtracklet) { + best_ideltaphi_disk = idrphicut; + best_ideltar_disk = idrcut; + } + double drphicut = idrphicut * settings_.kphi() * settings_.kr(); double drcut = idrcut * settings_.krprojshiftdisk(); @@ -694,7 +742,12 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b } bool match = (std::abs(drphi) < drphicut) && (std::abs(deltar) < drcut); - bool imatch = (std::abs(ideltaphi * irstub) < idrphicut) && (std::abs(ideltar) < idrcut); + bool imatch = (std::abs(ideltaphi * irstub) < best_ideltaphi_disk) && (std::abs(ideltar) < best_ideltar_disk); + // Update the "best" values + if (imatch) { + best_ideltaphi_disk = std::abs(ideltaphi) * irstub; + best_ideltar_disk = std::abs(ideltar); + } if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "imatch match disk: " << imatch << " " << match << " " << std::abs(ideltaphi) From 63922093866ee3992a4188678faadff423cd580a Mon Sep 17 00:00:00 2001 From: tschuh Date: Wed, 7 Sep 2022 19:16:46 +0100 Subject: [PATCH 05/30] fix for stubs with identical position but different bends. (#183) * fix for stubs with identical position but different bends. * Update L1FPGATrackProducer.cc --- .../plugins/L1FPGATrackProducer.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 5c8ec8d51df34..220e72b46d91f 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -129,12 +129,12 @@ struct L1TStubCompare { bool operator()(const trklet::L1TStub& a, const trklet::L1TStub& b) const { if (a.x() != b.x()) return (b.x() > a.x()); - else { - if (a.y() != b.y()) - return (b.y() > a.y()); - else - return (a.z() > b.z()); - } + else if (a.y() != b.y()) + return (b.y() > a.y()); + else if (a.z() != b.z()) + return (a.z() > b.z()); + else + return a.bend() > b.bend(); } }; From bff95fe1e2206a9b9ccaddcbb295096b0e42cb01 Mon Sep 17 00:00:00 2001 From: Jack Li <43122048+Jingyan95@users.noreply.github.com> Date: Thu, 22 Sep 2022 18:32:31 +0200 Subject: [PATCH 06/30] Move module loop to setup (#175) * Move module loop to setup * Import functions from trackerTFP * Ian's 2nd comment * Code-format Co-authored-by: Jack Li --- .../interface/HitPatternHelper.h | 78 +++++---- .../interface/HitPatternHelperRcd.h | 6 +- .../plugins/L1FPGATrackProducer.cc | 10 +- .../plugins/ProducerHPH.cc | 18 +- .../python/L1HybridEmulationTracks_cff.py | 2 +- .../python/ProducerHPH_cff.py | 2 +- .../python/ProducerHPH_cfi.py | 12 ++ .../src/ES_HitPatternHelper.cc | 2 +- .../src/HitPatternHelper.cc | 159 ++++++++++-------- .../src/HitPatternHelperRcd.cc | 2 +- .../TrackFindingTracklet/test/BuildFile.xml | 1 - .../test/HybridTracksNewKF_cfg.py | 4 +- .../test/L1TrackNtupleMaker.cc | 2 +- .../test/L1TrackNtupleMaker_cfg.py | 2 + .../TrackTrigger/interface/L1TrackQuality.h | 5 +- .../TrackTrigger/python/ProducerHPH_cfi.py | 11 -- L1Trigger/TrackTrigger/src/L1TrackQuality.cc | 15 +- .../TrackerTFP/interface/LayerEncoding.h | 7 +- L1Trigger/TrackerTFP/src/LayerEncoding.cc | 11 +- 19 files changed, 200 insertions(+), 149 deletions(-) rename L1Trigger/{TrackTrigger => TrackFindingTracklet}/interface/HitPatternHelper.h (73%) rename L1Trigger/{TrackTrigger => TrackFindingTracklet}/interface/HitPatternHelperRcd.h (69%) rename L1Trigger/{TrackTrigger => TrackFindingTracklet}/plugins/ProducerHPH.cc (56%) rename L1Trigger/{TrackTrigger => TrackFindingTracklet}/python/ProducerHPH_cff.py (60%) create mode 100644 L1Trigger/TrackFindingTracklet/python/ProducerHPH_cfi.py rename L1Trigger/{TrackTrigger => TrackFindingTracklet}/src/ES_HitPatternHelper.cc (63%) rename L1Trigger/{TrackTrigger => TrackFindingTracklet}/src/HitPatternHelper.cc (65%) rename L1Trigger/{TrackTrigger => TrackFindingTracklet}/src/HitPatternHelperRcd.cc (67%) delete mode 100644 L1Trigger/TrackTrigger/python/ProducerHPH_cfi.py diff --git a/L1Trigger/TrackTrigger/interface/HitPatternHelper.h b/L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h similarity index 73% rename from L1Trigger/TrackTrigger/interface/HitPatternHelper.h rename to L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h index 7714dc6cde406..1d36db6f4bb44 100644 --- a/L1Trigger/TrackTrigger/interface/HitPatternHelper.h +++ b/L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h @@ -28,8 +28,10 @@ #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "Geometry/CommonTopologies/interface/PixelGeomDetUnit.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "L1Trigger/TrackTrigger/interface/HitPatternHelperRcd.h" +#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelperRcd.h" #include "L1Trigger/TrackTrigger/interface/Setup.h" +#include "L1Trigger/TrackerTFP/interface/DataFormats.h" +#include "L1Trigger/TrackerTFP/interface/LayerEncoding.h" #include #include @@ -42,27 +44,42 @@ namespace hph { //Class that stores configuration for HitPatternHelper class Setup { public: - Setup() {} - Setup(const edm::ParameterSet& iConfig, const tt::Setup& setupTT); + Setup(const edm::ParameterSet& iConfig, + const tt::Setup& setupTT, + const trackerTFP::DataFormats& dataFormats, + const trackerTFP::LayerEncoding& layerEncoding); ~Setup() {} - bool hphDebug() const { return iConfig_.getParameter("hphDebug"); } - bool useNewKF() const { return iConfig_.getParameter("useNewKF"); } - double deltaTanL() const { return iConfig_.getParameter("deltaTanL"); } - double chosenRofZ() const { return setupTT_.chosenRofZ(); } - std::vector etaRegions() const { return setupTT_.boundarieEta(); } - std::vector sensorModules() const { return setupTT_.sensorModules(); } + bool hphDebug() const { return hphDebug_; } + bool useNewKF() const { return useNewKF_; } + double chosenRofZ() const { return chosenRofZ_; } + std::vector etaRegions() const { return etaRegions_; } std::map>> layermap() const { return layermap_; } int nKalmanLayers() const { return nKalmanLayers_; } - static auto smallerID(std::pair lhs, std::pair rhs) { return lhs.first < rhs.first; } - static auto equalID(std::pair lhs, std::pair rhs) { return lhs.first == rhs.first; } + int etaRegion(double z0, double cot, bool useNewKF) const; + int digiCot(double cot, int binEta) const; + int digiZT(double z0, double cot, int binEta) const; + const std::vector& layerEncoding(int binEta, int binZT, int binCot) const { + return layerEncoding_.layerEncoding(binEta, binZT, binCot); + } + const std::map& layerEncodingMap(int binEta, int binZT, int binCot) const { + return layerEncoding_.layerEncodingMap(binEta, binZT, binCot); + } private: edm::ParameterSet iConfig_; + edm::ParameterSet oldKFPSet_; const tt::Setup setupTT_; // Helper class to store TrackTrigger configuration - std::vector> - layerIds_; // layer IDs (1~6->L1~L6;11~15->D1~D5) and whether or not they are from tracker barrel - // Only needed by Old KF + const trackerTFP::DataFormats dataFormats_; + const trackerTFP::DataFormat dfcot_; + const trackerTFP::DataFormat dfzT_; + const trackerTFP::LayerEncoding layerEncoding_; + bool hphDebug_; + bool useNewKF_; + double chosenRofZNewKF_; + std::vector etaRegionsNewKF_; + double chosenRofZ_; + std::vector etaRegions_; std::map>> layermap_; // Hard-coded layermap in Old KF int nEtaRegions_; // # of eta regions int nKalmanLayers_; // # of maximum KF layers allowed @@ -71,7 +88,6 @@ namespace hph { //Class that returns decoded information from hitpattern class HitPatternHelper { public: - HitPatternHelper() {} HitPatternHelper(const Setup* setup, int hitpattern, double cot, double z0); ~HitPatternHelper() {} @@ -94,17 +110,27 @@ namespace hph { return numMissingInterior2_; } //The number of missing interior layers (using hitpattern, layermap from Old KF and sensor modules) std::vector binary() { return binary_; } //11-bit hitmask needed by TrackQuality.cc (0~5->L1~L6;6~10->D1~D5) - static auto smallerID(tt::SensorModule lhs, tt::SensorModule rhs) { return lhs.layerId() < rhs.layerId(); } - static auto equalID(tt::SensorModule lhs, tt::SensorModule rhs) { return lhs.layerId() == rhs.layerId(); } + std::vector bonusFeatures() { return bonusFeatures_; } //bonus features for track quality - int ReducedId( + int reducedId( int layerId); //Converts layer ID (1~6->L1~L6;11~15->D1~D5) to reduced layer ID (0~5->L1~L6;6~10->D1~D5) int findLayer(int layerId); //Search for a layer ID from sensor modules private: - int etaSector_; - int hitpattern_; + const Setup* setup_; + bool hphDebug_; + bool useNewKF_; + std::vector etaRegions_; + std::map>> layermap_; + int nKalmanLayers_; + int etaBin_; + int cotBin_; + int zTBin_; + std::vector layerEncoding_; + std::map layerEncodingMap_; int numExpLayer_; + int hitpattern_; + int etaSector_; int numMissingLayer_; int numMissingPS_; int numMissing2S_; @@ -112,18 +138,8 @@ namespace hph { int num2S_; int numMissingInterior1_; int numMissingInterior2_; - double cot_; - double z0_; - const Setup* setup_; - std::vector layers_; //Sensor modules that particles are expected to hit std::vector binary_; - bool hphDebug_; - bool useNewKF_; - float chosenRofZ_; - float deltaTanL_; // Uncertainty added to tanL (cot) when layermap in new KF is determined - std::vector etaRegions_; - int nKalmanLayers_; - std::map>> layermap_; + std::vector bonusFeatures_; }; } // namespace hph diff --git a/L1Trigger/TrackTrigger/interface/HitPatternHelperRcd.h b/L1Trigger/TrackFindingTracklet/interface/HitPatternHelperRcd.h similarity index 69% rename from L1Trigger/TrackTrigger/interface/HitPatternHelperRcd.h rename to L1Trigger/TrackFindingTracklet/interface/HitPatternHelperRcd.h index 8b13f07e9f8be..0e74761f2ddaa 100644 --- a/L1Trigger/TrackTrigger/interface/HitPatternHelperRcd.h +++ b/L1Trigger/TrackFindingTracklet/interface/HitPatternHelperRcd.h @@ -6,14 +6,14 @@ #define L1Trigger_TrackTrigger_interface_HitPatternHelperRcd_h #include "FWCore/Framework/interface/DependentRecordImplementation.h" - #include "L1Trigger/TrackTrigger/interface/SetupRcd.h" - +#include "L1Trigger/TrackerTFP/interface/DataFormatsRcd.h" +#include "L1Trigger/TrackerTFP/interface/LayerEncodingRcd.h" #include "FWCore/Utilities/interface/mplVector.h" namespace hph { - typedef edm::mpl::Vector Rcds; + typedef edm::mpl::Vector Rcds; // record of hph::SetupRcd class SetupRcd : public edm::eventsetup::DependentRecordImplementation {}; diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 220e72b46d91f..c0a30f1972dcb 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -88,6 +88,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/Residual.h" #include "L1Trigger/TrackFindingTracklet/interface/Stub.h" #include "L1Trigger/TrackFindingTracklet/interface/StubStreamData.h" +#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h" //////////////// // PHYSICS TOOLS @@ -99,7 +100,6 @@ #include "L1Trigger/TrackTrigger/interface/StubPtConsistency.h" #include "L1Trigger/TrackTrigger/interface/L1TrackQuality.h" -#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h" ////////////// // STD HEADERS @@ -350,9 +350,6 @@ void L1FPGATrackProducer::beginRun(const edm::Run& run, const edm::EventSetup& i setup_ = &iSetup.getData(esGetToken_); setupHPH_ = &iSetup.getData(esGetTokenHPH_); - if (trackQuality_) { - trackQualityModel_->beginRun(setupHPH_); - } // Tracklet pattern reco output channel info. channelAssignment_ = &iSetup.getData(esGetTokenChannelAssignment_); // initialize the tracklet event processing (this sets all the processing & memory modules, wiring, etc) @@ -722,6 +719,11 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe trackQualityModel_->setL1TrackQuality(aTrack); } + // hph::HitPatternHelper hph(setupHPH_, tmp_hit, tmp_tanL, tmp_z0); + // if (trackQuality_) { + // trackQualityModel_->setBonusFeatures(hph.bonusFeatures()); + // } + // test track word //aTrack.testTrackWordBits(); diff --git a/L1Trigger/TrackTrigger/plugins/ProducerHPH.cc b/L1Trigger/TrackFindingTracklet/plugins/ProducerHPH.cc similarity index 56% rename from L1Trigger/TrackTrigger/plugins/ProducerHPH.cc rename to L1Trigger/TrackFindingTracklet/plugins/ProducerHPH.cc index e46d0be9f4bb3..cb308b8b628ea 100644 --- a/L1Trigger/TrackTrigger/plugins/ProducerHPH.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/ProducerHPH.cc @@ -10,8 +10,10 @@ #include "FWCore/Utilities/interface/ESGetToken.h" #include "FWCore/Utilities/interface/ESInputTag.h" #include "DataFormats/Provenance/interface/ParameterSetID.h" -#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h" +#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h" #include "L1Trigger/TrackTrigger/interface/Setup.h" +#include "L1Trigger/TrackerTFP/interface/DataFormats.h" +#include "L1Trigger/TrackerTFP/interface/LayerEncoding.h" #include @@ -28,17 +30,23 @@ namespace hph { private: const ParameterSet iConfig_; - ESGetToken getTokenSetup_; + ESGetToken esGetTokenSetup_; + ESGetToken esGetTokenDataFormats_; + ESGetToken esGetTokenLayerEncoding_; }; ProducerHPH::ProducerHPH(const ParameterSet& iConfig) : iConfig_(iConfig) { auto cc = setWhatProduced(this); - getTokenSetup_ = cc.consumes(); + esGetTokenSetup_ = cc.consumes(); + esGetTokenDataFormats_ = cc.consumes(); + esGetTokenLayerEncoding_ = cc.consumes(); } unique_ptr ProducerHPH::produce(const SetupRcd& Rcd) { - const tt::Setup& setupTT = Rcd.get(getTokenSetup_); - return make_unique(iConfig_, setupTT); + const tt::Setup& setupTT = Rcd.get(esGetTokenSetup_); + const trackerTFP::DataFormats& dataFormats = Rcd.get(esGetTokenDataFormats_); + const trackerTFP::LayerEncoding& layerEncoding = Rcd.get(esGetTokenLayerEncoding_); + return make_unique(iConfig_, setupTT, dataFormats, layerEncoding); } } // namespace hph diff --git a/L1Trigger/TrackFindingTracklet/python/L1HybridEmulationTracks_cff.py b/L1Trigger/TrackFindingTracklet/python/L1HybridEmulationTracks_cff.py index 63eeb319ff0e4..a91e4a26d08ae 100644 --- a/L1Trigger/TrackFindingTracklet/python/L1HybridEmulationTracks_cff.py +++ b/L1Trigger/TrackFindingTracklet/python/L1HybridEmulationTracks_cff.py @@ -6,7 +6,7 @@ from SimTracker.TrackTriggerAssociation.TrackTriggerAssociator_cff import * -from L1Trigger.TrackTrigger.ProducerHPH_cff import * +from L1Trigger.TrackFindingTracklet.ProducerHPH_cff import * # prompt hybrid emulation TTTrackAssociatorFromPixelDigis.TTTracks = cms.VInputTag(cms.InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks") ) diff --git a/L1Trigger/TrackTrigger/python/ProducerHPH_cff.py b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py similarity index 60% rename from L1Trigger/TrackTrigger/python/ProducerHPH_cff.py rename to L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py index d788e09a4748b..9bc3718c98da3 100644 --- a/L1Trigger/TrackTrigger/python/ProducerHPH_cff.py +++ b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms -from L1Trigger.TrackTrigger.ProducerHPH_cfi import HitPatternHelper_params +from L1Trigger.TrackFindingTracklet.ProducerHPH_cfi import HitPatternHelper_params HitPatternHelperSetup = cms.ESProducer("hph::ProducerHPH", HitPatternHelper_params) diff --git a/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cfi.py b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cfi.py new file mode 100644 index 0000000000000..a53cf62a9524a --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cfi.py @@ -0,0 +1,12 @@ +import FWCore.ParameterSet.Config as cms +from L1Trigger.TrackFindingTMTT.TMTrackProducer_Defaults_cfi import TMTrackProducer_params + +# ParameterSet used by HitPatternHelper + +HitPatternHelper_params = cms.PSet ( + + hphDebug = cms.bool(False), # switch on/off debug statement + useNewKF = cms.bool(False), # switch between new/old KF + oldKFPSet = cms.PSet(TMTrackProducer_params.EtaSectors) # import eta sector boundries from old kf package + +) diff --git a/L1Trigger/TrackTrigger/src/ES_HitPatternHelper.cc b/L1Trigger/TrackFindingTracklet/src/ES_HitPatternHelper.cc similarity index 63% rename from L1Trigger/TrackTrigger/src/ES_HitPatternHelper.cc rename to L1Trigger/TrackFindingTracklet/src/ES_HitPatternHelper.cc index 24881410dc8f7..f2bb09a2833b3 100644 --- a/L1Trigger/TrackTrigger/src/ES_HitPatternHelper.cc +++ b/L1Trigger/TrackFindingTracklet/src/ES_HitPatternHelper.cc @@ -3,6 +3,6 @@ // #include "FWCore/Utilities/interface/typelookup.h" -#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h" +#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h" TYPELOOKUP_DATA_REG(hph::Setup); diff --git a/L1Trigger/TrackTrigger/src/HitPatternHelper.cc b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc similarity index 65% rename from L1Trigger/TrackTrigger/src/HitPatternHelper.cc rename to L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc index 53ef5bfc01bd1..bb3eada6ea447 100644 --- a/L1Trigger/TrackTrigger/src/HitPatternHelper.cc +++ b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc @@ -2,7 +2,7 @@ // Created by J.Li on 1/23/21. // -#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h" +#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h" #include "L1Trigger/TrackFindingTMTT/interface/KFbase.h" #include "L1Trigger/TrackFindingTMTT/interface/TrackerModule.h" @@ -13,37 +13,63 @@ namespace hph { - Setup::Setup(const edm::ParameterSet& iConfig, const tt::Setup& setupTT) + Setup::Setup(const edm::ParameterSet& iConfig, + const tt::Setup& setupTT, + const trackerTFP::DataFormats& dataFormats, + const trackerTFP::LayerEncoding& layerEncoding) : iConfig_(iConfig), + oldKFPSet_(iConfig.getParameter("oldKFPSet")), setupTT_(setupTT), - layerIds_(), + dataFormats_(dataFormats), + dfcot_(dataFormats_.format(trackerTFP::Variable::cot, trackerTFP::Process::kfin)), + dfzT_(dataFormats_.format(trackerTFP::Variable::zT, trackerTFP::Process::kfin)), + layerEncoding_(layerEncoding), + hphDebug_(iConfig.getParameter("hphDebug")), + useNewKF_(iConfig.getParameter("useNewKF")), + chosenRofZNewKF_(setupTT_.chosenRofZ()), + etaRegionsNewKF_(setupTT_.boundarieEta()), layermap_(), nEtaRegions_(tmtt::KFbase::nEta_ / 2), nKalmanLayers_(tmtt::KFbase::nKFlayer_) { - for (const tt::SensorModule& sm : setupTT_.sensorModules()) { - layerIds_.push_back(std::make_pair(sm.layerId(), sm.barrel())); + if (useNewKF_) { + chosenRofZ_ = chosenRofZNewKF_; + etaRegions_ = etaRegionsNewKF_; + } else { + chosenRofZ_ = oldKFPSet_.getParameter("ChosenRofZ"); + etaRegions_ = oldKFPSet_.getParameter>("EtaRegions"); } - sort(layerIds_.begin(), layerIds_.end(), smallerID); - layerIds_.erase(unique(layerIds_.begin(), layerIds_.end(), equalID), layerIds_.end()); //Keep only unique layerIds + static constexpr auto layerIds = {1, 2, 3, 4, 5, 6, 11, 12, 13, 14, 15}; //layer ID 11~15 correspond to D1~D5 // Converting tmtt::KFbase::layerMap_ to a format that is acceptatble by HitPatternHelper for (int i = 0; i < nEtaRegions_; i++) { - for (int j = 0; j < (int)layerIds_.size(); j++) { + for (int j : layerIds) { int layer; - if (layerIds_[j].second) { - layer = tmtt::KFbase::layerMap_[i][tmtt::TrackerModule::calcLayerIdReduced(layerIds_[j].first)].first; + if (j < 7) { + layer = tmtt::KFbase::layerMap_[i][tmtt::TrackerModule::calcLayerIdReduced(j)].first; } else { - layer = tmtt::KFbase::layerMap_[i][tmtt::TrackerModule::calcLayerIdReduced(layerIds_[j].first)].second; + layer = tmtt::KFbase::layerMap_[i][tmtt::TrackerModule::calcLayerIdReduced(j)].second; } if (layer < nKalmanLayers_) { - layermap_[i][layer].push_back(layerIds_[j].first); + layermap_[i][layer].push_back(j); } } } } HitPatternHelper::HitPatternHelper(const Setup* setup, int hitpattern, double cot, double z0) - : hitpattern_(hitpattern), - numExpLayer_(0), + : setup_(setup), + hphDebug_(setup_->hphDebug()), + useNewKF_(setup_->useNewKF()), + etaRegions_(setup_->etaRegions()), + layermap_(setup_->layermap()), + nKalmanLayers_(setup_->nKalmanLayers()), + etaBin_(setup_->etaRegion(z0, cot, true)), + cotBin_(setup_->digiCot(cot, etaBin_)), + zTBin_(setup_->digiZT(z0, cot, etaBin_)), + layerEncoding_(setup->layerEncoding(etaBin_, zTBin_, cotBin_)), + layerEncodingMap_(setup->layerEncodingMap(etaBin_, zTBin_, cotBin_)), + numExpLayer_(layerEncoding_.size()), + hitpattern_(hitpattern), + etaSector_(setup_->etaRegion(z0, cot, useNewKF_)), numMissingLayer_(0), numMissingPS_(0), numMissing2S_(0), @@ -51,53 +77,14 @@ namespace hph { num2S_(0), numMissingInterior1_(0), numMissingInterior2_(0), - cot_(cot), - z0_(z0), - setup_(setup), - binary_(11, 0), - hphDebug_(setup_->hphDebug()), - useNewKF_(setup_->useNewKF()), - chosenRofZ_(setup_->chosenRofZ()), - deltaTanL_(setup_->deltaTanL()), - etaRegions_(setup_->etaRegions()), - nKalmanLayers_(setup_->nKalmanLayers()), - layermap_(setup_->layermap()) { - //Calculating eta sector based on cot and z0 - float kfzRef = z0_ + chosenRofZ_ * cot_; - int kf_eta_reg = 0; - for (int iEtaSec = 1; iEtaSec < ((int)etaRegions_.size() - 1); iEtaSec++) { // Doesn't apply eta < 2.4 cut. - float etaMax = etaRegions_[iEtaSec]; - float zRefMax = chosenRofZ_ / tan(2. * atan(exp(-etaMax))); - if (kfzRef > zRefMax) { - kf_eta_reg = iEtaSec; - } - } - etaSector_ = kf_eta_reg; + binary_(11, 0), //there are 11 unique layer IDs, as defined in variable "layerIds" + bonusFeatures_() { + int kf_eta_reg = etaSector_; if (kf_eta_reg < ((int)etaRegions_.size() - 1) / 2) { kf_eta_reg = ((int)etaRegions_.size() - 1) / 2 - 1 - kf_eta_reg; } else { kf_eta_reg = kf_eta_reg - (int)(etaRegions_.size() - 1) / 2; } - //Looping over sensor modules to make predictions on which layers particles are expected to hit - for (const tt::SensorModule& sm : setup_->sensorModules()) { - double d = (z0_ - sm.z() + sm.r() * cot_) / (sm.cosTilt() - sm.sinTilt() * cot_); - double d_p = - (z0_ - sm.z() + sm.r() * (cot_ + deltaTanL_ / 2)) / (sm.cosTilt() - sm.sinTilt() * (cot_ + deltaTanL_ / 2)); - double d_m = - (z0_ - sm.z() + sm.r() * (cot_ - deltaTanL_ / 2)) / (sm.cosTilt() - sm.sinTilt() * (cot_ - deltaTanL_ / 2)); - if (useNewKF_ && - (abs(d_p) < sm.numColumns() * sm.pitchCol() / 2. || abs(d_m) < sm.numColumns() * sm.pitchCol() / 2.)) { - layers_.push_back(sm); - } - if (!useNewKF_ && abs(d) < sm.numColumns() * sm.pitchCol() / 2.) { - layers_.push_back(sm); - } - } - //layers_ constains all the sensor modules that particles are expected to hit - sort(layers_.begin(), layers_.end(), smallerID); - layers_.erase(unique(layers_.begin(), layers_.end(), equalID), layers_.end()); //Keep only one sensor per layer - - numExpLayer_ = layers_.size(); int nbits = floor(log2(hitpattern_)) + 1; int lay_i = 0; @@ -141,10 +128,10 @@ namespace hph { if (hphDebug_) { edm::LogVerbatim("TrackTriggerHPH") << "--------------------------"; edm::LogVerbatim("TrackTriggerHPH") << "Looking at KF layer " << i; - if (layers_[i].layerId() < 10) { - edm::LogVerbatim("TrackTriggerHPH") << "KF expects L" << layers_[i].layerId(); + if (layerEncoding_[i] < 10) { + edm::LogVerbatim("TrackTriggerHPH") << "KF expects L" << layerEncoding_[i]; } else { - edm::LogVerbatim("TrackTriggerHPH") << "KF expects D" << layers_[i].layerId() - 10; + edm::LogVerbatim("TrackTriggerHPH") << "KF expects D" << layerEncoding_[i] - 10; } } @@ -153,8 +140,8 @@ namespace hph { edm::LogVerbatim("TrackTriggerHPH") << "Layer found in hitpattern"; } - binary_[ReducedId(layers_[i].layerId())] = 1; - if (layers_[i].psModule()) { + binary_[reducedId(layerEncoding_[i])] = 1; + if (layerEncodingMap_[layerEncoding_[i]]->psModule()) { numPS_++; } else { num2S_++; @@ -164,7 +151,7 @@ namespace hph { edm::LogVerbatim("TrackTriggerHPH") << "Layer missing in hitpattern"; } - if (layers_[i].psModule()) { + if (layerEncodingMap_[layerEncoding_[i]]->psModule()) { numMissingPS_++; } else { numMissing2S_++; @@ -219,8 +206,8 @@ namespace hph { edm::LogVerbatim("TrackTriggerHPH") << "Layer found in hitpattern"; } - binary_[ReducedId(j)] = 1; - if (layers_[k].psModule()) { + binary_[reducedId(j)] = 1; + if (layerEncodingMap_[layerEncoding_[k]]->psModule()) { numPS_++; } else { num2S_++; @@ -230,7 +217,7 @@ namespace hph { edm::LogVerbatim("TrackTriggerHPH") << "Layer missing in hitpattern"; } - if (layers_[k].psModule()) { + if (layerEncodingMap_[layerEncoding_[k]]->psModule()) { numMissingPS_++; } else { numMissing2S_++; @@ -248,7 +235,41 @@ namespace hph { } } - int HitPatternHelper::ReducedId(int layerId) { + int Setup::etaRegion(double z0, double cot, bool useNewKF) const { + //Calculating eta sector based on cot and z0 + double chosenRofZ; + std::vector etaRegions; + if (useNewKF) { + chosenRofZ = chosenRofZNewKF_; + etaRegions = etaRegionsNewKF_; + } else { + chosenRofZ = chosenRofZ_; + etaRegions = etaRegions_; + } + double kfzRef = z0 + chosenRofZ * cot; + int kf_eta_reg = 0; + for (int iEtaSec = 1; iEtaSec < ((int)etaRegions.size() - 1); iEtaSec++) { // Doesn't apply eta < 2.4 cut. + double etaMax = etaRegions[iEtaSec]; + double zRefMax = chosenRofZ / tan(2. * atan(exp(-etaMax))); + if (kfzRef > zRefMax) { + kf_eta_reg = iEtaSec; + } + } + return kf_eta_reg; + } + + int Setup::digiCot(double cot, int binEta) const { + double cotLocal = dfcot_.digi(cot - setupTT_.sectorCot(binEta)); + return dfcot_.toUnsigned(dfcot_.integer(cotLocal)); + } + + int Setup::digiZT(double z0, double cot, int binEta) const { + double zT = z0 + setupTT_.chosenRofZ() * cot; + double zTLocal = dfzT_.digi(zT - setupTT_.sectorCot(binEta) * setupTT_.chosenRofZ()); + return dfzT_.toUnsigned(dfzT_.integer(zTLocal)); + } + + int HitPatternHelper::reducedId(int layerId) { if (hphDebug_ && (layerId > 15 || layerId < 1)) { edm::LogVerbatim("TrackTriggerHPH") << "Warning: invalid layer id !"; } @@ -259,11 +280,11 @@ namespace hph { layerId = layerId - 5; return layerId; } - }; + } int HitPatternHelper::findLayer(int layerId) { - for (int i = 0; i < (int)layers_.size(); i++) { - if (layerId == (int)layers_[i].layerId()) { + for (int i = 0; i < (int)layerEncoding_.size(); i++) { + if (layerId == (int)layerEncoding_[i]) { return i; } } diff --git a/L1Trigger/TrackTrigger/src/HitPatternHelperRcd.cc b/L1Trigger/TrackFindingTracklet/src/HitPatternHelperRcd.cc similarity index 67% rename from L1Trigger/TrackTrigger/src/HitPatternHelperRcd.cc rename to L1Trigger/TrackFindingTracklet/src/HitPatternHelperRcd.cc index b502d531ccc05..302d4084e62b6 100644 --- a/L1Trigger/TrackTrigger/src/HitPatternHelperRcd.cc +++ b/L1Trigger/TrackFindingTracklet/src/HitPatternHelperRcd.cc @@ -2,7 +2,7 @@ // Created by J.Li on 1/23/21. // -#include "L1Trigger/TrackTrigger/interface/HitPatternHelperRcd.h" +#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelperRcd.h" #include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" EVENTSETUP_RECORD_REG(hph::SetupRcd); diff --git a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml index 94d63baf35cbd..104eabaf8dcde 100644 --- a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml @@ -39,6 +39,5 @@ - diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py index 5f63520975198..5fff0a1926ad1 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py @@ -17,6 +17,8 @@ process.load( 'Configuration.StandardSequences.MagneticField_cff' ) process.load( 'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff' ) process.load( 'L1Trigger.TrackTrigger.TrackTrigger_cff' ) +process.load( 'L1Trigger.TrackerTFP.ProducerES_cff' ) +process.load( 'L1Trigger.TrackerTFP.ProducerLayerEncoding_cff' ) from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') @@ -112,4 +114,4 @@ outputCommands = cms.untracked.vstring('drop *', 'keep *_TTTrack*_*_*', 'keep *_TTStub*_*_*' ) ) process.FEVToutput_step = cms.EndPath( process.out ) - process.schedule.append( process.FEVToutput_step ) \ No newline at end of file + process.schedule.append( process.FEVToutput_step ) diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc index dea1f5092cf78..683da96a6abfb 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc @@ -56,7 +56,7 @@ //////////////// // PHYSICS TOOLS -#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h" +#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" #include "CLHEP/Units/PhysicalConstants.h" diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index 7bf733e0277c3..caf43f4927114 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -100,6 +100,8 @@ ############################################################ process.load('L1Trigger.TrackTrigger.TrackTrigger_cff') +process.load('L1Trigger.TrackerTFP.ProducerES_cff') +process.load('L1Trigger.TrackerTFP.ProducerLayerEncoding_cff') # remake stubs? #from L1Trigger.TrackTrigger.TTStubAlgorithmRegister_cfi import * diff --git a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h index 5de1cbd4caac0..5763a825e1ab4 100644 --- a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h +++ b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h @@ -20,7 +20,6 @@ C.Brown 28/07/20 #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/L1TrackTrigger/interface/TTTrack.h" #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" -#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h" #include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h" #include @@ -58,7 +57,7 @@ class L1TrackQuality { std::string const& ONNXInputName, std::vector const& featureNames); - void beginRun(const hph::Setup* setup); + void setBonusFeatures(std::vector bonusFeatures); private: // Private Member Data @@ -72,8 +71,8 @@ class L1TrackQuality { float bendchi2Max_; float minPt_; int nStubsmin_; - const hph::Setup* setupHPH_; bool useHPH_; + std::vector bonusFeatures_; std::unique_ptr runTime_; }; #endif diff --git a/L1Trigger/TrackTrigger/python/ProducerHPH_cfi.py b/L1Trigger/TrackTrigger/python/ProducerHPH_cfi.py deleted file mode 100644 index ddc4aaa4c1431..0000000000000 --- a/L1Trigger/TrackTrigger/python/ProducerHPH_cfi.py +++ /dev/null @@ -1,11 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -# ParameterSet used by HitPatternHelper - -HitPatternHelper_params = cms.PSet ( - - hphDebug = cms.bool(False), - useNewKF = cms.bool(False), - deltaTanL = cms.double(0.125) - -) diff --git a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc index 06c9dfa1a99dc..60e23bddb8c09 100644 --- a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc +++ b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc @@ -10,7 +10,7 @@ C.Brown & C.Savard 07/2020 L1TrackQuality::L1TrackQuality() {} -L1TrackQuality::L1TrackQuality(const edm::ParameterSet& qualityParams) : setupHPH_(), useHPH_(false) { +L1TrackQuality::L1TrackQuality(const edm::ParameterSet& qualityParams) : useHPH_(false), bonusFeatures_() { std::string AlgorithmString = qualityParams.getParameter("qualityAlgorithm"); // Unpacks EDM parameter set itself to save unecessary processing within TrackProducers if (AlgorithmString == "Cut") { @@ -67,14 +67,6 @@ std::vector L1TrackQuality::featureTransform(TTTrack>, TTStub>> stubRefs = aTrack.getStubRefs(); @@ -197,8 +189,7 @@ void L1TrackQuality::setONNXModel(std::string const& AlgorithmString, featureNames_ = featureNames; } -void L1TrackQuality::beginRun(const hph::Setup* setupHPH) { - // Initialize helper for decoding hit patterns. - setupHPH_ = setupHPH; +void L1TrackQuality::setBonusFeatures(std::vector bonusFeatures) { + bonusFeatures_ = bonusFeatures; useHPH_ = true; } diff --git a/L1Trigger/TrackerTFP/interface/LayerEncoding.h b/L1Trigger/TrackerTFP/interface/LayerEncoding.h index 52052d243b3be..a5adaf15b8b0b 100644 --- a/L1Trigger/TrackerTFP/interface/LayerEncoding.h +++ b/L1Trigger/TrackerTFP/interface/LayerEncoding.h @@ -4,6 +4,7 @@ #include "FWCore/Framework/interface/data_default_record_trait.h" #include "L1Trigger/TrackerTFP/interface/LayerEncodingRcd.h" #include "L1Trigger/TrackerTFP/interface/DataFormats.h" +#include "L1Trigger/TrackTrigger/interface/SensorModule.h" #include @@ -24,6 +25,9 @@ namespace trackerTFP { const std::vector& layerEncoding(int binEta, int binZT, int binCot) const { return layerEncoding_.at(binEta).at(binZT).at(binCot); } + const std::map& layerEncodingMap(int binEta, int binZT, int binCot) const { + return layerEncodingMap_.at(binEta).at(binZT).at(binCot); + } // maybe layers for given ets sector, bin in zT and bin in cotThea const std::vector& maybeLayer(int binEta, int binZT, int binCot) const { return maybeLayer_.at(binEta).at(binZT).at(binCot); @@ -44,6 +48,7 @@ namespace trackerTFP { const DataFormat* cot_; // outer to inner indices: eta sector, bin in zT, bin in cotTheta, layerId std::vector>>> layerEncoding_; + std::vector>>> layerEncodingMap_; // outer to inner indices: eta sector, bin in zT, bin in cotTheta, layerId of maybe layers std::vector>>> maybeLayer_; }; @@ -52,4 +57,4 @@ namespace trackerTFP { EVENTSETUP_DATA_DEFAULT_RECORD(trackerTFP::LayerEncoding, trackerTFP::LayerEncodingRcd); -#endif \ No newline at end of file +#endif diff --git a/L1Trigger/TrackerTFP/src/LayerEncoding.cc b/L1Trigger/TrackerTFP/src/LayerEncoding.cc index 353bc55167248..0687987c3bd25 100644 --- a/L1Trigger/TrackerTFP/src/LayerEncoding.cc +++ b/L1Trigger/TrackerTFP/src/LayerEncoding.cc @@ -1,5 +1,4 @@ #include "L1Trigger/TrackerTFP/interface/LayerEncoding.h" -#include "L1Trigger/TrackTrigger/interface/SensorModule.h" #include #include @@ -20,6 +19,9 @@ namespace trackerTFP { cot_(&dataFormats->format(Variable::cot, Process::zht)), layerEncoding_(setup_->numSectorsEta(), vector>>(pow(2, zT_->width()), vector>(pow(2, cot_->width())))), + layerEncodingMap_(setup_->numSectorsEta(), + vector>>( + pow(2, zT_->width()), vector>(pow(2, cot_->width())))), maybeLayer_(setup_->numSectorsEta(), vector>>(pow(2, zT_->width()), vector>(pow(2, cot_->width())))) { // number of boundaries of fiducial area in r-z plane for a given set of rough r-z track parameter @@ -58,6 +60,7 @@ namespace trackerTFP { const double cot = cot_->floating(cot_->toSigned(binCot)); // layer ids crossed by left and right rough r-z parameter shape boundaries vector> layers(boundaries); + map& layermaps = layerEncodingMap_[binEta][binZT][binCot]; // cotTheta wrt sectorCot of this bin boundaries const vector cots = {sectorCot + cot - cot_->base() / 2., sectorCot + cot + cot_->base() / 2.}; // loop over all unique modules @@ -71,8 +74,10 @@ namespace trackerTFP { const double d = (zTi - sm->z() + (sm->r() - setup_->chosenRofZ()) * coti) / (sm->cosTilt() - sm->sinTilt() * coti); // compare distance with module size and add module layer id to layers if module is crossed - if (abs(d) < sm->numColumns() * sm->pitchCol() / 2.) + if (abs(d) < sm->numColumns() * sm->pitchCol() / 2.) { layers[i].insert(sm->layerId()); + layermaps[sm->layerId()] = sm; + } } } // mayber layers are given by layer ids crossed by only one booundary @@ -165,4 +170,4 @@ namespace trackerTFP { return ttBV; } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP From 9e898972d25378dbd3747a2a1a494f46f912b9d9 Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Tue, 4 Oct 2022 10:44:47 +0200 Subject: [PATCH 07/30] Update FitTrack.cc Fixed comment in code --- L1Trigger/TrackFindingTracklet/src/FitTrack.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 3c4874e58fe70..fe6bbb9c04842 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -1038,7 +1038,7 @@ void FitTrack::execute(deque& streamTrackRaw, // store bit and clock accurate TB output if (settings_.storeTrackBuilderOutput() && bestTracklet) { - // add gap if enough layer to form track + // add gap if TrackBuilder rejected track (due to too few stub layers). if (!bestTracklet->fit()) { static const string invalid = "0"; streamTrackRaw.emplace_back(invalid); @@ -1074,7 +1074,7 @@ void FitTrack::execute(deque& streamTrackRaw, streamsStubRaw[ihit++].emplace_back(seedType, *stub, valid + r + phi + rz); } } - // fill all layer with no stubs with gaps + // fill all layers that have no stubs with gaps while (ihit < streamsStubRaw.size()) { streamsStubRaw[ihit++].emplace_back(); } From a9a4fffd5481ea9d78c487af12b32c1a4c0cdf1d Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Thu, 13 Oct 2022 16:20:31 +0100 Subject: [PATCH 08/30] Added option to print digi format (#187) --- L1Trigger/TrackerTFP/src/DataFormats.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/L1Trigger/TrackerTFP/src/DataFormats.cc b/L1Trigger/TrackerTFP/src/DataFormats.cc index c1cf78285c04d..628b32a4b0f50 100644 --- a/L1Trigger/TrackerTFP/src/DataFormats.cc +++ b/L1Trigger/TrackerTFP/src/DataFormats.cc @@ -69,6 +69,11 @@ namespace trackerTFP { numStreamsTracks_ = vector(+Process::end, 0); numStreamsTracks_[+Process::kfin] = numStreams_[+Process::kf]; numStreamsTracks_[+Process::kf] = numStreams_[+Process::kf]; + // Print digi data format of all variables of any specified algo step + //for (const Variable v : tracks_[+Process::kf]) { + // const DataFormat& f = format(v, Process::kf); + // cout <<" KF "<< f.base() << " " << f.range() << " " << f.width() << endl; + //} } // constructs data formats of all unique used variables and flavours From e0a65075ce1cf17a14259b1d05825ef7bd78a4e1 Mon Sep 17 00:00:00 2001 From: Austin Townsend Date: Wed, 26 Oct 2022 14:17:01 -0400 Subject: [PATCH 09/30] Atownse2 calc bend cuts (#178) * CalcBendCuts - Uses bend encoding to decode bend * Modified CalcBendCuts to be off by default, changed nzbinsPhiCorr to 1 by default * Added changed in TP LUT and set default nzbinsPhiCorr to 1 * Turned off CalcBendCuts and revised comments * PR Cleanup * More PR cleanup * Address PR comments * code-format --- .../TrackFindingTracklet/interface/Settings.h | 63 ++ .../interface/TrackletLUT.h | 25 +- .../TrackFindingTracklet/interface/Util.h | 23 +- .../plugins/L1FPGATrackProducer.cc | 3 + L1Trigger/TrackFindingTracklet/src/Sector.cc | 7 +- .../src/TrackletEngine.cc | 12 +- .../TrackFindingTracklet/src/TrackletLUT.cc | 563 +++++++++++++++--- .../TrackTrigger/interface/SensorModule.h | 2 + L1Trigger/TrackTrigger/interface/Setup.h | 3 + .../python/TTStubAlgorithmRegister_cfi.py | 2 +- L1Trigger/TrackTrigger/src/SensorModule.cc | 27 +- 11 files changed, 639 insertions(+), 91 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 5b161dac26e05..db5aee94ffe6a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -14,6 +14,10 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" +namespace tt { + class Setup; +} + namespace trklet { constexpr unsigned int N_SECTOR = 9; // # of phi sectors for L1TK processing @@ -62,6 +66,9 @@ namespace trklet { ~Settings() = default; + void passSetup(const tt::Setup* setup) { setup_ = setup; } + const tt::Setup* setup() const { return setup_; } + // processing & memory modules, wiring, etc. std::string const& fitPatternFile() const { return fitPatternFile_; } std::string const& processingModulesFile() const { return processingModulesFile_; } @@ -168,6 +175,9 @@ namespace trklet { double zmax(unsigned int iDisk) const { return zmean(iDisk) + dzmax(); } double zmin(unsigned int iDisk) const { return zmean(iDisk) - dzmax(); } + double zmindisk(unsigned int iDisk) const { return zmean(iDisk) - zsepdisk_ / 2; } + double zmaxdisk(unsigned int iDisk) const { return zmean(iDisk) + zsepdisk_ / 2; } + double rDSSinner(unsigned int iBin) const { return rDSSinner_mod_[iBin / 2] + halfstrip_ * ((iBin % 2 == 0) ? -1 : 1); } @@ -273,6 +283,8 @@ namespace trklet { void setStripPitch_PS(double stripPitch_PS) { stripPitch_PS_ = stripPitch_PS; } void setStripPitch_2S(double stripPitch_2S) { stripPitch_2S_ = stripPitch_2S; } + double sensorSpacing2S() const { return sensorSpacing_2S_; } + double stripLength(bool isPSmodule) const { return isPSmodule ? stripLength_PS_ : stripLength_2S_; } void setStripLength_PS(double stripLength_PS) { stripLength_PS_ = stripLength_PS; } void setStripLength_2S(double stripLength_2S) { stripLength_2S_ = stripLength_2S; } @@ -450,6 +462,23 @@ namespace trklet { return fact * bendcut(ibend, layerdisk, isPSmodule); } + bool useCalcBendCuts = true; + + double bendcutTE(unsigned int seed, bool inner) const { + if (inner) { + return bendcutTE_[seed][0]; + } else { + return bendcutTE_[seed][1]; + } + } + + double bendcutME(unsigned int layerdisk, bool isPSmodule) const { + if (layerdisk >= N_LAYER && (!isPSmodule)) + layerdisk += N_DISK; + + return bendcutME_[layerdisk]; + } + //layers/disks used by each seed std::array, N_SEED> seedlayers() const { return seedlayers_; } @@ -460,6 +489,8 @@ namespace trklet { std::array, N_SEED> projdisks() const { return projdisks_; } private: + const tt::Setup* setup_; + std::string fitPatternFile_; std::string processingModulesFile_; std::string memoryModulesFile_; @@ -542,6 +573,8 @@ namespace trklet { double rmaxdisk_{120.0}; double rmindisk_{20.0}; + double zsepdisk_{1.5}; //cm + double half2SmoduleWidth_{4.57}; double maxrinv_{0.006}; @@ -788,6 +821,34 @@ namespace trklet { {{2.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5}}, //D4 2S {{2.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5}}}}; //D5 2S + double FEbendcut = sqrt(1 / 6.0); + + double bendcutTE_[N_SEED_PROMPT][2] = {{2.2 * FEbendcut, 2.5 * FEbendcut}, //L1L2 + {2.0 * FEbendcut, 2.0 * FEbendcut}, //L2L3 + {2.0 * FEbendcut, 2.6 * FEbendcut}, //L3L4 + {2.4 * FEbendcut, 2.4 * FEbendcut}, //L5L6 + {2.5 * FEbendcut, 2.2 * FEbendcut}, //D1D2 PS + {2.0 * FEbendcut, 2.0 * FEbendcut}, //D3D4 PS + {2.0 * FEbendcut, 2.4 * FEbendcut}, //L1D1 PS + {2.2 * FEbendcut, 2.2 * FEbendcut}}; //L2D1 PS + + double bendcutME_[N_LAYER + 2 * N_DISK] = {2.0 * FEbendcut, //0 L1 + 2.5 * FEbendcut, //1 L2 + 2.0 * FEbendcut, //2 L3 + 2.5 * FEbendcut, //3 L4 + 2.2 * FEbendcut, //4 L5 + 2.3 * FEbendcut, //5 L6 + 4.0 * FEbendcut, //6 D1 PS + 3.5 * FEbendcut, //7 D2 PS + 3.5 * FEbendcut, //8 D3 PS + 3.5 * FEbendcut, //9 D4 PS + 2.7 * FEbendcut, //10 D5 PS + 3.5 * FEbendcut, //11 D1 2S + 3.4 * FEbendcut, //12 D2 2S + 3.5 * FEbendcut, //13 D3 2S + 3.7 * FEbendcut, //14 D4 2S + 3.5 * FEbendcut}; //15 D5 2S + // Offset to the maximum number of steps in each processing step: // Set to 0 (default) means standard truncation // Set to large value, e.g. 10000, to disable truncation @@ -968,6 +1029,8 @@ namespace trklet { double stripLength_PS_{0.1467}; double stripLength_2S_{5.0250}; + + double sensorSpacing_2S_{0.18}; }; constexpr unsigned int N_TILTED_RINGS = 12; // # of tilted rings per half-layer in TBPS layers diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h index b6438428adaec..b71238aaa78ca 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h @@ -10,6 +10,10 @@ #include #include +#include "L1Trigger/TrackTrigger/interface/Setup.h" + +class Setup; + namespace trklet { class Settings; @@ -93,13 +97,28 @@ namespace trklet { unsigned int size() const { return table_.size(); } private: + const Settings& settings_; + const tt::Setup* setup_; + + //Determine bend/bend cuts in LUT regions + std::vector getSensorModules(unsigned int layerdisk, + bool isPS, + std::array tan_range = {{-1, -1}}, + unsigned int nzbins = 1, + unsigned int zbin = 0); + + std::array getTanRange(const std::vector& sensorModules); + + std::vector> getBendCut(unsigned int layerdisk, + const std::vector& sensorModules, + bool isPS, + double FEbendcut = 0); + int getphiCorrValue( - unsigned int layerdisk, unsigned int ibend, unsigned int irbin, double rmean, double dr, double drmax) const; + unsigned int layerdisk, double bend, unsigned int irbin, double rmean, double dr, double drmax) const; int getVMRLookup(unsigned int layerdisk, double z, double r, double dz, double dr, int iseed = -1) const; - const Settings& settings_; - std::string name_; std::vector table_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Util.h b/L1Trigger/TrackFindingTracklet/interface/Util.h index deaf18936d052..1af25813c8360 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Util.h +++ b/L1Trigger/TrackFindingTracklet/interface/Util.h @@ -39,13 +39,30 @@ namespace trklet { return str; } - inline double bendstrip(double r, double rinv, double stripPitch) { - constexpr double dr = 0.18; - double delta = r * dr * 0.5 * rinv; + inline double bendstrip(double r, double rinv, double stripPitch, double sensorSpacing) { + double delta = r * sensorSpacing * 0.5 * rinv; double bend = delta / stripPitch; return bend; } + inline double convertFEBend( + double FEbend, double sensorSep, double sensorSpacing, double CF, bool barrel, double r = 0) { + double bend = sensorSpacing * CF * FEbend / sensorSep; + return bend; + } + + inline double tan_theta(double r, double z, double z0, bool z0_max) { + //Calculates tan(theta) = z_displaced/r + //measure tan theta at different points to account for displaced tracks + double tan; + if (z0_max) + tan = (z - z0) / r; + else + tan = (z + z0) / r; + + return tan; + } + inline double rinv(double phi1, double phi2, double r1, double r2) { assert(r1 < r2); //Can not form tracklet should not call function with r2<=r1 diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index c0a30f1972dcb..26c8ad4233fc5 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -349,6 +349,9 @@ void L1FPGATrackProducer::beginRun(const edm::Run& run, const edm::EventSetup& i settings_.setBfield(mMagneticFieldStrength); setup_ = &iSetup.getData(esGetToken_); + + settings_.passSetup(setup_); + setupHPH_ = &iSetup.getData(esGetTokenHPH_); // Tracklet pattern reco output channel info. channelAssignment_ = &iSetup.getData(esGetTokenChannelAssignment_); diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index f3cd083cf729b..b17e9adf692fb 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -71,10 +71,11 @@ void Sector::setSector(unsigned int isector) { bool Sector::addStub(L1TStub stub, string dtc) { unsigned int layerdisk = stub.layerdisk(); + int nrbits = 3; if (layerdisk < N_LAYER && globals_->phiCorr(layerdisk) == nullptr) { globals_->phiCorr(layerdisk) = new TrackletLUT(settings_); - globals_->phiCorr(layerdisk)->initPhiCorrTable(layerdisk, 3); + globals_->phiCorr(layerdisk)->initPhiCorrTable(layerdisk, nrbits); } Stub fpgastub(stub, settings_, *globals_); @@ -82,9 +83,9 @@ bool Sector::addStub(L1TStub stub, string dtc) { if (layerdisk < N_LAYER) { FPGAWord r = fpgastub.r(); int bendbin = fpgastub.bend().value(); - int rbin = (r.value() + (1 << (r.nbits() - 1))) >> (r.nbits() - 3); + int rbin = (r.value() + (1 << (r.nbits() - 1))) >> (r.nbits() - nrbits); const TrackletLUT& phiCorrTable = *globals_->phiCorr(layerdisk); - int iphicorr = phiCorrTable.lookup(bendbin * (1 << 3) + rbin); + int iphicorr = phiCorrTable.lookup(bendbin * (1 << nrbits) + rbin); fpgastub.setPhiCorr(iphicorr); } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc index 7f32e78191fbc..4510ce2079561 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc @@ -95,7 +95,7 @@ void TrackletEngine::execute() { countall++; const VMStubTE& outervmstub = outervmstubs_->getVMStubTEBinned(ibin, j); - int rzbin = outervmstub.vmbits().bits(0, 3); + int rzbin = outervmstub.vmbits().bits(0, N_RZBITS); FPGAWord iphiinnerbin = innervmstub.finephi(); FPGAWord iphiouterbin = outervmstub.finephi(); @@ -103,12 +103,16 @@ void TrackletEngine::execute() { unsigned int index = (iphiinnerbin.value() << outerphibits_) + iphiouterbin.value(); if (iSeed_ >= 4) { //Also use r-position - int ir = ((ibin & 3) << 1) + (rzbin >> 2); - index = (index << 3) + ir; + + int nrbits = 3; // Number of bits used for r position in disk LUT + int ibinmask = (1 << (nrbits - 1)) - 1; // Mask of two least significant bits + + int ir = ((ibin & ibinmask) << 1) + (rzbin >> (N_RZBITS - 1)); + index += (ir << (outerphibits_ + innerphibits_)); } if (start != ibin) - rzbin += 8; + rzbin += (1 << N_RZBITS); if ((rzbin < rzbinfirst) || (rzbin - rzbinfirst > rzdiffmax)) { continue; } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index a07bd4694a24d..ae24c5bf8f8ac 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -2,14 +2,187 @@ #include "L1Trigger/TrackFindingTracklet/interface/Util.h" #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h" -#include "L1Trigger/L1TCommon/interface/BitShift.h" +#include "L1Trigger/TrackTrigger/interface/Setup.h" #include using namespace std; using namespace trklet; -TrackletLUT::TrackletLUT(const Settings& settings) : settings_(settings) {} +TrackletLUT::TrackletLUT(const Settings& settings) : settings_(settings), setup_(settings.setup()) {} + +std::vector TrackletLUT::getSensorModules( + unsigned int layerdisk, bool isPS, std::array tan_range, unsigned int nzbins, unsigned int zbin) { + //Returns a vector of SensorModules using T. Schuh's Setup and SensorModule classes. + //Can be used 3 ways: + //Default: No specified tan_range or nzbins, returns all SensorModules in specified layerdisk (unique in |z|) + //tan_range: Returns modules in given tan range, where the min and max tan(theta) are measured from 0 -/+ z0 to account for displaced tracks + //zbins: Returns modules in specified z bin (2 zbins = (Flat, Tilted), 13 zbins = (Flat, TR1, ..., TR12). Only for tilted barrel + + bool use_tan_range = !(tan_range[0] == -1 and tan_range[1] == -1); + bool use_zbins = (nzbins > 1); + + bool barrel = layerdisk < N_LAYER; + + int layerId = barrel ? layerdisk + 1 : layerdisk + N_LAYER - 1; + + std::vector sensorModules; + + double z0 = settings_.z0cut(); + + for (auto& sm : setup_->sensorModules()) { + if (sm.layerId() != layerId || sm.z() < 0 || sm.psModule() != isPS) { + continue; + } + + if (use_tan_range) { + double rmin = sm.r() - (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.sinTilt()); + double rmax = sm.r() + (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.sinTilt()); + + double zmin = std::abs(sm.z()) - (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.cosTilt()); + double zmax = std::abs(sm.z()) + (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.cosTilt()); + + //z0_max is swapped here so that the comparison down 5 lines is from same origin (+/- z0) + double mod_tan_max = tan_theta(rmin, zmax, z0, false); + double mod_tan_min = tan_theta(rmax, zmin, z0, true); + + if (mod_tan_max >= tan_range[0] && mod_tan_min <= tan_range[1]) { + sensorModules.push_back(&sm); + } + } else if (use_zbins) { + assert(layerdisk < 3); + + if (nzbins == 2) { + bool useFlat = (zbin == 0); + bool isFlat = (sm.tilt() == 0); + + if (useFlat and isFlat) + sensorModules.push_back(&sm); + else if (!useFlat and !isFlat) + sensorModules.push_back(&sm); + } else if (nzbins == 13) { + if (sm.ringId(setup_) == zbin) + sensorModules.push_back(&sm); + } else { + throw cms::Exception("Unspecified number of z bins"); + } + } else { + sensorModules.push_back(&sm); + } + } + + //Remove Duplicate Modules + static constexpr double delta = 1.e-3; + auto smallerR = [](const tt::SensorModule* lhs, const tt::SensorModule* rhs) { return lhs->r() < rhs->r(); }; + auto smallerZ = [](const tt::SensorModule* lhs, const tt::SensorModule* rhs) { return lhs->z() < rhs->z(); }; + auto equalRZ = [](const tt::SensorModule* lhs, const tt::SensorModule* rhs) { + return abs(lhs->r() - rhs->r()) < delta && abs(lhs->z() - rhs->z()) < delta; + }; + stable_sort(sensorModules.begin(), sensorModules.end(), smallerR); + stable_sort(sensorModules.begin(), sensorModules.end(), smallerZ); + sensorModules.erase(unique(sensorModules.begin(), sensorModules.end(), equalRZ), sensorModules.end()); + + return sensorModules; +} + +std::array TrackletLUT::getTanRange(const std::vector& sensorModules) { + //Given a set of modules returns a range in tan(theta), the angle is measured in the r-z(+/-z0) plane from the r-axis + + std::array tan_range = {{2147483647, 0}}; //(tan_min, tan_max) + + double z0 = settings_.z0cut(); + + for (auto sm : sensorModules) { + double rmin = sm->r() - (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * std::abs(sm->sinTilt()); + double rmax = sm->r() + (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * std::abs(sm->sinTilt()); + + double zmin = std::abs(sm->z()) - (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * sm->cosTilt(); + double zmax = std::abs(sm->z()) + (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * sm->cosTilt(); + + double mod_tan_max = tan_theta(rmin, zmax, z0, true); //(r, z, z0, bool z0_max), z0_max measures from +/- z0 + double mod_tan_min = tan_theta(rmax, zmin, z0, false); + + if (mod_tan_min < tan_range[0]) + tan_range[0] = mod_tan_min; + if (mod_tan_max > tan_range[1]) + tan_range[1] = mod_tan_max; + } + return tan_range; +} + +std::vector> TrackletLUT::getBendCut(unsigned int layerdisk, + const std::vector& sensorModules, + bool isPS, + double FEbendcut) { + //Finds range of bendstrip for given SensorModules as a function of the encoded bend. Returns in format (mid, half_range). + //This uses the stub windows provided by T. Schuh's SensorModule class to determine the bend encoding. TODO test changes in stub windows + //Any other change to the bend encoding requires changes here, perhaps a function that given (FEbend, isPS, stub window) and outputs an encoded bend + //would be useful for consistency. + + unsigned int bendbits = isPS ? 3 : 4; + + std::vector> bendpars; // mid, cut + std::vector> bendminmax; // min, max + + //Initialize array + for (int i = 0; i < 1 << bendbits; i++) { + bendpars.push_back({{99, 0}}); + bendminmax.push_back({{99, -99}}); + } + + //Loop over modules + for (auto sm : sensorModules) { + int window = sm->windowSize(); //Half-strip units + const vector& encodingBend = setup_->encodingBend(window, isPS); + + //Loop over FEbends + for (int ibend = 0; ibend <= 2 * window; ibend++) { + int FEbend = ibend - window; //Half-strip units + double BEbend = setup_->stubAlgorithm()->degradeBend(isPS, window, FEbend); //Full strip units + + const auto pos = std::find(encodingBend.begin(), encodingBend.end(), std::abs(BEbend)); + int bend = std::signbit(BEbend) ? (1 << bendbits) - distance(encodingBend.begin(), pos) + : distance(encodingBend.begin(), pos); //Encoded bend + + double bendmin = FEbend / 2.0 - FEbendcut; //Full Strip units + double bendmax = FEbend / 2.0 + FEbendcut; + + //Convert to bendstrip, calculate at module edges (z min, r max) and (z max, r min) + double z_mod[2]; + double r_mod[2]; + + z_mod[0] = std::abs(sm->z()) + (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * sm->cosTilt(); //z max + z_mod[1] = std::abs(sm->z()) - (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * sm->cosTilt(); //z min + + r_mod[0] = sm->r() - (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * std::abs(sm->sinTilt()); //r min + r_mod[1] = sm->r() + (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * std::abs(sm->sinTilt()); //r max + + for (int i = 0; i < 2; i++) { // 2 points to cover range in tan(theta) = z/r + double CF = std::abs(sm->sinTilt()) * (z_mod[i] / r_mod[i]) + sm->cosTilt(); + + double cbendmin = + convertFEBend(bendmin, sm->sep(), settings_.sensorSpacing2S(), CF, (layerdisk < N_LAYER), r_mod[i]); + double cbendmax = + convertFEBend(bendmax, sm->sep(), settings_.sensorSpacing2S(), CF, (layerdisk < N_LAYER), r_mod[i]); + + if (cbendmin < bendminmax[bend][0]) + bendminmax.at(bend)[0] = cbendmin; + if (cbendmax > bendminmax[bend][1]) + bendminmax.at(bend)[1] = cbendmax; + } + } + } + //Convert min, max to mid, cut for ease of use + for (int i = 0; i < 1 << bendbits; i++) { + double mid = (bendminmax[i][1] + bendminmax[i][0]) / 2; + double cut = (bendminmax[i][1] - bendminmax[i][0]) / 2; + + bendpars[i][0] = mid; + bendpars[i][1] = cut; + } + + return bendpars; +} void TrackletLUT::initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region) { char cregion = 'A' + region; @@ -118,15 +291,25 @@ void TrackletLUT::initTPlut(bool fillInner, double dphi[2]; double router[2]; - unsigned int nbendbitsinner = 3; - unsigned int nbendbitsouter = 3; + bool isPSinner; + bool isPSouter; + if (iSeed == Seed::L3L4) { - nbendbitsouter = 4; + isPSinner = true; + isPSouter = false; } else if (iSeed == Seed::L5L6) { - nbendbitsinner = 4; - nbendbitsouter = 4; + isPSinner = false; + isPSouter = false; + } else { + isPSinner = true; + isPSouter = true; } + unsigned int nbendbitsinner = isPSinner ? N_BENDBITS_PS : N_BENDBITS_2S; + unsigned int nbendbitsouter = isPSouter ? N_BENDBITS_PS : N_BENDBITS_2S; + + double z0 = settings_.z0cut(); + int nbinsfinephidiff = (1 << nbitsfinephidiff); for (int iphibin = 0; iphibin < nbinsfinephidiff; iphibin++) { @@ -148,11 +331,64 @@ void TrackletLUT::initTPlut(bool fillInner, router[1] = settings_.rmean(layerdisk2); } + //Determine bend cuts using geometry + std::vector> bend_cuts_inner; + std::vector> bend_cuts_outer; + + if (settings_.useCalcBendCuts) { + std::vector sminner; + std::vector smouter; + + if (iSeed == Seed::L1L2 || iSeed == Seed::L2L3 || iSeed == Seed::L3L4 || iSeed == Seed::L5L6) { + double outer_tan_max = tan_theta(settings_.rmean(layerdisk2), settings_.zlength(), z0, true); + std::array tan_range = {{0, outer_tan_max}}; + + smouter = getSensorModules(layerdisk2, isPSouter, tan_range); + sminner = getSensorModules(layerdisk1, isPSinner, tan_range); + + } else if (iSeed == Seed::L1D1 || iSeed == Seed::L2D1) { + double outer_tan_min = tan_theta(router[1], settings_.zmindisk(layerdisk2 - N_LAYER), z0, false); + double outer_tan_max = tan_theta(router[0], settings_.zmaxdisk(layerdisk2 - N_LAYER), z0, true); + + smouter = getSensorModules(layerdisk2, isPSouter, {{outer_tan_min, outer_tan_max}}); + std::array tan_range = getTanRange(smouter); + sminner = getSensorModules(layerdisk1, isPSinner, tan_range); + + } else { // D1D2 D3D4 + + double outer_tan_min = tan_theta(router[1], settings_.zmindisk(layerdisk2 - N_LAYER), z0, false); + double outer_tan_max = tan_theta(router[0], settings_.zmaxdisk(layerdisk2 - N_LAYER), z0, true); + + smouter = getSensorModules(layerdisk2, isPSouter, {{outer_tan_min, outer_tan_max}}); + + std::array tan_range = getTanRange(smouter); + sminner = getSensorModules(layerdisk1, isPSinner, tan_range); + } + + bend_cuts_inner = getBendCut(layerdisk1, sminner, isPSinner, settings_.bendcutTE(iSeed, true)); + bend_cuts_outer = getBendCut(layerdisk2, smouter, isPSouter, settings_.bendcutTE(iSeed, false)); + + } else { + for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) { + double mid = settings_.benddecode(ibend, layerdisk1, isPSinner); + double cut = settings_.bendcutte(ibend, layerdisk1, isPSinner); + bend_cuts_inner.push_back({{mid, cut}}); + } + for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) { + double mid = settings_.benddecode(ibend, layerdisk2, isPSouter); + double cut = settings_.bendcutte(ibend, layerdisk2, isPSouter); + bend_cuts_outer.push_back({{mid, cut}}); + } + } + double bendinnermin = 20.0; double bendinnermax = -20.0; double bendoutermin = 20.0; double bendoutermax = -20.0; double rinvmin = 1.0; + double rinvmax = -1.0; + double absrinvmin = 1.0; + for (int i2 = 0; i2 < 2; i2++) { for (int i3 = 0; i3 < 2; i3++) { double rinner = 0.0; @@ -161,12 +397,16 @@ void TrackletLUT::initTPlut(bool fillInner, } else { rinner = settings_.rmean(layerdisk1); } + if (settings_.useCalcBendCuts) { + if (rinner >= router[i3]) + continue; + } 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); - double abendinner = bendstrip(rinner, rinv1, pitchinner); - double abendouter = bendstrip(router[i3], rinv1, pitchouter); + double abendinner = bendstrip(rinner, rinv1, pitchinner, settings_.sensorSpacing2S()); + double abendouter = bendstrip(router[i3], rinv1, pitchouter, settings_.sensorSpacing2S()); if (abendinner < bendinnermin) bendinnermin = abendinner; if (abendinner > bendinnermax) @@ -175,28 +415,53 @@ void TrackletLUT::initTPlut(bool fillInner, bendoutermin = abendouter; if (abendouter > bendoutermax) bendoutermax = abendouter; - if (std::abs(rinv1) < rinvmin) { - rinvmin = std::abs(rinv1); - } + if (std::abs(rinv1) < absrinvmin) + absrinvmin = std::abs(rinv1); + if (rinv1 > rinvmax) + rinvmax = rinv1; + if (rinv1 < rinvmin) + rinvmin = rinv1; } } - bool passptcut = rinvmin < settings_.rinvcutte(); + bool passptcut; + double bendfac; + double rinvcutte = settings_.rinvcutte(); + + if (settings_.useCalcBendCuts) { + double lowrinvcutte = + rinvcutte / 3; //Somewhat arbitrary value, allows for better acceptance in bins with low rinv (high pt) + passptcut = rinvmin < rinvcutte and rinvmax > -rinvcutte; + bendfac = (rinvmin < lowrinvcutte and rinvmax > -lowrinvcutte) + ? 1.05 + : 1.0; //Somewhat arbirary value, bend cuts are 5% larger in bins with low rinv (high pt) + } else { + passptcut = absrinvmin < rinvcutte; + bendfac = 1.0; + } if (fillInner) { for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) { - double bend = settings_.benddecode(ibend, layerdisk1, nbendbitsinner == 3); + double bendminfac = (isPSinner and (ibend == 2 or ibend == 3)) ? bendfac : 1.0; + double bendmaxfac = (isPSinner and (ibend == 6 or ibend == 5)) ? bendfac : 1.0; + + double mid = bend_cuts_inner.at(ibend)[0]; + double cut = bend_cuts_inner.at(ibend)[1]; + + bool passinner = mid + cut * bendmaxfac > bendinnermin && mid - cut * bendminfac < bendinnermax; - bool passinner = bend <= bendinnermax + settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3) && - bend >= bendinnermin - settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3); table_.push_back(passinner && passptcut); } } else { for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) { - double bend = settings_.benddecode(ibend, layerdisk2, nbendbitsouter == 3); + double bendminfac = (isPSouter and (ibend == 2 or ibend == 3)) ? bendfac : 1.0; + double bendmaxfac = (isPSouter and (ibend == 6 or ibend == 5)) ? bendfac : 1.0; + + double mid = bend_cuts_outer.at(ibend)[0]; + double cut = bend_cuts_outer.at(ibend)[1]; + + bool passouter = mid + cut * bendmaxfac > bendoutermin && mid - cut * bendminfac < bendoutermax; - bool passouter = bend <= bendoutermax + settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3) && - bend >= bendoutermin - settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3); table_.push_back(passouter && passptcut); } } @@ -300,16 +565,23 @@ void TrackletLUT::initteptlut(bool fillInner, double phiouter[2]; double router[2]; - unsigned int nbendbitsinner = 3; - unsigned int nbendbitsouter = 3; + bool isPSinner; + bool isPSouter; + if (iSeed == Seed::L3L4) { - nbendbitsouter = 4; - } - if (iSeed == Seed::L5L6) { - nbendbitsinner = 4; - nbendbitsouter = 4; + isPSinner = true; + isPSouter = false; + } else if (iSeed == Seed::L5L6) { + isPSinner = false; + isPSouter = false; + } else { + isPSinner = true; + isPSouter = true; } + unsigned int nbendbitsinner = isPSinner ? N_BENDBITS_PS : N_BENDBITS_2S; + unsigned int nbendbitsouter = isPSouter ? N_BENDBITS_PS : N_BENDBITS_2S; + if (fillTEMem) { if (fillInner) { table_.resize((1 << nbendbitsinner), false); @@ -318,28 +590,83 @@ void TrackletLUT::initteptlut(bool fillInner, } } - for (int iphiinnerbin = 0; iphiinnerbin < innerphibins; iphiinnerbin++) { - phiinner[0] = innerphimin + iphiinnerbin * (innerphimax - innerphimin) / innerphibins; - phiinner[1] = innerphimin + (iphiinnerbin + 1) * (innerphimax - innerphimin) / innerphibins; - for (int iphiouterbin = 0; iphiouterbin < outerphibins; iphiouterbin++) { - phiouter[0] = outerphimin + iphiouterbin * (outerphimax - outerphimin) / outerphibins; - phiouter[1] = outerphimin + (iphiouterbin + 1) * (outerphimax - outerphimin) / outerphibins; - for (int irouterbin = 0; irouterbin < outerrbins; irouterbin++) { - if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1 || iSeed == Seed::L2D1) { - router[0] = - settings_.rmindiskvm() + irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; - router[1] = settings_.rmindiskvm() + - (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; - } else { - router[0] = settings_.rmean(layerdisk2); - router[1] = settings_.rmean(layerdisk2); - } + double z0 = settings_.z0cut(); + + for (int irouterbin = 0; irouterbin < outerrbins; irouterbin++) { + if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1 || iSeed == Seed::L2D1) { + router[0] = settings_.rmindiskvm() + irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; + router[1] = + settings_.rmindiskvm() + (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; + } else { + router[0] = settings_.rmean(layerdisk2); + router[1] = settings_.rmean(layerdisk2); + } + + //Determine bend cuts using geometry + std::vector> bend_cuts_inner; + std::vector> bend_cuts_outer; + + if (settings_.useCalcBendCuts) { + std::vector sminner; + std::vector smouter; + + if (iSeed == Seed::L1L2 || iSeed == Seed::L2L3 || iSeed == Seed::L3L4 || iSeed == Seed::L5L6) { + double outer_tan_max = tan_theta(settings_.rmean(layerdisk2), settings_.zlength(), z0, true); + std::array tan_range = {{0, outer_tan_max}}; + + smouter = getSensorModules(layerdisk2, isPSouter, tan_range); + sminner = getSensorModules(layerdisk1, isPSinner, tan_range); + + } else if (iSeed == Seed::L1D1 || iSeed == Seed::L2D1) { + double outer_tan_min = tan_theta(router[1], settings_.zmindisk(layerdisk2 - N_LAYER), z0, false); + double outer_tan_max = tan_theta(router[0], settings_.zmaxdisk(layerdisk2 - N_LAYER), z0, true); + + smouter = getSensorModules(layerdisk2, isPSouter, {{outer_tan_min, outer_tan_max}}); + std::array tan_range = getTanRange(smouter); + sminner = getSensorModules(layerdisk1, isPSinner, tan_range); + + } else { // D1D2 D3D4 + + double outer_tan_min = tan_theta(router[1], settings_.zmindisk(layerdisk2 - N_LAYER), z0, false); + double outer_tan_max = tan_theta(router[0], settings_.zmaxdisk(layerdisk2 - N_LAYER), z0, true); + + smouter = getSensorModules(layerdisk2, isPSouter, {{outer_tan_min, outer_tan_max}}); + + std::array tan_range = getTanRange(smouter); + sminner = getSensorModules(layerdisk1, isPSinner, tan_range); + } + + bend_cuts_inner = getBendCut(layerdisk1, sminner, isPSinner, settings_.bendcutTE(iSeed, true)); + bend_cuts_outer = getBendCut(layerdisk2, smouter, isPSouter, settings_.bendcutTE(iSeed, false)); + + } else { + for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) { + double mid = settings_.benddecode(ibend, layerdisk1, nbendbitsinner == 3); + double cut = settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3); + bend_cuts_inner.push_back({{mid, cut}}); + } + for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) { + double mid = settings_.benddecode(ibend, layerdisk2, nbendbitsouter == 3); + double cut = settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3); + bend_cuts_outer.push_back({{mid, cut}}); + } + } + + for (int iphiinnerbin = 0; iphiinnerbin < innerphibins; iphiinnerbin++) { + phiinner[0] = innerphimin + iphiinnerbin * (innerphimax - innerphimin) / innerphibins; + phiinner[1] = innerphimin + (iphiinnerbin + 1) * (innerphimax - innerphimin) / innerphibins; + for (int iphiouterbin = 0; iphiouterbin < outerphibins; iphiouterbin++) { + phiouter[0] = outerphimin + iphiouterbin * (outerphimax - outerphimin) / outerphibins; + phiouter[1] = outerphimin + (iphiouterbin + 1) * (outerphimax - outerphimin) / outerphibins; double bendinnermin = 20.0; double bendinnermax = -20.0; double bendoutermin = 20.0; double bendoutermax = -20.0; double rinvmin = 1.0; + double rinvmax = -1.0; + double absrinvmin = 1.0; + for (int i1 = 0; i1 < 2; i1++) { for (int i2 = 0; i2 < 2; i2++) { for (int i3 = 0; i3 < 2; i3++) { @@ -349,13 +676,21 @@ void TrackletLUT::initteptlut(bool fillInner, } else { rinner = settings_.rmean(layerdisk1); } + + if (settings_.useCalcBendCuts) { + if (rinner >= router[i3]) + continue; + } + 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 = (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double abendinner = bendstrip(rinner, rinv1, pitchinner); - double abendouter = bendstrip(router[i3], rinv1, pitchouter); + + double abendinner = bendstrip(rinner, rinv1, pitchinner, settings_.sensorSpacing2S()); + double abendouter = bendstrip(router[i3], rinv1, pitchouter, settings_.sensorSpacing2S()); + if (abendinner < bendinnermin) bendinnermin = abendinner; if (abendinner > bendinnermax) @@ -364,40 +699,59 @@ void TrackletLUT::initteptlut(bool fillInner, bendoutermin = abendouter; if (abendouter > bendoutermax) bendoutermax = abendouter; - if (std::abs(rinv1) < rinvmin) { - rinvmin = std::abs(rinv1); - } + if (std::abs(rinv1) < absrinvmin) + absrinvmin = std::abs(rinv1); + if (rinv1 > rinvmax) + rinvmax = rinv1; + if (rinv1 < rinvmin) + rinvmin = rinv1; } } } - bool passptcut = rinvmin < settings_.rinvcutte(); + double lowrinvcutte = 0.002; + + bool passptcut; + double bendfac; + + if (settings_.useCalcBendCuts) { + passptcut = rinvmin < settings_.rinvcutte() and rinvmax > -settings_.rinvcutte(); + bendfac = (rinvmin < lowrinvcutte and rinvmax > -lowrinvcutte) ? 1.05 : 1.0; // Better acceptance for high pt + } else { + passptcut = absrinvmin < settings_.rinvcutte(); + bendfac = 1.0; + } if (fillInner) { for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) { - double bend = settings_.benddecode(ibend, layerdisk1, nbendbitsinner == 3); + double bendminfac = (isPSinner and (ibend == 2 or ibend == 3)) ? bendfac : 1.0; + double bendmaxfac = (isPSinner and (ibend == 6 or ibend == 5)) ? bendfac : 1.0; + + double mid = bend_cuts_inner.at(ibend)[0]; + double cut = bend_cuts_inner.at(ibend)[1]; - bool passinner = bend > bendinnermin - settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3) && - bend < bendinnermax + settings_.bendcutte(ibend, layerdisk1, nbendbitsinner == 3); + bool passinner = mid + cut * bendmaxfac > bendinnermin && mid - cut * bendminfac < bendinnermax; if (fillTEMem) { - if (passinner) { + if (passinner) table_[ibend] = 1; - } } else { table_.push_back(passinner && passptcut); } } } else { for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) { - double bend = settings_.benddecode(ibend, layerdisk2, nbendbitsouter == 3); + double bendminfac = (isPSouter and (ibend == 2 or ibend == 3)) ? bendfac : 1.0; + double bendmaxfac = (isPSouter and (ibend == 6 or ibend == 5)) ? bendfac : 1.0; + + double mid = bend_cuts_outer.at(ibend)[0]; + double cut = bend_cuts_outer.at(ibend)[1]; + + bool passouter = mid + cut * bendmaxfac > bendoutermin && mid - cut * bendminfac < bendoutermax; - bool passouter = bend > bendoutermin - settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3) && - bend < bendoutermax + settings_.bendcutte(ibend, layerdisk2, nbendbitsouter == 3); if (fillTEMem) { - if (passouter) { + if (passouter) table_[ibend] = 1; - } } else { table_.push_back(passouter && passptcut); } @@ -423,7 +777,6 @@ void TrackletLUT::initteptlut(bool fillInner, name_ += "_stubptoutercut.tab"; } } - writeTable(); } @@ -457,7 +810,7 @@ void TrackletLUT::initProjectionBend(double k_phider, double rinv = -phider * (2.0 * t); double stripPitch = (rproj < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double bendproj = bendstrip(rproj, rinv, stripPitch); + double bendproj = bendstrip(rproj, rinv, stripPitch, settings_.sensorSpacing2S()); static double maxbend = (1 << NRINVBITS) - 1; @@ -484,36 +837,85 @@ void TrackletLUT::initBendMatch(unsigned int layerdisk) { double rinvhalf = 0.5 * ((1 << nrinv) - 1); bool barrel = layerdisk < N_LAYER; - bool isPSmodule = layerdisk < N_PSLAYER; - double stripPitch = settings_.stripPitch(isPSmodule); if (barrel) { + bool isPSmodule = layerdisk < N_PSLAYER; + double stripPitch = settings_.stripPitch(isPSmodule); unsigned int nbits = isPSmodule ? N_BENDBITS_PS : N_BENDBITS_2S; + std::vector> bend_cuts; + + if (settings_.useCalcBendCuts) { + double bendcutFE = settings_.bendcutME(layerdisk, isPSmodule); + std::vector sm = getSensorModules(layerdisk, isPSmodule); + bend_cuts = getBendCut(layerdisk, sm, isPSmodule, bendcutFE); + + } else { + for (unsigned int ibend = 0; ibend < (1u << nbits); ibend++) { + double mid = settings_.benddecode(ibend, layerdisk, isPSmodule); + double cut = settings_.bendcutte(ibend, layerdisk, isPSmodule); + bend_cuts.push_back({{mid, cut}}); + } + } + for (unsigned int irinv = 0; irinv < (1u << nrinv); irinv++) { double rinv = (irinv - rinvhalf) * (1 << (settings_.nbitsrinv() - nrinv)) * settings_.krinvpars(); - double projbend = bendstrip(settings_.rmean(layerdisk), rinv, stripPitch); + double projbend = bendstrip(settings_.rmean(layerdisk), rinv, stripPitch, settings_.sensorSpacing2S()); for (unsigned int ibend = 0; ibend < (1u << nbits); ibend++) { - double stubbend = settings_.benddecode(ibend, layerdisk, isPSmodule); - bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk, isPSmodule); + double mid = bend_cuts[ibend][0]; + double cut = bend_cuts[ibend][1]; + + double pass = mid + cut > projbend && mid - cut < projbend; + table_.push_back(pass); } } } else { + std::vector> bend_cuts_2S; + std::vector> bend_cuts_PS; + + if (settings_.useCalcBendCuts) { + double bendcutFE2S = settings_.bendcutME(layerdisk, false); + std::vector sm2S = getSensorModules(layerdisk, false); + bend_cuts_2S = getBendCut(layerdisk, sm2S, false, bendcutFE2S); + + double bendcutFEPS = settings_.bendcutME(layerdisk, true); + std::vector smPS = getSensorModules(layerdisk, true); + bend_cuts_PS = getBendCut(layerdisk, smPS, true, bendcutFEPS); + + } else { + for (unsigned int ibend = 0; ibend < (1 << N_BENDBITS_2S); ibend++) { + double mid = settings_.benddecode(ibend, layerdisk, false); + double cut = settings_.bendcutme(ibend, layerdisk, false); + bend_cuts_2S.push_back({{mid, cut}}); + } + for (unsigned int ibend = 0; ibend < (1 << N_BENDBITS_PS); ibend++) { + double mid = settings_.benddecode(ibend, layerdisk, true); + double cut = settings_.bendcutme(ibend, layerdisk, true); + bend_cuts_PS.push_back({{mid, cut}}); + } + } + for (unsigned int iprojbend = 0; iprojbend < (1u << nrinv); iprojbend++) { double projbend = 0.5 * (iprojbend - rinvhalf); for (unsigned int ibend = 0; ibend < (1 << N_BENDBITS_2S); ibend++) { - double stubbend = settings_.benddecode(ibend, layerdisk, false); - bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk, false); + double mid = bend_cuts_2S[ibend][0]; + double cut = bend_cuts_2S[ibend][1]; + + double pass = mid + cut > projbend && mid - cut < projbend; + table_.push_back(pass); } } - for (unsigned int iprojbend = 0; iprojbend < (1u << nrinv); iprojbend++) { + for (unsigned int iprojbend = 0; iprojbend < (1u << nrinv); iprojbend++) { //Should this be binned in r? double projbend = 0.5 * (iprojbend - rinvhalf); for (unsigned int ibend = 0; ibend < (1 << N_BENDBITS_PS); ibend++) { - double stubbend = settings_.benddecode(ibend, layerdisk, true); - bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk, true); + double mid = bend_cuts_PS[ibend][0]; + double cut = bend_cuts_PS[ibend][1]; + + double pass = mid + cut > projbend && mid - cut < projbend; + table_.push_back(pass); } } @@ -871,11 +1273,22 @@ void TrackletLUT::initPhiCorrTable(unsigned int layerdisk, unsigned int rbits) { double dr = 2.0 * drmax / rbins; - unsigned int bendbins = (1 << bendbits); + std::vector> bend_vals; + + if (settings_.useCalcBendCuts) { + std::vector sm = getSensorModules(layerdisk, psmodule); + bend_vals = getBendCut(layerdisk, sm, psmodule); - for (unsigned int ibend = 0; ibend < bendbins; ibend++) { + } else { + for (int ibend = 0; ibend < 1 << bendbits; ibend++) { + bend_vals.push_back({{settings_.benddecode(ibend, layerdisk, layerdisk < N_PSLAYER), 0}}); + } + } + + for (int ibend = 0; ibend < 1 << bendbits; ibend++) { for (unsigned int irbin = 0; irbin < rbins; irbin++) { - int value = getphiCorrValue(layerdisk, ibend, irbin, rmean, dr, drmax); + double bend = -bend_vals[ibend][0]; + int value = getphiCorrValue(layerdisk, bend, irbin, rmean, dr, drmax); table_.push_back(value); } } @@ -888,11 +1301,9 @@ void TrackletLUT::initPhiCorrTable(unsigned int layerdisk, unsigned int rbits) { } int TrackletLUT::getphiCorrValue( - unsigned int layerdisk, unsigned int ibend, unsigned int irbin, double rmean, double dr, double drmax) const { + unsigned int layerdisk, double bend, unsigned int irbin, double rmean, double dr, double drmax) const { bool psmodule = layerdisk < N_PSLAYER; - double bend = -settings_.benddecode(ibend, layerdisk, psmodule); - //for the rbin - calculate the distance to the nominal layer radius double Delta = (irbin + 0.5) * dr - drmax; diff --git a/L1Trigger/TrackTrigger/interface/SensorModule.h b/L1Trigger/TrackTrigger/interface/SensorModule.h index e111af06eeb0f..a10c701f24344 100644 --- a/L1Trigger/TrackTrigger/interface/SensorModule.h +++ b/L1Trigger/TrackTrigger/interface/SensorModule.h @@ -70,6 +70,8 @@ namespace tt { // double tiltCorrection(double cot) const { return std::abs(tiltCorrectionSlope_ * cot) + tiltCorrectionIntercept_; } + unsigned int ringId(const Setup* setup) const; + private: enum TypeTilt { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 }; // cmssw det id diff --git a/L1Trigger/TrackTrigger/interface/Setup.h b/L1Trigger/TrackTrigger/interface/Setup.h index 5a36cc5cac026..584e8823e7a68 100644 --- a/L1Trigger/TrackTrigger/interface/Setup.h +++ b/L1Trigger/TrackTrigger/interface/Setup.h @@ -512,6 +512,9 @@ namespace tt { // internal memory depth int drDepthMemory() const { return drDepthMemory_; } + //getBendCut + const StubAlgorithmOfficial* stubAlgorithm() const { return stubAlgorithm_; } + private: // checks consitency between history and current configuration for a specific module void checkHistory(const edm::ProcessHistory&, diff --git a/L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py b/L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py index b386315251859..16276daa49e51 100644 --- a/L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py +++ b/L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py @@ -25,7 +25,7 @@ cms.PSet( TiltedCut = cms.vdouble( 0, 3, 3, 2.5, 3, 3, 2.5, 2.5, 2, 1.5, 1.5, 1, 1) ), cms.PSet( TiltedCut = cms.vdouble( 0, 3.5, 3, 3, 3, 3, 2.5, 2.5, 3, 3, 2.5, 2.5, 2.5) ), cms.PSet( TiltedCut = cms.vdouble( 0, 4, 4, 4, 3.5, 3.5, 3.5, 3.5, 3, 3, 3, 3, 3) ), - ), + ), EndcapCutSet = cms.VPSet( cms.PSet( EndcapCut = cms.vdouble( 0 ) ), cms.PSet( EndcapCut = cms.vdouble( 0, 1, 2.5, 2.5, 3, 2.5, 3, 3.5, 4, 4, 4.5, 3.5, 4, 4.5, 5, 5.5) ), diff --git a/L1Trigger/TrackTrigger/src/SensorModule.cc b/L1Trigger/TrackTrigger/src/SensorModule.cc index de8011d3e2f60..e30e75819c744 100644 --- a/L1Trigger/TrackTrigger/src/SensorModule.cc +++ b/L1Trigger/TrackTrigger/src/SensorModule.cc @@ -119,4 +119,29 @@ namespace tt { } } -} // namespace tt \ No newline at end of file + unsigned int SensorModule::ringId(const Setup* setup) const { + // In barrel PS: Tilted module ring no. (Increasing 1 to 12 as |z| increases) + // In barrel 2S: 0 + // In disk: Endcap module ring number (1-15) in endcap disks + + // See https://github.com/cms-sw/cmssw/tree/master/Geometry/TrackerNumberingBuilder + const TrackerTopology* trackerTopology = setup->trackerTopology(); + enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 }; + const TypeBarrel type = static_cast(trackerTopology->tobSide(detId_)); + bool tiltedBarrel = barrel_ && (type == tiltedMinus || type == tiltedPlus); + unsigned int ringId = 0; + // Tilted module ring no. (Increasing 1 to 12 as |z| increases). + if (tiltedBarrel) { + ringId = trackerTopology->tobRod(detId_); + if (type == tiltedMinus) { + unsigned int layp1 = trackerTopology->layer(detId_); + unsigned int nTilted = setup->numTiltedLayerRing(layp1); + ringId = 1 + nTilted - ringId; + } + } else { + ringId = barrel_ ? 0 : trackerTopology->tidRing(detId_); + } + return ringId; + } + +} // namespace tt From 8b7574d28dc457c50127a0cdb4826750076e81e1 Mon Sep 17 00:00:00 2001 From: tschuh Date: Fri, 28 Oct 2022 09:55:32 +0100 Subject: [PATCH 10/30] kf bug fixes, f/w sync. (#188) * kf bug fixes, f/w sync. * updated reduced dat files and channel assignment. * correct channel assignment. * reduced dat files deleted. --- .../python/Customize_cff.py | 2 +- .../python/Demonstrator_cfi.py | 6 ++-- .../test/demonstrator_cfg.py | 6 ++-- L1Trigger/TrackerTFP/interface/Demonstrator.h | 2 +- L1Trigger/TrackerTFP/interface/State.h | 4 +-- L1Trigger/TrackerTFP/src/Demonstrator.cc | 20 ++++++------- L1Trigger/TrackerTFP/src/KalmanFilter.cc | 29 +++++++++---------- L1Trigger/TrackerTFP/src/State.cc | 22 +++++++------- 8 files changed, 42 insertions(+), 49 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/python/Customize_cff.py b/L1Trigger/TrackFindingTracklet/python/Customize_cff.py index 436edaf44a235..e9aae2a02c24e 100644 --- a/L1Trigger/TrackFindingTracklet/python/Customize_cff.py +++ b/L1Trigger/TrackFindingTracklet/python/Customize_cff.py @@ -24,7 +24,7 @@ def reducedConfig(process): # this are tt::Setup::dtcId in order as in process.TTTracksFromTrackletEmulation.processingModulesFile translated by # reverssing naming logic described in L1FPGATrackProducer # TO DO: Eliminate cfg param IRChannelsIn by taking this info from Tracklet wiring map. - process.ChannelAssignment.IRChannelsIn = cms.vint32( 0, 1, 25, 2, 26, 4, 28, 5, 29, 6, 30, 7, 31, 8, 32, 9, 33 ) + process.ChannelAssignment.IRChannelsIn = cms.vint32( 0, 1, 25, 2, 26, 4, 5, 29, 6, 30, 7, 31, 8, 9, 33 ) process.TTTracksFromTrackletEmulation.Reduced = True process.TTTracksFromTrackletEmulation.memoryModulesFile = 'L1Trigger/TrackFindingTracklet/data/reduced_memorymodules.dat' process.TTTracksFromTrackletEmulation.processingModulesFile = 'L1Trigger/TrackFindingTracklet/data/reduced_processingmodules.dat' diff --git a/L1Trigger/TrackFindingTracklet/python/Demonstrator_cfi.py b/L1Trigger/TrackFindingTracklet/python/Demonstrator_cfi.py index 44e368621a018..755325c8114b0 100644 --- a/L1Trigger/TrackFindingTracklet/python/Demonstrator_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/Demonstrator_cfi.py @@ -3,9 +3,9 @@ TrackTriggerDemonstrator_params = cms.PSet ( - LabelIn = cms.string( "TrackFindingTrackletProducerTBout" ), # - LabelOut = cms.string( "TrackFindingTrackletProducerKFin" ), # - DirIPBB = cms.string( "/heplnw039/tschuh/work/proj/kfin/" ), # path to ipbb proj area + LabelIn = cms.string( "TrackFindingTrackletProducerIRin" ), # + LabelOut = cms.string( "TrackFindingTrackletProducerTBout" ), # + DirIPBB = cms.string( "/heplnw039/tschuh/work/proj/IRinTBout/" ), # path to ipbb proj area RunTime = cms.double( 8.0 ) # runtime in us ) \ No newline at end of file diff --git a/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py b/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py index 6e45507b61120..1479e38c0f161 100644 --- a/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py @@ -24,8 +24,8 @@ #--- Load code that compares s/w with f/w process.load( 'L1Trigger.TrackFindingTracklet.Demonstrator_cff' ) from L1Trigger.TrackFindingTracklet.Customize_cff import * -#reducedConfig( process ) -fwConfig( process ) +reducedConfig( process ) +#fwConfig( process ) # build schedule process.tt = cms.Sequence ( process.TrackerDTCProducer @@ -67,7 +67,7 @@ process.source = cms.Source( "PoolSource", fileNames = cms.untracked.vstring( options.inputMC ), - #skipEvents = cms.untracked.uint32( 993 ), + skipEvents = cms.untracked.uint32( 1 ), secondaryFileNames = cms.untracked.vstring(), duplicateCheckMode = cms.untracked.string( 'noDuplicateCheck' ) ) diff --git a/L1Trigger/TrackerTFP/interface/Demonstrator.h b/L1Trigger/TrackerTFP/interface/Demonstrator.h index 73799b10816fd..07d077502268a 100644 --- a/L1Trigger/TrackerTFP/interface/Demonstrator.h +++ b/L1Trigger/TrackerTFP/interface/Demonstrator.h @@ -39,7 +39,7 @@ namespace trackerTFP { // creates frame number std::string frame(int& nFrame) const; // converts bv into hex - std::string hex(const tt::Frame& bv) const; + std::string hex(const tt::Frame& bv, bool first = false) const; // path to ipbb proj area std::string dirIPBB_; diff --git a/L1Trigger/TrackerTFP/interface/State.h b/L1Trigger/TrackerTFP/interface/State.h index 91804aa4648e8..2a18009d1b2c1 100644 --- a/L1Trigger/TrackerTFP/interface/State.h +++ b/L1Trigger/TrackerTFP/interface/State.h @@ -82,8 +82,8 @@ namespace trackerTFP { double v1() const { return pow(stub_->dZ(), 2); } // output frame tt::FrameTrack frame() const { return TrackKF(*track_, x1_, x0_, x3_, x2_).frame(); } - // collection of stubs added so far to state - std::vector stubs() const; + // fill collection of stubs added so far to state + void fill(std::vector& stubs) const; private: // provides data fomats diff --git a/L1Trigger/TrackerTFP/src/Demonstrator.cc b/L1Trigger/TrackerTFP/src/Demonstrator.cc index e4ba89e515003..acccab3e07406 100644 --- a/L1Trigger/TrackerTFP/src/Demonstrator.cc +++ b/L1Trigger/TrackerTFP/src/Demonstrator.cc @@ -57,10 +57,10 @@ namespace trackerTFP { ss << this->frame(nFrame); for (int channel = 0; channel < numChannel; channel++) { const vector& bvs = bits[offset + channel]; - ss << (frame < (int)bvs.size() ? hex(bvs[frame]) : hex(Frame())); + ss << (frame < (int)bvs.size() ? hex(bvs[frame], frame == 0) : hex(Frame(), frame == 0)); } for (int channel = 0; channel < voidChannel; channel++) - ss << " 0v" << string(TTBV::S_ / 4, '0'); + ss << " 0000 " << string(TTBV::S_ / 4, '0'); ss << endl; } } @@ -108,15 +108,13 @@ namespace trackerTFP { string Demonstrator::header(int numLinks) const { stringstream ss; // file header - ss << "Board CMSSW" << endl << " Quad/Chan :"; - // quad header - for (int link = 0; link < numLinks; link++) - ss << " q" << setfill('0') << setw(2) << link / 4 << "c" << link % 4 << " "; - ss << endl; + ss << "Board CMSSW" << endl + << "Metadata: (strobe,) start of orbit, start of packet, end of packet, valid" << endl + << endl; // link header ss << " Link :"; for (int link = 0; link < numLinks; link++) - ss << " " << setfill('0') << setw(3) << link << " "; + ss << " " << setfill('0') << setw(3) << link << " "; ss << endl; return ss.str(); } @@ -127,7 +125,7 @@ namespace trackerTFP { for (int gap = 0; gap < numFramesInfra_; gap++) { ss << frame(nFrame); for (int link = 0; link < numLinks; link++) - ss << " 0v" << string(TTBV::S_ / 4, '0'); + ss << " 0000 " << string(TTBV::S_ / 4, '0'); ss << endl; } return ss.str(); @@ -141,9 +139,9 @@ namespace trackerTFP { } // converts bv into hex - string Demonstrator::hex(const Frame& bv) const { + string Demonstrator::hex(const Frame& bv, bool first) const { stringstream ss; - ss << " 1v" << setfill('0') << setw(TTBV::S_ / 4) << std::hex << bv.to_ullong(); + ss << (first ? " 1001 " : " 0001 ") << setfill('0') << setw(TTBV::S_ / 4) << std::hex << bv.to_ullong(); return ss.str(); } diff --git a/L1Trigger/TrackerTFP/src/KalmanFilter.cc b/L1Trigger/TrackerTFP/src/KalmanFilter.cc index 30b550b28e87b..b8c66cd8de90f 100644 --- a/L1Trigger/TrackerTFP/src/KalmanFilter.cc +++ b/L1Trigger/TrackerTFP/src/KalmanFilter.cc @@ -146,7 +146,9 @@ namespace trackerTFP { streamsStubs[offset + layer].reserve(states.size()); for (State* state : states) { tracks.emplace_back(state->frame()); - for (const StubKF& stub : state->stubs()) + vector stubs; + state->fill(stubs); + for (const StubKF& stub : stubs) streamsStubs[offset + stub.layer()].emplace_back(stub.frame()); // adding a gap to all layer without a stub for (int layer : state->hitPattern().ids(false)) @@ -225,21 +227,19 @@ namespace trackerTFP { state = pop_front(stack); streamOutput.push_back(state); // The remainder of the code in this loop deals with combinatoric states. - if (state != nullptr) + if (state) // Assign next combinatoric stub to state comb(state); delay.push_back(state); state = pop_front(delay); - if (state != nullptr) + if (state) stack.push_back(state); } stream = streamOutput; - for (State*& state : stream) { - if (!state || !state->stub() || state->layer() != layer_) - continue; - // Update state with next stub using KF maths - update(state); - } + // Update state with next stub using KF maths + for (State*& state : stream) + if (state && state->stub() && state->layer() == layer_) + update(state); } // Assign next combinatoric (i.e. not first in layer) stub to state @@ -249,18 +249,14 @@ namespace trackerTFP { const vector& stubs = track->layerStubs(layer_); const TTBV& hitPattern = state->hitPattern(); StubKFin* stubNext = nullptr; - // Get first stub on this layer if state reached min layers - if (!stub) { - if (hitPattern.count() < setup_->kfMaxLayers() && track->hitPattern(layer_)) - stubNext = track->layerStub(layer_); - } else if (stub->layer() == layer_) { + bool valid = state->stub() && state->layer() == layer_; + if (valid) { // Get next unused stub on this layer const int pos = distance(stubs.begin(), find(stubs.begin(), stubs.end(), stub)) + 1; if (pos != (int)stubs.size()) stubNext = stubs[pos]; // picks next stub on different layer, nullifies state if skipping layer is not valid else { - bool valid(true); // having already maximum number of added layers if (hitPattern.count() == setup_->kfMaxLayers()) valid = false; @@ -268,6 +264,7 @@ namespace trackerTFP { if (hitPattern.count() + track->hitPattern().count(stub->layer() + 1, setup_->numLayers()) < setup_->kfMinLayers()) valid = false; + // not diffrent layers left if (layer_ == setup_->numLayers() - 1) valid = false; if (valid) { @@ -281,7 +278,7 @@ namespace trackerTFP { } } } - if (stubNext) { + if (valid) { // create combinatoric state states_.emplace_back(state, stubNext); state = &states_.back(); diff --git a/L1Trigger/TrackerTFP/src/State.cc b/L1Trigger/TrackerTFP/src/State.cc index 90e9aca2cea02..455089e4632c5 100644 --- a/L1Trigger/TrackerTFP/src/State.cc +++ b/L1Trigger/TrackerTFP/src/State.cc @@ -83,7 +83,7 @@ namespace trackerTFP { layerMap_[layer] = distance(stubs.begin(), find(stubs.begin(), stubs.end(), stub_)); // pick next stub (first stub in next layer with stub) stub_ = nullptr; - if (hitPattern_.count() == setup_->kfMinLayers()) + if (hitPattern_.count() == setup_->kfMaxLayers()) return; for (int nextLayer = layer + 1; nextLayer < setup_->numLayers(); nextLayer++) { if (track_->hitPattern(nextLayer)) { @@ -93,30 +93,28 @@ namespace trackerTFP { } } - // collection of stubs added so far to state - vector State::stubs() const { - vector stubs; + // fills collection of stubs added so far to state + void State::fill(vector& stubs) const { stubs.reserve(hitPattern_.count()); State* s = parent_; while (s) { stubs.emplace_back(*(s->stub()), x0_, x1_, x2_, x3_); s = s->parent(); } - return stubs; } // Determine quality of completed state void State::finish() { - const vector& stubs = this->stubs(); auto consistent = [this](int& sum, const StubKF& stub) { - auto inConsistentRange = [](float v, float r, float d) { return abs(v) <= (r + d) / 2.; }; - // Check stub consistent with helix, allowing for stub & digi uncertainty - const bool inRange0 = - inConsistentRange(stub.phi(), stub.dPhi(), dataFormats_->format(Variable::dPhi, Process::kf).base()); - const bool inRange1 = - inConsistentRange(stub.z(), stub.dZ(), dataFormats_->format(Variable::dZ, Process::kf).base()); + static const DataFormat& phi = dataFormats_->format(Variable::phi, Process::kf); + static const DataFormat& z = dataFormats_->format(Variable::z, Process::kf); + // Check stub consistent with helix, allowing for stub uncertainty + const bool inRange0 = 2. * abs(stub.phi()) - stub.dPhi() < phi.base(); + const bool inRange1 = 2. * abs(stub.z()) - stub.dZ() < z.base(); return sum += (inRange0 && inRange1 ? 1 : 0); }; + vector stubs; + fill(stubs); numConsistentLayers_ = accumulate(stubs.begin(), stubs.end(), 0, consistent); TTBV pattern = hitPattern_; pattern |= maybePattern(); From ed5014704fd0cc80111738d836f4e0421007bcda Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Wed, 2 Nov 2022 09:06:13 -0400 Subject: [PATCH 11/30] MP disk projection LUT (#185) * These changes implements a LUT as function of the raidal projection in the disks to determine which r bins needs to be searched - and the finer position within the r bin * Added extra pipeline stage to match HLS * Ran code-format * Remove some hard-coded numbers * Fixed parentheses * code-format * Minor fixes to remove some hardcoded numbers * Run code-format Co-authored-by: Anders --- .../interface/MatchEngineUnit.h | 14 +++--- .../interface/MatchProcessor.h | 5 ++ .../interface/TrackletLUT.h | 2 + .../src/MatchEngineUnit.cc | 28 ++++++++--- .../src/MatchProcessor.cc | 30 ++++++++++-- .../TrackFindingTracklet/src/TrackletLUT.cc | 47 +++++++++++++++++++ 6 files changed, 108 insertions(+), 18 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index 6aad8567e0a0f..2fbd253507b51 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -108,13 +108,13 @@ namespace trklet { //Various manually pipelined variables //Each _ represents a layer of pipelining //e.g., good__ is set and one iteration later good___ is updated - VMStubME vmstub__, vmstub___; - bool isPSseed__, isPSseed___; - bool good__, good___; - int projfinerz__, projfinerz___; - int projfinephi__, projfinephi___; - int projrinv__, projrinv___; - Tracklet *proj__, *proj___; + VMStubME vmstub__, vmstub__t, vmstub___; + bool isPSseed__, isPSseed__t, isPSseed___; + bool good__, good__t, good___; + int projfinerz__, projfinerz__t, projfinerz___; + int projfinephi__, projfinephi__t, projfinephi___; + int projrinv__, projrinv__t, projrinv___; + Tracklet *proj__, *proj__t, *proj___; //save the candidate matches CircularBuffer> candmatches_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index 624de1af99743..7914e8e51d2ae 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -63,9 +63,14 @@ namespace trklet { TrackletLUT rSSinner_; TrackletLUT rSSouter_; + TrackletLUT diskRadius_; + int nrbits_; int nphiderbits_; + //Number of r bits for the projection to use in LUT for disk + int nrprojbits_; + AllStubsMemory* allstubs_; std::vector vmstubs_; std::vector inputprojs_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h index b71238aaa78ca..30b0172ad0805 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h @@ -83,6 +83,8 @@ namespace trklet { void initBendMatch(unsigned int layerdisk); + void initProjectionDiskRadius(int nrbits); + enum VMRTableType { me, disk, inner, inneroverlap, innerthird }; //region only used for name - should be removed diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc index 30d6762c7f139..456163c4e97d9 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc @@ -16,6 +16,7 @@ MatchEngineUnit::MatchEngineUnit(const Settings& settings, barrel_ = barrel; layerdisk_ = layerdisk; good__ = false; + good__t = false; good___ = false; } @@ -154,13 +155,21 @@ void MatchEngineUnit::processPipeline() { } } - proj___ = proj__; - projfinephi___ = projfinephi__; - projfinerz___ = projfinerz__; - projrinv___ = projrinv__; - isPSseed___ = isPSseed__; - good___ = good__; - vmstub___ = vmstub__; + proj___ = proj__t; + projfinephi___ = projfinephi__t; + projfinerz___ = projfinerz__t; + projrinv___ = projrinv__t; + isPSseed___ = isPSseed__t; + good___ = good__t; + vmstub___ = vmstub__t; + + proj__t = proj__; + projfinephi__t = projfinephi__; + projfinerz__t = projfinerz__; + projrinv__t = projrinv__; + isPSseed__t = isPSseed__; + good__t = good__; + vmstub__t = vmstub__; } void MatchEngineUnit::reset() { @@ -168,6 +177,7 @@ void MatchEngineUnit::reset() { idle_ = true; istub_ = 0; good__ = false; + good__t = false; good___ = false; } @@ -180,6 +190,10 @@ int MatchEngineUnit::TCID() const { return proj___->TCID(); } + if (good__t) { + return proj__t->TCID(); + } + if (good__) { return proj__->TCID(); } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 9efde018a66b8..a3c0c04905282 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -37,6 +37,7 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g alphaouter_(settings), rSSinner_(settings), rSSouter_(settings), + diskRadius_(settings), fullmatches_(12), rinvbendlut_(settings), luttable_(settings), @@ -63,6 +64,8 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g nrbits_ = 5; nphiderbits_ = 6; + nrprojbits_ = 8; + if (!barrel_) { rinvbendlut_.initProjectionBend( global->ITC_L1L2()->der_phiD_final.K(), layerdisk_ - N_LAYER, nrbits_, nphiderbits_); @@ -85,6 +88,7 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g alphaouter_.initmatchcut(layerdisk_, TrackletLUT::MatchType::alphaouter, region); rSSinner_.initmatchcut(layerdisk_, TrackletLUT::MatchType::rSSinner, region); rSSouter_.initmatchcut(layerdisk_, TrackletLUT::MatchType::rSSouter, region); + diskRadius_.initProjectionDiskRadius(nrprojbits_); } for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { @@ -396,12 +400,30 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { } assert(projrinv >= 0); - unsigned int slot = proj->proj(layerdisk_).fpgarzbin1projvm().value(); - bool second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); - unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + NFINEPHIBITS))) & ((1 << NFINEPHIBITS) - 1); - int projfinerz = proj->proj(layerdisk_).fpgafinerzvm().value(); + + unsigned int slot; + bool second; + int projfinerz; + + if (barrel_) { + slot = proj->proj(layerdisk_).fpgarzbin1projvm().value(); + second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); + projfinerz = proj->proj(layerdisk_).fpgafinerzvm().value(); + } else { + //The -1 here is due to not using the full range of bits. Should be fixed. + unsigned int ir = proj->proj(layerdisk_).fpgarzproj().value() >> + (proj->proj(layerdisk_).fpgarzproj().nbits() - nrprojbits_ - 1); + unsigned int word = diskRadius_.lookup(ir); + + slot = (word >> 1) & ((1 << N_RZBITS) - 1); + if (proj->proj(layerdisk_).fpgarzprojder().value() < 0) { + slot += (1 << N_RZBITS); + } + second = word & 1; + projfinerz = word >> 4; + } bool isPSseed = proj->PSseed(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index ae24c5bf8f8ac..6e2b3e9774f89 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -832,6 +832,53 @@ void TrackletLUT::initProjectionBend(double k_phider, writeTable(); } +void TrackletLUT::initProjectionDiskRadius(int nrbits) { + //When a projection to a disk is considered this offset and added and subtracted to calculate + //the bin the projection is pointing to. This is to account for resolution effects such that + //projections that are near a bin boundary will be assigned to both bins. The value (3 cm) should + //cover the uncertanty in the resolution. + double roffset = 3.0; + + for (unsigned int ir = 0; ir < (1u << nrbits); ir++) { + double r = ir * settings_.rmaxdisk() / (1u << nrbits); + + int rbin1 = + (1 << N_RZBITS) * (r - roffset - settings_.rmindiskvm()) / (settings_.rmaxdisk() - settings_.rmindiskvm()); + int rbin2 = + (1 << N_RZBITS) * (r + roffset - settings_.rmindiskvm()) / (settings_.rmaxdisk() - settings_.rmindiskvm()); + + if (rbin1 < 0) { + rbin1 = 0; + } + rbin2 = clamp(rbin2, 0, ((1 << N_RZBITS) - 1)); + + assert(rbin1 <= rbin2); + assert(rbin2 - rbin1 <= 1); + + int d = rbin1 != rbin2; + + int finer = + (1 << (N_RZBITS + NFINERZBITS)) * + ((r - settings_.rmindiskvm()) - rbin1 * (settings_.rmaxdisk() - settings_.rmindiskvm()) / (1 << N_RZBITS)) / + (settings_.rmaxdisk() - settings_.rmindiskvm()); + + finer = clamp(finer, 0, ((1 << (NFINERZBITS + 1)) - 1)); + + //Pack the data in a 8 bit word (ffffrrrd) where f is finer, r is rbin1, and d is difference + int N_DIFF_FLAG = 1; // Single bit for bool flag + + int word = (finer << (N_RZBITS + N_DIFF_FLAG)) + (rbin1 << N_DIFF_FLAG) + d; + + table_.push_back(word); + } + + //Size of the data word from above (8 bits) + nbits_ = NFINERZBITS + 1 + N_RZBITS + 1; + positive_ = true; + name_ = "ProjectionDiskRadius.tab"; + writeTable(); +} + void TrackletLUT::initBendMatch(unsigned int layerdisk) { unsigned int nrinv = NRINVBITS; double rinvhalf = 0.5 * ((1 << nrinv) - 1); From 4dc5a447dc8ccab932ffa30ef816c5818868d8f9 Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Wed, 9 Nov 2022 15:15:30 +0000 Subject: [PATCH 12/30] Produce combined module MemPrint & LUT files for reduced project (#189) * Changes from Anders * code-formatted --- .../interface/TrackletLUT.h | 18 ++++++++ .../TrackFindingTracklet/src/TrackletLUT.cc | 43 ++++++++++++++++--- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h index 30b0172ad0805..ca15854a527a9 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h @@ -3,6 +3,11 @@ // This class writes out the variuos look up tables // for all modules. ////////////////////////////////////////////////////////////////// +// +// This class has methods to build the LUT (LookUp Tables) used by the track finding +// It also provides a method to write out the file for use by the firmware implementation +// +// #ifndef L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h #define L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h @@ -49,6 +54,8 @@ namespace trklet { //region only used for name - should be removed void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region); + //Builds LUT that for each TP returns if the phi differences between inner and outer + //stub is consistent with the pT cut and the stub pair should be kept. void initTPlut(bool fillInner, unsigned int iSeed, unsigned int layerdisk1, @@ -56,6 +63,9 @@ namespace trklet { unsigned int nbitsfinephidiff, unsigned int iTP); + //Builds a lut for the TP ro decide if the region should be used. This is used in the + //first stage of the TP to decide which regions in the outer layer an inner stub needs + //to be combined with void initTPregionlut(unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, @@ -65,6 +75,7 @@ namespace trklet { const TrackletLUT& tplutinner, unsigned int iTP); + //Stub pt consistency for tracklet engine void initteptlut(bool fillInner, bool fillTEMem, unsigned int iSeed, @@ -79,21 +90,28 @@ namespace trklet { const std::string& innermem, const std::string& outermem); + //This LUT uses the phi derivative known in the projection to calculate the corresponding bend void initProjectionBend(double k_phider, unsigned int idisk, unsigned int nrbits, unsigned int nphiderbits); + //This LUT implements consistence check for match engine to check that stub bend is consistent with projection void initBendMatch(unsigned int layerdisk); void initProjectionDiskRadius(int nrbits); enum VMRTableType { me, disk, inner, inneroverlap, innerthird }; + //In the VMR we used the position of the stub (r, z) to calculate the bin and fine rz position the stub has //region only used for name - should be removed void initVMRTable(unsigned int layerdisk, VMRTableType type, int region = -1); + //Used in barrel to calculate the phi position of a stub at the nominal radis of the layer based on the stub radial + //psotion and bend void initPhiCorrTable(unsigned int layerdisk, unsigned int rbits); + //writes out the LUT in standared format for firmware void writeTable() const; + //Evaluate the LUT int lookup(unsigned int index) const; unsigned int size() const { return table_.size(); } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index 6e2b3e9774f89..7cb01cff59d75 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -187,7 +187,7 @@ std::vector> TrackletLUT::getBendCut(unsigned int layerdis void TrackletLUT::initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region) { char cregion = 'A' + region; - for (unsigned int iSeed = 0; iSeed < 12; iSeed++) { + for (unsigned int iSeed = 0; iSeed < N_SEED; iSeed++) { if (type == barrelphi) { table_.push_back(settings_.rphimatchcut(iSeed, layerdisk) / (settings_.kphi1() * settings_.rmean(layerdisk))); } @@ -318,8 +318,10 @@ void TrackletLUT::initTPlut(bool fillInner, iphidiff = iphibin - nbinsfinephidiff; } //min and max dphi - dphi[0] = (iphidiff - 1.5) * dfinephi; - dphi[1] = (iphidiff + 1.5) * dfinephi; + //ramge of dphi to consider due to resolution + double deltaphi = 1.5; + dphi[0] = (iphidiff - deltaphi) * dfinephi; + dphi[1] = (iphidiff + deltaphi) * dfinephi; for (int irouterbin = 0; irouterbin < outerrbins; irouterbin++) { if (iSeed == Seed::D1D2 || iSeed == Seed::D3D4 || iSeed == Seed::L1D1 || iSeed == Seed::L2D1) { router[0] = @@ -468,6 +470,8 @@ void TrackletLUT::initTPlut(bool fillInner, } } + nbits_ = 8; + positive_ = false; char cTP = 'A' + iTP; @@ -1023,7 +1027,9 @@ void TrackletLUT::initVMRTable(unsigned int layerdisk, VMRTableType type, int re } } - if (layerdisk >= N_LAYER && irbin < 10) //special case for the tabulated radii in 2S disks + unsigned int NRING = + 5; //number of 2S rings in disks. This is multiplied below by two since we have two halfs of a module + if (layerdisk >= N_LAYER && irbin < 2 * NRING) //special case for the tabulated radii in 2S disks r = (layerdisk < N_LAYER + 2) ? settings_.rDSSinner(irbin) : settings_.rDSSouter(irbin); int bin; @@ -1155,7 +1161,8 @@ int TrackletLUT::getVMRLookup(unsigned int layerdisk, double z, double r, double double z0cut = settings_.z0cut(); if (layerdisk < N_LAYER) { - if (iseed == Seed::L2L3 && std::abs(z) < 52.0) + double zcutL2L3 = 52.0; //Stubs closer to IP in z will not be used for L2L3 seeds + if (iseed == Seed::L2L3 && std::abs(z) < zcutL2L3) return -1; double rmean = settings_.rmean(layerdisk); @@ -1355,7 +1362,8 @@ int TrackletLUT::getphiCorrValue( double Delta = (irbin + 0.5) * dr - drmax; //calculate the phi correction - this is a somewhat approximate formula - double dphi = (Delta / 0.18) * bend * settings_.stripPitch(psmodule) / rmean; + double drnom = 0.18; //This is the nominal module separation for which bend is referenced + double dphi = (Delta / drnom) * bend * settings_.stripPitch(psmodule) / rmean; double kphi = psmodule ? settings_.kphi() : settings_.kphi1(); @@ -1393,6 +1401,29 @@ void TrackletLUT::writeTable() const { } out << endl << "};" << endl; out.close(); + + string name = name_; + + name[name_.size() - 3] = 'd'; + name[name_.size() - 2] = 'a'; + name[name_.size() - 1] = 't'; + + out = openfile(settings_.tablePath(), name, __FILE__, __LINE__); + + int width = (nbits_ + 3) / 4; + + for (unsigned int i = 0; i < table_.size(); i++) { + int itable = table_[i]; + if (positive_) { + if (table_[i] < 0) { + itable = (1 << nbits_) - 1; + } + } + + out << uppercase << setfill('0') << setw(width) << hex << itable << dec << endl; + } + + out.close(); } int TrackletLUT::lookup(unsigned int index) const { From 03725db27784f967d55f9b88766f2b69645d8f67 Mon Sep 17 00:00:00 2001 From: tschuh Date: Wed, 9 Nov 2022 21:25:47 +0000 Subject: [PATCH 13/30] tiny fix of start_of_orbit_bit. (#190) --- L1Trigger/TrackerTFP/src/Demonstrator.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/L1Trigger/TrackerTFP/src/Demonstrator.cc b/L1Trigger/TrackerTFP/src/Demonstrator.cc index acccab3e07406..98a509f33cb13 100644 --- a/L1Trigger/TrackerTFP/src/Demonstrator.cc +++ b/L1Trigger/TrackerTFP/src/Demonstrator.cc @@ -48,6 +48,7 @@ namespace trackerTFP { ss << header(numChannel + voidChannel); int nFrame(0); // create one packet per region + bool first = true; for (int region = 0; region < numRegions_; region++) { const int offset = region * numChannel; // start with emp 6 frame gap @@ -57,11 +58,12 @@ namespace trackerTFP { ss << this->frame(nFrame); for (int channel = 0; channel < numChannel; channel++) { const vector& bvs = bits[offset + channel]; - ss << (frame < (int)bvs.size() ? hex(bvs[frame], frame == 0) : hex(Frame(), frame == 0)); + ss << (frame < (int)bvs.size() ? hex(bvs[frame], first) : hex(Frame(), first)); } for (int channel = 0; channel < voidChannel; channel++) ss << " 0000 " << string(TTBV::S_ / 4, '0'); ss << endl; + first = false; } } } From 305d6df6a04faeab49a7512910484e5d555e110e Mon Sep 17 00:00:00 2001 From: dally96 <73979415+dally96@users.noreply.github.com> Date: Wed, 16 Nov 2022 22:56:44 +0100 Subject: [PATCH 14/30] Duplicate Removal with overlapping rinv bins (#181) * Changed DR so that tracks are only compared to each other if they're in the same overlapping rinv bin. * Added some comments * Changed parts of the code dealing with overlapbins to make it less complex. * Ran scram b -j 8 code-format and other such commands * Fixed line breaks from scram b -j8 code-format. * Fixed line breaks * Fixed line breaks * Deleted unused variables, made comments describing functions more explicit, and declared several things const to save CPU. * Added values that limit the number of tracks per bin and number of comparisons per bin based on firmware limitations. * Added variables that would allow cutting tracks after a set number of tracks is reached in each bin as well as limiting the number of tracks that are compared in eachbin. * Fixed the formatting of new values in Settings.h and PurgeDuplicate.cc * Fixed the formatting of new values in Settings.h and PurgeDuplicate.cc * Changed the way PurgeDuplicate.cc evaluates seedRank * To help rebase * Atownse2 calc bend cuts (#178) * CalcBendCuts - Uses bend encoding to decode bend * Modified CalcBendCuts to be off by default, changed nzbinsPhiCorr to 1 by default * Added changed in TP LUT and set default nzbinsPhiCorr to 1 * Turned off CalcBendCuts and revised comments * PR Cleanup * More PR cleanup * Address PR comments * code-format * Deleted git comments from rebase. * Added comments to better explain functions in Settings.h * Changed a vector size comparison for DR that would keep 1 more track per bin than allowed * Changed DR values to recover performance * Added a DR variable to the maxStep map Co-authored-by: Daniel Ally Co-authored-by: Austin Townsend readd data files as not yet in CMSSW release Create github_CI.yml Readd git CI code after branching from latest CMSSW relese bug fixes dummy tweak Make DR easier to understand update to python3 tweak tweak tweak tweak Switch to D88 geometry updated to geometry D88 migrate to D77 geom Switch to D88 geometry Update to new label names Update to new label names Switch to D88 geometry Allow use of D76 MC tweak Create README.md Update README.md Update README.md Update README.md DUMMY COMMIT BEFORE PR Removed CI and data files --- .../test/tmtt_tf_analysis_cfg.py | 19 +- L1Trigger/TrackFindingTracklet/README.md | 19 + .../TrackFindingTracklet/interface/FitTrack.h | 3 + .../interface/PurgeDuplicate.h | 34 +- .../TrackFindingTracklet/interface/Settings.h | 52 +- .../interface/TrackFitMemory.h | 2 + .../python/Customize_cff.py | 18 +- .../python/Producer_cfi.py | 4 +- .../src/HitPatternHelper.cc | 4 +- .../src/PurgeDuplicate.cc | 562 +++++++++++------- .../TrackFindingTracklet/src/TrackletLUT.cc | 6 +- .../test/HybridTracksNewKF_cfg.py | 28 +- .../test/HybridTracks_cfg.py | 6 +- .../test/L1TrackNtupleMaker_cfg.py | 48 +- .../test/demonstrator_cfg.py | 26 +- .../TrackFindingTracklet/test/makeHists.csh | 2 +- .../test/skimForCI_cfg.py | 13 +- L1Trigger/TrackerTFP/test/demonstrator_cfg.py | 19 +- L1Trigger/TrackerTFP/test/test_cfg.py | 17 +- 19 files changed, 490 insertions(+), 392 deletions(-) create mode 100644 L1Trigger/TrackFindingTracklet/README.md diff --git a/L1Trigger/TrackFindingTMTT/test/tmtt_tf_analysis_cfg.py b/L1Trigger/TrackFindingTMTT/test/tmtt_tf_analysis_cfg.py index 628ce03bf8116..59e9d0e9d2613 100644 --- a/L1Trigger/TrackFindingTMTT/test/tmtt_tf_analysis_cfg.py +++ b/L1Trigger/TrackFindingTMTT/test/tmtt_tf_analysis_cfg.py @@ -11,16 +11,12 @@ process = cms.Process("Demo") -GEOMETRY = "D76" +GEOMETRY = "D88" -if GEOMETRY == "D49": +if GEOMETRY == "D88": print("using geometry " + GEOMETRY + " (tilted)") - process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') - process.load('Configuration.Geometry.GeometryExtended2026D49_cff') -elif GEOMETRY == "D76": - print("using geometry " + GEOMETRY + " (tilted)") - process.load('Configuration.Geometry.GeometryExtended2026D76Reco_cff') - process.load('Configuration.Geometry.GeometryExtended2026D76_cff') + process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') + process.load('Configuration.Geometry.GeometryExtended2026D88_cff') else: print("this is not a valid geometry!!!") @@ -42,10 +38,7 @@ #from MCsamples.Scripts.getCMSdata_cfi import * #from MCsamples.Scripts.getCMSlocaldata_cfi import * -if GEOMETRY == "D49": - inputMC = ["/store/relval/CMSSW_11_3_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/00000/00260a30-734a-4a3a-a4b0-f836ce5502c6.root"] - -elif GEOMETRY == "D76": +if GEOMETRY == "D88": # Read data from card files (defines getCMSdataFromCards()): #from MCsamples.RelVal_1130_D76.PU200_TTbar_14TeV_cfi import * #inputMC = getCMSdataFromCards() @@ -59,7 +52,7 @@ #inputMC=getCMSdata(dataName) # Or read specified .root file: - inputMC = ["/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root"] + inputMC = ["/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root"] else: print("this is not a valid geometry!!!") diff --git a/L1Trigger/TrackFindingTracklet/README.md b/L1Trigger/TrackFindingTracklet/README.md new file mode 100644 index 0000000000000..a1aec2a9a969d --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/README.md @@ -0,0 +1,19 @@ +To run L1 tracking & create TTree of tracking performance: + +cmsRun L1TrackNtupleMaker_cfg.py + +By setting variable L1TRKALGO inside this script, you can change the +L1 tracking algo used. + +For the baseline HYBRID algo, which runs Tracklet pattern reco followed +by KF track fit, TrackFindingTracklet/interface/Settings.h configures the pattern reco, (although some +parameters there are overridden by l1tTTTracksFromTrackletEmulation_cfi.py). +The KF fit is configued by the constructor of TrackFindingTMTT/src/Settings.cc. + +The ROOT macros L1TrackNtuplePlot.C & L1TrackQualityPlot.C make tracking +performance & BDT track quality performance plots from the TTree. +Both can be run via makeHists.csh . + +The optional "NewKF" track fit, (which is not yet baseline, as no duplicate +track removal is compatible with it), is configured via +TrackTrigger/python/ProducerSetup_cfi.py, (which also configures the DTC). diff --git a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h index 50b4584d0d853..c7f97fdf7e51b 100644 --- a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h +++ b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h @@ -30,6 +30,9 @@ namespace trklet { void trackFitChisq(Tracklet* tracklet, std::vector&, std::vector>&); // used if USEHYBRID is defined + // tracklet = input track cand, updated with fitted helix info. + // returns trackstublist = pointers to Stubs on track. + // returns stubidslist = (layer, unique stub index in layer). void trackFitKF(Tracklet* tracklet, std::vector& trackstublist, std::vector>& stubidslist); diff --git a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h index 614cd396fe22c..03a4c510d4698 100644 --- a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h +++ b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h @@ -36,22 +36,24 @@ namespace trklet { void execute(std::vector& outputtracks_, unsigned int iSector); private: - double getPhiRes(Tracklet* curTracklet, const Stub* curStub); - bool isSeedingStub(int, int, int); - std::string l1tinfo(const L1TStub*, std::string); - std::pair findLayerDisk(const Stub*); - std::vector getInventedCoords( - unsigned int, - const Stub*, - Tracklet*); // calculate stub coordinates based on tracklet trajectory for prompt tracking - std::vector getInventedCoordsExtended( - unsigned int, - const Stub*, - Tracklet*); // calculate stub coordinates based on tracklet trajectory for extended tracking - std::vector getInventedSeedingStub( - unsigned int, - Tracklet*, - std::vector); // return stub with invented x,y,z coords, if it's a seeding one for this tracklet + double getPhiRes(Tracklet* curTracklet, const Stub* curStub) const; + bool isSeedingStub(int, int, int) const; + std::string l1tinfo(const L1TStub*, std::string) const; + std::pair findLayerDisk(const Stub*) const; + // calculate stub coordinates based on tracklet trajectory for prompt tracking + std::vector getInventedCoords(unsigned int, const Stub*, const Tracklet*) const; + // calculate stub coordinates based on tracklet trajectory for extended tracking + std::vector getInventedCoordsExtended(unsigned int, const Stub*, const Tracklet*) const; + // return stub with invented x,y,z coords, if it's a seeding one for this tracklet + std::vector getInventedSeedingStub(unsigned int, + const Tracklet*, + const std::vector&) const; + // return the regular rinvbins which contain the input tracklet + unsigned int findVarRInvBin(const Tracklet* trk) const; + // return the overlap rinvbins which contain the input tracklet + std::vector findOverlapRInvBins(const Tracklet* trk) const; + // sort the tracklets into the correct bin by comparing the overlap rinv bin(s) the tracklets are in to the current bin + bool isTrackInBin(const std::vector& vec, unsigned int num) const; std::vector inputtracks_; std::vector> inputstublists_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index db5aee94ffe6a..b5542ef6ae03a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -289,6 +289,14 @@ namespace trklet { void setStripLength_PS(double stripLength_PS) { stripLength_PS_ = stripLength_PS; } void setStripLength_2S(double stripLength_2S) { stripLength_2S_ = stripLength_2S; } + //Following functions are used for duplicate removal + //Function which gets the value corresponding to the overlap size for the overlap rinv bins in DR + double overlapSize() const { return overlapSize_; } + //Function which gets the value corresponding to the number of tracks that are compared to all the other tracks per rinv bin + unsigned int numTracksComparedPerBin() const { return numTracksComparedPerBin_; } + //Grabs the bin edges you need for duplicate removal bins + const std::vector varRInvBins() const { return varRInvBins_; } + std::string skimfile() const { return skimfile_; } void setSkimfile(std::string skimfile) { skimfile_ = skimfile; } @@ -859,23 +867,25 @@ namespace trklet { //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", 107}, - {"TE", 107}, - {"TC", 108}, - {"PR", 108}, - {"ME", 108}, - //NOTE: The MC is set to 108, but `mergedepth` - //removes 3 iterations to emulate the delay - //due to the HLS priority encoder - {"MC", 108}, - {"TB", 108}, - {"MP", 108}, - {"TP", 108}, - {"TRE", 108}}; + 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", 107}, + {"TE", 107}, + {"TC", 108}, + {"PR", 108}, + {"ME", 108}, + //NOTE: The MC is set to 108, but `mergedepth` + //removes 3 iterations to emulate the delay + //due to the HLS priority encoder + {"MC", 108}, + {"TB", 108}, + {"MP", 108}, + {"TP", 108}, + {"TRE", 108}, + {"DR", 108}}; //Specifies how many tracks allowed per bin in DR // If set to true this will generate debub printout in text files std::unordered_map writeMonitorData_{{"IL", false}, @@ -1030,6 +1040,14 @@ namespace trklet { double stripLength_PS_{0.1467}; double stripLength_2S_{5.0250}; + //Following values are used for duplicate removal + //Variable bin edges for 6 bins. + std::vector varRInvBins_{-rinvcut(), -0.004968, -0.003828, 0, 0.003828, 0.004968, rinvcut()}; + //Overlap size for the overlap rinv bins in DR + double overlapSize_{0.0004}; + //The maximum number of tracks that are compared to all the other tracks per rinv bin + int numTracksComparedPerBin_{64}; + double sensorSpacing_2S_{0.18}; }; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h b/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h index f8c9335abd8fa..2897643e143ed 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h @@ -27,7 +27,9 @@ namespace trklet { unsigned int nStubidslists() const { return stubidslists_.size(); } Tracklet* getTrack(unsigned int i) { return tracks_[i]; } + // Get pointers to Stubs on track. std::vector getStublist(unsigned int i) const { return stublists_[i]; } + // Get (layer, unique stub index in layer) of stubs on track. std::vector> getStubidslist(unsigned int i) const { return stubidslists_[i]; } void clean() override { diff --git a/L1Trigger/TrackFindingTracklet/python/Customize_cff.py b/L1Trigger/TrackFindingTracklet/python/Customize_cff.py index e9aae2a02c24e..192a65beef491 100644 --- a/L1Trigger/TrackFindingTracklet/python/Customize_cff.py +++ b/L1Trigger/TrackFindingTracklet/python/Customize_cff.py @@ -2,15 +2,15 @@ # configures track finding s/w to use KF emulator instead of KF simulator def newKFConfig(process): - process.TTTracksFromTrackletEmulation.Fakefit = True + process.l1tTTTracksFromTrackletEmulation.Fakefit = True # configures track finding s/w to behave as track finding f/w def fwConfig(process): newKFConfig(process) process.TrackTriggerSetup.Firmware.FreqBE = 240 # Frequency of DTC & KF (determines truncation) - process.TTTracksFromTrackletEmulation.RemovalType = "" - process.TTTracksFromTrackletEmulation.DoMultipleMatches = False - process.TTTracksFromTrackletEmulation.StoreTrackBuilderOutput = True + process.l1tTTTracksFromTrackletEmulation.RemovalType = "" + process.l1tTTTracksFromTrackletEmulation.DoMultipleMatches = False + process.l1tTTTracksFromTrackletEmulation.StoreTrackBuilderOutput = True process.ChannelAssignment.UseDuplicateRemoval = False process.TrackTriggerSetup.KalmanFilter.NumWorker = 8 @@ -21,11 +21,11 @@ def reducedConfig(process): process.ChannelAssignment.SeedTypes = cms.vstring( "L1L2" ) process.ChannelAssignment.SeedTypesSeedLayers = cms.PSet( L1L2 = cms.vint32( 1, 2 ) ) process.ChannelAssignment.SeedTypesProjectionLayers = cms.PSet( L1L2 = cms.vint32( 3, 4, 5, 6 ) ) - # this are tt::Setup::dtcId in order as in process.TTTracksFromTrackletEmulation.processingModulesFile translated by + # this are tt::Setup::dtcId in order as in process.l1tTTTracksFromTrackletEmulation.processingModulesFile translated by # reverssing naming logic described in L1FPGATrackProducer # TO DO: Eliminate cfg param IRChannelsIn by taking this info from Tracklet wiring map. process.ChannelAssignment.IRChannelsIn = cms.vint32( 0, 1, 25, 2, 26, 4, 5, 29, 6, 30, 7, 31, 8, 9, 33 ) - process.TTTracksFromTrackletEmulation.Reduced = True - process.TTTracksFromTrackletEmulation.memoryModulesFile = 'L1Trigger/TrackFindingTracklet/data/reduced_memorymodules.dat' - process.TTTracksFromTrackletEmulation.processingModulesFile = 'L1Trigger/TrackFindingTracklet/data/reduced_processingmodules.dat' - process.TTTracksFromTrackletEmulation.wiresFile = 'L1Trigger/TrackFindingTracklet/data/reduced_wires.dat' + process.l1tTTTracksFromTrackletEmulation.Reduced = True + process.l1tTTTracksFromTrackletEmulation.memoryModulesFile = 'L1Trigger/TrackFindingTracklet/data/reduced_memorymodules.dat' + process.l1tTTTracksFromTrackletEmulation.processingModulesFile = 'L1Trigger/TrackFindingTracklet/data/reduced_processingmodules.dat' + process.l1tTTTracksFromTrackletEmulation.wiresFile = 'L1Trigger/TrackFindingTracklet/data/reduced_wires.dat' diff --git a/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py b/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py index 0519783a8f65d..929af970fa0b1 100644 --- a/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py @@ -2,7 +2,7 @@ TrackFindingTrackletProducer_params = cms.PSet ( - InputTag = cms.InputTag( "TTTracksFromTrackletEmulation", "Level1TTTracks"), # + InputTag = cms.InputTag( "l1tTTTracksFromTrackletEmulation", "Level1TTTracks"), # InputTagDTC = cms.InputTag( "TrackerDTCProducer", "StubAccepted"), # LabelTBout = cms.string ( "TrackFindingTrackletProducerTBout" ), # LabelKFin = cms.string ( "TrackFindingTrackletProducerKFin" ), # @@ -19,4 +19,4 @@ PrintKFDebug = cms.bool ( False ), # print end job internal unused MSB UseTTStubResiduals = cms.bool ( False ), # stub residuals are recalculated from seed parameter and TTStub position -) \ No newline at end of file +) diff --git a/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc index bb3eada6ea447..aa14dae8de1d9 100644 --- a/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc +++ b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc @@ -5,9 +5,9 @@ #include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h" #include "L1Trigger/TrackFindingTMTT/interface/KFbase.h" #include "L1Trigger/TrackFindingTMTT/interface/TrackerModule.h" - #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include #include #include @@ -36,7 +36,7 @@ namespace hph { etaRegions_ = etaRegionsNewKF_; } else { chosenRofZ_ = oldKFPSet_.getParameter("ChosenRofZ"); - etaRegions_ = oldKFPSet_.getParameter>("EtaRegions"); + etaRegions_ = oldKFPSet_.getParameter>("EtaRegions"); } static constexpr auto layerIds = {1, 2, 3, 4, 5, 6, 11, 12, 13, 14, 15}; //layer ID 11~15 correspond to D1~D5 // Converting tmtt::KFbase::layerMap_ to a format that is acceptatble by HitPatternHelper diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 87cbb261ac73a..829ecf563bd37 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -108,264 +108,324 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe #ifdef USEHYBRID if (settings_.removalType() == "merge") { - std::vector> trackInfo; // Track seed & duplicate flag + // Track seed & duplicate flag + std::vector> trackInfo; + // Flag for tracks in multiple bins that get merged but are not in the correct variable bin + std::vector trackBinInfo; // Vector to store the relative rank of the track candidate for merging, based on seed type std::vector seedRank; - // Get vectors from TrackFit and save them - // inputtracklets: Tracklet objects from the FitTrack (not actually fit yet) - // inputstublists: L1Stubs for that track - // inputstubidslists: Stub stubIDs for that 3rack - // mergedstubidslists: the same as inputstubidslists, but will be used during duplicate removal - for (unsigned int i = 0; i < inputtrackfits_.size(); i++) { - if (inputtrackfits_[i]->nStublists() == 0) - continue; - if (inputtrackfits_[i]->nStublists() != inputtrackfits_[i]->nTracks()) - throw "Number of stublists and tracks don't match up!"; - for (unsigned int j = 0; j < inputtrackfits_[i]->nStublists(); j++) { - Tracklet* aTrack = inputtrackfits_[i]->getTrack(j); - inputtracklets_.push_back(inputtrackfits_[i]->getTrack(j)); - - std::vector stublist = inputtrackfits_[i]->getStublist(j); - - inputstublists_.push_back(stublist); - - std::vector> stubidslist = inputtrackfits_[i]->getStubidslist(j); - inputstubidslists_.push_back(stubidslist); - mergedstubidslists_.push_back(stubidslist); - - // Encoding: L1L2=0, L2L3=1, L3L4=2, L5L6=3, D1D2=4, D3D4=5, L1D1=6, L2D1=7 - // Best Guess: L1L2 > L1D1 > L2L3 > L2D1 > D1D2 > L3L4 > L5L6 > D3D4 - // Best Rank: L1L2 > L3L4 > D3D4 > D1D2 > L2L3 > L2D1 > L5L6 > L1D1 - // Rank-Informed Guess: L1L2 > L3L4 > L1D1 > L2L3 > L2D1 > D1D2 > L5L6 > D3D4 - unsigned int curSeed = aTrack->seedIndex(); - if (curSeed == 0) { - seedRank.push_back(1); - } else if (curSeed == 2) { - seedRank.push_back(2); - } else if (curSeed == 5) { - seedRank.push_back(3); - } else if (curSeed == 4) { - seedRank.push_back(4); - } else if (curSeed == 1) { - seedRank.push_back(5); - } else if (curSeed == 7) { - seedRank.push_back(6); - } else if (curSeed == 3) { - seedRank.push_back(7); - } else if (curSeed == 6) { - seedRank.push_back(8); - } else if (settings_.extended()) { - seedRank.push_back(9); - } else { - throw cms::Exception("LogError") << __FILE__ << " " << __LINE__ << " Seed " << curSeed - << " not found in list, and settings->extended() not set."; + // Stubs on every track + std::vector> inputstublistsall; + // (layer, unique stub index within layer) of each stub on every track + std::vector>> mergedstubidslistsall; + std::vector>> inputstubidslistsall; + std::vector inputtrackletsall; + + std::vector prefTracks; // Stores all the tracks that are sent to the KF from each bin + std::vector prefTrackFit; // Stores the track seed that corresponds to the associated track in prefTracks + + for (unsigned int bin = 0; bin < settings_.varRInvBins().size() - 1; bin++) { + // Get vectors from TrackFit and save them + // inputtracklets: Tracklet objects from the FitTrack (not actually fit yet) + // inputstublists: L1Stubs for that track + // inputstubidslists: Stub stubIDs for that 3rack + // mergedstubidslists: the same as inputstubidslists, but will be used during duplicate removal + for (unsigned int i = 0; i < inputtrackfits_.size(); i++) { + if (inputtrackfits_[i]->nStublists() == 0) + continue; + if (inputtrackfits_[i]->nStublists() != inputtrackfits_[i]->nTracks()) + throw "Number of stublists and tracks don't match up!"; + for (unsigned int j = 0; j < inputtrackfits_[i]->nStublists(); j++) { + if (isTrackInBin(findOverlapRInvBins(inputtrackfits_[i]->getTrack(j)), bin)) { + if (inputtracklets_.size() >= settings_.maxStep("DR")) + continue; + Tracklet* aTrack = inputtrackfits_[i]->getTrack(j); + inputtracklets_.push_back(inputtrackfits_[i]->getTrack(j)); + std::vector stublist = inputtrackfits_[i]->getStublist(j); + inputstublists_.push_back(stublist); + std::vector> stubidslist = inputtrackfits_[i]->getStubidslist(j); + inputstubidslists_.push_back(stubidslist); + mergedstubidslists_.push_back(stubidslist); + + // Encoding: L1L2=0, L2L3=1, L3L4=2, L5L6=3, D1D2=4, D3D4=5, L1D1=6, L2D1=7 + // Best Guess: L1L2 > L1D1 > L2L3 > L2D1 > D1D2 > L3L4 > L5L6 > D3D4 + // Best Rank: L1L2 > L3L4 > D3D4 > D1D2 > L2L3 > L2D1 > L5L6 > L1D1 + // Rank-Informed Guess: L1L2 > L3L4 > L1D1 > L2L3 > L2D1 > D1D2 > L5L6 > D3D4 + unsigned int curSeed = aTrack->seedIndex(); + std::vector ranks{1, 5, 2, 7, 4, 3, 8, 6}; + if (settings_.extended()) + seedRank.push_back(9); + else + seedRank.push_back(ranks[curSeed]); + + if (stublist.size() != stubidslist.size()) + throw "Number of stubs and stubids don't match up!"; + + trackInfo.emplace_back(i, false); + trackBinInfo.emplace_back(false); + } else + continue; } + } - if (stublist.size() != stubidslist.size()) - throw "Number of stubs and stubids don't match up!"; + if (inputtracklets_.empty()) + continue; + unsigned int numStublists = inputstublists_.size(); - trackInfo.emplace_back(i, false); + if (settings_.inventStubs()) { + for (unsigned int itrk = 0; itrk < numStublists; itrk++) { + inputstublists_[itrk] = getInventedSeedingStub(iSector, inputtracklets_[itrk], inputstublists_[itrk]); + } } - } - - if (inputtracklets_.empty()) - return; - unsigned int numStublists = inputstublists_.size(); - if (settings_.inventStubs()) { + // Initialize all-false 2D array of tracks being duplicates to other tracks + bool dupMap[numStublists][numStublists]; // Ends up symmetric for (unsigned int itrk = 0; itrk < numStublists; itrk++) { - inputstublists_[itrk] = getInventedSeedingStub(iSector, inputtracklets_[itrk], inputstublists_[itrk]); + for (unsigned int jtrk = 0; jtrk < numStublists; jtrk++) { + dupMap[itrk][jtrk] = false; + } } - } - // Initialize all-false 2D array of tracks being duplicates to other tracks - bool dupMap[numStublists][numStublists]; // Ends up symmetric - for (unsigned int itrk = 0; itrk < numStublists; itrk++) { - for (unsigned int jtrk = 0; jtrk < numStublists; jtrk++) { - dupMap[itrk][jtrk] = false; + // Used to check if a track is in two bins, is not a duplicate in either bin, so is sent out twice + bool noMerge[numStublists]; + for (unsigned int itrk = 0; itrk < numStublists; itrk++) { + noMerge[itrk] = false; } - } - // Find duplicates; Fill dupMap by looping over all pairs of "tracks" - // numStublists-1 since last track has no other to compare to - for (unsigned int itrk = 0; itrk < numStublists - 1; itrk++) { - for (unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) { - // Get primary track stubids - const std::vector>& stubsTrk1 = inputstubidslists_[itrk]; - - // Get and count secondary track stubids - const std::vector>& stubsTrk2 = inputstubidslists_[jtrk]; - - // Count number of Unique Regions (UR) that share stubs, and the number of UR that each track hits - unsigned int nShareUR = 0; - unsigned int nURStubTrk1 = 0; - unsigned int nURStubTrk2 = 0; - if (settings_.mergeComparison() == "CompareAll") { - bool URArray[16]; - for (auto& i : URArray) { - i = false; - }; - for (const auto& st1 : stubsTrk1) { - for (const auto& st2 : stubsTrk2) { - if (st1.first == st2.first && st1.second == st2.second) { - // Converts region encoded in st1->first to an index in the Unique Region (UR) array - int i = st1.first; - int reg = (i > 0 && i < 10) * (i - 1) + (i > 10) * (i - 5) - (i < 0) * i; - if (!URArray[reg]) { - nShareUR++; - URArray[reg] = true; + // Find duplicates; Fill dupMap by looping over all pairs of "tracks" + // numStublists-1 since last track has no other to compare to + for (unsigned int itrk = 0; itrk < numStublists - 1; itrk++) { + for (unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) { + if (itrk >= settings_.numTracksComparedPerBin()) + continue; + // Get primary track stubids = (layer, unique stub index within layer) + const std::vector>& stubsTrk1 = inputstubidslists_[itrk]; + + // Get and count secondary track stubids + const std::vector>& stubsTrk2 = inputstubidslists_[jtrk]; + + // Count number of layers that share stubs, and the number of UR that each track hits + unsigned int nShareLay = 0; + unsigned int nLayStubTrk1 = 0; + unsigned int nLayStubTrk2 = 0; + if (settings_.mergeComparison() == "CompareAll") { + bool layerArr[16]; + for (auto& i : layerArr) { + i = false; + }; + for (const auto& st1 : stubsTrk1) { + for (const auto& st2 : stubsTrk2) { + if (st1.first == st2.first && st1.second == st2.second) { // tracks share stub + // Converts layer/disk encoded in st1->first to an index in the layer array + int i = st1.first; // layer/disk + bool barrel = (i > 0 && i < 10); + bool endcapA = (i > 10); + bool endcapB = (i < 0); + int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15 + if (!layerArr[lay]) { + nShareLay++; + layerArr[lay] = true; + } } } } - } - } else if (settings_.mergeComparison() == "CompareBest") { - std::vector fullStubslistsTrk1 = inputstublists_[itrk]; - std::vector fullStubslistsTrk2 = inputstublists_[jtrk]; - - // Arrays to store the index of the best stub in each region - int URStubidsTrk1[16]; - int URStubidsTrk2[16]; - for (int i = 0; i < 16; i++) { - URStubidsTrk1[i] = -1; - URStubidsTrk2[i] = -1; - } - // For each stub on the first track, find the stub with the best residual and store its index in the URStubidsTrk1 array - for (unsigned int stcount = 0; stcount < stubsTrk1.size(); stcount++) { - int i = stubsTrk1[stcount].first; - int reg = (i > 0 && i < 10) * (i - 1) + (i > 10) * (i - 5) - (i < 0) * i; - double nres = getPhiRes(inputtracklets_[itrk], fullStubslistsTrk1[stcount]); - double ores = 0; - if (URStubidsTrk1[reg] != -1) - ores = getPhiRes(inputtracklets_[itrk], fullStubslistsTrk1[URStubidsTrk1[reg]]); - if (URStubidsTrk1[reg] == -1 || nres < ores) { - URStubidsTrk1[reg] = stcount; + } else if (settings_.mergeComparison() == "CompareBest") { + std::vector fullStubslistsTrk1 = inputstublists_[itrk]; + std::vector fullStubslistsTrk2 = inputstublists_[jtrk]; + + // Arrays to store the index of the best stub in each layer + int layStubidsTrk1[16]; + int layStubidsTrk2[16]; + for (int i = 0; i < 16; i++) { + layStubidsTrk1[i] = -1; + layStubidsTrk2[i] = -1; } - } - // For each stub on the second track, find the stub with the best residual and store its index in the URStubidsTrk1 array - for (unsigned int stcount = 0; stcount < stubsTrk2.size(); stcount++) { - int i = stubsTrk2[stcount].first; - int reg = (i > 0 && i < 10) * (i - 1) + (i > 10) * (i - 5) - (i < 0) * i; - double nres = getPhiRes(inputtracklets_[jtrk], fullStubslistsTrk2[stcount]); - double ores = 0; - if (URStubidsTrk2[reg] != -1) - ores = getPhiRes(inputtracklets_[jtrk], fullStubslistsTrk2[URStubidsTrk2[reg]]); - if (URStubidsTrk2[reg] == -1 || nres < ores) { - URStubidsTrk2[reg] = stcount; + // For each stub on the first track, find the stub with the best residual and store its index in the layStubidsTrk1 array + for (unsigned int stcount = 0; stcount < stubsTrk1.size(); stcount++) { + int i = stubsTrk1[stcount].first; // layer/disk + bool barrel = (i > 0 && i < 10); + bool endcapA = (i > 10); + bool endcapB = (i < 0); + int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15 + double nres = getPhiRes(inputtracklets_[itrk], fullStubslistsTrk1[stcount]); + double ores = 0; + if (layStubidsTrk1[lay] != -1) + ores = getPhiRes(inputtracklets_[itrk], fullStubslistsTrk1[layStubidsTrk1[lay]]); + if (layStubidsTrk1[lay] == -1 || nres < ores) { + layStubidsTrk1[lay] = stcount; + } + } + // For each stub on the second track, find the stub with the best residual and store its index in the layStubidsTrk1 array + for (unsigned int stcount = 0; stcount < stubsTrk2.size(); stcount++) { + int i = stubsTrk2[stcount].first; // layer/disk + bool barrel = (i > 0 && i < 10); + bool endcapA = (i > 10); + bool endcapB = (i < 0); + int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15 + double nres = getPhiRes(inputtracklets_[jtrk], fullStubslistsTrk2[stcount]); + double ores = 0; + if (layStubidsTrk2[lay] != -1) + ores = getPhiRes(inputtracklets_[jtrk], fullStubslistsTrk2[layStubidsTrk2[lay]]); + if (layStubidsTrk2[lay] == -1 || nres < ores) { + layStubidsTrk2[lay] = stcount; + } + } + // For all 16 layers (6 layers and 10 disks), count the number of layers who's best stub on both tracks are the same + for (int i = 0; i < 16; i++) { + int t1i = layStubidsTrk1[i]; + int t2i = layStubidsTrk2[i]; + if (t1i != -1 && t2i != -1 && stubsTrk1[t1i].first == stubsTrk2[t2i].first && + stubsTrk1[t1i].second == stubsTrk2[t2i].second) + nShareLay++; + } + // Calculate the number of layers hit by each track, so that this number can be used in calculating the number of independent + // stubs on a track (not enabled/used by default) + for (int i = 0; i < 16; i++) { + if (layStubidsTrk1[i] != -1) + nLayStubTrk1++; + if (layStubidsTrk2[i] != -1) + nLayStubTrk2++; } } - // For all 16 regions (6 layers and 10 disks), count the number of regions who's best stub on both tracks are the same - for (int i = 0; i < 16; i++) { - int t1i = URStubidsTrk1[i]; - int t2i = URStubidsTrk2[i]; - if (t1i != -1 && t2i != -1 && stubsTrk1[t1i].first == stubsTrk2[t2i].first && - stubsTrk1[t1i].second == stubsTrk2[t2i].second) - nShareUR++; - } - // Calculate the number of unique regions hit by each track, so that this number can be used in calculating the number of independent - // stubs on a track (not enabled/used by default) - for (int i = 0; i < 16; i++) { - if (URStubidsTrk1[i] != -1) - nURStubTrk1++; - if (URStubidsTrk2[i] != -1) - nURStubTrk2++; - } - } - // Fill duplicate map - if (nShareUR >= settings_.minIndStubs()) { // For number of shared stub merge condition - dupMap[itrk][jtrk] = true; - dupMap[jtrk][itrk] = true; + // Fill duplicate map + if (nShareLay >= settings_.minIndStubs()) { // For number of shared stub merge condition + dupMap[itrk][jtrk] = true; + dupMap[jtrk][itrk] = true; + } } } - } - // Merge duplicate tracks - for (unsigned int itrk = 0; itrk < numStublists - 1; itrk++) { - for (unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) { - // Merge a track with its first duplicate found. - if (dupMap[itrk][jtrk]) { - // Set preferred track based on seed rank - int preftrk; - int rejetrk; - if (seedRank[itrk] < seedRank[jtrk]) { - preftrk = itrk; - rejetrk = jtrk; - } else { - preftrk = jtrk; - rejetrk = itrk; + // Check to see if the track is a duplicate + for (unsigned int itrk = 0; itrk < numStublists; itrk++) { + for (unsigned int jtrk = 0; jtrk < numStublists; jtrk++) { + if (dupMap[itrk][jtrk]) { + noMerge[itrk] = true; } + } + } - // Get a merged stub list - std::vector newStubList; - std::vector stubsTrk1 = inputstublists_[preftrk]; - std::vector stubsTrk2 = inputstublists_[rejetrk]; - std::vector stubsTrk1indices; - std::vector stubsTrk2indices; - for (unsigned int stub1it = 0; stub1it < stubsTrk1.size(); stub1it++) { - stubsTrk1indices.push_back(stubsTrk1[stub1it]->l1tstub()->uniqueIndex()); - } - for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { - stubsTrk2indices.push_back(stubsTrk2[stub2it]->l1tstub()->uniqueIndex()); + // If the track isn't a duplicate, and if it's in more than one bin, and it is not in the proper varrinvbin, then mark it so it won't be sent to output + for (unsigned int itrk = 0; itrk < numStublists; itrk++) { + if (noMerge[itrk] == false) { + if ((findOverlapRInvBins(inputtracklets_[itrk]).size() > 1) && + (findVarRInvBin(inputtracklets_[itrk]) != bin)) { + trackInfo[itrk].second = true; } - newStubList = stubsTrk1; - for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { - if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) == - stubsTrk1indices.end()) { - newStubList.push_back(stubsTrk2[stub2it]); + } + } + // Merge duplicate tracks + for (unsigned int itrk = 0; itrk < numStublists - 1; itrk++) { + for (unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) { + // Merge a track with its first duplicate found. + if (dupMap[itrk][jtrk]) { + // Set preferred track based on seed rank + int preftrk; + int rejetrk; + if (seedRank[itrk] < seedRank[jtrk]) { + preftrk = itrk; + rejetrk = jtrk; + } else { + preftrk = jtrk; + rejetrk = itrk; } - } - // Overwrite stublist of preferred track with merged list - inputstublists_[preftrk] = newStubList; - - std::vector> newStubidsList; - std::vector> stubidsTrk1 = mergedstubidslists_[preftrk]; - std::vector> stubidsTrk2 = mergedstubidslists_[rejetrk]; - newStubidsList = stubidsTrk1; - - for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { - if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) == - stubsTrk1indices.end()) { - newStubidsList.push_back(stubidsTrk2[stub2it]); + + // If the preffered track is in more than one bin, but not in the proper varrinvbin, then mark as true + if ((findOverlapRInvBins(inputtracklets_[preftrk]).size() > 1) && + (findVarRInvBin(inputtracklets_[preftrk]) != bin)) { + trackBinInfo[preftrk] = true; + trackBinInfo[rejetrk] = true; + } else { + // Get a merged stub list + std::vector newStubList; + std::vector stubsTrk1 = inputstublists_[preftrk]; + std::vector stubsTrk2 = inputstublists_[rejetrk]; + std::vector stubsTrk1indices; + std::vector stubsTrk2indices; + for (unsigned int stub1it = 0; stub1it < stubsTrk1.size(); stub1it++) { + stubsTrk1indices.push_back(stubsTrk1[stub1it]->l1tstub()->uniqueIndex()); + } + for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { + stubsTrk2indices.push_back(stubsTrk2[stub2it]->l1tstub()->uniqueIndex()); + } + newStubList = stubsTrk1; + for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { + if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) == + stubsTrk1indices.end()) { + newStubList.push_back(stubsTrk2[stub2it]); + } + } + // Overwrite stublist of preferred track with merged list + inputstublists_[preftrk] = newStubList; + + std::vector> newStubidsList; + std::vector> stubidsTrk1 = mergedstubidslists_[preftrk]; + std::vector> stubidsTrk2 = mergedstubidslists_[rejetrk]; + newStubidsList = stubidsTrk1; + + for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { + if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) == + stubsTrk1indices.end()) { + newStubidsList.push_back(stubidsTrk2[stub2it]); + } + } + // Overwrite stubidslist of preferred track with merged list + mergedstubidslists_[preftrk] = newStubidsList; + + // Mark that rejected track has been merged into another track + trackInfo[rejetrk].second = true; } } - // Overwrite stubidslist of preferred track with merged list - mergedstubidslists_[preftrk] = newStubidsList; + } + } - // Mark that rejected track has been merged into another track - trackInfo[rejetrk].second = true; + for (unsigned int ktrk = 0; ktrk < numStublists; ktrk++) { + if ((trackInfo[ktrk].second != true) && (trackBinInfo[ktrk] != true)) { + prefTracks.push_back(ktrk); + prefTrackFit.push_back(trackInfo[ktrk].first); + inputtrackletsall.push_back(inputtracklets_[ktrk]); + inputstublistsall.push_back(inputstublists_[ktrk]); + inputstubidslistsall.push_back(inputstubidslists_[ktrk]); + mergedstubidslistsall.push_back(mergedstubidslists_[ktrk]); } } + + // Need to clear all the vectors which will be used in the next bin + seedRank.clear(); + trackInfo.clear(); + trackBinInfo.clear(); + inputtracklets_.clear(); + inputstublists_.clear(); + inputstubidslists_.clear(); + mergedstubidslists_.clear(); } // Make the final track objects, fit with KF, and send to output - for (unsigned int itrk = 0; itrk < numStublists; itrk++) { - bool duplicateTrack = trackInfo[itrk].second; - if (not duplicateTrack) { // Don't waste CPU by calling KF for duplicates - - Tracklet* tracklet = inputtracklets_[itrk]; - std::vector trackstublist = inputstublists_[itrk]; - - // Run KF track fit - HybridFit hybridFitter(iSector, settings_, globals_); - hybridFitter.Fit(tracklet, trackstublist); - - // If the track was accepted (and thus fit), add to output - if (tracklet->fit()) { - // Add fitted Track to output (later converted to TTTrack) - Track* outtrack = tracklet->getTrack(); - outtrack->setSector(iSector); - // Also store fitted track as more detailed Tracklet object. - outputtracklets_[trackInfo[itrk].first]->addTrack(tracklet); - - // Add all tracks to standalone root file output - outtrack->setStubIDpremerge(inputstubidslists_[itrk]); - outtrack->setStubIDprefit(mergedstubidslists_[itrk]); - outputtracks_.push_back(*outtrack); - } + for (unsigned int itrk = 0; itrk < prefTracks.size(); itrk++) { + Tracklet* tracklet = inputtrackletsall[itrk]; + std::vector trackstublist = inputstublistsall[itrk]; + + // Run KF track fit + HybridFit hybridFitter(iSector, settings_, globals_); + hybridFitter.Fit(tracklet, trackstublist); + + // If the track was accepted (and thus fit), add to output + if (tracklet->fit()) { + // Add fitted Track to output (later converted to TTTrack) + Track* outtrack = tracklet->getTrack(); + outtrack->setSector(iSector); + // Also store fitted track as more detailed Tracklet object. + outputtracklets_[prefTrackFit[itrk]]->addTrack(tracklet); + + // Add all tracks to standalone root file output + outtrack->setStubIDpremerge(inputstubidslistsall[itrk]); + outtrack->setStubIDprefit(mergedstubidslistsall[itrk]); + outputtracks_.push_back(*outtrack); } } } + #endif ////////////////// @@ -496,13 +556,13 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe } } -double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { +double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) const { double phiproj; double stubphi; double phires; // Get phi position of stub stubphi = curStub->l1tstub()->phi(); - // Get region that the stub is in (Layer 1->6, Disk 1->5) + // Get layer that the stub is in (Layer 1->6, Disk 1->5) int Layer = curStub->layerdisk() + 1; if (Layer > N_LAYER) { Layer = 0; @@ -525,7 +585,7 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { return phires; } -bool PurgeDuplicate::isSeedingStub(int seedindex, int Layer, int Disk) { +bool PurgeDuplicate::isSeedingStub(int seedindex, int Layer, int Disk) const { if ((seedindex == 0 && (Layer == 1 || Layer == 2)) || (seedindex == 1 && (Layer == 2 || Layer == 3)) || (seedindex == 2 && (Layer == 3 || Layer == 4)) || (seedindex == 3 && (Layer == 5 || Layer == 6)) || (seedindex == 4 && (abs(Disk) == 1 || abs(Disk) == 2)) || @@ -540,7 +600,7 @@ bool PurgeDuplicate::isSeedingStub(int seedindex, int Layer, int Disk) { return false; } -std::pair PurgeDuplicate::findLayerDisk(const Stub* st) { +std::pair PurgeDuplicate::findLayerDisk(const Stub* st) const { std::pair layer_disk; layer_disk.first = st->layerdisk() + 1; if (layer_disk.first > N_LAYER) { @@ -553,7 +613,7 @@ std::pair PurgeDuplicate::findLayerDisk(const Stub* st) { return layer_disk; } -std::string PurgeDuplicate::l1tinfo(const L1TStub* l1stub, std::string str = "") { +std::string PurgeDuplicate::l1tinfo(const L1TStub* l1stub, std::string str = "") const { std::string thestr = Form("\t %s stub info: r/z/phi:\t%f\t%f\t%f\t%d\t%f\t%d", str.c_str(), l1stub->r(), @@ -565,7 +625,9 @@ std::string PurgeDuplicate::l1tinfo(const L1TStub* l1stub, std::string str = "") return thestr; } -std::vector PurgeDuplicate::getInventedCoords(unsigned int iSector, const Stub* st, Tracklet* tracklet) { +std::vector PurgeDuplicate::getInventedCoords(unsigned int iSector, + const Stub* st, + const Tracklet* tracklet) const { int stubLayer = (findLayerDisk(st)).first; int stubDisk = (findLayerDisk(st)).second; @@ -595,7 +657,7 @@ std::vector PurgeDuplicate::getInventedCoords(unsigned int iSector, cons std::vector PurgeDuplicate::getInventedCoordsExtended(unsigned int iSector, const Stub* st, - Tracklet* tracklet) { + const Tracklet* tracklet) const { int stubLayer = (findLayerDisk(st)).first; int stubDisk = (findLayerDisk(st)).second; @@ -644,9 +706,8 @@ std::vector PurgeDuplicate::getInventedCoordsExtended(unsigned int iSect return invented_coords; } -std::vector PurgeDuplicate::getInventedSeedingStub(unsigned int iSector, - Tracklet* tracklet, - std::vector originalStubsList) { +std::vector PurgeDuplicate::getInventedSeedingStub( + unsigned int iSector, const Tracklet* tracklet, const std::vector& originalStubsList) const { std::vector newStubList; for (unsigned int stubit = 0; stubit < originalStubsList.size(); stubit++) { @@ -681,3 +742,44 @@ std::vector PurgeDuplicate::getInventedSeedingStub(unsigned int iSe } return newStubList; } + +// Tells us the variable bin to which a track would belong +unsigned int PurgeDuplicate::findVarRInvBin(const Tracklet* trk) const { + std::vector rInvBins = settings_.varRInvBins(); + + //Get rinverse of track + double rInv = trk->rinv(); + + //Check between what 2 values in rinvbins rinv is between + auto bins = std::upper_bound(rInvBins.begin(), rInvBins.end(), rInv); + + //return integer for bin index + unsigned int rIndx = std::distance(rInvBins.begin(), bins); + if (rIndx == std::distance(rInvBins.end(), bins)) + return rInvBins.size() - 2; + else if (bins == rInvBins.begin()) + return std::distance(rInvBins.begin(), bins); + else + return rIndx - 1; +} + +// Tells us the overlap bin(s) to which a track belongs +std::vector PurgeDuplicate::findOverlapRInvBins(const Tracklet* trk) const { + double rInv = trk->rinv(); + const double overlapSize = settings_.overlapSize(); + const std::vector& varRInvBins = settings_.varRInvBins(); + std::vector chosenBins; + for (long unsigned int i = 0; i < varRInvBins.size() - 1; i++) { + if ((rInv < varRInvBins[i + 1] + overlapSize) && (rInv > varRInvBins[i] - overlapSize)) { + chosenBins.push_back(i); + } + } + return chosenBins; +} + +// Tells us if a track is in the current bin +bool PurgeDuplicate::isTrackInBin(const std::vector& vec, unsigned int num) const { + auto result = std::find(vec.begin(), vec.end(), num); + bool found = (result != vec.end()); + return found; +} diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index 7cb01cff59d75..e3a0531c765e0 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -521,7 +521,7 @@ void TrackletLUT::initTPregionlut(unsigned int iSeed, int idphi1 = idphi; if (iSeed >= 4) idphi1 = (idphi << 3) + ir; - int ptinnerindexnew = l1t::bitShift(idphi1, nbendbitsinner) + innerbend; + int ptinnerindexnew = (idphi1 << nbendbitsinner) + innerbend; match = match || (inrange && tplutinner.lookup(ptinnerindexnew)); } if (match) { @@ -797,12 +797,12 @@ void TrackletLUT::initProjectionBend(double k_phider, int ir = irbin; if (ir > (1 << (nrbits - 1))) ir -= (1 << nrbits); - ir = l1t::bitShift(ir, (settings_.nrbitsstub(N_LAYER) - nrbits)); + ir = ir << (settings_.nrbitsstub(N_LAYER) - nrbits); for (unsigned int iphiderbin = 0; iphiderbin < nphiderbins; iphiderbin++) { int iphider = iphiderbin; if (iphider > (1 << (nphiderbits - 1))) iphider -= (1 << nphiderbits); - iphider = l1t::bitShift(iphider, (settings_.nbitsphiprojderL123() - nphiderbits)); + iphider = iphider << (settings_.nbitsphiprojderL123() - nphiderbits); double rproj = ir * settings_.krprojshiftdisk(); double phider = iphider * k_phider; diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py index 5fff0a1926ad1..dddb5a04ea214 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py @@ -12,8 +12,8 @@ process = cms.Process( "Demo" ) process.load( 'FWCore.MessageService.MessageLogger_cfi' ) process.load( 'Configuration.EventContent.EventContent_cff' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76Reco_cff' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88Reco_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88_cff' ) process.load( 'Configuration.StandardSequences.MagneticField_cff' ) process.load( 'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff' ) process.load( 'L1Trigger.TrackTrigger.TrackTrigger_cff' ) @@ -48,7 +48,7 @@ # build schedule process.mc = cms.Sequence( process.StubAssociator ) process.dtc = cms.Sequence( process.TrackerDTCProducer + process.TrackerDTCAnalyzer ) -process.tracklet = cms.Sequence( process.L1HybridTracks + process.TrackFindingTrackletAnalyzerTracklet ) +process.tracklet = cms.Sequence( process.L1THybridTracks + process.TrackFindingTrackletAnalyzerTracklet ) process.TBout = cms.Sequence( process.TrackFindingTrackletProducerTBout + process.TrackFindingTrackletAnalyzerTBout ) process.interIn = cms.Sequence( process.TrackFindingTrackletProducerKFin + process.TrackFindingTrackletAnalyzerKFin ) process.kf = cms.Sequence( process.TrackFindingTrackletProducerKF + process.TrackFindingTrackletAnalyzerKF ) @@ -66,27 +66,7 @@ #from MCsamples.RelVal_1130_D76.PU200_TTbar_14TeV_cfi import * #inputMC = getCMSdataFromCards() inputMC = [ - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/05f802b7-b0b3-4cca-8b70-754682c3bb4c.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/0b69ed0a-66e9-403a-88f0-fb3115615461.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/0f4dea68-7574-43bb-97c3-5382d68a2704.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/156b3ca6-c74a-4f46-ae5e-03d9b01acd4c.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/16727f1d-2922-4e0a-8239-82e1ffecd43b.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/1af620bf-1f6d-4d5a-8170-4135ac798581.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/1dc513d9-75fc-44c0-b8e0-e2925323416b.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/2010f402-2133-4c3a-851b-1ae68fe23eb3.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/228dfbba-3d5c-42b9-b827-cfa8f11a2f38.root', - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/27d006b1-d023-4775-8430-382e6962149c.root' - #'/store/relval/CMSSW_11_3_0_pre6/RelValDisplacedMuPt2To100Dxy100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/00000/011da61a-9524-4a96-b91f-03e8690af3bd.root' - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/013d0125-8f6e-496b-8335-614398c9210d.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/058bd134-86de-47e1-bcde-379ed9b79e1b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0915d66c-cbd4-4ef6-9971-7dd59e198b56.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/09823c8d-e443-4066-8347-8c704929cb2b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0c39a1aa-93ee-41c1-8543-6d90c09114a7.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0fcdcc53-fb9f-4f0b-8529-a4d60d914c14.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/16760a5c-9cd2-41c3-82e5-399bb962d537.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/1752640f-2001-4d14-9276-063ec07cea92.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/180712c9-31a5-4f2a-bf92-a7fbee4dabad.root' +'/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root' ] options.register( 'inputMC', inputMC, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Files to be processed" ) # specify number of events to process. diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py index 0b50e7cded947..2e03d29479bfb 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py @@ -15,8 +15,8 @@ process.load('Configuration.EventContent.EventContent_cff') process.load('Configuration.StandardSequences.MagneticField_cff') -process.load('Configuration.Geometry.GeometryExtended2026D76Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D76_cff') +process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D88_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') @@ -32,7 +32,7 @@ process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10)) Source_Files = cms.untracked.vstring( - "/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root" +"/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root" ) process.source = cms.Source("PoolSource", fileNames = Source_Files) diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index caf43f4927114..6907b0c5e11f6 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -11,7 +11,10 @@ # edit options here ############################################################ -GEOMETRY = "D76" +# D76 used for old CMSSW_11_3 MC datasets. D88 used for CMSSW_12_6 datasets. +#GEOMETRY = "D76" +GEOMETRY = "D88" + # Set L1 tracking algorithm: # 'HYBRID' (baseline, 4par fit) or 'HYBRID_DISPLACED' (extended, 5par fit). # 'HYBRID_NEWKF' (baseline, 4par fit, with bit-accurate KF emulation), @@ -34,14 +37,12 @@ process.MessageLogger.Tracklet = dict(limit = -1) process.MessageLogger.TrackTriggerHPH = dict(limit = -1) -if GEOMETRY == "D49": - print("using geometry " + GEOMETRY + " (tilted)") - process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') - process.load('Configuration.Geometry.GeometryExtended2026D49_cff') -elif GEOMETRY == "D76": +if GEOMETRY == "D76" or GEOMETRY == "D88": + # Use D88 for both, as both correspond to identical CMS Tracker design, and D76 + # unavailable in CMSSW_12_6_0. print("using geometry " + GEOMETRY + " (tilted)") - process.load('Configuration.Geometry.GeometryExtended2026D76Reco_cff') - process.load('Configuration.Geometry.GeometryExtended2026D76_cff') + process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') + process.load('Configuration.Geometry.GeometryExtended2026D88_cff') else: print("this is not a valid geometry!!!") @@ -64,16 +65,13 @@ #from MCsamples.Scripts.getCMSdata_cfi import * #from MCsamples.Scripts.getCMSlocaldata_cfi import * -if GEOMETRY == "D49": - inputMC = ["/store/relval/CMSSW_11_3_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/00000/00260a30-734a-4a3a-a4b0-f836ce5502c6.root"] - -elif GEOMETRY == "D76": +if GEOMETRY == "D76": # Read data from card files (defines getCMSdataFromCards()): #from MCsamples.RelVal_1130_D76.PU200_TTbar_14TeV_cfi import * #inputMC = getCMSdataFromCards() # Or read .root files from directory on local computer: - #dirName = "$myDir/whatever/" + #dirName = "$scratchmc/MCsamples1130_D76/RelVal/TTbar/PU200/" #inputMC=getCMSlocaldata(dirName) # Or read specified dataset (accesses CMS DB, so use this method only occasionally): @@ -83,13 +81,29 @@ # Or read specified .root file: inputMC = ["/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root"] +elif GEOMETRY == "D88": + + # Read specified .root file: + inputMC = ["/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root"] + else: print("this is not a valid geometry!!!") process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(*inputMC)) + +if GEOMETRY == "D76": + # If reading old MC dataset, drop incompatible EDProducts. + process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(False) + process.source.inputCommands = cms.untracked.vstring() + process.source.inputCommands.append('keep *_*_*Level1TTTracks*_*') + process.source.inputCommands.append('keep *_*_*StubAccepted*_*') + process.source.inputCommands.append('keep *_*_*ClusterAccepted*_*') + process.source.inputCommands.append('keep *_*_*MergedTrackTruth*_*') + process.source.inputCommands.append('keep *_genParticles_*_*') + # Use skipEvents to select particular single events for test vectors -#process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(*inputMC), skipEvents = cms.untracked.uint32(11)) +#process.source.skipEvents = cms.untracked.uint32(11) process.TFileService = cms.Service("TFileService", fileName = cms.string('TTbar_PU200_'+GEOMETRY+'.root'), closeFileFast = cms.untracked.bool(True)) process.Timing = cms.Service("Timing", summaryOnly = cms.untracked.bool(True)) @@ -159,7 +173,7 @@ L1TRK_LABEL = process.TrackFindingTrackletProducer_params.BranchAcceptedTracks.value() L1TRUTH_NAME = "TTTrackAssociatorFromPixelDigis" process.TTTrackAssociatorFromPixelDigis.TTTracks = cms.VInputTag( cms.InputTag(L1TRK_NAME, L1TRK_LABEL) ) - process.HybridNewKF = cms.Sequence(process.L1HybridTracks + process.TrackFindingTrackletProducerTBout + process.TrackFindingTrackletProducerKFin + process.TrackFindingTrackletProducerKF + process.TrackFindingTrackletProducerTT + process.TrackFindingTrackletProducerAS + process.TrackFindingTrackletProducerKFout) + process.HybridNewKF = cms.Sequence(process.L1THybridTracks + process.TrackFindingTrackletProducerTBout + process.TrackFindingTrackletProducerKFin + process.TrackFindingTrackletProducerKF + process.TrackFindingTrackletProducerTT + process.TrackFindingTrackletProducerAS + process.TrackFindingTrackletProducerKFout) process.TTTracksEmulation = cms.Path(process.HybridNewKF) #process.TTTracksEmulationWithTruth = cms.Path(process.HybridNewKF + process.TrackTriggerAssociatorTracks) # Optionally include code producing performance plots & end-of-job summary. @@ -174,8 +188,8 @@ # LEGACY ALGORITHM (EXPERTS ONLY): TRACKLET elif (L1TRKALGO == 'TRACKLET'): - print "\n WARNING: This is not the baseline algorithm! Prefer HYBRID or HYBRID_DISPLACED!" - print "\n To run the Tracklet-only algorithm, ensure you have commented out 'CXXFLAGS=-DUSEHYBRID' in BuildFile.xml & recompiled! \n" + print("\n WARNING: This is not the baseline algorithm! Prefer HYBRID or HYBRID_DISPLACED!") + print("\n To run the Tracklet-only algorithm, ensure you have commented out 'CXXFLAGS=-DUSEHYBRID' in BuildFile.xml & recompiled! \n") process.TTTracksEmulation = cms.Path(process.L1THybridTracks) process.TTTracksEmulationWithTruth = cms.Path(process.L1THybridTracksWithAssociators) NHELIXPAR = 4 diff --git a/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py b/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py index 1479e38c0f161..9c29d51308110 100644 --- a/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py @@ -4,10 +4,8 @@ process = cms.Process( "Demo" ) process.load( 'FWCore.MessageService.MessageLogger_cfi' ) process.load( 'Configuration.EventContent.EventContent_cff' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76Reco_cff' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76_cff' ) -#process.load( 'Configuration.Geometry.GeometryExtended2026D49Reco_cff' ) -#process.load( 'Configuration.Geometry.GeometryExtended2026D49_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88Reco_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88_cff' ) process.load( 'Configuration.StandardSequences.MagneticField_cff' ) process.load( 'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff' ) process.load( 'L1Trigger.TrackTrigger.TrackTrigger_cff' ) @@ -29,7 +27,7 @@ # build schedule process.tt = cms.Sequence ( process.TrackerDTCProducer - + process.L1HybridTracks + + process.L1THybridTracks + process.TrackFindingTrackletProducerIRin + process.TrackFindingTrackletProducerTBout + process.TrackFindingTrackletProducerKFin @@ -42,21 +40,7 @@ import FWCore.ParameterSet.VarParsing as VarParsing options = VarParsing.VarParsing( 'analysis' ) # specify input MC -inputMC = [ - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/05f802b7-b0b3-4cca-8b70-754682c3bb4c.root' - #'/store/relval/CMSSW_11_3_0_pre6/RelValDisplacedMuPt2To100Dxy100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/00000/011da61a-9524-4a96-b91f-03e8690af3bd.root' - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/013d0125-8f6e-496b-8335-614398c9210d.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/058bd134-86de-47e1-bcde-379ed9b79e1b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0915d66c-cbd4-4ef6-9971-7dd59e198b56.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/09823c8d-e443-4066-8347-8c704929cb2b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0c39a1aa-93ee-41c1-8543-6d90c09114a7.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0fcdcc53-fb9f-4f0b-8529-a4d60d914c14.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/16760a5c-9cd2-41c3-82e5-399bb962d537.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/1752640f-2001-4d14-9276-063ec07cea92.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/180712c9-31a5-4f2a-bf92-a7fbee4dabad.root' - #"/store/relval/CMSSW_11_3_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/00000/00260a30-734a-4a3a-a4b0-f836ce5502c6.root" -] + inputMC = ["/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root"] options.register( 'inputMC', inputMC, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Files to be processed" ) # specify number of events to process. options.register( 'Events',100,VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Number of Events to analyze" ) @@ -71,4 +55,4 @@ secondaryFileNames = cms.untracked.vstring(), duplicateCheckMode = cms.untracked.string( 'noDuplicateCheck' ) ) -process.Timing = cms.Service( "Timing", summaryOnly = cms.untracked.bool( True ) ) \ No newline at end of file +process.Timing = cms.Service( "Timing", summaryOnly = cms.untracked.bool( True ) ) diff --git a/L1Trigger/TrackFindingTracklet/test/makeHists.csh b/L1Trigger/TrackFindingTracklet/test/makeHists.csh index 426b0a05dcb9b..43aac9492b58b 100755 --- a/L1Trigger/TrackFindingTracklet/test/makeHists.csh +++ b/L1Trigger/TrackFindingTracklet/test/makeHists.csh @@ -13,7 +13,7 @@ ######################################################################## if ($#argv == 0) then - set inputFullFileName = "TTbar_PU200_D76.root" + set inputFullFileName = "TTbar_PU200_D88.root" else set inputFullFileName = $1 endif diff --git a/L1Trigger/TrackFindingTracklet/test/skimForCI_cfg.py b/L1Trigger/TrackFindingTracklet/test/skimForCI_cfg.py index d21f0528f2d9d..debce78408d99 100644 --- a/L1Trigger/TrackFindingTracklet/test/skimForCI_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/skimForCI_cfg.py @@ -31,9 +31,9 @@ process.load('Configuration.EventContent.EventContent_cff') process.load('Configuration.StandardSequences.MagneticField_cff') -# D49 geometry (T15 tracker) -process.load('Configuration.Geometry.GeometryExtended2026D76Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D76_cff') +# D88 geometry (T24 tracker) +process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D88_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') @@ -46,8 +46,11 @@ from MCsamples.Scripts.getCMSdata_cfi import * # Read data from card files (defines getCMSdataFromCards()): -from MCsamples.RelVal_1130_D76.PU0_TTbar_14TeV_cfi import * -inputMC = getCMSdataFromCards() +#from MCsamples.RelVal_1130_D76.PU0_TTbar_14TeV_cfi import * +#inputMC = getCMSdataFromCards() + +dataName="/RelValTTbar_14TeV/CMSSW_12_6_0_pre4-125X_mcRun4_realistic_v2_2026D88noPU-v1/GEN-SIM-DIGI-RAW" +inputMC=getCMSdata(dataName) process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(*inputMC)) diff --git a/L1Trigger/TrackerTFP/test/demonstrator_cfg.py b/L1Trigger/TrackerTFP/test/demonstrator_cfg.py index 6778baed03186..fef2ececea3d8 100644 --- a/L1Trigger/TrackerTFP/test/demonstrator_cfg.py +++ b/L1Trigger/TrackerTFP/test/demonstrator_cfg.py @@ -3,8 +3,8 @@ process = cms.Process( "Demo" ) process.load( 'FWCore.MessageService.MessageLogger_cfi' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76Reco_cff' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88Reco_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88_cff' ) process.load( 'Configuration.StandardSequences.MagneticField_cff' ) process.load( 'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff' ) process.load( 'L1Trigger.TrackTrigger.TrackTrigger_cff' ) @@ -41,18 +41,7 @@ options = VarParsing.VarParsing( 'analysis' ) # specify input MC Samples = [ - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/05f802b7-b0b3-4cca-8b70-754682c3bb4c.root' - #'/store/relval/CMSSW_11_3_0_pre6/RelValDisplacedMuPt2To100Dxy100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/00000/011da61a-9524-4a96-b91f-03e8690af3bd.root' - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/013d0125-8f6e-496b-8335-614398c9210d.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/058bd134-86de-47e1-bcde-379ed9b79e1b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0915d66c-cbd4-4ef6-9971-7dd59e198b56.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/09823c8d-e443-4066-8347-8c704929cb2b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0c39a1aa-93ee-41c1-8543-6d90c09114a7.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0fcdcc53-fb9f-4f0b-8529-a4d60d914c14.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/16760a5c-9cd2-41c3-82e5-399bb962d537.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/1752640f-2001-4d14-9276-063ec07cea92.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/180712c9-31a5-4f2a-bf92-a7fbee4dabad.root' +'/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root' ] options.register( 'inputMC', Samples, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Files to be processed" ) # specify number of events to process. @@ -68,4 +57,4 @@ secondaryFileNames = cms.untracked.vstring(), duplicateCheckMode = cms.untracked.string( 'noDuplicateCheck' ) ) -process.Timing = cms.Service( "Timing", summaryOnly = cms.untracked.bool( True ) ) \ No newline at end of file +process.Timing = cms.Service( "Timing", summaryOnly = cms.untracked.bool( True ) ) diff --git a/L1Trigger/TrackerTFP/test/test_cfg.py b/L1Trigger/TrackerTFP/test/test_cfg.py index 6f09abfed25a1..9ccf4a01e99f0 100644 --- a/L1Trigger/TrackerTFP/test/test_cfg.py +++ b/L1Trigger/TrackerTFP/test/test_cfg.py @@ -10,8 +10,8 @@ process = cms.Process( "Demo" ) process.load( 'FWCore.MessageService.MessageLogger_cfi' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76Reco_cff' ) -process.load( 'Configuration.Geometry.GeometryExtended2026D76_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88Reco_cff' ) +process.load( 'Configuration.Geometry.GeometryExtended2026D88_cff' ) process.load( 'Configuration.StandardSequences.MagneticField_cff' ) process.load( 'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff' ) process.load( 'L1Trigger.TrackTrigger.TrackTrigger_cff' ) @@ -54,18 +54,7 @@ options = VarParsing.VarParsing( 'analysis' ) # specify input MC Samples = [ - #'/store/relval/CMSSW_11_3_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/10000/05f802b7-b0b3-4cca-8b70-754682c3bb4c.root' - #'/store/relval/CMSSW_11_3_0_pre6/RelValDisplacedMuPt2To100Dxy100/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v6_2026D76noPU-v1/00000/011da61a-9524-4a96-b91f-03e8690af3bd.root' - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/013d0125-8f6e-496b-8335-614398c9210d.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/058bd134-86de-47e1-bcde-379ed9b79e1b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0915d66c-cbd4-4ef6-9971-7dd59e198b56.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/09823c8d-e443-4066-8347-8c704929cb2b.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0c39a1aa-93ee-41c1-8543-6d90c09114a7.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/0fcdcc53-fb9f-4f0b-8529-a4d60d914c14.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/16760a5c-9cd2-41c3-82e5-399bb962d537.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/1752640f-2001-4d14-9276-063ec07cea92.root', - '/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/180712c9-31a5-4f2a-bf92-a7fbee4dabad.root' +'/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root' ] options.register( 'inputMC', Samples, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Files to be processed" ) # specify number of events to process. From 217f4af4f8213dc480cf88e4f035b8e9fab9b077 Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Wed, 4 Jan 2023 18:16:32 +0000 Subject: [PATCH 15/30] Fix missing ESProducts in HPH --- L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py | 6 ++++++ .../TrackFindingTracklet/test/HybridTracksNewKF_cfg.py | 2 -- .../TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py index 9bc3718c98da3..cf287e9b34b4c 100644 --- a/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py +++ b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py @@ -1,5 +1,11 @@ import FWCore.ParameterSet.Config as cms +# Get required input ESProducts +from L1Trigger.TrackerTFP.ProducerES_cff import TrackTriggerDataFormats +from L1Trigger.TrackerTFP.ProducerLayerEncoding_cff import TrackTriggerLayerEncoding +from L1Trigger.TrackTrigger.ProducerSetup_cff import TrackTriggerSetup + +# HitPatternHelper configuration from L1Trigger.TrackFindingTracklet.ProducerHPH_cfi import HitPatternHelper_params HitPatternHelperSetup = cms.ESProducer("hph::ProducerHPH", HitPatternHelper_params) diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py index dddb5a04ea214..8c618b0c7f183 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py @@ -17,8 +17,6 @@ process.load( 'Configuration.StandardSequences.MagneticField_cff' ) process.load( 'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff' ) process.load( 'L1Trigger.TrackTrigger.TrackTrigger_cff' ) -process.load( 'L1Trigger.TrackerTFP.ProducerES_cff' ) -process.load( 'L1Trigger.TrackerTFP.ProducerLayerEncoding_cff' ) from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index 6907b0c5e11f6..6ad0bd508cf05 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -114,8 +114,6 @@ ############################################################ process.load('L1Trigger.TrackTrigger.TrackTrigger_cff') -process.load('L1Trigger.TrackerTFP.ProducerES_cff') -process.load('L1Trigger.TrackerTFP.ProducerLayerEncoding_cff') # remake stubs? #from L1Trigger.TrackTrigger.TTStubAlgorithmRegister_cfi import * From e8c858721fb607931e12dd2806a6542ce44c2eee Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Fri, 20 Jan 2023 16:13:28 +0000 Subject: [PATCH 16/30] Fix to set nbits_ for the VMRME/TE files (#196) (#198) Co-authored-by: aryd --- L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index e3a0531c765e0..8760815ae2249 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -1100,10 +1100,12 @@ void TrackletLUT::initVMRTable(unsigned int layerdisk, VMRTableType type, int re if (settings_.combined()) { if (type == VMRTableType::me) { + nbits_ = 2 * settings_.NLONGVMBITS(); positive_ = false; name_ = "VMRME_" + TrackletConfigBuilder::LayerName(layerdisk) + ".tab"; } if (type == VMRTableType::disk) { + nbits_ = 2 * settings_.NLONGVMBITS(); positive_ = false; name_ = "VMRTE_" + TrackletConfigBuilder::LayerName(layerdisk) + ".tab"; } From 4f95bd3f66bd8e42ffd0f535d3b528b72ff39a1f Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Thu, 6 Apr 2023 14:12:09 +0100 Subject: [PATCH 17/30] Update L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc Co-authored-by: Andrea Perrotta --- L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index 8760815ae2249..9577d282833c3 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -816,7 +816,7 @@ void TrackletLUT::initProjectionBend(double k_phider, double stripPitch = (rproj < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); double bendproj = bendstrip(rproj, rinv, stripPitch, settings_.sensorSpacing2S()); - static double maxbend = (1 << NRINVBITS) - 1; + constexpr double maxbend = (1 << NRINVBITS) - 1; int ibendproj = 2.0 * bendproj + 0.5 * maxbend; if (ibendproj < 0) From c6ea5149e941d0ad117a099ac912fb1502d55ad8 Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Thu, 6 Apr 2023 14:13:05 +0100 Subject: [PATCH 18/30] Update L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc Co-authored-by: Andrea Perrotta --- L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index 9577d282833c3..aecda97fd6f87 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -1163,7 +1163,7 @@ int TrackletLUT::getVMRLookup(unsigned int layerdisk, double z, double r, double double z0cut = settings_.z0cut(); if (layerdisk < N_LAYER) { - double zcutL2L3 = 52.0; //Stubs closer to IP in z will not be used for L2L3 seeds + double constexpr zcutL2L3 = 52.0; //Stubs closer to IP in z will not be used for L2L3 seeds if (iseed == Seed::L2L3 && std::abs(z) < zcutL2L3) return -1; From bf60e52cb3b96a4474d6413c7a63b74cd745b9ac Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Thu, 6 Apr 2023 14:14:18 +0100 Subject: [PATCH 19/30] Update L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc Co-authored-by: Andrea Perrotta --- L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 829ecf563bd37..ccde13886e4e8 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -171,7 +171,7 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe if (inputtracklets_.empty()) continue; - unsigned int numStublists = inputstublists_.size(); + const unsigned int numStublists = inputstublists_.size(); if (settings_.inventStubs()) { for (unsigned int itrk = 0; itrk < numStublists; itrk++) { From e6b8892e6249c20409cf18e3e8dd33b97d21230e Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Thu, 6 Apr 2023 09:43:55 -0400 Subject: [PATCH 20/30] Update L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc Co-authored-by: Andrea Perrotta --- L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 43631168503fe..23141719df185 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -420,12 +420,11 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { next_projid = projindex; // Do we have a new tracklet? bool newtracklet = (j == 0 || projindex != curr_projid); - if (j == 0) - best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible // If so, replace the "best" values with the cut tables if (newtracklet) { best_ideltaphi_disk = idrphicut; - best_ideltar_disk = idrcut; + // Set to the maximum possible if j==0 + best_ideltar_disk = (j == 0)? (1 << (fpgastub->r().nbits() - 1)) : idrcut; } // Update the cut vales (cut table if new tracklet, otherwise current best) From 65982fa6df21705f873cbf126fd3a396fd55e7dc Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Thu, 6 Apr 2023 09:44:58 -0400 Subject: [PATCH 21/30] Update L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc Co-authored-by: Andrea Perrotta --- L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index aecda97fd6f87..b405ee909f81a 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -36,11 +36,12 @@ std::vector TrackletLUT::getSensorModules( } if (use_tan_range) { - double rmin = sm.r() - (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.sinTilt()); - double rmax = sm.r() + (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.sinTilt()); + const double term = (sm.numColumns() / 2 - 0.5) * sm.pitchCol(); + double rmin = sm.r() - term * std::abs(sm.sinTilt()); + double rmax = sm.r() + term * std::abs(sm.sinTilt()); - double zmin = std::abs(sm.z()) - (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.cosTilt()); - double zmax = std::abs(sm.z()) + (sm.numColumns() / 2 - 0.5) * sm.pitchCol() * std::abs(sm.cosTilt()); + double zmin = std::abs(sm.z()) - term * std::abs(sm.cosTilt()); + double zmax = std::abs(sm.z()) + term * std::abs(sm.cosTilt()); //z0_max is swapped here so that the comparison down 5 lines is from same origin (+/- z0) double mod_tan_max = tan_theta(rmin, zmax, z0, false); From a8358f10a70f9d48fe78c22103f4c666f5fdd4c4 Mon Sep 17 00:00:00 2001 From: "Brent R. Yates" Date: Thu, 6 Apr 2023 09:45:58 -0400 Subject: [PATCH 22/30] Update L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc Co-authored-by: Andrea Perrotta --- L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index b405ee909f81a..273ac56ffdd7e 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -94,11 +94,12 @@ std::array TrackletLUT::getTanRange(const std::vectorr() - (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * std::abs(sm->sinTilt()); - double rmax = sm->r() + (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * std::abs(sm->sinTilt()); + const double term = (sm->numColumns() / 2 - 0.5) * sm->pitchCol(); + double rmin = sm->r() - term * std::abs(sm->sinTilt()); + double rmax = sm->r() + term * std::abs(sm->sinTilt()); - double zmin = std::abs(sm->z()) - (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * sm->cosTilt(); - double zmax = std::abs(sm->z()) + (sm->numColumns() / 2 - 0.5) * sm->pitchCol() * sm->cosTilt(); + double zmin = std::abs(sm->z()) - term * sm->pitchCol() * sm->cosTilt(); + double zmax = std::abs(sm->z()) + term * sm->cosTilt(); double mod_tan_max = tan_theta(rmin, zmax, z0, true); //(r, z, z0, bool z0_max), z0_max measures from +/- z0 double mod_tan_min = tan_theta(rmax, zmin, z0, false); From 53bb196aab2db9566a9e4fdaa1cf6b0dadf2be65 Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Thu, 6 Apr 2023 15:18:38 +0100 Subject: [PATCH 23/30] Fix bug in PR review comment suggestion --- L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc index 273ac56ffdd7e..8a769ff71aa5e 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -98,7 +98,7 @@ std::array TrackletLUT::getTanRange(const std::vectorr() - term * std::abs(sm->sinTilt()); double rmax = sm->r() + term * std::abs(sm->sinTilt()); - double zmin = std::abs(sm->z()) - term * sm->pitchCol() * sm->cosTilt(); + double zmin = std::abs(sm->z()) - term * sm->cosTilt(); double zmax = std::abs(sm->z()) + term * sm->cosTilt(); double mod_tan_max = tan_theta(rmin, zmax, z0, true); //(r, z, z0, bool z0_max), z0_max measures from +/- z0 From 760d5d6676afa9829e98e43a46c0ab8f69b9447b Mon Sep 17 00:00:00 2001 From: bryates Date: Thu, 6 Apr 2023 17:17:08 +0200 Subject: [PATCH 24/30] Fxied crash by just using `idrcut` --- L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 23141719df185..43631168503fe 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -420,11 +420,12 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { next_projid = projindex; // Do we have a new tracklet? bool newtracklet = (j == 0 || projindex != curr_projid); + if (j == 0) + best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible // If so, replace the "best" values with the cut tables if (newtracklet) { best_ideltaphi_disk = idrphicut; - // Set to the maximum possible if j==0 - best_ideltar_disk = (j == 0)? (1 << (fpgastub->r().nbits() - 1)) : idrcut; + best_ideltar_disk = idrcut; } // Update the cut vales (cut table if new tracklet, otherwise current best) From b76bdd488cfc5266a3718f2cbb2980bb8c138812 Mon Sep 17 00:00:00 2001 From: bryates Date: Thu, 6 Apr 2023 17:46:01 +0200 Subject: [PATCH 25/30] Fixed `idrcut` in MP and MC --- L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc | 2 -- L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc | 2 -- 2 files changed, 4 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 43631168503fe..1e529d0d1e576 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -420,8 +420,6 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { next_projid = projindex; // Do we have a new tracklet? bool newtracklet = (j == 0 || projindex != curr_projid); - if (j == 0) - best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible // If so, replace the "best" values with the cut tables if (newtracklet) { best_ideltaphi_disk = idrphicut; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index a3c0c04905282..83e07573af631 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -742,8 +742,6 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b next_tracklet = tracklet; // Do we have a new tracklet? bool newtracklet = (istep == 0 || tracklet != curr_tracklet); - if (istep == 0) - best_ideltar_disk = (1 << (fpgastub->r().nbits() - 1)); // Set to the maximum possible // If so, replace the "best" values with the cut tables if (newtracklet) { best_ideltaphi_disk = idrphicut; From 98a168f4ac37affce71ca68b1af130ed293059c2 Mon Sep 17 00:00:00 2001 From: bryates Date: Wed, 12 Apr 2023 15:56:13 +0200 Subject: [PATCH 26/30] Removed uneeded lines --- L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 1e529d0d1e576..b39cc0d31e3b0 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -426,10 +426,6 @@ void MatchCalculator::execute(unsigned int iSector, double phioffset) { best_ideltar_disk = idrcut; } - // Update the cut vales (cut table if new tracklet, otherwise current best) - idrphicut = newtracklet ? idrphicut : best_ideltaphi_disk; - idrcut = newtracklet ? idrcut : best_ideltar_disk; - double drphicut = idrphicut * settings_.kphi() * settings_.kr(); double drcut = idrcut * settings_.krprojshiftdisk(); From cf78e6329393aa71ea91aa16b1641155af6a2e03 Mon Sep 17 00:00:00 2001 From: Jack Li Date: Mon, 17 Apr 2023 13:55:19 +0200 Subject: [PATCH 27/30] PR comment concerning Hitpatternhelper --- L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc index aa14dae8de1d9..4dbe2b27186e1 100644 --- a/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc +++ b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc @@ -251,9 +251,8 @@ namespace hph { for (int iEtaSec = 1; iEtaSec < ((int)etaRegions.size() - 1); iEtaSec++) { // Doesn't apply eta < 2.4 cut. double etaMax = etaRegions[iEtaSec]; double zRefMax = chosenRofZ / tan(2. * atan(exp(-etaMax))); - if (kfzRef > zRefMax) { - kf_eta_reg = iEtaSec; - } + if (kfzRef < zRefMax) break; + kf_eta_reg = iEtaSec; } return kf_eta_reg; } From 0c3107d921e27fd0327b7c627fb541acf257cdce Mon Sep 17 00:00:00 2001 From: Jack Li Date: Mon, 17 Apr 2023 14:08:02 +0200 Subject: [PATCH 28/30] Update sample in cfg.py --- L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py | 2 +- L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py | 2 +- L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py index 8c618b0c7f183..b1c007be27a36 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py @@ -64,7 +64,7 @@ #from MCsamples.RelVal_1130_D76.PU200_TTbar_14TeV_cfi import * #inputMC = getCMSdataFromCards() inputMC = [ -'/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root' +'/store/mc/CMSSW_12_6_0/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v5_2026D88PU200RV183v2-v1/30000/0959f326-3f52-48d8-9fcf-65fc41de4e27.root' ] options.register( 'inputMC', inputMC, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Files to be processed" ) # specify number of events to process. diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py index 2e03d29479bfb..6cfb82bc8b37a 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py @@ -32,7 +32,7 @@ process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10)) Source_Files = cms.untracked.vstring( -"/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root" +"/store/mc/CMSSW_12_6_0/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v5_2026D88PU200RV183v2-v1/30000/0959f326-3f52-48d8-9fcf-65fc41de4e27.root" ) process.source = cms.Source("PoolSource", fileNames = Source_Files) diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index 6ad0bd508cf05..511c56aa15532 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -84,7 +84,7 @@ elif GEOMETRY == "D88": # Read specified .root file: - inputMC = ["/store/relval/CMSSW_12_6_0_pre4/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v2_2026D88PU200-v1/2590000/00b3d04b-4c7b-4506-8d82-9538fb21ee19.root"] + inputMC = ["/store/mc/CMSSW_12_6_0/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_125X_mcRun4_realistic_v5_2026D88PU200RV183v2-v1/30000/0959f326-3f52-48d8-9fcf-65fc41de4e27.root"] else: From dc53680442387e29d052e8d6da7b751678d5ac6d Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Tue, 9 May 2023 16:22:41 +0100 Subject: [PATCH 29/30] Applied official code formatting --- L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc index 4dbe2b27186e1..9ff54c3d35aeb 100644 --- a/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc +++ b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc @@ -251,7 +251,8 @@ namespace hph { for (int iEtaSec = 1; iEtaSec < ((int)etaRegions.size() - 1); iEtaSec++) { // Doesn't apply eta < 2.4 cut. double etaMax = etaRegions[iEtaSec]; double zRefMax = chosenRofZ / tan(2. * atan(exp(-etaMax))); - if (kfzRef < zRefMax) break; + if (kfzRef < zRefMax) + break; kf_eta_reg = iEtaSec; } return kf_eta_reg; From 9f23b968e23a7fa01115657bddd1ae12e9228c76 Mon Sep 17 00:00:00 2001 From: Ian Tomalin Date: Tue, 13 Jun 2023 16:21:35 +0100 Subject: [PATCH 30/30] Removed unused lines of code --- L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 4108ab6add021..be4858359f9fb 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -207,8 +207,6 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe // Count number of layers that share stubs, and the number of UR that each track hits unsigned int nShareLay = 0; - unsigned int nLayStubTrk1 = 0; - unsigned int nLayStubTrk2 = 0; if (settings_.mergeComparison() == "CompareAll") { bool layerArr[16]; for (auto& i : layerArr) { @@ -279,14 +277,6 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe stubsTrk1[t1i].second == stubsTrk2[t2i].second) nShareLay++; } - // Calculate the number of layers hit by each track, so that this number can be used in calculating the number of independent - // stubs on a track (not enabled/used by default) - for (int i = 0; i < 16; i++) { - if (layStubidsTrk1[i] != -1) - nLayStubTrk1++; - if (layStubidsTrk2[i] != -1) - nLayStubTrk2++; - } } // Fill duplicate map if (nShareLay >= settings_.minIndStubs()) { // For number of shared stub merge condition