diff --git a/L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h b/L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h deleted file mode 100644 index 7f84afe390301..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_AllProjectionsMemory_h -#define L1Trigger_TrackFindingTracklet_interface_AllProjectionsMemory_h - -#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" - -#include -#include - -namespace trklet { - - class Settings; - class Tracklet; - - class AllProjectionsMemory : public MemoryBase { - public: - AllProjectionsMemory(std::string name, Settings const& settings); - - ~AllProjectionsMemory() override = default; - - void addTracklet(Tracklet* tracklet) { tracklets_.push_back(tracklet); } - - unsigned int nTracklets() const { return tracklets_.size(); } - - const Tracklet* getTracklet(unsigned int i) const { return tracklets_[i]; } - - void clean() override { tracklets_.clear(); } - - void writeAP(bool first, unsigned int iSector); - - private: - std::vector tracklets_; - - int layer_; - int disk_; - }; -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h b/L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h deleted file mode 100644 index 8a20813e378d4..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_CandidateMatchMemory_h -#define L1Trigger_TrackFindingTracklet_interface_CandidateMatchMemory_h - -#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" - -#include -#include -#include - -namespace trklet { - - class Settings; - class Stub; - class L1TStub; - class Tracklet; - - class CandidateMatchMemory : public MemoryBase { - public: - CandidateMatchMemory(std::string name, Settings const& settings); - - ~CandidateMatchMemory() override = default; - - void addMatch(std::pair tracklet, const Stub* stub); - - unsigned int nMatches() const { return matches_.size(); } - - std::pair, const Stub*> getMatch(unsigned int i) { return matches_[i]; } - - void clean() override { matches_.clear(); } - - void writeCM(bool first, unsigned int iSector); - - private: - std::vector, const Stub*> > matches_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h b/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h deleted file mode 100644 index 3f4865598b388..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_MatchCalculator_h -#define L1Trigger_TrackFindingTracklet_interface_MatchCalculator_h - -#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h" - -#include -#include - -namespace trklet { - - class Globals; - class Stub; - class L1TStub; - class Tracklet; - class AllStubsMemory; - class AllProjectionsMemory; - class CandidateMatchMemory; - class FullMatchMemory; - - class MatchCalculator : public ProcessBase { - public: - MatchCalculator(std::string name, Settings const& settings, Globals* global); - - ~MatchCalculator() override = default; - - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(unsigned int iSector, double phioffset); - - std::vector, const Stub*> > mergeMatches( - std::vector& candmatch); - - private: - unsigned int layerdisk_; - unsigned int phiregion_; - - int fact_; - int icorrshift_; - int icorzshift_; - int phi0shift_; - - TrackletLUT phimatchcuttable_; - TrackletLUT zmatchcuttable_; - - TrackletLUT rphicutPStable_; - 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]; - - AllStubsMemory* allstubs_; - AllProjectionsMemory* allprojs_; - - std::vector matches_; - std::vector fullMatches_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h deleted file mode 100644 index 10b76d002169b..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_MatchEngine_h -#define L1Trigger_TrackFindingTracklet_interface_MatchEngine_h - -#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h" -#include - -namespace trklet { - - class Settings; - class Globals; - class MemoryBase; - class VMStubsMEMemory; - class VMProjectionsMemory; - class CandidateMatchMemory; - - class MatchEngine : public ProcessBase { - public: - MatchEngine(std::string name, Settings const& settings, Globals* global); - - ~MatchEngine() override = default; - - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(unsigned int iSector); - - private: - VMStubsMEMemory* vmstubs_; - VMProjectionsMemory* vmprojs_; - - CandidateMatchMemory* candmatches_; - - unsigned int layerdisk_; - - bool barrel_; - - unsigned int nrinv_; //number of bits for rinv in stub bend LUT - - //LUT for bend consistency - TrackletLUT luttable_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h b/L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h deleted file mode 100644 index 230de71eb656d..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_ProjectionRouter_h -#define L1Trigger_TrackFindingTracklet_interface_ProjectionRouter_h - -#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h" - -namespace trklet { - - class Settings; - class Globals; - class MemoryBase; - - class ProjectionRouter : public ProcessBase { - public: - ProjectionRouter(std::string name, Settings const& settings, Globals* global); - - ~ProjectionRouter() override = default; - - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(); - - private: - unsigned int layerdisk_; - - int nrbits_; - int nphiderbits_; - - //disk projectionrinv table - TrackletLUT rinvbendlut_; - - std::vector inputproj_; - - AllProjectionsMemory* allproj_; - std::vector vmprojs_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Sector.h b/L1Trigger/TrackFindingTracklet/interface/Sector.h index eb724e2d003c7..e87c3dad8fb1a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Sector.h +++ b/L1Trigger/TrackFindingTracklet/interface/Sector.h @@ -31,31 +31,19 @@ namespace trklet { class AllInnerStubsMemory; class VMStubsTEMemory; class VMStubsMEMemory; - class StubPairsMemory; class StubTripletsMemory; class TrackletParametersMemory; class TrackletProjectionsMemory; - class AllProjectionsMemory; - class VMProjectionsMemory; - class CandidateMatchMemory; class FullMatchMemory; class TrackFitMemory; class CleanTrackMemory; //Processing modules class InputRouter; - class VMRouter; class VMRouterCM; - class TrackletEngine; - class TrackletEngineDisplaced; - class TripletEngine; - class TrackletCalculator; class TrackletProcessor; class TrackletProcessorDisplaced; class TrackletCalculatorDisplaced; - class ProjectionRouter; - class MatchEngine; - class MatchCalculator; class MatchProcessor; class FitTrack; class PurgeDuplicate; @@ -90,13 +78,9 @@ namespace trklet { void writeVMSME(bool first); void writeAS(bool first); void writeAIS(bool first); - void writeSP(bool first); void writeST(bool first); void writeTPAR(bool first); void writeTPROJ(bool first); - void writeAP(bool first); - void writeVMPROJ(bool first); - void writeCM(bool first); void writeMC(bool first); void writeTF(bool first); void writeCT(bool first); @@ -106,16 +90,11 @@ namespace trklet { // execute the different tracklet processing modules void executeIR(); void executeVMR(); - void executeTE(); void executeTED(); void executeTRE(); void executeTP(); void executeTPD(); - void executeTC(); void executeTCD(); - void executePR(); - void executeME(); - void executeMC(); void executeMP(); void executeFT(std::vector>& streamsTrackRaw, std::vector>& streamsStubRaw); @@ -157,31 +136,19 @@ namespace trklet { std::vector> AIS_; std::vector> VMSTE_; std::vector> VMSME_; - std::vector> SP_; std::vector> ST_; std::vector> TPAR_; std::vector> TPROJ_; - std::vector> AP_; - std::vector> VMPROJ_; - std::vector> CM_; std::vector> FM_; std::vector> TF_; std::vector> CT_; std::map Processes_; std::vector> IR_; - std::vector> VMR_; std::vector> VMRCM_; - std::vector> TE_; - std::vector> TED_; - std::vector> TRE_; std::vector> TP_; std::vector> TPD_; - std::vector> TC_; std::vector> TCD_; - std::vector> PR_; - std::vector> ME_; - std::vector> MC_; std::vector> MP_; std::vector> FT_; std::vector> PD_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 22bd087ab5000..5e171bb55ba9c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -65,8 +65,6 @@ namespace trklet { std::string const& processingModulesFile() const { return processingModulesFile_; } std::string const& memoryModulesFile() const { return memoryModulesFile_; } std::string const& wiresFile() const { return wiresFile_; } - std::string const& tableTEDFile() const { return tableTEDFile_; } - std::string const& tableTREFile() const { return tableTREFile_; } void setFitPatternFile(std::string fitPatternFileName) { fitPatternFile_ = fitPatternFileName; } void setProcessingModulesFile(std::string processingModulesFileName) { @@ -74,8 +72,6 @@ namespace trklet { } void setMemoryModulesFile(std::string memoryModulesFileName) { memoryModulesFile_ = memoryModulesFileName; } void setWiresFile(std::string wiresFileName) { wiresFile_ = wiresFileName; } - void setTableTEDFile(std::string tableTEDFileName) { tableTEDFile_ = tableTEDFileName; } - void setTableTREFile(std::string tableTREFileName) { tableTREFile_ = tableTREFileName; } unsigned int nzbitsstub(unsigned int layerdisk) const { return nzbitsstub_[layerdisk]; } unsigned int nphibitsstub(unsigned int layerdisk) const { return nphibitsstub_[layerdisk]; } @@ -201,9 +197,6 @@ namespace trklet { unsigned int writememsect() const { return writememsect_; } - bool enableTripletTables() const { return enableTripletTables_; } - bool writeTripletTables() const { return writeTripletTables_; } - bool writeoutReal() const { return writeoutReal_; } bool bookHistos() const { return bookHistos_; } @@ -506,8 +499,6 @@ namespace trklet { std::string processingModulesFile_; std::string memoryModulesFile_; std::string wiresFile_; - std::string tableTEDFile_; - std::string tableTREFile_; double rcrit_{55.0}; // critical radius for the hourglass configuration @@ -956,14 +947,6 @@ namespace trklet { unsigned int writememsect_{3}; //writemem only for this sector (note that the files will have _4 extension) - bool enableTripletTables_{false}; //Enable the application of the TED and - //TRE tables; when this flag is false, - //the tables will not be read from disk - bool writeTripletTables_{false}; //Train and write the TED and TRE tables. N.B.: the tables - //cannot be applied while they are being trained, i.e., - //this flag effectively turns off the cuts in - //TrackletEngineDisplaced and TripletEngine - bool writeoutReal_{false}; //set to true/false to turn on/off histogram booking internal to the tracking (class "HistBase/HistImp", does nothing in central CMSSW) diff --git a/L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h b/L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h deleted file mode 100644 index 9f87f84ee490f..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_StubPairsMemory_h -#define L1Trigger_TrackFindingTracklet_interface_StubPairsMemory_h - -#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubTE.h" - -#include - -namespace trklet { - - class Settings; - - class StubPairsMemory : public MemoryBase { - public: - StubPairsMemory(std::string name, Settings const& settings); - - ~StubPairsMemory() override = default; - - void addStubPair(const VMStubTE& stub1, - const VMStubTE& stub2, - const unsigned index = 0, - const std::string& tedName = "") { - stubs_.emplace_back(stub1, stub2); - indices_.push_back(index); - tedNames_.push_back(tedName); - } - - unsigned int nStubPairs() const { return stubs_.size(); } - - const VMStubTE& getVMStub1(unsigned int i) const { return stubs_[i].first; } - const VMStubTE& getVMStub2(unsigned int i) const { return stubs_[i].second; } - - unsigned getIndex(const unsigned i) const { return indices_.at(i); } - const std::string& getTEDName(const unsigned i) const { return tedNames_.at(i); } - - void clean() override { - stubs_.clear(); - indices_.clear(); - tedNames_.clear(); - } - - void writeSP(bool first, unsigned int iSector); - - private: - std::vector > stubs_; - - std::vector indices_; - std::vector tedNames_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h deleted file mode 100644 index a271bab238d69..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_TrackletCalculator_h -#define L1Trigger_TrackFindingTracklet_interface_TrackletCalculator_h - -#include "L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h" - -#include -#include - -namespace trklet { - - class Settings; - class Globals; - class TrackletProjectionsMemory; - class MemoryBase; - class AllStubsMemory; - class StubPairsMemory; - class VarInv; - class VarBase; - - class TrackletCalculator : public TrackletCalculatorBase { - public: - TrackletCalculator(std::string name, Settings const& settings, Globals* globals); - - ~TrackletCalculator() override = default; - - void addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory); - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(unsigned int iSector, double phimin, double phimax); - - private: - int iTC_; - - std::vector innerallstubs_; - std::vector outerallstubs_; - std::vector stubpairs_; - - void writeInvTable(void (*writeLUT)(const VarInv&, const std::string&)); - void writeFirmwareDesign(void (*writeDesign)(const std::vector&, const std::string&)); - }; -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h deleted file mode 100644 index 054f66bca1b47..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_TrackletEngine_h -#define L1Trigger_TrackFindingTracklet_interface_TrackletEngine_h - -#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h" - -#include -#include - -namespace trklet { - - class Settings; - class Globals; - class MemoryBase; - class VMStubsTEMemory; - class StubPairsMemory; - - class TrackletEngine : public ProcessBase { - public: - TrackletEngine(std::string name, Settings const& settings, Globals* global); - - ~TrackletEngine() override = default; - - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(); - - void setVMPhiBin(); - - private: - //Which seed type and which layer/disk is used - unsigned int iSeed_; - unsigned int layerdisk1_; //inner seeding layer - unsigned int layerdisk2_; //outer seeding layer - - //The input vmstubs memories - VMStubsTEMemory* innervmstubs_; - VMStubsTEMemory* outervmstubs_; - - //The output stub pair memory - StubPairsMemory* stubpairs_; - - //The stub pt (bend) lookup table for the inner and outer stub - TrackletLUT innerptlut_; - TrackletLUT outerptlut_; - - //Number of phi bits used in the lookup table - unsigned int innerphibits_; - unsigned int outerphibits_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h deleted file mode 100644 index 91ea9e6ad4ee8..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h +++ /dev/null @@ -1,54 +0,0 @@ -// TrackletEngineDisplaced: this class forms tracklets (pairs of stubs) w/o beamspot constraint for the displaced (extended) tracking. -// Triplet seeds are formed in the TripletEngine from these (=TrackletEngineDisplaced) + a third stub. -#ifndef L1Trigger_TrackFindingTracklet_interface_TrackletEngineDisplaced_h -#define L1Trigger_TrackFindingTracklet_interface_TrackletEngineDisplaced_h - -#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" - -#include -#include -#include - -namespace trklet { - - class Settings; - class Globals; - class MemoryBase; - class VMStubsTEMemory; - class StubPairsMemory; - - class TrackletEngineDisplaced : public ProcessBase { - public: - TrackletEngineDisplaced(std::string name, Settings const& settings, Globals* global); - - ~TrackletEngineDisplaced() override; - - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(); - - void readTables(); - - short memNameToIndex(const std::string& name); - - private: - int layer1_; - int layer2_; - int disk1_; - int disk2_; - - std::vector firstvmstubs_; - VMStubsTEMemory* secondvmstubs_; - - std::vector stubpairs_; - - std::vector > table_; - - int firstphibits_; - int secondphibits_; - - int iSeed_; - }; -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h index e617ef173e6ea..18916de015cef 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h @@ -57,16 +57,8 @@ namespace trklet { Timer addStubTimer_; Timer InputRouterTimer_; Timer VMRouterTimer_; - Timer TETimer_; - Timer TEDTimer_; - Timer TRETimer_; Timer TPTimer_; Timer TPDTimer_; - Timer TCTimer_; - Timer TCDTimer_; - Timer PRTimer_; - Timer METimer_; - Timer MCTimer_; Timer MPTimer_; Timer FTTimer_; Timer PDTimer_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TripletEngine.h b/L1Trigger/TrackFindingTracklet/interface/TripletEngine.h deleted file mode 100644 index ad5840af13a0e..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/TripletEngine.h +++ /dev/null @@ -1,70 +0,0 @@ -// TripletEngine: Adds third stub to stub pairs found by TrackletEngineDisplaced to form "triplet" seeds for the displaced (extended) tracking -#ifndef L1Trigger_TrackFindingTracklet_interface_TripletEngine_h -#define L1Trigger_TrackFindingTracklet_interface_TripletEngine_h - -#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/StubTripletsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h" - -#include -#include - -namespace trklet { - - class Settings; - class Globals; - - class TripletEngine : public ProcessBase { - public: - TripletEngine(std::string name, Settings const& settings, Globals* global); - - ~TripletEngine() override; - - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(); - - void readTables(); - void writeTables(); - - private: - int count_; - - int layer1_; - int layer2_; - int layer3_; - int disk1_; - int disk2_; - int disk3_; - int dct1_; - int dct2_; - int dct3_; - int phi1_; - int phi2_; - int phi3_; - int z1_; - int z2_; - int z3_; - int r1_; - int r2_; - int r3_; - - std::vector thirdvmstubs_; - std::vector stubpairs_; - - StubTripletsMemory* stubtriplets_; - - std::map > > tmpSPTable_; - std::map > > spTable_; - std::vector table_; - - int secondphibits_; - int thirdphibits_; - - int iSeed_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h b/L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h deleted file mode 100644 index 47f15743dc6c8..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h +++ /dev/null @@ -1,41 +0,0 @@ -// VMProjectionsMemory: Class to hold a reduced format of the tracklet projections (from ProjectionRouter) -#ifndef L1Trigger_TrackFindingTracklet_interface_VMProjectionsMemory_h -#define L1Trigger_TrackFindingTracklet_interface_VMProjectionsMemory_h - -#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" - -#include - -namespace trklet { - - class Settings; - class Tracklet; - - class VMProjectionsMemory : public MemoryBase { - public: - VMProjectionsMemory(std::string name, Settings const& settings); - - ~VMProjectionsMemory() override = default; - - void addTracklet(Tracklet* tracklet, unsigned int allprojindex); - - unsigned int nTracklets() const { return tracklets_.size(); } - - Tracklet* getTracklet(unsigned int i) { return tracklets_[i].first; } - int getAllProjIndex(unsigned int i) const { return tracklets_[i].second; } - - void writeVMPROJ(bool first, unsigned int iSector); - - void clean() override { tracklets_.clear(); } - - int layer() const { return layer_; } - int disk() const { return disk_; } - - private: - int layer_; - int disk_; - std::vector > tracklets_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/VMRouter.h b/L1Trigger/TrackFindingTracklet/interface/VMRouter.h deleted file mode 100644 index 5f5fc7ae6d981..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/VMRouter.h +++ /dev/null @@ -1,77 +0,0 @@ -// VMRouter: sorts input stubs into smaller units in phi (and possibly z), referred to as "Virtual Modules" (VMs) -#ifndef L1Trigger_TrackFindingTracklet_interface_VMRouter_h -#define L1Trigger_TrackFindingTracklet_interface_VMRouter_h - -#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h" - -#include -#include -#include - -namespace trklet { - - class Settings; - class Globals; - class MemoryBase; - class InputLinkMemory; - class AllStubsMemory; - class VMStubsMEMemory; - class VMStubsTEMemory; - - struct VMStubsTEPHI { - VMStubsTEPHI(unsigned int seednumber_, - unsigned int stubposition_, - std::vector > vmstubmem_) - : seednumber(seednumber_), stubposition(stubposition_), vmstubmem(vmstubmem_) {} - - unsigned int seednumber; //seed number [0,11] - unsigned int stubposition; //stub position in the seed - std::vector > - vmstubmem; // m_vmstubmem[iVM][n] is the VMStubsTEMemory for iVM and the nth copy - }; - - class VMRouter : public ProcessBase { - public: - VMRouter(std::string name, Settings const& settings, Globals* global); - - ~VMRouter() override = default; - - void addOutput(MemoryBase* memory, std::string output) override; - void addInput(MemoryBase* memory, std::string input) override; - - void execute(); - - private: - //0-5 are the layers and 6-10 are the disks - unsigned int layerdisk_; - - //overlapbits_ is the top bits of phicorr used to add or subtract one to see if stub should be added to - //two VMs. nextrabits_ is the number of bits beyond the bits for the phivm that is used by overlapbits_ - unsigned int overlapbits_; - unsigned int nextrabits_; - - int nbitszfinebintable_; - int nbitsrfinebintable_; - - TrackletLUT meTable_; //used for ME and outer TE barrel - TrackletLUT diskTable_; //outer disk used by D1, D2, and D4 - TrackletLUT innerTable_; //projection to next layer/disk - TrackletLUT innerOverlapTable_; //projection to disk from layer - TrackletLUT innerThirdTable_; //projection to disk1 for extended - iseed=10 - - //The input stub memories the two tmp inputs are used to build the order needed in HLS - std::vector stubinputs_, stubinputtmp_, stubinputdisk2stmp_; - - //The all stub memories - std::vector allstubs_; - - //The VM stubs memories used by the MEs - std::vector vmstubsMEPHI_; - - //The VM stubs memories used by the TEs (using structure defined above) - std::vector vmstubsTEPHI_; - }; -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 7bf8133418866..078e8437727a7 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -154,9 +154,6 @@ class L1FPGATrackProducer : public edm::one::EDProducer { edm::FileInPath processingModulesFile; edm::FileInPath wiresFile; - edm::FileInPath tableTEDFile; - edm::FileInPath tableTREFile; - std::string asciiEventOutName_; std::ofstream asciiEventOut_; @@ -264,11 +261,6 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) reduced_ = iConfig.getParameter("Reduced"); nHelixPar_ = iConfig.getParameter("Hnpar"); - if (extended_) { - tableTEDFile = iConfig.getParameter("tableTEDFile"); - tableTREFile = iConfig.getParameter("tableTREFile"); - } - // -------------------------------------------------------------------------------- // set options in Settings based on inputs from configuration files // -------------------------------------------------------------------------------- @@ -291,12 +283,8 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) settings_.setDoMultipleMatches(iConfig.getParameter("DoMultipleMatches")); if (extended_) { - settings_.setTableTEDFile(tableTEDFile.fullPath()); - settings_.setTableTREFile(tableTREFile.fullPath()); - - //FIXME: The TED and TRE tables are currently disabled by default, so we - //need to allow for the additional tracklets that will eventually be - //removed by these tables, once they are finalized + //FIXME: We need to allow for the additional tracklets that will eventually + // be removed by lookup tables, once they are finalized settings_.setNbitstrackletindex(15); } @@ -312,10 +300,6 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) #endif << "\n process modules : " << processingModulesFile.fullPath() << "\n memory modules : " << memoryModulesFile.fullPath() << "\n wires : " << wiresFile.fullPath(); - if (extended_) { - edm::LogVerbatim("Tracklet") << "table_TED : " << tableTEDFile.fullPath() - << "\n table_TRE : " << tableTREFile.fullPath(); - } } if (settings_.storeTrackBuilderOutput() && (settings_.doMultipleMatches() || !settings_.removalType().empty())) { cms::Exception exception("ConfigurationNotSupported."); diff --git a/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py b/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py index 4066a576a5250..b82b35f83a058 100644 --- a/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py @@ -35,9 +35,6 @@ Extended = cms.bool(True), Reduced = cms.bool(False), Hnpar = cms.uint32(5), - # specifying where the TrackletEngineDisplaced(TED)/TripletEngine(TRE) tables are located - tableTEDFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/table_TED/table_TED_D1PHIA1_D2PHIA1.txt'), - tableTREFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/table_TRE/table_TRE_D1AD2A_1.txt'), # Quality Flag and Quality params TrackQuality = cms.bool(False) ) diff --git a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc deleted file mode 100644 index 409bd8eb7e663..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc +++ /dev/null @@ -1,40 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Util.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include -#include - -using namespace trklet; -using namespace std; - -AllProjectionsMemory::AllProjectionsMemory(string name, Settings const& settings) : MemoryBase(name, settings) { - initLayerDisk(3, layer_, disk_); -} - -void AllProjectionsMemory::writeAP(bool first, unsigned int iSector) { - iSector_ = iSector; - const string dirTP = settings_.memPath() + "TrackletProjections/"; - - std::ostringstream oss; - oss << dirTP << "AllProj_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; - auto const& fname = oss.str(); - - openfile(out_, first, dirTP, fname, __FILE__, __LINE__); - - out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; - - for (unsigned int j = 0; j < tracklets_.size(); j++) { - string proj = - (layer_ > 0) ? tracklets_[j]->trackletprojstrlayer(layer_) : tracklets_[j]->trackletprojstrdisk(disk_); - out_ << hexstr(j) << " " << proj << " " << trklet::hexFormat(proj) << endl; - } - out_.close(); - - bx_++; - event_++; - if (bx_ > 7) - bx_ = 0; -} diff --git a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc deleted file mode 100644 index adef2141b7223..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc +++ /dev/null @@ -1,59 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h" -#include "L1Trigger/TrackFindingTracklet/interface/Stub.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include -#include - -using namespace std; -using namespace trklet; - -CandidateMatchMemory::CandidateMatchMemory(string name, Settings const& settings) : MemoryBase(name, settings) {} - -void CandidateMatchMemory::addMatch(std::pair tracklet, const Stub* stub) { - std::pair, const Stub*> tmp(tracklet, stub); - - //Check for consistency - for (auto& match : matches_) { - if (tracklet.first->TCID() < match.first.first->TCID()) { - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " In " << getName() << " adding tracklet " - << tracklet.first << " with lower TCID : " << tracklet.first->TCID() - << " than earlier TCID " << match.first.first->TCID(); - } - } - matches_.push_back(tmp); -} - -void CandidateMatchMemory::writeCM(bool first, unsigned int iSector) { - iSector_ = iSector; - const string dirM = settings_.memPath() + "Matches/"; - - std::ostringstream oss; - oss << dirM << "CandidateMatches_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) - << ".dat"; - auto const& fname = oss.str(); - - openfile(out_, first, dirM, fname, __FILE__, __LINE__); - - out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; - - for (unsigned int j = 0; j < matches_.size(); j++) { - string stubid = matches_[j].second->stubindex().str(); // stub ID - int projindex = matches_[j].first.second; // Allproj index - FPGAWord tmp; - if (projindex >= (1 << 7)) { - projindex = (1 << 7) - 1; - } - tmp.set(projindex, 7, true, __LINE__, __FILE__); - out_ << hexstr(j) << " " << tmp.str() << "|" << stubid << " " << trklet::hexFormat(tmp.str() + stubid) << endl; - } - out_.close(); - - bx_++; - event_++; - if (bx_ > 7) - bx_ = 0; -} diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc deleted file mode 100644 index 010ce6b3b771a..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ /dev/null @@ -1,581 +0,0 @@ -////////////////////////////////////////////////////////////////// -// 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" -#include "L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/FullMatchMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h" -#include "L1Trigger/TrackFindingTracklet/interface/Stub.h" -#include "L1Trigger/TrackFindingTracklet/interface/HistBase.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" -#include "DataFormats/Math/interface/deltaPhi.h" - -#include -#include - -using namespace std; -using namespace trklet; - -MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global), - phimatchcuttable_(settings), - zmatchcuttable_(settings), - rphicutPStable_(settings), - rphicut2Stable_(settings), - rcutPStable_(settings), - rcut2Stable_(settings), - alphainner_(settings), - alphaouter_(settings), - rSSinner_(settings), - rSSouter_(settings) { - phiregion_ = name[8] - 'A'; - layerdisk_ = initLayerDisk(3); - - fullMatches_.resize(12, nullptr); - - //TODO - need to sort out constants here - icorrshift_ = 7; - - if (layerdisk_ < N_PSLAYER) { - icorzshift_ = -1 - settings_.PS_zderL_shift(); - } else { - icorzshift_ = -1 - settings_.SS_zderL_shift(); - } - phi0shift_ = 3; - fact_ = 1; - if (layerdisk_ >= N_PSLAYER && layerdisk_ < N_LAYER) { - fact_ = (1 << (settings_.nzbitsstub(0) - settings_.nzbitsstub(5))); - icorrshift_ -= (10 - settings_.nrbitsstub(layerdisk_)); - icorzshift_ += (settings_.nzbitsstub(0) - settings_.nzbitsstub(5) + settings_.nrbitsstub(layerdisk_) - - settings_.nrbitsstub(0)); - phi0shift_ = 0; - } - - unsigned int region = getName()[8] - 'A'; - assert(region < settings_.nallstubs(layerdisk_)); - - if (layerdisk_ < N_LAYER) { - phimatchcuttable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::barrelphi, region); - zmatchcuttable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::barrelz, region); - } else { - rphicutPStable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::diskPSphi, region); - 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++) { - ialphafactinner_[i] = (1 << settings_.alphashift()) * settings_.krprojshiftdisk() * settings_.half2SmoduleWidth() / - (1 << (settings_.nbitsalpha() - 1)) / (settings_.rDSSinner(i) * settings_.rDSSinner(i)) / - settings_.kphi(); - ialphafactouter_[i] = (1 << settings_.alphashift()) * settings_.krprojshiftdisk() * settings_.half2SmoduleWidth() / - (1 << (settings_.nbitsalpha() - 1)) / (settings_.rDSSouter(i) * settings_.rDSSouter(i)) / - settings_.kphi(); - } -} - -void MatchCalculator::addOutput(MemoryBase* memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - if (output.substr(0, 8) == "matchout") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - unsigned int iSeed = getISeed(memory->getName()); - fullMatches_[iSeed] = tmp; - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output " << output; -} - -void MatchCalculator::addInput(MemoryBase* memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input == "allstubin") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - allstubs_ = tmp; - return; - } - if (input == "allprojin") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - allprojs_ = tmp; - return; - } - if (input.substr(0, 5) == "match" && input.substr(input.size() - 2, 2) == "in") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - matches_.push_back(tmp); - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input " << input; -} - -void MatchCalculator::execute(unsigned int iSector, double phioffset) { - unsigned int countall = 0; - unsigned int countsel = 0; - - //bool print = getName() == "MC_L4PHIC" && iSector == 3; - - 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 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"; - } - - countall++; - - const Stub* fpgastub = mergedMatches[j].second; - Tracklet* tracklet = mergedMatches[j].first.first; - const L1TStub* stub = fpgastub->l1tstub(); - - //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()); - } - oldTracklet = tracklet; - - if (layerdisk_ < N_LAYER) { - //Integer calculation - - const Projection& proj = tracklet->proj(layerdisk_); - - int ir = fpgastub->r().value(); - int iphi = proj.fpgaphiproj().value(); - int icorr = (ir * proj.fpgaphiprojder().value()) >> icorrshift_; - iphi += icorr; - - int iz = proj.fpgarzproj().value(); - int izcor = (ir * proj.fpgarzprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_; - iz += izcor; - - int ideltaz = fpgastub->z().value() - iz; - int ideltaphi = (fpgastub->phi().value() << phi0shift_) - (iphi << (settings_.phi0bitshift() - 1 + phi0shift_)); - - //Floating point calculations - - double phi = stub->phi() - phioffset; - double r = stub->r(); - double z = stub->z(); - - if (settings_.useapprox()) { - double dphi = reco::reducePhiRange(phi - fpgastub->phiapprox(0.0, 0.0)); - assert(std::abs(dphi) < 0.001); - phi = fpgastub->phiapprox(0.0, 0.0); - z = fpgastub->zapprox(); - r = fpgastub->rapprox(); - } - - if (phi < 0) - phi += 2 * M_PI; - - double dr = r - settings_.rmean(layerdisk_); - assert(std::abs(dr) < settings_.drmax()); - - double dphi = reco::reducePhiRange(phi - (proj.phiproj() + dr * proj.phiprojder())); - - double dz = z - (proj.rzproj() + dr * proj.rzprojder()); - - double dphiapprox = reco::reducePhiRange(phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox())); - - 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); - - if (settings_.bookHistos()) { - bool truthmatch = tracklet->stubtruthmatch(stub); - - HistBase* hists = globals_->histograms(); - hists->FillLayerResidual(layerdisk_ + 1, - seedindex, - dphiapprox * settings_.rmean(layerdisk_), - ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_), - ideltaz * fact_ * settings_.kz(), - dz, - truthmatch); - } - - //This would catch significant consistency problems in the configuration - helps to debug if there are problems. - if (std::abs(dphi) > 0.5 * settings_.dphisectorHG() || std::abs(dphiapprox) > 0.5 * settings_.dphisectorHG()) { - throw cms::Exception("LogicError") - << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox << endl; - } - - if (settings_.writeMonitorData("Residuals")) { - double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); - - globals_->ofstream("layerresiduals.txt") - << layerdisk_ + 1 << " " << seedindex << " " << pt << " " - << ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_) << " " - << dphiapprox * settings_.rmean(layerdisk_) << " " - << phimatchcuttable_.lookup(seedindex) * settings_.kphi1() * settings_.rmean(layerdisk_) << " " - << ideltaz * fact_ * settings_.kz() << " " << dz << " " - << zmatchcuttable_.lookup(seedindex) * settings_.kz() << endl; - } - - // 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 << " ideltaphi cut " << ideltaphi << " " - << phimatchcuttable_.lookup(seedindex) << " ideltaz*fact cut " << ideltaz * fact_ - << " " << zmatchcuttable_.lookup(seedindex); - } - - if (imatch) { - countsel++; - - tracklet->addMatch(layerdisk_, - ideltaphi, - ideltaz, - dphi, - dz, - dphiapprox, - dzapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), - mergedMatches[j].second); - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet; - } - - 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); - - int sign = (tracklet->t() > 0.0) ? 1 : -1; - int disk = sign * (layerdisk_ - (N_LAYER - 1)); - assert(disk != 0); - - //Perform integer calculations here - - const Projection& proj = tracklet->proj(layerdisk_); - - int iz = fpgastub->z().value(); - int iphi = proj.fpgaphiproj().value(); - - //TODO - need to express in terms of constants - int shifttmp = 6; - int iphicorr = (iz * proj.fpgaphiprojder().value()) >> shifttmp; - - iphi += iphicorr; - - int ir = proj.fpgarzproj().value(); - - //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()) { - assert(irstub < (int)N_DSS_MOD * 2); - if (abs(disk) <= 2) { - ialphafact = ialphafactinner_[irstub]; - irstub = settings_.rDSSinner(irstub) / settings_.kr(); - } else { - ialphafact = ialphafactouter_[irstub]; - irstub = settings_.rDSSouter(irstub) / settings_.kr(); - } - } - - //TODO stub and projection r should not use different # bits... - int ideltar = (irstub >> 1) - ir; - - if (!stub->isPSmodule()) { - int ialpha = fpgastub->alpha().value(); - int iphialphacor = ((ideltar * ialpha * ialphafact) >> settings_.alphashift()); - ideltaphi += iphialphacor; - } - - //Perform floating point calculations here - - double phi = stub->phi() - phioffset; - double z = stub->z(); - double r = stub->r(); - - if (settings_.useapprox()) { - double dphi = reco::reducePhiRange(phi - fpgastub->phiapprox(0.0, 0.0)); - assert(std::abs(dphi) < 0.001); - phi = fpgastub->phiapprox(0.0, 0.0); - z = fpgastub->zapprox(); - r = fpgastub->rapprox(); - } - - if (phi < 0) - phi += 2 * M_PI; - - double dz = z - sign * settings_.zmean(layerdisk_ - N_LAYER); - - if (std::abs(dz) > settings_.dzmax()) { - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " " << name_ << " " << tracklet->getISeed() - << "\n stub " << stub->z() << " disk " << disk << " " << dz; - } - - double phiproj = proj.phiproj() + dz * proj.phiprojder(); - - double rproj = proj.rzproj() + dz * proj.rzprojder(); - - double deltar = r - rproj; - - double dr = stub->r() - rproj; - - double dphi = reco::reducePhiRange(phi - phiproj); - - double dphiapprox = reco::reducePhiRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox())); - - double drapprox = stub->r() - (proj.rzprojapprox() + dz * proj.rzprojderapprox()); - - double drphi = dphi * stub->r(); - double drphiapprox = dphiapprox * stub->r(); - - if (!stub->isPSmodule()) { - double alphanorm = stub->alphanorm(); - dphi += dr * alphanorm * settings_.half2SmoduleWidth() / stub->r2(); - dphiapprox += drapprox * alphanorm * settings_.half2SmoduleWidth() / stub->r2(); - - drphi += dr * alphanorm * settings_.half2SmoduleWidth() / stub->r(); - drphiapprox += dr * alphanorm * settings_.half2SmoduleWidth() / stub->r(); - } - - int seedindex = tracklet->getISeed(); - - int idrphicut = rphicutPStable_.lookup(seedindex); - int idrcut = rcutPStable_.lookup(seedindex); - if (!stub->isPSmodule()) { - idrphicut = rphicut2Stable_.lookup(seedindex); - 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(); - - bool match, imatch; - if (std::abs(dphi) < third * settings_.dphisectorHG() && - std::abs(dphiapprox) < third * settings_.dphisectorHG()) { //1/3 of sector size to catch errors - if (settings_.writeMonitorData("Residuals")) { - double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); - - globals_->ofstream("diskresiduals.txt") - << disk << " " << stub->isPSmodule() << " " << tracklet->layer() << " " << abs(tracklet->disk()) << " " - << pt << " " << ideltaphi * settings_.kphi() * stub->r() << " " << drphiapprox << " " << drphicut << " " - << ideltar * settings_.krprojshiftdisk() << " " << deltar << " " << drcut << " " << endl; - } - - // floating point match - match = (std::abs(drphi) < drphicut) && (std::abs(deltar) < drcut); - - // 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; - } - if (settings_.debugTracklet()) { - 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) { - countsel++; - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "MatchCalculator found match in disk " << getName(); - } - - tracklet->addMatch(layerdisk_, - ideltaphi, - ideltar, - drphi / stub->r(), - dr, - drphiapprox / stub->r(), - drapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), - fpgastub); - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet; - } - - fullMatches_[seedindex]->addMatch(tracklet, mergedMatches[j].second); - } - } - if (countall >= settings_.maxStep("MC")) - break; - } - - if (settings_.writeMonitorData("MC")) { - globals_->ofstream("matchcalculator.txt") << getName() << " " << countall << " " << countsel << endl; - } -} - -// Combines all tracklet/stub pairs into a vector -std::vector, const Stub*> > MatchCalculator::mergeMatches( - vector& candmatch) { - std::vector, const Stub*> > tmp; - - std::vector indexArray; - indexArray.reserve(candmatch.size()); - for (unsigned int i = 0; i < candmatch.size(); i++) { - indexArray.push_back(0); - } - - int bestIndex = -1; - do { - int bestSector = 100; - int bestTCID = -1; - bestIndex = -1; - for (unsigned int i = 0; i < candmatch.size(); i++) { - if (indexArray[i] >= candmatch[i]->nMatches()) { - // skip as we were at the end - continue; - } - int TCID = candmatch[i]->getMatch(indexArray[i]).first.first->TCID(); - int dSector = 0; - if (dSector > 2) - dSector -= N_SECTOR; - if (dSector < -2) - dSector += N_SECTOR; - assert(abs(dSector) < 2); - if (dSector == -1) - dSector = 2; - if (dSector < bestSector) { - bestSector = dSector; - bestTCID = TCID; - bestIndex = i; - } - if (dSector == bestSector) { - if (TCID < bestTCID || bestTCID < 0) { - bestTCID = TCID; - bestIndex = i; - } - } - } - if (bestIndex != -1) { - tmp.push_back(candmatch[bestIndex]->getMatch(indexArray[bestIndex])); - indexArray[bestIndex]++; - } - } while (bestIndex != -1); - - if (layerdisk_ < N_LAYER) { - int lastTCID = -1; - bool error = false; - - //Allow equal TCIDs since we can have multiple candidate matches - for (unsigned int i = 1; i < tmp.size(); i++) { - if (lastTCID > tmp[i].first.first->TCID()) { - edm::LogProblem("Tracklet") << "Wrong TCID ordering for projections in " << getName() << " last " << lastTCID - << " " << tmp[i].first.first->TCID(); - error = true; - } else { - lastTCID = tmp[i].first.first->TCID(); - } - } - - if (error) { - for (unsigned int i = 1; i < tmp.size(); i++) { - edm::LogProblem("Tracklet") << "Wrong order for in " << getName() << " " << i << " " << tmp[i].first.first - << " " << tmp[i].first.first->TCID(); - } - } - } - - for (unsigned int i = 0; i < tmp.size(); i++) { - if (i > 0) { - //This allows for equal TCIDs. This means that we can e.g. have a track seeded - //in L1L2 that projects to both L3 and D4. The algorithm will pick up the first hit and - //drop the second - - assert(tmp[i - 1].first.first->TCID() <= tmp[i].first.first->TCID()); - } - } - - return tmp; -} diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc deleted file mode 100644 index 61e17acac9a82..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ /dev/null @@ -1,302 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/MatchEngine.h" -#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" -#include "L1Trigger/TrackFindingTracklet/interface/Util.h" -#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include - -using namespace std; -using namespace trklet; - -MatchEngine::MatchEngine(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global), luttable_(settings) { - layerdisk_ = initLayerDisk(3); - - barrel_ = layerdisk_ < N_LAYER; - - luttable_.initBendMatch(layerdisk_); - - nrinv_ = NRINVBITS; -} - -void MatchEngine::addOutput(MemoryBase* memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - if (output == "matchout") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - candmatches_ = tmp; - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output: " << output; -} - -void MatchEngine::addInput(MemoryBase* memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input == "vmstubin") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - vmstubs_ = tmp; - return; - } - if (input == "vmprojin") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - vmprojs_ = tmp; - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input: " << input; -} - -void MatchEngine::execute(unsigned int iSector) { - unsigned int countall = 0; - unsigned int countpass = 0; - - //bool print = (iSector == 3 && getName() == "ME_L3PHIC20"); - bool print = false; - - constexpr unsigned int kNBitsBuffer = 3; - - int writeindex = 0; - int readindex = 0; - std::pair projbuffer[1 << kNBitsBuffer]; //iproj zbin - - //The next projection to read, the number of projections and flag if we have more projections to read - int iproj = 0; - int nproj = vmprojs_->nTracklets(); - bool moreproj = iproj < nproj; - - //Projection that is read from the buffer and compared to stubs - int rzbin = 0; - int projfinerz = 0; - int projfinerzadj = 0; - unsigned int projfinephi = 0; - - int projindex = 0; - int projrinv = 0; - bool isPSseed = false; - - //Number of stubs for current zbin and the stub being processed on this clock - int nstubs = 0; - int istub = 0; - - //Main processing loops starts here - for (unsigned int istep = 0; istep < settings_.maxStep("ME"); istep++) { - countall++; - - int writeindexplus = (writeindex + 1) % (1 << kNBitsBuffer); - int writeindexplusplus = (writeindex + 2) % (1 << kNBitsBuffer); - - //Determine if buffer is full - or near full as a projection - //can point to two z bins we might fill two slots in the buffer - bool bufferfull = (writeindexplus == readindex) || (writeindexplusplus == readindex); - - //Determin if buffer is empty - bool buffernotempty = (writeindex != readindex); - - //If we have more projections and the buffer is not full we read - //next projection and put in buffer if there are stubs in the - //memory the projection points to - - if ((!moreproj) && (!buffernotempty)) - break; - - if (moreproj && (!bufferfull)) { - Tracklet* proj = vmprojs_->getTracklet(iproj); - - int iprojtmp = iproj; - - iproj++; - moreproj = iproj < nproj; - - unsigned int rzfirst = proj->proj(layerdisk_).fpgarzbin1projvm().value(); - unsigned int rzlast = rzfirst; - - bool second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); - - if (second) - rzlast += 1; - - //Check if there are stubs in the memory - int nstubfirst = vmstubs_->nStubsBin(rzfirst); - int nstublast = vmstubs_->nStubsBin(rzlast); - bool savefirst = nstubfirst != 0; - bool savelast = second && (nstublast != 0); - - int writeindextmp = writeindex; - int writeindextmpplus = (writeindex + 1) % (1 << kNBitsBuffer); - - if (savefirst && savelast) { - writeindex = writeindexplusplus; - } else if (savefirst || savelast) { - writeindex = writeindexplus; - } - - if (savefirst) { //TODO for HLS (make code logic simpler) - std::pair tmp(iprojtmp, rzfirst); - projbuffer[writeindextmp] = tmp; - } - if (savelast) { - std::pair tmp(iprojtmp, rzlast + 100); //TODO for HLS (fix flagging that this is second bin) - if (savefirst) { - projbuffer[writeindextmpplus] = tmp; - } else { - projbuffer[writeindextmp] = tmp; - } - } - } - - //If the buffer is not empty we have a projection that we need to process. - - if (buffernotempty) { - int istubtmp = istub; - - //New projection - if (istub == 0) { - projindex = projbuffer[readindex].first; - rzbin = projbuffer[readindex].second; - bool second = false; - if (rzbin >= 100) { - rzbin -= 100; - second = true; - } - - Tracklet* proj = vmprojs_->getTracklet(projindex); - - FPGAWord fpgafinephi = proj->proj(layerdisk_).fpgafinephivm(); - - projfinephi = fpgafinephi.value(); - - nstubs = vmstubs_->nStubsBin(rzbin); - - projfinerz = proj->proj(layerdisk_).fpgafinerzvm().value(); - - projrinv = barrel_ ? ((1 << (nrinv_ - 1)) + ((-2 * proj->proj(layerdisk_).fpgaphiprojder().value()) >> - (proj->proj(layerdisk_).fpgaphiprojder().nbits() - (nrinv_ - 1)))) - : proj->proj(layerdisk_).getBendIndex().value(); - assert(projrinv >= 0); - if (settings_.extended() && projrinv == (1 << nrinv_)) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Extended tracking, projrinv:" << projrinv; - } - projrinv = (1 << nrinv_) - 1; - } - assert(projrinv < (1 << nrinv_)); - - isPSseed = proj->PSseed(); - - //Calculate fine z position - if (second) { - projfinerzadj = projfinerz - (1 << NFINERZBITS); - } else { - projfinerzadj = projfinerz; - } - if (nstubs == 1) { - istub = 0; - readindex = (readindex + 1) % (1 << kNBitsBuffer); - } else { - istub++; - } - } else { - //Check if last stub, if so, go to next buffer entry - if (istub + 1 >= nstubs) { - istub = 0; - readindex = (readindex + 1) % (1 << kNBitsBuffer); - } else { - istub++; - } - } - - //Read vmstub memory and extract data fields - const VMStubME& vmstub = vmstubs_->getVMStubMEBin(rzbin, istubtmp); - - int stubfinerz = vmstub.finerz().value(); - - bool isPSmodule; - - if (barrel_) { - isPSmodule = layerdisk_ < N_PSLAYER; - } else { - if (layerdisk_ < N_LAYER + 2) { - isPSmodule = ((rzbin & 7) < 3) || ((rzbin & 7) == 3 && stubfinerz <= 3); - } else { - isPSmodule = ((rzbin & 7) < 3) || ((rzbin & 7) == 3 && stubfinerz <= 2); - } - } - - assert(isPSmodule == vmstub.isPSmodule()); - - int nbits = isPSmodule ? N_BENDBITS_PS : N_BENDBITS_2S; - - int deltaphi = projfinephi - vmstub.finephi().value(); - - constexpr int mindeltaphicut = 3; - constexpr int maxdeltaphicut = 5; - bool passphi = (std::abs(deltaphi) < mindeltaphicut) || (std::abs(deltaphi) > maxdeltaphicut); - - unsigned int index = (projrinv << nbits) + vmstub.bend().value(); - if (!barrel_ && isPSmodule) { - index += (1 << (nrinv_ + N_BENDBITS_2S)); - } - - //Check if stub z position consistent - int idrz = stubfinerz - projfinerzadj; - bool passz; - - if (barrel_) { - if (isPSseed) { - constexpr int drzcut = 1; - passz = std::abs(idrz) <= drzcut; - } else { - constexpr int drzcut = 5; - passz = std::abs(idrz) <= drzcut; - } - } else { - if (isPSmodule) { - constexpr int drzcut = 1; - passz = std::abs(idrz) <= drzcut; - } else { - constexpr int drzcut = 3; - passz = std::abs(idrz) <= drzcut; - } - } - - if (print) { - edm::LogVerbatim("Tracklet") << "istep index : " << istep << " " << index << " " << vmstub.bend().value() - << " rzbin istubtmp : " << rzbin << " " << istubtmp << " dz " << stubfinerz << " " - << projfinerzadj << " dphi: " << deltaphi; - } - - //Check if stub bend and proj rinv consistent - if (passz && passphi) { - if (luttable_.lookup(index)) { - Tracklet* proj = vmprojs_->getTracklet(projindex); - std::pair tmp(proj, vmprojs_->getAllProjIndex(projindex)); - if (settings_.writeMonitorData("Seeds")) { - ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << proj->getISeed() << endl; - fout.close(); - } - candmatches_->addMatch(tmp, vmstub.stub()); - countpass++; - } - } - } - } - - if (settings_.writeMonitorData("ME")) { - globals_->ofstream("matchengine.txt") << getName() << " " << countall << " " << countpass << endl; - } -} diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc deleted file mode 100644 index 0e59a8b0dafc2..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ /dev/null @@ -1,152 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" -#include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h" -#include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" -#include "L1Trigger/TrackFindingTracklet/interface/IMATH_TrackletCalculator.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -using namespace std; -using namespace trklet; - -ProjectionRouter::ProjectionRouter(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global), rinvbendlut_(settings) { - layerdisk_ = initLayerDisk(3); - - vmprojs_.resize(settings_.nvmme(layerdisk_), nullptr); - - nrbits_ = 5; - nphiderbits_ = 6; - - if (layerdisk_ >= N_LAYER) { - rinvbendlut_.initProjectionBend( - global->ITC_L1L2()->der_phiD_final.K(), layerdisk_ - N_LAYER, nrbits_, nphiderbits_); - } -} - -void ProjectionRouter::addOutput(MemoryBase* memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - if (output == "allprojout") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - allproj_ = tmp; - return; - } - - unsigned int nproj = settings_.nallstubs(layerdisk_); - unsigned int nprojvm = settings_.nvmme(layerdisk_); - - for (unsigned int iproj = 0; iproj < nproj; iproj++) { - for (unsigned int iprojvm = 0; iprojvm < nprojvm; iprojvm++) { - std::string name = "vmprojoutPHI"; - name += char(iproj + 'A'); - name += std::to_string(iproj * nprojvm + iprojvm + 1); - if (output == name) { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - vmprojs_[iprojvm] = tmp; - return; - } - } - } - - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output: " << output; -} - -void ProjectionRouter::addInput(MemoryBase* memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input.substr(0, 4) == "proj" && input.substr(input.size() - 2, 2) == "in") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - inputproj_.push_back(tmp); - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input: " << input; -} - -void ProjectionRouter::execute() { - unsigned int allprojcount = 0; - - //These are just here to test that the order is correct. Does not affect the actual execution - - int lastTCID = -1; - - for (auto& iproj : inputproj_) { - for (unsigned int i = 0; i < iproj->nTracklets(); i++) { - if (allprojcount >= settings_.maxStep("PR")) - continue; - - Tracklet* tracklet = iproj->getTracklet(i); - - FPGAWord fpgaphi; - - if (layerdisk_ < N_LAYER) { - fpgaphi = tracklet->proj(layerdisk_).fpgaphiproj(); - } else { - Projection& proj = tracklet->proj(layerdisk_); - fpgaphi = proj.fpgaphiproj(); - - //The next lines looks up the predicted bend based on: - // 1 - r projections - // 2 - phi derivative - // 3 - the sign - i.e. if track is forward or backward - - int rindex = (proj.fpgarzproj().value() >> (proj.fpgarzproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - - int phiderindex = (proj.fpgaphiprojder().value() >> (proj.fpgaphiprojder().nbits() - nphiderbits_)) & - ((1 << nphiderbits_) - 1); - - int signindex = (proj.fpgarzprojder().value() < 0); - - int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex; - - int ibendproj = rinvbendlut_.lookup(bendindex); - - proj.setBendIndex(ibendproj); - } - - unsigned int iphivm = - fpgaphi.bits(fpgaphi.nbits() - settings_.nbitsallstubs(layerdisk_) - settings_.nbitsvmme(layerdisk_), - settings_.nbitsvmme(layerdisk_)); - - //This block of code just checks that the configuration is consistent - if (lastTCID >= tracklet->TCID()) { - edm::LogPrint("Tracklet") << "Wrong TCID ordering for projections in " << getName(); - } else { - lastTCID = tracklet->TCID(); - } - - allproj_->addTracklet(tracklet); - - vmprojs_[iphivm]->addTracklet(tracklet, allprojcount); - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " projection to " << vmprojs_[iphivm]->getName() << " iphivm " - << iphivm; - } - - allprojcount++; - } - } - - if (settings_.writeMonitorData("AP")) { - globals_->ofstream("allprojections.txt") << getName() << " " << allproj_->nTracklets() << endl; - } - - if (settings_.writeMonitorData("VMP")) { - ofstream& out = globals_->ofstream("chisq.txt"); - for (unsigned int i = 0; i < 8; i++) { - if (vmprojs_[i] != nullptr) { - out << vmprojs_[i]->getName() << " " << vmprojs_[i]->nTracklets() << endl; - } - } - } -} diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 2e20e18a5c80d..48c0bdfe9b42d 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -9,30 +9,18 @@ #include "L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/StubTripletsMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/FullMatchMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/CleanTrackMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/InputRouter.h" #include "L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMRouter.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h" -#include "L1Trigger/TrackFindingTracklet/interface/TripletEngine.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletProcessorDisplaced.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h" -#include "L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h" -#include "L1Trigger/TrackFindingTracklet/interface/MatchEngine.h" -#include "L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h" #include "L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h" #include "L1Trigger/TrackFindingTracklet/interface/FitTrack.h" #include "L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h" @@ -117,20 +105,12 @@ void Sector::addMem(string memType, string memName) { addMemToVec(VMSTE_, memName, settings_); } else if (memType == "VMStubsME:") { addMemToVec(VMSME_, memName, settings_); - } else if (memType == "StubPairs:" || memType == "StubPairsDisplaced:") { - addMemToVec(SP_, memName, settings_); } else if (memType == "StubTriplets:") { addMemToVec(ST_, memName, settings_); } else if (memType == "TrackletParameters:") { addMemToVec(TPAR_, memName, settings_); } else if (memType == "TrackletProjections:") { addMemToVec(TPROJ_, memName, settings_); - } else if (memType == "AllProj:") { - addMemToVec(AP_, memName, settings_); - } else if (memType == "VMProjections:") { - addMemToVec(VMPROJ_, memName, settings_); - } else if (memType == "CandidateMatch:") { - addMemToVec(CM_, memName, settings_); } else if (memType == "FullMatch:") { addMemToVec(FM_, memName, settings_); } else if (memType == "TrackFit:") { @@ -146,31 +126,14 @@ void Sector::addMem(string memType, string memName) { void Sector::addProc(string procType, string procName) { if (procType == "InputRouter:") { addProcToVec(IR_, procName, settings_, globals_); - } else if (procType == "VMRouter:") { - addProcToVec(VMR_, procName, settings_, globals_); } else if (procType == "VMRouterCM:") { addProcToVec(VMRCM_, procName, settings_, globals_); - } else if (procType == "TrackletEngine:") { - addProcToVec(TE_, procName, settings_, globals_); - } else if (procType == "TrackletEngineDisplaced:") { - addProcToVec(TED_, procName, settings_, globals_); - } else if (procType == "TripletEngine:") { - addProcToVec(TRE_, procName, settings_, globals_); - } else if (procType == "TrackletCalculator:") { - addProcToVec(TC_, procName, settings_, globals_); } else if (procType == "TrackletProcessor:") { addProcToVec(TP_, procName, settings_, globals_); } else if (procType == "TrackletProcessorDisplaced:") { addProcToVec(TPD_, procName, settings_, globals_); } else if (procType == "TrackletCalculatorDisplaced:") { addProcToVec(TCD_, procName, settings_, globals_); - } else if (procType == "ProjectionRouter:") { - addProcToVec(PR_, procName, settings_, globals_); - } else if (procType == "MatchEngine:") { - addProcToVec(ME_, procName, settings_, globals_); - } else if (procType == "MatchCalculator:" || - procType == "DiskMatchCalculator:") { //TODO should not be used in configurations - addProcToVec(MC_, procName, settings_, globals_); } else if (procType == "MatchProcessor:") { addProcToVec(MP_, procName, settings_, globals_); } else if (procType == "FitTrack:") { @@ -263,12 +226,6 @@ void Sector::writeAIS(bool first) { } } -void Sector::writeSP(bool first) { - for (auto& i : SP_) { - i->writeSP(first, isector_); - } -} - void Sector::writeST(bool first) { for (auto& i : ST_) { i->writeST(first, isector_); @@ -287,24 +244,6 @@ void Sector::writeTPROJ(bool first) { } } -void Sector::writeAP(bool first) { - for (auto& i : AP_) { - i->writeAP(first, isector_); - } -} - -void Sector::writeVMPROJ(bool first) { - for (auto& i : VMPROJ_) { - i->writeVMPROJ(first, isector_); - } -} - -void Sector::writeCM(bool first) { - for (auto& i : CM_) { - i->writeCM(first, isector_); - } -} - void Sector::writeMC(bool first) { for (auto& i : FM_) { i->writeMC(first, isector_); @@ -342,32 +281,11 @@ void Sector::executeVMR() { out << i->getName() << " " << i->nStubs() << endl; } } - for (auto& i : VMR_) { - i->execute(); - } for (auto& i : VMRCM_) { i->execute(isector_); } } -void Sector::executeTE() { - for (auto& i : TE_) { - i->execute(); - } -} - -void Sector::executeTED() { - for (auto& i : TED_) { - i->execute(); - } -} - -void Sector::executeTRE() { - for (auto& i : TRE_) { - i->execute(); - } -} - void Sector::executeTP() { for (auto& i : TP_) { i->execute(isector_, phimin_, phimax_); @@ -380,43 +298,12 @@ void Sector::executeTPD() { } } -void Sector::executeTC() { - for (auto& i : TC_) { - i->execute(isector_, phimin_, phimax_); - } - - if (settings_.writeMonitorData("TrackProjOcc")) { - ofstream& out = globals_->ofstream("trackprojocc.txt"); - for (auto& i : TPROJ_) { - out << i->getName() << " " << i->nTracklets() << endl; - } - } -} - void Sector::executeTCD() { for (auto& i : TCD_) { i->execute(isector_, phimin_, phimax_); } } -void Sector::executePR() { - for (auto& i : PR_) { - i->execute(); - } -} - -void Sector::executeME() { - for (auto& i : ME_) { - i->execute(isector_); - } -} - -void Sector::executeMC() { - for (auto& i : MC_) { - i->execute(isector_, phimin_); - } -} - void Sector::executeMP() { for (auto& i : MP_) { i->execute(isector_, phimin_); diff --git a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc deleted file mode 100644 index ea29fe811d0fd..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc +++ /dev/null @@ -1,35 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubTE.h" -#include -#include - -using namespace std; -using namespace trklet; - -StubPairsMemory::StubPairsMemory(string name, Settings const& settings) : MemoryBase(name, settings) {} - -void StubPairsMemory::writeSP(bool first, unsigned int iSector) { - iSector_ = iSector; - const string dirSP = settings_.memPath() + "StubPairs/"; - - std::ostringstream oss; - oss << dirSP << "StubPairs_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; - auto const& fname = oss.str(); - - openfile(out_, first, dirSP, fname, __FILE__, __LINE__); - - out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; - - for (unsigned int j = 0; j < stubs_.size(); j++) { - string stub1index = stubs_[j].first.stub()->stubindex().str(); - string stub2index = stubs_[j].second.stub()->stubindex().str(); - out_ << hexstr(j) << " " << stub1index << "|" << stub2index << " " << trklet::hexFormat(stub1index + stub2index) - << endl; - } - out_.close(); - - bx_++; - event_++; - if (bx_ > 7) - bx_ = 0; -} diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc deleted file mode 100644 index 74e93e2040eb2..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc +++ /dev/null @@ -1,472 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" -#include "L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/IMATH_TrackletCalculator.h" -#include "L1Trigger/TrackFindingTracklet/interface/IMATH_TrackletCalculatorDisk.h" -#include "L1Trigger/TrackFindingTracklet/interface/IMATH_TrackletCalculatorOverlap.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -using namespace std; -using namespace trklet; - -TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Globals* globals) - : TrackletCalculatorBase(name, settings, globals) { - for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) { - vector tmp(settings.nallstubs(ilayer), nullptr); - trackletprojlayers_.push_back(tmp); - } - - for (unsigned int idisk = 0; idisk < N_DISK; idisk++) { - vector tmp(settings.nallstubs(idisk + N_LAYER), nullptr); - trackletprojdisks_.push_back(tmp); - } - - initLayerDisksandISeed(layerdisk1_, layerdisk2_, iSeed_); - - // set TC index - iTC_ = name_[7] - 'A'; - - TCIndex_ = (iSeed_ << 4) + iTC_; - assert(TCIndex_ >= 0 && TCIndex_ <= (int)settings_.ntrackletmax()); - - if (settings_.usephicritapprox()) { - double phicritFactor = - 0.5 * settings_.rcrit() * globals_->ITC_L1L2()->rinv_final.K() / globals_->ITC_L1L2()->phi0_final.K(); - if (std::abs(phicritFactor - 2.) > 0.25) - edm::LogPrint("Tracklet") - << "TrackletCalculator::TrackletCalculator phicrit approximation may be invalid! Please check."; - } - - // reduced config has only one TC, so this must be the first - const bool isFirstTC = (iTC_ == 0 || settings_.reduced()); - - // write the drinv and invt inverse tables - if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable()) && isFirstTC) { - void (*writeLUT)(const VarInv&, const string&) = nullptr; - if (settings.writeInvTable()) { // Verilog version - writeLUT = [](const VarInv& x, const string& basename) -> void { - ofstream fs(basename + ".tab"); - return x.writeLUT(fs, VarBase::verilog); - }; - } else { // HLS version - writeLUT = [](const VarInv& x, const string& basename) -> void { - ofstream fs(basename + ".tab"); - return x.writeLUT(fs, VarBase::hls); - }; - } - writeInvTable(writeLUT); - } - - // write the firmware design for the calculation of the tracklet parameters - // and projections - if ((settings_.writeVerilog() || settings_.writeHLS()) && isFirstTC) { - void (*writeDesign)(const vector&, const string&) = nullptr; - if (settings.writeVerilog()) { // Verilog version - writeDesign = [](const vector& v, const string& basename) -> void { - ofstream fs(basename + ".v"); - return VarBase::verilog_print(v, fs); - }; - } else { // HLS version - writeDesign = [](const vector& v, const string& basename) -> void { - ofstream fs(basename + ".cpp"); - return VarBase::hls_print(v, fs); - }; - } - writeFirmwareDesign(writeDesign); - } -} - -void TrackletCalculator::addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory) { - outputProj = dynamic_cast(memory); - assert(outputProj != nullptr); -} - -void TrackletCalculator::addOutput(MemoryBase* memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - if (output == "trackpar") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - trackletpars_ = tmp; - return; - } - - if (output.substr(0, 7) == "projout") { - //output is on the form 'projoutL2PHIC' or 'projoutD3PHIB' - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - - unsigned int layerdisk = output[8] - '1'; //layer or disk counting from 0 - unsigned int phiregion = output[12] - 'A'; //phiregion counting from 0 - - if (output[7] == 'L') { - assert(layerdisk < N_LAYER); - assert(phiregion < trackletprojlayers_[layerdisk].size()); - //check that phiregion not already initialized - assert(trackletprojlayers_[layerdisk][phiregion] == nullptr); - trackletprojlayers_[layerdisk][phiregion] = tmp; - return; - } - - if (output[7] == 'D') { - assert(layerdisk < N_DISK); - assert(phiregion < trackletprojdisks_[layerdisk].size()); - //check that phiregion not already initialized - assert(trackletprojdisks_[layerdisk][phiregion] == nullptr); - trackletprojdisks_[layerdisk][phiregion] = tmp; - return; - } - } - - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output; -} - -void TrackletCalculator::addInput(MemoryBase* memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input == "innerallstubin") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - innerallstubs_.push_back(tmp); - return; - } - if (input == "outerallstubin") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - outerallstubs_.push_back(tmp); - return; - } - if (input.substr(0, 8) == "stubpair") { - auto* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - stubpairs_.push_back(tmp); - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find intput : " << input; -} - -void TrackletCalculator::execute(unsigned int iSector, double phimin, double phimax) { - unsigned int countall = 0; - unsigned int countsel = 0; - - phimin_ = phimin; - phimax_ = phimax; - iSector_ = iSector; - - //Helpfull to have for debugging the HLS code - will keep here for now. - //bool print = (iSector == 3) && (getName() == "TC_L1L2G"); - //print = false; - - for (auto& stubpair : stubpairs_) { - if (trackletpars_->nTracklets() >= settings_.ntrackletmax()) { - edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName(); - break; - } - for (unsigned int i = 0; i < stubpair->nStubPairs(); i++) { - countall++; - const Stub* innerFPGAStub = stubpair->getVMStub1(i).stub(); - const L1TStub* innerStub = innerFPGAStub->l1tstub(); - - const Stub* outerFPGAStub = stubpair->getVMStub2(i).stub(); - const L1TStub* outerStub = outerFPGAStub->l1tstub(); - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "TrackletCalculator execute " << getName() << "[" << iSector << "]"; - } - - if (innerFPGAStub->layerdisk() < N_LAYER && (getName() != "TC_D1L2A" && getName() != "TC_D1L2B")) { - if (outerFPGAStub->layerdisk() >= N_LAYER) { - //overlap seeding - bool accept = overlapSeeding(outerFPGAStub, outerStub, innerFPGAStub, innerStub); - if (accept) - countsel++; - } else { - //barrel+barrel seeding - bool accept = barrelSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); - if (accept) - countsel++; - } - } else { - if (outerFPGAStub->layerdisk() >= N_LAYER) { - //disk+disk seeding - bool accept = diskSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); - if (accept) - countsel++; - } else if (innerFPGAStub->layerdisk() >= N_LAYER) { - //layer+disk seeding - bool accept = overlapSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); - if (accept) - countsel++; - } else { - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " invalid seeding"; - } - } - - if (trackletpars_->nTracklets() >= settings_.ntrackletmax()) { - edm::LogVerbatim("Tracklet") << "Will break on number of tracklets in " << getName(); - break; - } - - if (countall >= settings_.maxStep("TC")) { - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Will break on MAXTC 1"; - break; - } - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "TrackletCalculator execute done"; - } - } - if (countall >= settings_.maxStep("TC")) { - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Will break on MAXTC 2"; - break; - } - } - - if (settings_.writeMonitorData("TC")) { - globals_->ofstream("trackletcalculator.txt") << getName() << " " << countall << " " << countsel << endl; - } -} - -void TrackletCalculator::writeInvTable(void (*writeLUT)(const VarInv&, const string&)) { - switch (iSeed_) { - case 0: // L1L2 - writeLUT(globals_->ITC_L1L2()->drinv, settings_.tablePath() + "TC_L1L2_drinv"); - writeLUT(globals_->ITC_L1L2()->invt, settings_.tablePath() + "TC_L1L2_invt"); - break; - case 1: // L2L3 - writeLUT(globals_->ITC_L2L3()->drinv, settings_.tablePath() + "TC_L2L3_drinv"); - writeLUT(globals_->ITC_L2L3()->invt, settings_.tablePath() + "TC_L2L3_invt"); - break; - case 2: // L3L4 - writeLUT(globals_->ITC_L3L4()->drinv, settings_.tablePath() + "TC_L3L4_drinv"); - writeLUT(globals_->ITC_L3L4()->invt, settings_.tablePath() + "TC_L3L4_invt"); - break; - case 3: // L5L6 - writeLUT(globals_->ITC_L5L6()->drinv, settings_.tablePath() + "TC_L5L6_drinv"); - writeLUT(globals_->ITC_L5L6()->invt, settings_.tablePath() + "TC_L5L6_invt"); - break; - case 4: // D1D2 - writeLUT(globals_->ITC_F1F2()->drinv, settings_.tablePath() + "TC_F1F2_drinv"); - writeLUT(globals_->ITC_F1F2()->invt, settings_.tablePath() + "TC_F1F2_invt"); - writeLUT(globals_->ITC_B1B2()->drinv, settings_.tablePath() + "TC_B1B2_drinv"); - writeLUT(globals_->ITC_B1B2()->invt, settings_.tablePath() + "TC_B1B2_invt"); - break; - case 5: // D3D4 - writeLUT(globals_->ITC_F3F4()->drinv, settings_.tablePath() + "TC_F3F4_drinv"); - writeLUT(globals_->ITC_F3F4()->invt, settings_.tablePath() + "TC_F3F4_invt"); - writeLUT(globals_->ITC_B3B4()->drinv, settings_.tablePath() + "TC_B3B4_drinv"); - writeLUT(globals_->ITC_B3B4()->invt, settings_.tablePath() + "TC_B3B4_invt"); - break; - case 6: // L1D1 - writeLUT(globals_->ITC_L1F1()->drinv, settings_.tablePath() + "TC_L1F1_drinv"); - writeLUT(globals_->ITC_L1F1()->invt, settings_.tablePath() + "TC_L1F1_invt"); - writeLUT(globals_->ITC_L1B1()->drinv, settings_.tablePath() + "TC_L1B1_drinv"); - writeLUT(globals_->ITC_L1B1()->invt, settings_.tablePath() + "TC_L1B1_invt"); - break; - case 7: // L2D1 - writeLUT(globals_->ITC_L2F1()->drinv, settings_.tablePath() + "TC_L2F1_drinv"); - writeLUT(globals_->ITC_L2F1()->invt, settings_.tablePath() + "TC_L2F1_invt"); - writeLUT(globals_->ITC_L2B1()->drinv, settings_.tablePath() + "TC_L2B1_drinv"); - writeLUT(globals_->ITC_L2B1()->invt, settings_.tablePath() + "TC_L2B1_invt"); - break; - } -} - -void TrackletCalculator::writeFirmwareDesign(void (*writeDesign)(const vector&, const string&)) { - switch (iSeed_) { - case 0: // L1L2 - { - const vector v = {&globals_->ITC_L1L2()->rinv_final, &globals_->ITC_L1L2()->phi0_final, - &globals_->ITC_L1L2()->t_final, &globals_->ITC_L1L2()->z0_final, - &globals_->ITC_L1L2()->phiL_0_final, &globals_->ITC_L1L2()->phiL_1_final, - &globals_->ITC_L1L2()->phiL_2_final, &globals_->ITC_L1L2()->phiL_3_final, - &globals_->ITC_L1L2()->zL_0_final, &globals_->ITC_L1L2()->zL_1_final, - &globals_->ITC_L1L2()->zL_2_final, &globals_->ITC_L1L2()->zL_3_final, - &globals_->ITC_L1L2()->der_phiL_final, &globals_->ITC_L1L2()->der_zL_final, - &globals_->ITC_L1L2()->phiD_0_final, &globals_->ITC_L1L2()->phiD_1_final, - &globals_->ITC_L1L2()->phiD_2_final, &globals_->ITC_L1L2()->phiD_3_final, - &globals_->ITC_L1L2()->phiD_4_final, &globals_->ITC_L1L2()->rD_0_final, - &globals_->ITC_L1L2()->rD_1_final, &globals_->ITC_L1L2()->rD_2_final, - &globals_->ITC_L1L2()->rD_3_final, &globals_->ITC_L1L2()->rD_4_final, - &globals_->ITC_L1L2()->der_phiD_final, &globals_->ITC_L1L2()->der_rD_final}; - writeDesign(v, "TC_L1L2"); - } break; - case 1: // L2L3 - { - const vector v = {&globals_->ITC_L2L3()->rinv_final, &globals_->ITC_L2L3()->phi0_final, - &globals_->ITC_L2L3()->t_final, &globals_->ITC_L2L3()->z0_final, - &globals_->ITC_L2L3()->phiL_0_final, &globals_->ITC_L2L3()->phiL_1_final, - &globals_->ITC_L2L3()->phiL_2_final, &globals_->ITC_L2L3()->phiL_3_final, - &globals_->ITC_L2L3()->zL_0_final, &globals_->ITC_L2L3()->zL_1_final, - &globals_->ITC_L2L3()->zL_2_final, &globals_->ITC_L2L3()->zL_3_final, - &globals_->ITC_L2L3()->der_phiL_final, &globals_->ITC_L2L3()->der_zL_final, - &globals_->ITC_L2L3()->phiD_0_final, &globals_->ITC_L2L3()->phiD_1_final, - &globals_->ITC_L2L3()->phiD_2_final, &globals_->ITC_L2L3()->phiD_3_final, - &globals_->ITC_L2L3()->phiD_4_final, &globals_->ITC_L2L3()->rD_0_final, - &globals_->ITC_L2L3()->rD_1_final, &globals_->ITC_L2L3()->rD_2_final, - &globals_->ITC_L2L3()->rD_3_final, &globals_->ITC_L2L3()->rD_4_final, - &globals_->ITC_L2L3()->der_phiD_final, &globals_->ITC_L2L3()->der_rD_final}; - writeDesign(v, "TC_L2L3"); - } break; - case 2: // L3L4 - { - const vector v = {&globals_->ITC_L3L4()->rinv_final, &globals_->ITC_L3L4()->phi0_final, - &globals_->ITC_L3L4()->t_final, &globals_->ITC_L3L4()->z0_final, - &globals_->ITC_L3L4()->phiL_0_final, &globals_->ITC_L3L4()->phiL_1_final, - &globals_->ITC_L3L4()->phiL_2_final, &globals_->ITC_L3L4()->phiL_3_final, - &globals_->ITC_L3L4()->zL_0_final, &globals_->ITC_L3L4()->zL_1_final, - &globals_->ITC_L3L4()->zL_2_final, &globals_->ITC_L3L4()->zL_3_final, - &globals_->ITC_L3L4()->der_phiL_final, &globals_->ITC_L3L4()->der_zL_final, - &globals_->ITC_L3L4()->phiD_0_final, &globals_->ITC_L3L4()->phiD_1_final, - &globals_->ITC_L3L4()->phiD_2_final, &globals_->ITC_L3L4()->phiD_3_final, - &globals_->ITC_L3L4()->phiD_4_final, &globals_->ITC_L3L4()->rD_0_final, - &globals_->ITC_L3L4()->rD_1_final, &globals_->ITC_L3L4()->rD_2_final, - &globals_->ITC_L3L4()->rD_3_final, &globals_->ITC_L3L4()->rD_4_final, - &globals_->ITC_L3L4()->der_phiD_final, &globals_->ITC_L3L4()->der_rD_final}; - writeDesign(v, "TC_L3L4"); - } break; - case 3: // L5L6 - { - const vector v = {&globals_->ITC_L5L6()->rinv_final, &globals_->ITC_L5L6()->phi0_final, - &globals_->ITC_L5L6()->t_final, &globals_->ITC_L5L6()->z0_final, - &globals_->ITC_L5L6()->phiL_0_final, &globals_->ITC_L5L6()->phiL_1_final, - &globals_->ITC_L5L6()->phiL_2_final, &globals_->ITC_L5L6()->phiL_3_final, - &globals_->ITC_L5L6()->zL_0_final, &globals_->ITC_L5L6()->zL_1_final, - &globals_->ITC_L5L6()->zL_2_final, &globals_->ITC_L5L6()->zL_3_final, - &globals_->ITC_L5L6()->der_phiL_final, &globals_->ITC_L5L6()->der_zL_final, - &globals_->ITC_L5L6()->phiD_0_final, &globals_->ITC_L5L6()->phiD_1_final, - &globals_->ITC_L5L6()->phiD_2_final, &globals_->ITC_L5L6()->phiD_3_final, - &globals_->ITC_L5L6()->phiD_4_final, &globals_->ITC_L5L6()->rD_0_final, - &globals_->ITC_L5L6()->rD_1_final, &globals_->ITC_L5L6()->rD_2_final, - &globals_->ITC_L5L6()->rD_3_final, &globals_->ITC_L5L6()->rD_4_final, - &globals_->ITC_L5L6()->der_phiD_final, &globals_->ITC_L5L6()->der_rD_final}; - writeDesign(v, "TC_L5L6"); - } break; - case 4: // D1D2 - { - const vector v = {&globals_->ITC_F1F2()->rinv_final, &globals_->ITC_F1F2()->phi0_final, - &globals_->ITC_F1F2()->t_final, &globals_->ITC_F1F2()->z0_final, - &globals_->ITC_F1F2()->phiL_0_final, &globals_->ITC_F1F2()->phiL_1_final, - &globals_->ITC_F1F2()->phiL_2_final, &globals_->ITC_F1F2()->zL_0_final, - &globals_->ITC_F1F2()->zL_1_final, &globals_->ITC_F1F2()->zL_2_final, - &globals_->ITC_F1F2()->der_phiL_final, &globals_->ITC_F1F2()->der_zL_final, - &globals_->ITC_F1F2()->phiD_0_final, &globals_->ITC_F1F2()->phiD_1_final, - &globals_->ITC_F1F2()->phiD_2_final, &globals_->ITC_F1F2()->rD_0_final, - &globals_->ITC_F1F2()->rD_1_final, &globals_->ITC_F1F2()->rD_2_final, - &globals_->ITC_F1F2()->der_phiD_final, &globals_->ITC_F1F2()->der_rD_final}; - writeDesign(v, "TC_F1F2"); - } - { - const vector v = {&globals_->ITC_B1B2()->rinv_final, &globals_->ITC_B1B2()->phi0_final, - &globals_->ITC_B1B2()->t_final, &globals_->ITC_B1B2()->z0_final, - &globals_->ITC_B1B2()->phiL_0_final, &globals_->ITC_B1B2()->phiL_1_final, - &globals_->ITC_B1B2()->phiL_2_final, &globals_->ITC_B1B2()->zL_0_final, - &globals_->ITC_B1B2()->zL_1_final, &globals_->ITC_B1B2()->zL_2_final, - &globals_->ITC_B1B2()->der_phiL_final, &globals_->ITC_B1B2()->der_zL_final, - &globals_->ITC_B1B2()->phiD_0_final, &globals_->ITC_B1B2()->phiD_1_final, - &globals_->ITC_B1B2()->phiD_2_final, &globals_->ITC_B1B2()->rD_0_final, - &globals_->ITC_B1B2()->rD_1_final, &globals_->ITC_B1B2()->rD_2_final, - &globals_->ITC_B1B2()->der_phiD_final, &globals_->ITC_B1B2()->der_rD_final}; - writeDesign(v, "TC_B1B2"); - } - break; - case 5: // D3D4 - { - const vector v = {&globals_->ITC_F3F4()->rinv_final, &globals_->ITC_F3F4()->phi0_final, - &globals_->ITC_F3F4()->t_final, &globals_->ITC_F3F4()->z0_final, - &globals_->ITC_F3F4()->phiL_0_final, &globals_->ITC_F3F4()->phiL_1_final, - &globals_->ITC_F3F4()->phiL_2_final, &globals_->ITC_F3F4()->zL_0_final, - &globals_->ITC_F3F4()->zL_1_final, &globals_->ITC_F3F4()->zL_2_final, - &globals_->ITC_F3F4()->der_phiL_final, &globals_->ITC_F3F4()->der_zL_final, - &globals_->ITC_F3F4()->phiD_0_final, &globals_->ITC_F3F4()->phiD_1_final, - &globals_->ITC_F3F4()->phiD_2_final, &globals_->ITC_F3F4()->rD_0_final, - &globals_->ITC_F3F4()->rD_1_final, &globals_->ITC_F3F4()->rD_2_final, - &globals_->ITC_F3F4()->der_phiD_final, &globals_->ITC_F3F4()->der_rD_final}; - writeDesign(v, "TC_F3F4"); - } - { - const vector v = {&globals_->ITC_B3B4()->rinv_final, &globals_->ITC_B3B4()->phi0_final, - &globals_->ITC_B3B4()->t_final, &globals_->ITC_B3B4()->z0_final, - &globals_->ITC_B3B4()->phiL_0_final, &globals_->ITC_B3B4()->phiL_1_final, - &globals_->ITC_B3B4()->phiL_2_final, &globals_->ITC_B3B4()->zL_0_final, - &globals_->ITC_B3B4()->zL_1_final, &globals_->ITC_B3B4()->zL_2_final, - &globals_->ITC_B3B4()->der_phiL_final, &globals_->ITC_B3B4()->der_zL_final, - &globals_->ITC_B3B4()->phiD_0_final, &globals_->ITC_B3B4()->phiD_1_final, - &globals_->ITC_B3B4()->phiD_2_final, &globals_->ITC_B3B4()->rD_0_final, - &globals_->ITC_B3B4()->rD_1_final, &globals_->ITC_B3B4()->rD_2_final, - &globals_->ITC_B3B4()->der_phiD_final, &globals_->ITC_B3B4()->der_rD_final}; - writeDesign(v, "TC_B3B4"); - } - break; - case 6: // L1D1 - { - const vector v = {&globals_->ITC_L1F1()->rinv_final, &globals_->ITC_L1F1()->phi0_final, - &globals_->ITC_L1F1()->t_final, &globals_->ITC_L1F1()->z0_final, - &globals_->ITC_L1F1()->phiL_0_final, &globals_->ITC_L1F1()->phiL_1_final, - &globals_->ITC_L1F1()->phiL_2_final, &globals_->ITC_L1F1()->zL_0_final, - &globals_->ITC_L1F1()->zL_1_final, &globals_->ITC_L1F1()->zL_2_final, - &globals_->ITC_L1F1()->der_phiL_final, &globals_->ITC_L1F1()->der_zL_final, - &globals_->ITC_L1F1()->phiD_0_final, &globals_->ITC_L1F1()->phiD_1_final, - &globals_->ITC_L1F1()->phiD_2_final, &globals_->ITC_L1F1()->phiD_3_final, - &globals_->ITC_L1F1()->rD_0_final, &globals_->ITC_L1F1()->rD_1_final, - &globals_->ITC_L1F1()->rD_2_final, &globals_->ITC_L1F1()->rD_3_final, - &globals_->ITC_L1F1()->der_phiD_final, &globals_->ITC_L1F1()->der_rD_final}; - writeDesign(v, "TC_L1F1"); - } - { - const vector v = {&globals_->ITC_L1B1()->rinv_final, &globals_->ITC_L1B1()->phi0_final, - &globals_->ITC_L1B1()->t_final, &globals_->ITC_L1B1()->z0_final, - &globals_->ITC_L1B1()->phiL_0_final, &globals_->ITC_L1B1()->phiL_1_final, - &globals_->ITC_L1B1()->phiL_2_final, &globals_->ITC_L1B1()->zL_0_final, - &globals_->ITC_L1B1()->zL_1_final, &globals_->ITC_L1B1()->zL_2_final, - &globals_->ITC_L1B1()->der_phiL_final, &globals_->ITC_L1B1()->der_zL_final, - &globals_->ITC_L1B1()->phiD_0_final, &globals_->ITC_L1B1()->phiD_1_final, - &globals_->ITC_L1B1()->phiD_2_final, &globals_->ITC_L1B1()->phiD_3_final, - &globals_->ITC_L1B1()->rD_0_final, &globals_->ITC_L1B1()->rD_1_final, - &globals_->ITC_L1B1()->rD_2_final, &globals_->ITC_L1B1()->rD_3_final, - &globals_->ITC_L1B1()->der_phiD_final, &globals_->ITC_L1B1()->der_rD_final}; - writeDesign(v, "TC_L1B1"); - } - break; - case 7: // L2D1 - { - const vector v = {&globals_->ITC_L2F1()->rinv_final, &globals_->ITC_L2F1()->phi0_final, - &globals_->ITC_L2F1()->t_final, &globals_->ITC_L2F1()->z0_final, - &globals_->ITC_L2F1()->phiL_0_final, &globals_->ITC_L2F1()->phiL_1_final, - &globals_->ITC_L2F1()->phiL_2_final, &globals_->ITC_L2F1()->zL_0_final, - &globals_->ITC_L2F1()->zL_1_final, &globals_->ITC_L2F1()->zL_2_final, - &globals_->ITC_L2F1()->der_phiL_final, &globals_->ITC_L2F1()->der_zL_final, - &globals_->ITC_L2F1()->phiD_0_final, &globals_->ITC_L2F1()->phiD_1_final, - &globals_->ITC_L2F1()->phiD_2_final, &globals_->ITC_L2F1()->phiD_3_final, - &globals_->ITC_L2F1()->rD_0_final, &globals_->ITC_L2F1()->rD_1_final, - &globals_->ITC_L2F1()->rD_2_final, &globals_->ITC_L2F1()->rD_3_final, - &globals_->ITC_L2F1()->der_phiD_final, &globals_->ITC_L2F1()->der_rD_final}; - writeDesign(v, "TC_L2F1"); - } - { - const vector v = {&globals_->ITC_L2B1()->rinv_final, &globals_->ITC_L2B1()->phi0_final, - &globals_->ITC_L2B1()->t_final, &globals_->ITC_L2B1()->z0_final, - &globals_->ITC_L2B1()->phiL_0_final, &globals_->ITC_L2B1()->phiL_1_final, - &globals_->ITC_L2B1()->phiL_2_final, &globals_->ITC_L2B1()->zL_0_final, - &globals_->ITC_L2B1()->zL_1_final, &globals_->ITC_L2B1()->zL_2_final, - &globals_->ITC_L2B1()->der_phiL_final, &globals_->ITC_L2B1()->der_zL_final, - &globals_->ITC_L2B1()->phiD_0_final, &globals_->ITC_L2B1()->phiD_1_final, - &globals_->ITC_L2B1()->phiD_2_final, &globals_->ITC_L2B1()->phiD_3_final, - &globals_->ITC_L2B1()->rD_0_final, &globals_->ITC_L2B1()->rD_1_final, - &globals_->ITC_L2B1()->rD_2_final, &globals_->ITC_L2B1()->rD_3_final, - &globals_->ITC_L2B1()->der_phiD_final, &globals_->ITC_L2B1()->der_rD_final}; - writeDesign(v, "TC_L2B1"); - } - break; - } -} diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc deleted file mode 100644 index 4510ce2079561..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc +++ /dev/null @@ -1,230 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h" -#include "L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Util.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include - -using namespace trklet; -using namespace std; - -TrackletEngine::TrackletEngine(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global), innerptlut_(settings), outerptlut_(settings) { - stubpairs_ = nullptr; - innervmstubs_ = nullptr; - outervmstubs_ = nullptr; - - initLayerDisksandISeed(layerdisk1_, layerdisk2_, iSeed_); - - innerphibits_ = settings.nfinephi(0, iSeed_); - outerphibits_ = settings.nfinephi(1, iSeed_); -} - -void TrackletEngine::addOutput(MemoryBase* memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - if (output == "stubpairout") { - StubPairsMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - stubpairs_ = tmp; - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output; -} - -void TrackletEngine::addInput(MemoryBase* memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input == "innervmstubin") { - VMStubsTEMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - innervmstubs_ = tmp; - setVMPhiBin(); - return; - } - if (input == "outervmstubin") { - VMStubsTEMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - outervmstubs_ = tmp; - setVMPhiBin(); - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; -} - -void TrackletEngine::execute() { - if (!settings_.useSeed(iSeed_)) - return; - - unsigned int countall = 0; - unsigned int countpass = 0; - - assert(innervmstubs_ != nullptr); - assert(outervmstubs_ != nullptr); - - for (unsigned int i = 0; i < innervmstubs_->nVMStubs(); i++) { - const VMStubTE& innervmstub = innervmstubs_->getVMStubTE(i); - FPGAWord lookupbits = innervmstub.vmbits(); - - unsigned int nbits = 7; - if (iSeed_ == 4 || iSeed_ == 5) - nbits = 6; - int rzdiffmax = lookupbits.bits(nbits, lookupbits.nbits() - nbits); - int rzbinfirst = lookupbits.bits(0, 3); - int start = lookupbits.bits(4, nbits - 4); - int next = lookupbits.bits(3, 1); - - if ((iSeed_ == 4 || iSeed_ == 5) && innervmstub.stub()->disk().value() < 0) { //TODO - need to store negative disk - start += 4; - } - int last = start + next; - - for (int ibin = start; ibin <= last; ibin++) { - for (unsigned int j = 0; j < outervmstubs_->nVMStubsBinned(ibin); j++) { - if (countall >= settings_.maxStep("TE")) - break; - countall++; - const VMStubTE& outervmstub = outervmstubs_->getVMStubTEBinned(ibin, j); - - int rzbin = outervmstub.vmbits().bits(0, N_RZBITS); - - FPGAWord iphiinnerbin = innervmstub.finephi(); - FPGAWord iphiouterbin = outervmstub.finephi(); - - unsigned int index = (iphiinnerbin.value() << outerphibits_) + iphiouterbin.value(); - - if (iSeed_ >= 4) { //Also use r-position - - 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 += (1 << N_RZBITS); - if ((rzbin < rzbinfirst) || (rzbin - rzbinfirst > rzdiffmax)) { - continue; - } - - FPGAWord innerbend = innervmstub.bend(); - FPGAWord outerbend = outervmstub.bend(); - - int ptinnerindex = (index << innerbend.nbits()) + innerbend.value(); - int ptouterindex = (index << outerbend.nbits()) + outerbend.value(); - - if (!(innerptlut_.lookup(ptinnerindex) && outerptlut_.lookup(ptouterindex))) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : " - << settings_.benddecode( - innervmstub.bend().value(), layerdisk1_, innervmstub.isPSmodule()) - << " " - << settings_.benddecode( - outervmstub.bend().value(), layerdisk2_, outervmstub.isPSmodule()); - } - continue; - } - - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Adding stub pair in " << getName(); - - assert(stubpairs_ != nullptr); - stubpairs_->addStubPair(innervmstub, outervmstub); - countpass++; - } - } - } - - if (settings_.writeMonitorData("TE")) { - globals_->ofstream("trackletengine.txt") << getName() << " " << countall << " " << countpass << endl; - } -} - -void TrackletEngine::setVMPhiBin() { - if (innervmstubs_ == nullptr || outervmstubs_ == nullptr) - return; - - innervmstubs_->setother(outervmstubs_); - outervmstubs_->setother(innervmstubs_); - - double innerphimin, innerphimax; - innervmstubs_->getPhiRange(innerphimin, innerphimax, iSeed_, 0); - - double outerphimin, outerphimax; - outervmstubs_->getPhiRange(outerphimin, outerphimax, iSeed_, 1); - - string innermem = innervmstubs_->getName().substr(6); - string outermem = outervmstubs_->getName().substr(6); - - innerptlut_.initteptlut(true, - false, - iSeed_, - layerdisk1_, - layerdisk2_, - innerphibits_, - outerphibits_, - innerphimin, - innerphimax, - outerphimin, - outerphimax, - innermem, - outermem); - - outerptlut_.initteptlut(false, - false, - iSeed_, - layerdisk1_, - layerdisk2_, - innerphibits_, - outerphibits_, - innerphimin, - innerphimax, - outerphimin, - outerphimax, - innermem, - outermem); - - TrackletLUT innertememlut(settings_); - TrackletLUT outertememlut(settings_); - - innertememlut.initteptlut(true, - true, - iSeed_, - layerdisk1_, - layerdisk2_, - innerphibits_, - outerphibits_, - innerphimin, - innerphimax, - outerphimin, - outerphimax, - innermem, - outermem); - - outertememlut.initteptlut(false, - true, - iSeed_, - layerdisk1_, - layerdisk2_, - innerphibits_, - outerphibits_, - innerphimin, - innerphimax, - outerphimin, - outerphimax, - innermem, - outermem); - - innervmstubs_->setbendtable(innertememlut); - outervmstubs_->setbendtable(outertememlut); -} diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc deleted file mode 100644 index 927cd2b43505a..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc +++ /dev/null @@ -1,422 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -using namespace std; -using namespace trklet; - -TrackletEngineDisplaced::TrackletEngineDisplaced(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global) { - stubpairs_.clear(); - firstvmstubs_.clear(); - secondvmstubs_ = nullptr; - layer1_ = 0; - layer2_ = 0; - disk1_ = 0; - disk2_ = 0; - string name1 = name.substr(1); //this is to correct for "TED" having one more letter then "TE" - if (name1[3] == 'L') { - layer1_ = name1[4] - '0'; - } - if (name1[3] == 'D') { - disk1_ = name1[4] - '0'; - } - if (name1[11] == 'L') { - layer2_ = name1[12] - '0'; - } - if (name1[11] == 'D') { - disk2_ = name1[12] - '0'; - } - if (name1[12] == 'L') { - layer2_ = name1[13] - '0'; - } - if (name1[12] == 'D') { - disk2_ = name1[13] - '0'; - } - - iSeed_ = -1; - if (layer1_ == 3 && layer2_ == 4) - iSeed_ = 8; - if (layer1_ == 5 && layer2_ == 6) - iSeed_ = 9; - if (layer1_ == 2 && layer2_ == 3) - iSeed_ = 10; - if (disk1_ == 1 && disk2_ == 2) - iSeed_ = 11; - - firstphibits_ = settings_.nfinephi(0, iSeed_); - secondphibits_ = settings_.nfinephi(1, iSeed_); -} - -TrackletEngineDisplaced::~TrackletEngineDisplaced() { table_.clear(); } - -void TrackletEngineDisplaced::addOutput(MemoryBase* memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - if (output == "stubpairout") { - StubPairsMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - stubpairs_.push_back(tmp); - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output; -} - -void TrackletEngineDisplaced::addInput(MemoryBase* memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input == "firstvmstubin") { - VMStubsTEMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - firstvmstubs_.push_back(tmp); - return; - } - if (input == "secondvmstubin") { - VMStubsTEMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - secondvmstubs_ = tmp; - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; -} - -void TrackletEngineDisplaced::execute() { - if (!settings_.useSeed(iSeed_)) - return; - - if (table_.empty() && (settings_.enableTripletTables() && !settings_.writeTripletTables())) - readTables(); - - unsigned int countall = 0; - unsigned int countpass = 0; - unsigned int nInnerStubs = 0; - - for (unsigned int iInnerMem = 0; iInnerMem < firstvmstubs_.size(); - nInnerStubs += firstvmstubs_.at(iInnerMem)->nVMStubs(), iInnerMem++) - ; - - assert(!firstvmstubs_.empty()); - assert(secondvmstubs_ != nullptr); - - for (auto& iInnerMem : firstvmstubs_) { - assert(iInnerMem->nVMStubs() == iInnerMem->nVMStubs()); - for (unsigned int i = 0; i < iInnerMem->nVMStubs(); i++) { - const VMStubTE& firstvmstub = iInnerMem->getVMStubTE(i); - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "In " << getName() << " have first stub"; - } - - if ((layer1_ == 3 && layer2_ == 4) || (layer1_ == 5 && layer2_ == 6)) { - int lookupbits = firstvmstub.vmbits().value() & 1023; - int zdiffmax = (lookupbits >> 7); - int newbin = (lookupbits & 127); - int bin = newbin / 8; - - int zbinfirst = newbin & 7; - - int start = (bin >> 1); - int last = start + (bin & 1); - - assert(last < 8); - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Will look in zbins " << start << " to " << last; - } - for (int ibin = start; ibin <= last; ibin++) { - for (unsigned int j = 0; j < secondvmstubs_->nVMStubsBinned(ibin); j++) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "In " << getName() << " have second stub(1) " << ibin << " " << j; - } - - if (countall >= settings_.maxStep("TE")) - break; - countall++; - const VMStubTE& secondvmstub = secondvmstubs_->getVMStubTEBinned(ibin, j); - - int zbin = (secondvmstub.vmbits().value() & 7); - if (start != ibin) - zbin += 8; - if (zbin < zbinfirst || zbin - zbinfirst > zdiffmax) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Stubpair rejected because of wrong zbin"; - } - continue; - } - - assert(firstphibits_ != -1); - assert(secondphibits_ != -1); - - FPGAWord iphifirstbin = firstvmstub.finephi(); - FPGAWord iphisecondbin = secondvmstub.finephi(); - - unsigned int index = (iphifirstbin.value() << secondphibits_) + iphisecondbin.value(); - - FPGAWord firstbend = firstvmstub.bend(); - FPGAWord secondbend = secondvmstub.bend(); - - index = (index << firstbend.nbits()) + firstbend.value(); - index = (index << secondbend.nbits()) + secondbend.value(); - - if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) && - (index >= table_.size() || table_.at(index).empty())) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") - << "Stub pair rejected because of stub pt cut bends : " - << settings_.benddecode(firstvmstub.bend().value(), layer1_ - 1, firstvmstub.isPSmodule()) << " " - << settings_.benddecode(secondvmstub.bend().value(), layer2_ - 1, secondvmstub.isPSmodule()); - } - - //FIXME temporarily commented out until stub bend table fixed - //if (!settings_.writeTripletTables()) - // continue; - } - - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Adding layer-layer pair in " << getName(); - for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) { - if (!settings_.enableTripletTables() || settings_.writeTripletTables() || table_.at(index).count(isp)) { - if (settings_.writeMonitorData("Seeds")) { - ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; - fout.close(); - } - stubpairs_.at(isp)->addStubPair(firstvmstub, secondvmstub, index, getName()); - } - } - - countpass++; - } - } - - } else if (layer1_ == 2 && layer2_ == 3) { - int lookupbits = firstvmstub.vmbits().value() & 1023; - int zdiffmax = (lookupbits >> 7); - int newbin = (lookupbits & 127); - int bin = newbin / 8; - - int zbinfirst = newbin & 7; - - int start = (bin >> 1); - int last = start + (bin & 1); - - assert(last < 8); - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Will look in zbins " << start << " to " << last; - } - for (int ibin = start; ibin <= last; ibin++) { - for (unsigned int j = 0; j < secondvmstubs_->nVMStubsBinned(ibin); j++) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "In " << getName() << " have second stub(2) "; - } - - if (countall >= settings_.maxStep("TE")) - break; - countall++; - - const VMStubTE& secondvmstub = secondvmstubs_->getVMStubTEBinned(ibin, j); - - int zbin = (secondvmstub.vmbits().value() & 7); - if (start != ibin) - zbin += 8; - if (zbin < zbinfirst || zbin - zbinfirst > zdiffmax) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Stubpair rejected because of wrong zbin"; - } - continue; - } - - assert(firstphibits_ != -1); - assert(secondphibits_ != -1); - - FPGAWord iphifirstbin = firstvmstub.finephi(); - FPGAWord iphisecondbin = secondvmstub.finephi(); - - unsigned int index = (iphifirstbin.value() << secondphibits_) + iphisecondbin.value(); - - FPGAWord firstbend = firstvmstub.bend(); - FPGAWord secondbend = secondvmstub.bend(); - - index = (index << firstbend.nbits()) + firstbend.value(); - index = (index << secondbend.nbits()) + secondbend.value(); - - if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) && - (index >= table_.size() || table_.at(index).empty())) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") - << "Stub pair rejected because of stub pt cut bends : " - << settings_.benddecode(firstvmstub.bend().value(), layer1_ - 1, firstvmstub.isPSmodule()) << " " - << settings_.benddecode(secondvmstub.bend().value(), layer2_ - 1, secondvmstub.isPSmodule()); - } - continue; - } - - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Adding layer-layer pair in " << getName(); - for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) { - if ((!settings_.enableTripletTables() || settings_.writeTripletTables()) || - (index < table_.size() && table_.at(index).count(isp))) { - if (settings_.writeMonitorData("Seeds")) { - ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; - fout.close(); - } - stubpairs_.at(isp)->addStubPair(firstvmstub, secondvmstub, index, getName()); - } - } - - countpass++; - } - } - - } else if (disk1_ == 1 && disk2_ == 2) { - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << getName() << " Disk-disk pair"; - - int lookupbits = firstvmstub.vmbits().value() & 511; - bool negdisk = firstvmstub.stub()->disk().value() < 0; - int rdiffmax = (lookupbits >> 6); - int newbin = (lookupbits & 63); - int bin = newbin / 8; - - int rbinfirst = newbin & 7; - - int start = (bin >> 1); - if (negdisk) - start += 4; - int last = start + (bin & 1); - assert(last < 8); - for (int ibin = start; ibin <= last; ibin++) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " looking for matching stub in " << secondvmstubs_->getName() - << " in bin = " << ibin << " with " << secondvmstubs_->nVMStubsBinned(ibin) - << " stubs"; - } - for (unsigned int j = 0; j < secondvmstubs_->nVMStubsBinned(ibin); j++) { - if (countall >= settings_.maxStep("TE")) - break; - countall++; - - const VMStubTE& secondvmstub = secondvmstubs_->getVMStubTEBinned(ibin, j); - - int rbin = (secondvmstub.vmbits().value() & 7); - if (start != ibin) - rbin += 8; - if (rbin < rbinfirst) - continue; - if (rbin - rbinfirst > rdiffmax) - continue; - - unsigned int irsecondbin = secondvmstub.vmbits().value() >> 2; - - FPGAWord iphifirstbin = firstvmstub.finephi(); - FPGAWord iphisecondbin = secondvmstub.finephi(); - - unsigned int index = (irsecondbin << (secondphibits_ + firstphibits_)) + - (iphifirstbin.value() << secondphibits_) + iphisecondbin.value(); - - FPGAWord firstbend = firstvmstub.bend(); - FPGAWord secondbend = secondvmstub.bend(); - - index = (index << firstbend.nbits()) + firstbend.value(); - index = (index << secondbend.nbits()) + secondbend.value(); - - if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) && - (index >= table_.size() || table_.at(index).empty())) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") - << "Stub pair rejected because of stub pt cut bends : " - << settings_.benddecode(firstvmstub.bend().value(), disk1_ + 5, firstvmstub.isPSmodule()) << " " - << settings_.benddecode(secondvmstub.bend().value(), disk2_ + 5, secondvmstub.isPSmodule()); - } - continue; - } - - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Adding disk-disk pair in " << getName(); - - for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) { - if ((!settings_.enableTripletTables() || settings_.writeTripletTables()) || - (index < table_.size() && table_.at(index).count(isp))) { - if (settings_.writeMonitorData("Seeds")) { - ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; - fout.close(); - } - stubpairs_.at(isp)->addStubPair(firstvmstub, secondvmstub, index, getName()); - } - } - countpass++; - } - } - } - } - } - if (countall > 5000) { - edm::LogVerbatim("Tracklet") << "In TrackletEngineDisplaced::execute : " << getName() << " " << nInnerStubs << " " - << secondvmstubs_->nVMStubs() << " " << countall << " " << countpass; - for (auto& iInnerMem : firstvmstubs_) { - for (unsigned int i = 0; i < iInnerMem->nVMStubs(); i++) { - const VMStubTE& firstvmstub = iInnerMem->getVMStubTE(i); - edm::LogVerbatim("Tracklet") << "In TrackletEngineDisplaced::execute first stub : " - << firstvmstub.stub()->l1tstub()->r() << " " - << firstvmstub.stub()->l1tstub()->phi() << " " - << firstvmstub.stub()->l1tstub()->r() * firstvmstub.stub()->l1tstub()->phi() << " " - << firstvmstub.stub()->l1tstub()->z(); - } - } - for (unsigned int i = 0; i < secondvmstubs_->nVMStubs(); i++) { - const VMStubTE& secondvmstub = secondvmstubs_->getVMStubTE(i); - edm::LogVerbatim("Tracklet") << "In TrackletEngineDisplaced::execute second stub : " - << secondvmstub.stub()->l1tstub()->r() << " " - << secondvmstub.stub()->l1tstub()->phi() << " " - << secondvmstub.stub()->l1tstub()->r() * secondvmstub.stub()->l1tstub()->phi() << " " - << secondvmstub.stub()->l1tstub()->z(); - } - } - - if (settings_.writeMonitorData("TED")) { - globals_->ofstream("trackletenginedisplaces.txt") << getName() << " " << countall << " " << countpass << endl; - } -} - -void TrackletEngineDisplaced::readTables() { - ifstream fin; - string tableName, line, word; - - string tablePath = settings_.tableTEDFile(); - unsigned int finddir = tablePath.find("table_TED_"); - tableName = tablePath.substr(0, finddir) + "table_" + name_ + ".txt"; - - fin.open(tableName, ifstream::in); - if (!fin) { - throw cms::Exception("BadConfig") << "TripletEngine::readTables, file " << tableName << " not known"; - } - - while (getline(fin, line)) { - istringstream iss(line); - table_.resize(table_.size() + 1); - - while (iss >> word) - table_[table_.size() - 1].insert(memNameToIndex(word)); - } - fin.close(); -} - -short TrackletEngineDisplaced::memNameToIndex(const string& name) { - for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) - if (stubpairs_.at(isp)->getName() == name) - return isp; - return -1; -} diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index 2104d3cea740b..d0c50b922e5c3 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -248,38 +248,11 @@ void TrackletEventProcessor::event(SLHCEvent& ev, } VMRouterTimer_.stop(); - // tracklet engine - TETimer_.start(); - sector_->executeTE(); - TETimer_.stop(); - - // tracklet engine displaced - TEDTimer_.start(); - sector_->executeTED(); - TEDTimer_.stop(); - - // triplet engine - TRETimer_.start(); - sector_->executeTRE(); - if (settings_->writeMem() && k == settings_->writememsect()) { - sector_->writeST(first); - } - TRETimer_.stop(); - // tracklet processor (alternative implementation to TE+TC) TPTimer_.start(); sector_->executeTP(); TPTimer_.stop(); - if (settings_->writeMem() && k == settings_->writememsect()) { - sector_->writeSP(first); - } - - // tracklet calculator - TCTimer_.start(); - sector_->executeTC(); - TCTimer_.stop(); - if (settings_->writeMonitorData("HitEff") || settings_->bookHistos()) { int nTP = globals_->event()->nsimtracks(); for (int iTP = 0; iTP < nTP; iTP++) { @@ -325,11 +298,6 @@ void TrackletEventProcessor::event(SLHCEvent& ev, } } - // tracklet calculator displaced - TCDTimer_.start(); - sector_->executeTCD(); - TCDTimer_.stop(); - // tracklet processor displaced TPDTimer_.start(); sector_->executeTPD(); @@ -340,28 +308,6 @@ void TrackletEventProcessor::event(SLHCEvent& ev, sector_->writeTPROJ(first); } - // projection router - PRTimer_.start(); - sector_->executePR(); - if (settings_->writeMem() && k == settings_->writememsect()) { - sector_->writeVMPROJ(first); - sector_->writeAP(first); - } - PRTimer_.stop(); - - // match engine - METimer_.start(); - sector_->executeME(); - if (settings_->writeMem() && k == settings_->writememsect()) { - sector_->writeCM(first); - } - METimer_.stop(); - - // match calculator - MCTimer_.start(); - sector_->executeMC(); - MCTimer_.stop(); - // match processor (alternative to ME+MC) MPTimer_.start(); sector_->executeMP(); @@ -408,45 +354,17 @@ void TrackletEventProcessor::printSummary() { << InputRouterTimer_.tottime() << "\n" << "VMRouter " << setw(10) << VMRouterTimer_.ntimes() << setw(20) << setprecision(3) << VMRouterTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << VMRouterTimer_.tottime(); - if (settings_->combined()) { - edm::LogVerbatim("Tracklet") << "TrackletProcessor " << setw(10) << TPTimer_.ntimes() << setw(20) - << setprecision(3) << TPTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << TPTimer_.tottime() << "\n" - << "MatchProcessor " << setw(10) << MPTimer_.ntimes() << setw(20) - << setprecision(3) << MPTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << MPTimer_.tottime(); - } else { - edm::LogVerbatim("Tracklet") << "TrackletEngine " << setw(10) << TETimer_.ntimes() << setw(20) - << setprecision(3) << TETimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << TETimer_.tottime(); - if (settings_->extended()) { - edm::LogVerbatim("Tracklet") << "TrackletEngineDisplaced" << setw(10) << TEDTimer_.ntimes() << setw(20) - << setprecision(3) << TEDTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << TEDTimer_.tottime() << "\n" - << "TripletEngine " << setw(10) << TRETimer_.ntimes() << setw(20) - << setprecision(3) << TRETimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << TRETimer_.tottime() << "\n" - << "TrackletCalculatorDisplaced" << setw(10) << TCDTimer_.ntimes() << setw(20) - << setprecision(3) << TCDTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << TCDTimer_.tottime() << "\n" - << TCDTimer_.tottime() << "\n" - << "TrackletProcessorDisplaced" << setw(10) << TPDTimer_.ntimes() << setw(20) - << setprecision(3) << TPDTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << TPDTimer_.tottime(); - } - edm::LogVerbatim("Tracklet") << "TrackletCalculator " << setw(10) << TCTimer_.ntimes() << setw(20) - << setprecision(3) << TCTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << TCTimer_.tottime() << "\n" - << "ProjectionRouter " << setw(10) << PRTimer_.ntimes() << setw(20) - << setprecision(3) << PRTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << PRTimer_.tottime() << "\n" - << "MatchEngine " << setw(10) << METimer_.ntimes() << setw(20) - << setprecision(3) << METimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << METimer_.tottime() << "\n" - << "MatchCalculator " << setw(10) << MCTimer_.ntimes() << setw(20) - << setprecision(3) << MCTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << MCTimer_.tottime(); + << VMRouterTimer_.tottime() << "\n" + << "TrackletProcessor " << setw(10) << TPTimer_.ntimes() << setw(20) + << setprecision(3) << TPTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) + << TPTimer_.tottime() << "\n" + << "MatchProcessor " << setw(10) << MPTimer_.ntimes() << setw(20) + << setprecision(3) << MPTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) + << MPTimer_.tottime(); + if (settings_->extended()) { + edm::LogVerbatim("Tracklet") << "TrackletProcessorDisplaced" << setw(10) << TPDTimer_.ntimes() << setw(20) + << setprecision(3) << TPDTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) + << TPDTimer_.tottime(); } edm::LogVerbatim("Tracklet") << "FitTrack " << setw(10) << FTTimer_.ntimes() << setw(20) << setprecision(3) << FTTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) diff --git a/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc deleted file mode 100644 index c934ecb220d06..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc +++ /dev/null @@ -1,481 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/TripletEngine.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include - -using namespace std; -using namespace trklet; - -TripletEngine::TripletEngine(string name, Settings const &settings, Globals *global) - : ProcessBase(name, settings, global) { - stubpairs_.clear(); - thirdvmstubs_.clear(); - layer1_ = 0; - layer2_ = 0; - layer3_ = 0; - disk1_ = 0; - disk2_ = 0; - disk3_ = 0; - dct1_ = 0; - dct2_ = 0; - dct3_ = 0; - phi1_ = 0; - phi2_ = 0; - phi3_ = 0; - z1_ = 0; - z2_ = 0; - z3_ = 0; - r1_ = 0; - r2_ = 0; - r3_ = 0; - - if (name_[4] == 'L') - layer1_ = name_[5] - '0'; - if (name_[4] == 'D') - disk1_ = name_[5] - '0'; - if (name_[7] == 'L') - layer2_ = name_[8] - '0'; - if (name_[7] == 'D') - disk2_ = name_[8] - '0'; - - if (layer1_ == 3 && layer2_ == 4) { - layer3_ = 2; - iSeed_ = 8; - } else if (layer1_ == 5 && layer2_ == 6) { - layer3_ = 4; - iSeed_ = 9; - } else if (layer1_ == 2 && layer2_ == 3) { - disk3_ = 1; - iSeed_ = 10; - } else if (disk1_ == 1 && disk2_ == 2) { - layer3_ = 2; - iSeed_ = 11; - } else - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Invalid seeding!"; - - if ((layer2_ == 4 && layer3_ == 2) || (layer2_ == 6 && layer3_ == 4)) { - secondphibits_ = settings_.nfinephi(1, iSeed_); - thirdphibits_ = settings_.nfinephi(2, iSeed_); - } - if ((layer2_ == 3 && disk3_ == 1) || (disk2_ == 2 && layer3_ == 2)) { - secondphibits_ = settings_.nfinephi(1, iSeed_); - thirdphibits_ = settings_.nfinephi(2, iSeed_); - } - if (settings_.enableTripletTables() && !settings_.writeTripletTables()) - readTables(); -} - -TripletEngine::~TripletEngine() { - if (settings_.writeTripletTables()) - writeTables(); -} - -void TripletEngine::addOutput(MemoryBase *memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - if (output == "stubtripout") { - auto *tmp = dynamic_cast(memory); - assert(tmp != nullptr); - stubtriplets_ = tmp; - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output; -} - -void TripletEngine::addInput(MemoryBase *memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input == "thirdvmstubin") { - auto *tmp = dynamic_cast(memory); - assert(tmp != nullptr); - thirdvmstubs_.push_back(tmp); - return; - } - if (input.substr(0, 8) == "stubpair") { - auto *tmp = dynamic_cast(memory); - assert(tmp != nullptr); - stubpairs_.push_back(tmp); - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; -} - -void TripletEngine::execute() { - unsigned int countall = 0; - unsigned int countpass = 0; - unsigned int nThirdStubs = 0; - count_ = 0; - - for (unsigned int iThirdMem = 0; iThirdMem < thirdvmstubs_.size(); - nThirdStubs += thirdvmstubs_.at(iThirdMem)->nVMStubs(), iThirdMem++) - ; - - assert(!thirdvmstubs_.empty()); - assert(!stubpairs_.empty()); - - bool print = false && (getName().substr(0, 10) == "TRE_L2cL3c"); - - print = print && nThirdStubs > 0; - - if (print) { - edm::LogVerbatim("Tracklet") << "In TripletEngine::execute : " << getName() << " " << nThirdStubs << ":"; - for (unsigned int i = 0; i < thirdvmstubs_.size(); ++i) { - edm::LogVerbatim("Tracklet") << thirdvmstubs_.at(i)->getName() << " " << thirdvmstubs_.at(i)->nVMStubs(); - } - std::string oss = ""; - for (unsigned int i = 0; i < stubpairs_.size(); ++i) { - oss += std::to_string(stubpairs_.at(i)->nStubPairs()); - oss += " "; - } - edm::LogVerbatim("Tracklet") << oss; - for (unsigned int i = 0; i < stubpairs_.size(); ++i) { - edm::LogVerbatim("Tracklet") << " " << stubpairs_.at(i)->getName(); - } - } - - tmpSPTable_.clear(); - - for (unsigned int i = 0; i < stubpairs_.size(); ++i) { - for (unsigned int j = 0; j < stubpairs_.at(i)->nStubPairs(); ++j) { - if (print) - edm::LogVerbatim("Tracklet") << " ***** " << stubpairs_.at(i)->getName() << " " - << stubpairs_.at(i)->nStubPairs(); - - auto firstvmstub = stubpairs_.at(i)->getVMStub1(j); - auto secondvmstub = stubpairs_.at(i)->getVMStub2(j); - - if ((layer2_ == 4 && layer3_ == 2) || (layer2_ == 6 && layer3_ == 4)) { - constexpr unsigned int vmbitshift = 10; - int lookupbits = (int)((firstvmstub.vmbits().value() >> vmbitshift) & 1023); //1023=2^vmbitshift-1 - int newbin = (lookupbits & 127); - int bin = newbin / 8; - - int start = (bin >> 1); - int last = start + (bin & 1); - - for (int ibin = start; ibin <= last; ibin++) { - for (unsigned int k = 0; k < thirdvmstubs_.size(); k++) { - string vmsteSuffix = thirdvmstubs_.at(k)->getLastPartOfName(); - vmsteSuffix = vmsteSuffix.substr(0, vmsteSuffix.find_last_of('n')); - if (stubpairs_.at(i)->getLastPartOfName() != vmsteSuffix) - continue; - for (unsigned int l = 0; l < thirdvmstubs_.at(k)->nVMStubsBinned(ibin); l++) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "In " << getName() << " have third stub"; - } - - if (countall >= settings_.maxStep("TRE")) - break; - countall++; - - const VMStubTE &thirdvmstub = thirdvmstubs_.at(k)->getVMStubTEBinned(ibin, l); - - assert(secondphibits_ != -1); - assert(thirdphibits_ != -1); - - unsigned int nvmsecond = settings_.nallstubs(layer2_ - 1) * settings_.nvmte(1, iSeed_); - unsigned int nvmbitssecond = nbits(nvmsecond); - - FPGAWord iphisecondbin = secondvmstub.stub()->iphivmFineBins(nvmbitssecond, secondphibits_); - - //currently not using same number of bits as in the TED - //assert(iphisecondbin==(int)secondvmstub.finephi()); - FPGAWord iphithirdbin = thirdvmstub.finephi(); - - unsigned int index = (iphisecondbin.value() << thirdphibits_) + iphithirdbin.value(); - - FPGAWord secondbend = secondvmstub.bend(); - FPGAWord thirdbend = thirdvmstub.bend(); - - index = (index << secondbend.nbits()) + secondbend.value(); - index = (index << thirdbend.nbits()) + thirdbend.value(); - - if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) && - (index >= table_.size() || !table_[index])) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") - << "Stub pair rejected because of stub pt cut bends : " - << settings_.benddecode(secondvmstub.bend().value(), layer2_ - 1, secondvmstub.isPSmodule()) - << " " << settings_.benddecode(thirdvmstub.bend().value(), layer3_ - 1, thirdvmstub.isPSmodule()); - } - - //FIXME temporarily commented out until bend table fixed - //if (!settings_.writeTripletTables()) - // continue; - } - if (settings_.writeTripletTables()) { - if (index >= table_.size()) - table_.resize(index + 1, false); - table_[index] = true; - - const unsigned spIndex = stubpairs_.at(i)->getIndex(j); - const string &tedName = stubpairs_.at(i)->getTEDName(j); - if (!tmpSPTable_.count(tedName)) - tmpSPTable_[tedName]; - if (spIndex >= tmpSPTable_.at(tedName).size()) - tmpSPTable_.at(tedName).resize(spIndex + 1); - tmpSPTable_.at(tedName).at(spIndex).push_back(stubpairs_.at(i)->getName()); - } - - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Adding layer-layer pair in " << getName(); - if (settings_.writeMonitorData("Seeds")) { - ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; - fout.close(); - } - stubtriplets_->addStubs(thirdvmstub.stub(), - (stubpairs_.at(i))->getVMStub1(j).stub(), - (stubpairs_.at(i))->getVMStub2(j).stub()); - - countpass++; - } - } - } - - } - - else if (disk2_ == 2 && layer3_ == 2) { - int lookupbits = (int)((firstvmstub.vmbits().value() >> 10) & 1023); - int newbin = (lookupbits & 127); - int bin = newbin / 8; - - int start = (bin >> 1); - int last = start + (bin & 1); - - if (firstvmstub.stub()->disk().value() < 0) { //TODO - negative disk should come from memory - start = settings_.NLONGVMBINS() - last - 1; - last = settings_.NLONGVMBINS() - start - 1; - } - - for (int ibin = start; ibin <= last; ibin++) { - for (unsigned int k = 0; k < thirdvmstubs_.size(); k++) { - string vmsteSuffix = thirdvmstubs_.at(k)->getLastPartOfName(); - vmsteSuffix = vmsteSuffix.substr(0, vmsteSuffix.find_last_of('n')); - if (stubpairs_.at(i)->getLastPartOfName() != vmsteSuffix) - continue; - - for (unsigned int l = 0; l < thirdvmstubs_.at(k)->nVMStubsBinned(ibin); l++) { - if (countall >= settings_.maxStep("TRE")) - break; - countall++; - - const VMStubTE &thirdvmstub = thirdvmstubs_.at(k)->getVMStubTEBinned(ibin, l); - - assert(secondphibits_ != -1); - assert(thirdphibits_ != -1); - - FPGAWord iphisecondbin = secondvmstub.finephi(); - FPGAWord iphithirdbin = thirdvmstub.finephi(); - - unsigned int index = (iphisecondbin.value() << thirdphibits_) + iphithirdbin.value(); - - FPGAWord secondbend = secondvmstub.bend(); - FPGAWord thirdbend = thirdvmstub.bend(); - - index = (index << secondbend.nbits()) + secondbend.value(); - index = (index << thirdbend.nbits()) + thirdbend.value(); - - if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) && - (index >= table_.size() || !table_[index])) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") - << "Stub triplet rejected because of stub pt cut bends : " - << settings_.benddecode(secondvmstub.bend().value(), disk2_ + 5, secondvmstub.isPSmodule()) << " " - << settings_.benddecode(thirdvmstub.bend().value(), layer3_ - 1, thirdvmstub.isPSmodule()); - } - continue; - } - if (settings_.writeTripletTables()) { - if (index >= table_.size()) - table_.resize(index + 1, false); - table_[index] = true; - - const unsigned spIndex = stubpairs_.at(i)->getIndex(j); - const string &tedName = stubpairs_.at(i)->getTEDName(j); - if (!tmpSPTable_.count(tedName)) - tmpSPTable_[tedName]; - if (spIndex >= tmpSPTable_.at(tedName).size()) - tmpSPTable_.at(tedName).resize(spIndex + 1); - tmpSPTable_.at(tedName).at(spIndex).push_back(stubpairs_.at(i)->getName()); - } - - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Adding layer-disk pair in " << getName(); - if (settings_.writeMonitorData("Seeds")) { - ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; - fout.close(); - } - stubtriplets_->addStubs(thirdvmstub.stub(), - (stubpairs_.at(i))->getVMStub1(j).stub(), - (stubpairs_.at(i))->getVMStub2(j).stub()); - countpass++; - } - } - } - } - - else if (layer2_ == 3 && disk3_ == 1) { - int lookupbits = (int)((firstvmstub.vmbits().value() >> 10) & 1023); - - int newbin = (lookupbits & 127); - int bin = newbin / 8; - - int start = (bin >> 1); - int last = start + (bin & 1); - - for (int ibin = start; ibin <= last; ibin++) { - for (unsigned int k = 0; k < thirdvmstubs_.size(); k++) { - string vmsteSuffix = thirdvmstubs_.at(k)->getLastPartOfName(); - vmsteSuffix = vmsteSuffix.substr(0, vmsteSuffix.find_last_of('n')); - if (stubpairs_.at(i)->getLastPartOfName() != vmsteSuffix) - continue; - for (unsigned int l = 0; l < thirdvmstubs_.at(k)->nVMStubsBinned(ibin); l++) { - if (countall >= settings_.maxStep("TRE")) - break; - countall++; - - const VMStubTE &thirdvmstub = thirdvmstubs_.at(k)->getVMStubTEBinned(ibin, l); - - assert(secondphibits_ != -1); - assert(thirdphibits_ != -1); - - unsigned int nvmsecond; - - nvmsecond = settings_.nallstubs(layer2_ - 1) * settings_.nvmte(1, iSeed_); - unsigned int nvmbitssecond = nbits(nvmsecond); - - FPGAWord iphisecondbin = secondvmstub.stub()->iphivmFineBins(nvmbitssecond, secondphibits_); - - //currentlty not using same number of bits as in the TED - //assert(iphisecondbin==(int)secondvmstub.finephi()); - FPGAWord iphithirdbin = thirdvmstub.finephi(); - - unsigned int index = (iphisecondbin.value() << thirdphibits_) + iphithirdbin.value(); - - FPGAWord secondbend = secondvmstub.bend(); - FPGAWord thirdbend = thirdvmstub.bend(); - - index = (index << secondbend.nbits()) + secondbend.value(); - index = (index << thirdbend.nbits()) + thirdbend.value(); - - if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) && - (index >= table_.size() || !table_[index])) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") - << "Stub pair rejected because of stub pt cut bends : " - << settings_.benddecode(secondvmstub.bend().value(), layer2_ - 1, secondvmstub.isPSmodule()) - << " " << settings_.benddecode(thirdvmstub.bend().value(), disk3_ + 5, thirdvmstub.isPSmodule()); - } - continue; - } - if (settings_.writeTripletTables()) { - if (index >= table_.size()) - table_.resize(index + 1, false); - table_[index] = true; - - const unsigned spIndex = stubpairs_.at(i)->getIndex(j); - const string &tedName = stubpairs_.at(i)->getTEDName(j); - if (!tmpSPTable_.count(tedName)) - tmpSPTable_[tedName]; - if (spIndex >= tmpSPTable_.at(tedName).size()) - tmpSPTable_.at(tedName).resize(spIndex + 1); - tmpSPTable_.at(tedName).at(spIndex).push_back(stubpairs_.at(i)->getName()); - } - - if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << "Adding layer-disk pair in " << getName(); - if (settings_.writeMonitorData("Seeds")) { - ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; - fout.close(); - } - stubtriplets_->addStubs(thirdvmstub.stub(), - (stubpairs_.at(i))->getVMStub1(j).stub(), - (stubpairs_.at(i))->getVMStub2(j).stub()); - countpass++; - } - } - } - } - } - } - - for (const auto &tedName : tmpSPTable_) { - for (unsigned spIndex = 0; spIndex < tedName.second.size(); spIndex++) { - if (tedName.second.at(spIndex).empty()) - continue; - vector entry(tedName.second.at(spIndex)); - sort(entry.begin(), entry.end()); - entry.erase(unique(entry.begin(), entry.end()), entry.end()); - const string &spName = entry.at(0); - - if (!spTable_.count(tedName.first)) - spTable_[tedName.first]; - if (spIndex >= spTable_.at(tedName.first).size()) - spTable_.at(tedName.first).resize(spIndex + 1); - if (!spTable_.at(tedName.first).at(spIndex).count(spName)) - spTable_.at(tedName.first).at(spIndex)[spName] = 0; - spTable_.at(tedName.first).at(spIndex)[spName]++; - } - } - - if (settings_.writeMonitorData("TRE")) { - globals_->ofstream("tripletengine.txt") << getName() << " " << countall << " " << countpass << endl; - } -} - -void TripletEngine::readTables() { - ifstream fin; - string tableName, word; - unsigned num; - - string tablePath = settings_.tableTREFile(); - unsigned int finddir = tablePath.find("table_TRE_"); - tableName = tablePath.substr(0, finddir) + "table_" + name_ + ".txt"; - - fin.open(tableName, ifstream::in); - if (!fin) { - throw cms::Exception("BadConfig") << "TripletEngine::readTables, file " << tableName << " not known"; - } - while (!fin.eof()) { - fin >> word; - num = atoi(word.c_str()); - table_.push_back(num > 0 ? true : false); - } - fin.close(); -} - -void TripletEngine::writeTables() { - ofstream fout; - stringstream tableName; - - tableName << "table/table_" << name_ << ".txt"; - - fout.open(tableName.str(), ofstream::out); - for (const auto entry : table_) - fout << entry << endl; - fout.close(); - - for (const auto &tedName : spTable_) { - tableName.str(""); - tableName << "table/table_" << tedName.first << "_" << name_ << ".txt"; - - fout.open(tableName.str(), ofstream::out); - for (const auto &entry : tedName.second) { - for (const auto &spName : entry) - fout << spName.first << ":" << spName.second << " "; - fout << endl; - } - fout.close(); - } -} diff --git a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc deleted file mode 100644 index 007f865f73db3..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc +++ /dev/null @@ -1,52 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include -#include - -using namespace std; -using namespace trklet; - -VMProjectionsMemory::VMProjectionsMemory(string name, Settings const& settings) : MemoryBase(name, settings) { - initLayerDisk(7, layer_, disk_); -} - -void VMProjectionsMemory::addTracklet(Tracklet* tracklet, unsigned int allprojindex) { - std::pair tmp(tracklet, allprojindex); - //Check that order of TCID is correct - if (!tracklets_.empty()) { - assert(tracklets_[tracklets_.size() - 1].first->TCID() <= tracklet->TCID()); - } - tracklets_.push_back(tmp); -} - -void VMProjectionsMemory::writeVMPROJ(bool first, unsigned int iSector) { - iSector_ = iSector; - const string dirVM = settings_.memPath() + "VMProjections/"; - - std::ostringstream oss; - oss << dirVM + "VMProjections_" << getName(); - //get rid of duplicates - auto const& tmp = oss.str(); - int len = tmp.size(); - if (tmp[len - 2] == 'n' && tmp[len - 1] > '1' && tmp[len - 1] <= '9') - return; - oss << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; - auto const& fname = oss.str(); - - openfile(out_, first, dirVM, fname, __FILE__, __LINE__); - - out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; - - for (unsigned int j = 0; j < tracklets_.size(); j++) { - string vmproj = (layer_ > 0) ? tracklets_[j].first->vmstrlayer(layer_, tracklets_[j].second) - : tracklets_[j].first->vmstrdisk(disk_, tracklets_[j].second); - out_ << hexstr(j) << " " << vmproj << " " << trklet::hexFormat(vmproj) << endl; - } - out_.close(); - - bx_++; - event_++; - if (bx_ > 7) - bx_ = 0; -} diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc deleted file mode 100644 index 8ba7cf4c39770..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc +++ /dev/null @@ -1,385 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/VMRouter.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" -#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubTE.h" -#include "L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h" -#include "L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -using namespace std; -using namespace trklet; - -VMRouter::VMRouter(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global), - meTable_(settings), - diskTable_(settings), - innerTable_(settings), - innerOverlapTable_(settings), - innerThirdTable_(settings) { - layerdisk_ = initLayerDisk(4); - - vmstubsMEPHI_.resize(settings_.nvmme(layerdisk_), nullptr); - - unsigned int region = name[9] - 'A'; - assert(region < settings_.nallstubs(layerdisk_)); - - overlapbits_ = 7; - nextrabits_ = overlapbits_ - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_)); - - meTable_.initVMRTable(layerdisk_, TrackletLUT::VMRTableType::me, region); //used for ME and outer TE barrel - - if (layerdisk_ == LayerDisk::D1 || layerdisk_ == LayerDisk::D2 || layerdisk_ == D4) { - diskTable_.initVMRTable(layerdisk_, TrackletLUT::VMRTableType::disk, region); //outer disk used by D1, D2, and D4 - } - - if (layerdisk_ == LayerDisk::L1 || layerdisk_ == LayerDisk::L2 || layerdisk_ == LayerDisk::L3 || - layerdisk_ == LayerDisk::L5 || layerdisk_ == LayerDisk::D1 || layerdisk_ == LayerDisk::D3) { - innerTable_.initVMRTable(layerdisk_, TrackletLUT::VMRTableType::inner, region); //projection to next layer/disk - } - - if (layerdisk_ == LayerDisk::L1 || layerdisk_ == LayerDisk::L2) { - innerOverlapTable_.initVMRTable( - layerdisk_, TrackletLUT::VMRTableType::inneroverlap, region); //projection to disk from layer - } - - if (layerdisk_ == LayerDisk::L2 || layerdisk_ == LayerDisk::L3 || layerdisk_ == LayerDisk::L5 || - layerdisk_ == LayerDisk::D1) { - innerThirdTable_.initVMRTable( - layerdisk_, TrackletLUT::VMRTableType::innerthird, region); //projection to third layer/disk - } - - nbitszfinebintable_ = settings_.vmrlutzbits(layerdisk_); - nbitsrfinebintable_ = settings_.vmrlutrbits(layerdisk_); -} - -void VMRouter::addOutput(MemoryBase* memory, string output) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " - << output; - } - - if (output.substr(0, 10) == "allstubout") { - AllStubsMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - allstubs_.push_back(tmp); - return; - } - - if (output.substr(0, 12) == "vmstuboutPHI" || output.substr(0, 14) == "vmstuboutMEPHI" || - output.substr(0, 15) == "vmstuboutTEIPHI" || output.substr(0, 15) == "vmstuboutTEOPHI") { - char seedtype = memory->getName().substr(11, 1)[0]; - unsigned int pos = 12; - int vmbin = memory->getName().substr(pos, 1)[0] - '0'; - pos++; - if (pos < memory->getName().size()) { - if (memory->getName().substr(pos, 1)[0] != 'n') { - vmbin = vmbin * 10 + memory->getName().substr(pos, 1)[0] - '0'; - pos++; - } - } - - int iseed = -1; - unsigned int inner = 1; - if (memory->getName().substr(3, 2) == "TE") { - VMStubsTEMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - if (seedtype < 'I') { - if (layerdisk_ == LayerDisk::L1 || layerdisk_ == LayerDisk::L2) - iseed = Seed::L1L2; - if (layerdisk_ == LayerDisk::L3 || layerdisk_ == LayerDisk::L4) - iseed = Seed::L3L4; - if (layerdisk_ == LayerDisk::L5 || layerdisk_ == LayerDisk::L6) - iseed = Seed::L5L6; - if (layerdisk_ == LayerDisk::D1 || layerdisk_ == LayerDisk::D2) - iseed = Seed::D1D2; - if (layerdisk_ == LayerDisk::D3 || layerdisk_ == LayerDisk::D4) - iseed = Seed::D3D4; - if (layerdisk_ == LayerDisk::L1 || layerdisk_ == LayerDisk::L3 || layerdisk_ == LayerDisk::L5 || - layerdisk_ == LayerDisk::D1 || layerdisk_ == LayerDisk::D3) - inner = 0; - } else if (seedtype < 'M') { - if (layerdisk_ == LayerDisk::L2 || layerdisk_ == LayerDisk::L3) - iseed = Seed::L2L3; - if (layerdisk_ == LayerDisk::L2) - inner = 0; - } else if (seedtype <= 'Z') { - if (layerdisk_ == LayerDisk::L1 || layerdisk_ == LayerDisk::D1) - iseed = Seed::L1D1; - if (layerdisk_ == LayerDisk::L2 || layerdisk_ == LayerDisk::D1) - iseed = Seed::L2D1; - if (layerdisk_ == LayerDisk::L1 || layerdisk_ == LayerDisk::L2) - inner = 0; - } else if (seedtype < 'o' && seedtype >= 'a') { - if (layerdisk_ == LayerDisk::L2 || layerdisk_ == LayerDisk::L3) - iseed = Seed::L2L3D1; - if (layerdisk_ == LayerDisk::L2) - inner = 0; - } else if (seedtype > 'o' && seedtype <= 'z') { - if (layerdisk_ == LayerDisk::L2) - iseed = Seed::D1D2L2; - if (layerdisk_ == LayerDisk::D1) - iseed = Seed::L2L3D1; - inner = 2; - } else { - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Invalid seeding!"; - } - assert(iseed != -1); - int seedindex = -1; - for (unsigned int k = 0; k < vmstubsTEPHI_.size(); k++) { - if (vmstubsTEPHI_[k].seednumber == (unsigned int)iseed) { - seedindex = k; - } - } - if (seedindex == -1) { - seedindex = vmstubsTEPHI_.size(); - vector avectmp; - vector > vectmp(settings_.nvmte(inner, iseed), avectmp); - VMStubsTEPHI atmp(iseed, inner, vectmp); - vmstubsTEPHI_.push_back(atmp); - } - vmstubsTEPHI_[seedindex].vmstubmem[(vmbin - 1) & (settings_.nvmte(inner, iseed) - 1)].push_back(tmp); - - } else if (memory->getName().substr(3, 2) == "ME") { - VMStubsMEMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - vmstubsMEPHI_[(vmbin - 1) & (settings_.nvmme(layerdisk_) - 1)] = tmp; - } else { - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " should never get here!"; - } - - return; - } - - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output; -} - -void VMRouter::addInput(MemoryBase* memory, string input) { - if (settings_.writetrace()) { - edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " - << input; - } - if (input == "stubin") { - InputLinkMemory* tmp1 = dynamic_cast(memory); - assert(tmp1 != nullptr); - if (tmp1 != nullptr) { - if (layerdisk_ >= N_LAYER && tmp1->getName().find("2S_") != string::npos) { - stubinputdisk2stmp_.push_back(tmp1); - } else { - stubinputtmp_.push_back(tmp1); - } - } - //This gymnastic is done to ensure that in the disks the PS stubs are processed before - //the 2S stubs. This is needed by the current HLS implemenation of the VM router. - stubinputs_ = stubinputtmp_; - for (auto& mem : stubinputdisk2stmp_) { - stubinputs_.push_back(mem); - } - return; - } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; -} - -void VMRouter::execute() { - unsigned int allStubCounter = 0; - - //Loop over the input stubs - for (auto& stubinput : stubinputs_) { - for (unsigned int i = 0; i < stubinput->nStubs(); i++) { - if (allStubCounter >= settings_.maxStep("VMR")) - continue; - if (allStubCounter >= (1 << N_BITSMEMADDRESS)) - continue; - Stub* stub = stubinput->getStub(i); - - //Note - below information is not part of the stub, but rather from which input memory we are reading - bool negdisk = (stub->disk().value() < 0); - - //use &127 to make sure we fit into the number of bits - - //though we should have protected against overflows above - FPGAWord allStubIndex(allStubCounter & ((1 << N_BITSMEMADDRESS) - 1), N_BITSMEMADDRESS, true, __LINE__, __FILE__); - - //TODO - should not be needed - but need to migrate some other pieces of code before removing - stub->setAllStubIndex(allStubCounter); - //TODO - should not be needed - but need to migrate some other pieces of code before removing - stub->l1tstub()->setAllStubIndex(allStubCounter); - - allStubCounter++; - - //Fill allstubs memories - in HLS this is the same write to multiple memories - for (auto& allstub : allstubs_) { - allstub->addStub(stub); - } - - //Fill all the ME VM memories - - FPGAWord iphi = stub->phicorr(); - unsigned int ivm = - iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_)), - settings_.nbitsvmme(layerdisk_)); - unsigned int extrabits = iphi.bits(iphi.nbits() - overlapbits_, nextrabits_); - - unsigned int ivmPlus = ivm; - - if (extrabits == ((1U << nextrabits_) - 1) && ivm != ((1U << settings_.nbitsvmme(layerdisk_)) - 1)) - ivmPlus++; - unsigned int ivmMinus = ivm; - if (extrabits == 0 && ivm != 0) - ivmMinus--; - - //Calculate the z and r position for the vmstub - - //Take the top nbitszfinebintable_ bits of the z coordinate - int indexz = (((1 << (stub->z().nbits() - 1)) + stub->z().value()) >> (stub->z().nbits() - nbitszfinebintable_)); - int indexr = -1; - if (layerdisk_ > (N_LAYER - 1)) { - if (negdisk) { - indexz = (1 << nbitszfinebintable_) - indexz; - } - indexr = stub->r().value(); - if (stub->isPSmodule()) { - indexr = stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_); - } - } else { - //Take the top nbitsfinebintable_ bits of the z coordinate. The & is to handle the negative z values. - indexr = (((1 << (stub->r().nbits() - 1)) + stub->r().value()) >> (stub->r().nbits() - nbitsrfinebintable_)); - } - - assert(indexz >= 0); - assert(indexr >= 0); - assert(indexz < (1 << nbitszfinebintable_)); - assert(indexr < (1 << nbitsrfinebintable_)); - - int melut = meTable_.lookup((indexz << nbitsrfinebintable_) + indexr); - assert(melut >= 0); - - int vmbin = melut >> 3; - if (negdisk) - vmbin += 8; - int rzfine = melut & 7; - - // pad disk PS bend word with a '0' in MSB so that all disk bends have 4 bits (for HLS compatibility) - int nbendbits = stub->bend().nbits(); - if (layerdisk_ >= N_LAYER) - nbendbits = settings_.nbendbitsmedisk(); - - VMStubME vmstub(stub, - stub->iphivmFineBins(settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_), 3), - FPGAWord(rzfine, 3, true, __LINE__, __FILE__), - FPGAWord(stub->bend().value(), nbendbits, true, __LINE__, __FILE__), - allStubIndex); - - if (!(settings_.reduced())) - assert(vmstubsMEPHI_[ivmPlus] != nullptr); - if (vmstubsMEPHI_[ivmPlus] != nullptr) - vmstubsMEPHI_[ivmPlus]->addStub(vmstub, vmbin); - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << vmstubsMEPHI_[ivmPlus]->getName() - << " ivmPlus" << ivmPlus << " bin=" << vmbin; - } - - if (ivmMinus != ivmPlus && vmstubsMEPHI_[ivmMinus] != nullptr) { - vmstubsMEPHI_[ivmMinus]->addStub(vmstub, vmbin); - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << vmstubsMEPHI_[ivmMinus]->getName() - << " ivmMinus" << ivmMinus << " bin=" << vmbin; - } - } - - //Fill the TE VM memories - - for (auto& ivmstubTEPHI : vmstubsTEPHI_) { - unsigned int iseed = ivmstubTEPHI.seednumber; - unsigned int inner = ivmstubTEPHI.stubposition; - if ((iseed == Seed::D1D2 || iseed == Seed::D3D4 || iseed == Seed::L1D1 || iseed == Seed::L2D1) && - (!stub->isPSmodule())) - continue; - - unsigned int lutwidth = settings_.lutwidthtab(inner, iseed); - if (settings_.extended()) { - lutwidth = settings_.lutwidthtabextended(inner, iseed); - } - - int lutval = -999; - - if (inner > 0) { - if (layerdisk_ < N_LAYER) { - lutval = melut; - } else { - if (inner == 2 && iseed == Seed::L2L3D1) { - lutval = 0; - if (stub->r().value() < 10) { - lutval = 8 * (1 + (stub->r().value() >> 2)); - } else { - if (stub->r().value() < settings_.rmindiskl3overlapvm() / settings_.kr()) { - lutval = -1; - } - } - } else { - lutval = diskTable_.lookup((indexz << nbitsrfinebintable_) + indexr); - } - } - if (lutval == -1) - continue; - } else { - if (iseed < Seed::L1D1 || iseed > Seed::L2D1) { - lutval = innerTable_.lookup((indexz << nbitsrfinebintable_) + indexr); - } else { - lutval = innerOverlapTable_.lookup((indexz << nbitsrfinebintable_) + indexr); - } - if (lutval == -1) - continue; - if (settings_.extended() && - (iseed == Seed::L3L4 || iseed == Seed::L5L6 || iseed == Seed::D1D2 || iseed == Seed::L2L3D1)) { - int lutval2 = innerThirdTable_.lookup((indexz << nbitsrfinebintable_) + indexr); - if (lutval2 != -1) - lutval += (lutval2 << 10); - } - } - - assert(lutval >= 0); - - FPGAWord binlookup(lutval, lutwidth, true, __LINE__, __FILE__); - - if (binlookup.value() < 0) - continue; - - unsigned int ivmte = - iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmte(inner, iseed)), - settings_.nbitsvmte(inner, iseed)); - - int bin = -1; - if (inner != 0) { - bin = binlookup.value() / 8; - unsigned int tmp = binlookup.value() & 7; //three bits in outer layers - this could be coded cleaner... - binlookup.set(tmp, 3, true, __LINE__, __FILE__); - } - - FPGAWord finephi = stub->iphivmFineBins(settings_.nphireg(inner, iseed), settings_.nfinephi(inner, iseed)); - - VMStubTE tmpstub(stub, finephi, stub->bend(), binlookup, allStubIndex); - - unsigned int nmem = ivmstubTEPHI.vmstubmem[ivmte].size(); - - if (!(settings_.reduced())) - assert(nmem > 0); - - for (unsigned int l = 0; l < nmem; l++) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " try adding stub to " - << ivmstubTEPHI.vmstubmem[ivmte][l]->getName() << " inner=" << inner - << " bin=" << bin; - } - if (inner == 0) { - ivmstubTEPHI.vmstubmem[ivmte][l]->addVMStub(tmpstub); - } else { - ivmstubTEPHI.vmstubmem[ivmte][l]->addVMStub(tmpstub, bin); - } - } - } - } - } -} diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index 101f15b9c2f9d..15ffeed7fe6e2 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -60,11 +60,6 @@ int main(const int argc, const char **argv) { settings.setMemoryModulesFile("../data/memorymodules_" + settings.geomext() + ".dat"); settings.setWiresFile("../data/wires_" + settings.geomext() + ".dat"); - if (settings.extended()) { - settings.setTableTEDFile("../data/table_TED/table_TED_Dummy.txt"); - settings.setTableTREFile("../data/table_TRE/table_TRE_Dummy.txt"); - } - edm::LogVerbatim("Tracklet") << "fit pattern : " << settings.fitPatternFile(); edm::LogVerbatim("Tracklet") << "process modules : " << settings.processingModulesFile(); edm::LogVerbatim("Tracklet") << "memory modules : " << settings.memoryModulesFile();