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/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/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/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/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 78b9573734922..7914e8e51d2ae 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -58,10 +58,19 @@ namespace trklet { TrackletLUT rphicut2Stable_; TrackletLUT rcutPStable_; TrackletLUT rcut2Stable_; + TrackletLUT alphainner_; + TrackletLUT alphaouter_; + 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_; @@ -83,6 +92,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/interface/PurgeDuplicate.h b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h index 7909efdbeb72d..03a4c510d4698 100644 --- a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h +++ b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h @@ -36,7 +36,24 @@ namespace trklet { void execute(std::vector& outputtracks_, unsigned int iSector); private: - double getPhiRes(Tracklet* curTracklet, const Stub* curStub); + 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/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..b5542ef6ae03a 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); } @@ -259,6 +269,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; } @@ -271,10 +283,20 @@ 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; } + //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; } @@ -448,6 +470,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_; } @@ -458,6 +497,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_; @@ -540,6 +581,8 @@ namespace trklet { double rmaxdisk_{120.0}; double rmindisk_{20.0}; + double zsepdisk_{1.5}; //cm + double half2SmoduleWidth_{4.57}; double maxrinv_{0.006}; @@ -786,6 +829,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 @@ -796,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}, @@ -945,6 +1018,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}; @@ -965,6 +1039,16 @@ 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}; }; constexpr unsigned int N_TILTED_RINGS = 12; // # of tilted rings per half-layer in TBPS layers 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/interface/TrackletLUT.h b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h index f37b8a909d498..ca15854a527a9 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h @@ -1,3 +1,13 @@ +////////////////////////////////////////////////////////////////// +// TrackletLUT +// 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 @@ -5,6 +15,10 @@ #include #include +#include "L1Trigger/TrackTrigger/interface/Setup.h" + +class Setup; + namespace trklet { class Settings; @@ -24,11 +38,24 @@ 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); + //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, @@ -36,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, @@ -45,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, @@ -59,31 +90,55 @@ 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(); } 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 dfa238dcc4153..c67565196e501 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 @@ -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(); } }; @@ -349,10 +349,10 @@ 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_); - 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) @@ -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++; } } } @@ -686,11 +694,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 } @@ -707,6 +718,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/Customize_cff.py b/L1Trigger/TrackFindingTracklet/python/Customize_cff.py index 436edaf44a235..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, 28, 5, 29, 6, 30, 7, 31, 8, 32, 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.ChannelAssignment.IRChannelsIn = cms.vint32( 0, 1, 25, 2, 26, 4, 5, 29, 6, 30, 7, 31, 8, 9, 33 ) + 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/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/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/TrackFindingTracklet/python/ProducerHPH_cff.py b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py new file mode 100644 index 0000000000000..cf287e9b34b4c --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/python/ProducerHPH_cff.py @@ -0,0 +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/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/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/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/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 687337c8b4d24..30bfa3a97cf5c 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -1036,7 +1036,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); @@ -1072,7 +1072,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(); } diff --git a/L1Trigger/TrackTrigger/src/HitPatternHelper.cc b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc similarity index 64% rename from L1Trigger/TrackTrigger/src/HitPatternHelper.cc rename to L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc index 53ef5bfc01bd1..9ff54c3d35aeb 100644 --- a/L1Trigger/TrackTrigger/src/HitPatternHelper.cc +++ b/L1Trigger/TrackFindingTracklet/src/HitPatternHelper.cc @@ -2,48 +2,74 @@ // 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" - #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include #include #include 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) + break; + 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/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/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index bda660edffddc..b39cc0d31e3b0 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" @@ -26,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); @@ -61,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++) { @@ -122,14 +140,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 +168,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 +221,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 +269,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 +304,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 +318,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 +326,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 +415,17 @@ 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 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(); @@ -399,34 +441,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 +496,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; 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 204c9d9d0d4d0..83e07573af631 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" @@ -21,6 +33,11 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g rphicut2Stable_(settings), rcutPStable_(settings), rcut2Stable_(settings), + alphainner_(settings), + alphaouter_(settings), + rSSinner_(settings), + rSSouter_(settings), + diskRadius_(settings), fullmatches_(12), rinvbendlut_(settings), luttable_(settings), @@ -47,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_); @@ -65,6 +84,11 @@ 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); + diskRadius_.initProjectionDiskRadius(nrprojbits_); } for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) { @@ -86,6 +110,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) { @@ -368,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(); @@ -440,7 +490,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) { @@ -487,6 +537,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); @@ -516,9 +578,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 << " " @@ -672,6 +738,16 @@ 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 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(); @@ -686,7 +762,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) diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index a49b47595f24f..be4858359f9fb 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -108,237 +108,313 @@ 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; + const 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(); + // 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; + } + } - // 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; - 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; + 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++; } } - // 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++; + // Fill duplicate map + if (nShareLay >= settings_.minIndStubs()) { // For number of shared stub merge condition + dupMap[itrk][jtrk] = true; + dupMap[jtrk][itrk] = true; } } + } - // Fill duplicate map - if (nShareUR >= settings_.minIndStubs()) { // For number of shared stub merge condition - dupMap[itrk][jtrk] = true; - dupMap[jtrk][itrk] = true; + // 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; + } } } - } - // 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; + // 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; } - - // Get a merged stub list - std::vector newStubList; - std::vector stubsTrk1 = inputstublists_[rejetrk]; - std::vector stubsTrk2 = inputstublists_[preftrk]; - newStubList = stubsTrk1; - for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) { - if (find(stubsTrk1.begin(), stubsTrk1.end(), stubsTrk2[stub2it]) == stubsTrk1.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_[rejetrk]; - std::vector> stubidsTrk2 = mergedstubidslists_[preftrk]; - newStubidsList = stubidsTrk1; - for (unsigned int stub2it = 0; stub2it < stubidsTrk2.size(); stub2it++) { - if (find(stubidsTrk1.begin(), stubidsTrk1.end(), stubidsTrk2[stub2it]) == stubidsTrk1.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 ////////////////// @@ -469,13 +545,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; @@ -487,6 +563,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) 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)) || @@ -495,13 +583,192 @@ 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) const { + 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 = "") 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(), + l1stub->z(), + l1stub->phi(), + l1stub->iphi(), + l1stub->bend(), + l1stub->layerdisk()); + return thestr; +} + +std::vector PurgeDuplicate::getInventedCoords(unsigned int iSector, + const Stub* st, + const Tracklet* tracklet) const { + 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, + const Tracklet* tracklet) const { + 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, const Tracklet* tracklet, const std::vector& originalStubsList) const { + 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; +} + +// 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/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; } 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 4f969a2e80cd2..8a769ff71aa5e 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletLUT.cc @@ -2,19 +2,194 @@ #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) { + 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()) - 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); + 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) { + 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()) - 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 + 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; - 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))); } @@ -34,6 +209,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 +254,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; @@ -82,15 +293,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++) { @@ -99,8 +320,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] = @@ -112,11 +335,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; @@ -125,12 +401,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) @@ -139,34 +419,61 @@ 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); } } } } + nbits_ = 8; + positive_ = false; char cTP = 'A' + iTP; @@ -216,7 +523,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) { @@ -264,16 +571,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); @@ -282,28 +596,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++) { @@ -313,13 +682,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) @@ -328,40 +705,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); } @@ -387,7 +783,6 @@ void TrackletLUT::initteptlut(bool fillInner, name_ += "_stubptoutercut.tab"; } } - writeTable(); } @@ -404,12 +799,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; @@ -421,9 +816,9 @@ 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; + constexpr double maxbend = (1 << NRINVBITS) - 1; int ibendproj = 2.0 * bendproj + 0.5 * maxbend; if (ibendproj < 0) @@ -443,41 +838,137 @@ 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); 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); } } @@ -538,7 +1029,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; @@ -609,10 +1102,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"; } @@ -670,7 +1165,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 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; double rmean = settings_.rmean(layerdisk); @@ -835,11 +1331,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; - for (unsigned int ibend = 0; ibend < bendbins; ibend++) { + if (settings_.useCalcBendCuts) { + std::vector sm = getSensorModules(layerdisk, psmodule); + bend_vals = getBendCut(layerdisk, sm, psmodule); + + } 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); } } @@ -852,16 +1359,15 @@ 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; //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(); @@ -899,6 +1405,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 { diff --git a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml index 67f24a2a96908..e0e2cfdb7e047 100644 --- a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml @@ -22,6 +22,5 @@ - diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py index 5f63520975198..b1c007be27a36 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' ) @@ -46,7 +46,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 ) @@ -64,27 +64,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/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. @@ -112,4 +92,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/HybridTracks_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py index 0b50e7cded947..6cfb82bc8b37a 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/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.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 0d27aea2ee548..4e2851197c5f4 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: diff --git a/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py b/L1Trigger/TrackFindingTracklet/test/demonstrator_cfg.py index 6e45507b61120..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' ) @@ -24,12 +22,12 @@ #--- 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 - + 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" ) @@ -67,8 +51,8 @@ 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' ) ) -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/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/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/ProducerHPH_cff.py b/L1Trigger/TrackTrigger/python/ProducerHPH_cff.py deleted file mode 100644 index d788e09a4748b..0000000000000 --- a/L1Trigger/TrackTrigger/python/ProducerHPH_cff.py +++ /dev/null @@ -1,5 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from L1Trigger.TrackTrigger.ProducerHPH_cfi import HitPatternHelper_params - -HitPatternHelperSetup = cms.ESProducer("hph::ProducerHPH", HitPatternHelper_params) 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/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/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/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 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/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/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/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 diff --git a/L1Trigger/TrackerTFP/src/Demonstrator.cc b/L1Trigger/TrackerTFP/src/Demonstrator.cc index e4ba89e515003..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]) : hex(Frame())); + ss << (frame < (int)bvs.size() ? hex(bvs[frame], first) : hex(Frame(), first)); } for (int channel = 0; channel < voidChannel; channel++) - ss << " 0v" << string(TTBV::S_ / 4, '0'); + ss << " 0000 " << string(TTBV::S_ / 4, '0'); ss << endl; + first = false; } } } @@ -108,15 +110,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 +127,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 +141,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/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 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(); 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.