From 67f080bb89688e9027aeaf1b4975bc65984d4dcf Mon Sep 17 00:00:00 2001 From: Louise Skinnari Date: Tue, 2 Mar 2021 19:37:58 +0100 Subject: [PATCH 01/45] Anders DTC merge with a gazillion manual fixes --- L1Trigger/TrackFindingTracklet/BuildFile.xml | 31 + .../interface/AllInnerStubsMemory.h | 37 + .../TrackFindingTracklet/interface/Cabling.h | 39 - .../interface/CircularBuffer.h | 12 + .../TrackFindingTracklet/interface/DTC.h | 46 - .../TrackFindingTracklet/interface/DTCLink.h | 34 - .../interface/DiskProjection.h | 19 +- .../interface/InputLinkMemory.h | 2 +- .../interface/L1SimTrack.h | 53 + .../TrackFindingTracklet/interface/L1TStub.h | 62 +- .../interface/LayerProjection.h | 19 +- .../interface/MatchEngine.h | 6 +- .../interface/MatchEngineUnit.h | 12 +- .../interface/MatchProcessor.h | 21 +- .../interface/ProjectionTemp.h | 3 + .../interface/SLHCEvent.h | 78 +- .../TrackFindingTracklet/interface/Sector.h | 22 +- .../TrackFindingTracklet/interface/Settings.h | 154 +- .../TrackFindingTracklet/interface/Stub.h | 27 +- .../interface/TETableBase.h | 3 +- .../TrackFindingTracklet/interface/Tracklet.h | 275 +--- .../interface/TrackletConfigBuilder.h | 242 ++++ .../interface/TrackletEngineDisplaced.h | 2 +- .../interface/TrackletEngineUnit.h | 40 +- .../interface/TrackletEventProcessor.h | 8 +- .../interface/TrackletProcessor.h | 23 +- .../TrackFindingTracklet/interface/Util.h | 244 ++-- .../interface/VMRouterCM.h | 4 +- .../interface/VMRouterTable.h | 7 +- .../interface/VMStubsTEMemory.h | 1 + .../plugins/BuildFile.xml | 8 +- .../plugins/L1FPGATrackProducer.cc | 353 ++--- .../python/Tracklet_cfi.py | 4 +- .../src/AllInnerStubsMemory.cc | 24 + .../src/AllProjectionsMemory.cc | 19 +- .../src/AllStubsMemory.cc | 2 +- L1Trigger/TrackFindingTracklet/src/Cabling.cc | 126 -- .../src/CandidateMatchMemory.cc | 16 +- .../src/CleanTrackMemory.cc | 16 +- L1Trigger/TrackFindingTracklet/src/DTC.cc | 52 - L1Trigger/TrackFindingTracklet/src/DTCLink.cc | 29 - .../src/DiskProjection.cc | 30 +- .../TrackFindingTracklet/src/FitTrack.cc | 119 +- .../src/FullMatchMemory.cc | 16 +- .../TrackFindingTracklet/src/HybridFit.cc | 2 +- .../src/InputLinkMemory.cc | 52 +- .../TrackFindingTracklet/src/L1SimTrack.cc | 38 + L1Trigger/TrackFindingTracklet/src/L1TStub.cc | 90 +- .../src/LayerProjection.cc | 70 +- .../src/MatchCalculator.cc | 99 +- .../TrackFindingTracklet/src/MatchEngine.cc | 155 +- .../src/MatchEngineUnit.cc | 19 +- .../src/MatchProcessor.cc | 491 +++---- .../TrackFindingTracklet/src/MemoryBase.cc | 23 +- .../src/ProjectionRouter.cc | 15 +- .../src/ProjectionRouterBendTable.cc | 4 +- .../src/ProjectionTemp.cc | 3 + .../src/PurgeDuplicate.cc | 14 +- .../TrackFindingTracklet/src/SLHCEvent.cc | 178 +-- L1Trigger/TrackFindingTracklet/src/Sector.cc | 150 +- L1Trigger/TrackFindingTracklet/src/Stub.cc | 211 +-- .../src/StubPairsMemory.cc | 16 +- .../src/StubTripletsMemory.cc | 16 +- .../TrackFindingTracklet/src/TETableBase.cc | 7 +- .../TrackFindingTracklet/src/TrackDerTable.cc | 66 +- .../src/TrackFitMemory.cc | 16 +- .../TrackFindingTracklet/src/Tracklet.cc | 26 +- .../src/TrackletCalculator.cc | 17 +- .../src/TrackletCalculatorBase.cc | 36 +- .../src/TrackletCalculatorDisplaced.cc | 190 +-- .../src/TrackletConfigBuilder.cc | 1264 +++++++++++++++++ .../src/TrackletEngine.cc | 40 +- .../src/TrackletEngineDisplaced.cc | 24 +- .../src/TrackletEngineUnit.cc | 152 +- .../src/TrackletEventProcessor.cc | 224 ++- .../src/TrackletParametersMemory.cc | 16 +- .../src/TrackletProcessor.cc | 816 ++++++----- .../src/TrackletProjectionsMemory.cc | 12 +- .../TrackFindingTracklet/src/TripletEngine.cc | 17 +- .../src/VMProjectionsMemory.cc | 16 +- .../TrackFindingTracklet/src/VMRouter.cc | 17 +- .../TrackFindingTracklet/src/VMRouterCM.cc | 190 ++- .../src/VMRouterPhiCorrTable.cc | 15 +- .../TrackFindingTracklet/src/VMRouterTable.cc | 132 +- .../src/VMStubsMEMemory.cc | 18 +- .../src/VMStubsTEMemory.cc | 43 +- .../TrackFindingTracklet/test/BuildFile.xml | 18 +- .../test/L1TrackNtupleMaker_cfg.py | 25 +- L1Trigger/TrackFindingTracklet/test/Makefile | 28 +- L1Trigger/TrackFindingTracklet/test/fpga.cc | 22 +- 90 files changed, 4337 insertions(+), 3096 deletions(-) create mode 100644 L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h delete mode 100644 L1Trigger/TrackFindingTracklet/interface/Cabling.h delete mode 100644 L1Trigger/TrackFindingTracklet/interface/DTC.h delete mode 100644 L1Trigger/TrackFindingTracklet/interface/DTCLink.h create mode 100644 L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h create mode 100644 L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h create mode 100644 L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc delete mode 100644 L1Trigger/TrackFindingTracklet/src/Cabling.cc delete mode 100644 L1Trigger/TrackFindingTracklet/src/DTC.cc delete mode 100644 L1Trigger/TrackFindingTracklet/src/DTCLink.cc create mode 100644 L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc create mode 100644 L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc diff --git a/L1Trigger/TrackFindingTracklet/BuildFile.xml b/L1Trigger/TrackFindingTracklet/BuildFile.xml index 9ca0665e2be06..93be87c2f1d1e 100644 --- a/L1Trigger/TrackFindingTracklet/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/BuildFile.xml @@ -3,10 +3,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h b/L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h new file mode 100644 index 0000000000000..376baf12cd4f8 --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h @@ -0,0 +1,37 @@ +#ifndef L1Trigger_TrackFindingTracklet_interface_AllInnerStubsMemory_h +#define L1Trigger_TrackFindingTracklet_interface_AllInnerStubsMemory_h + +#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" + +#include +#include +#include + +namespace trklet { + + class Settings; + class Stub; + class L1TStub; + + class AllInnerStubsMemory : public MemoryBase { + public: + AllInnerStubsMemory(std::string name, Settings const& settings, unsigned int iSector); + + ~AllInnerStubsMemory() override = default; + + void addStub(const Stub* stub) { stubs_.push_back(stub); } + + unsigned int nStubs() const { return stubs_.size(); } + + const Stub* getStub(unsigned int i) const { return stubs_[i]; } + + void clean() override { stubs_.clear(); } + + void writeStubs(bool first); + + private: + std::vector stubs_; + }; + +}; // namespace trklet +#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Cabling.h b/L1Trigger/TrackFindingTracklet/interface/Cabling.h deleted file mode 100644 index f835b0d446234..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/Cabling.h +++ /dev/null @@ -1,39 +0,0 @@ -// This class holds a list of stubs that are in a given layer and DCT region -#ifndef L1Trigger_TrackFindingTracklet_interface_Cabling_h -#define L1Trigger_TrackFindingTracklet_interface_Cabling_h - -#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" -#include "L1Trigger/TrackFindingTracklet/interface/DTC.h" -#include "L1Trigger/TrackFindingTracklet/interface/DTCLink.h" - -#include -#include - -namespace trklet { - - class Settings; - - class Cabling { - public: - Cabling(std::string dtcconfig, std::string moduleconfig, Settings const& settings); - - ~Cabling() = default; - - const std::string& dtc(int layer, int ladder, int module) const; - - void addphi(const std::string& dtc, double phi, int layer, int module); - - void writephirange() const; - - std::vector DTCs() const; - - private: - Settings const& settings_; - std::vector links_; - std::map dtcranges_; - std::map dtcs_; - std::map > > modules_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h b/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h index 3d0832f56dc5e..1480b6204e1fe 100644 --- a/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h +++ b/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h @@ -28,6 +28,9 @@ namespace trklet { //Almost full if writer ptr incremented by 1 or 2 is same as read ptr bool almostfull() const { return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_); } + //Almost full if writer ptr incremented by 1 or 2 is same as read ptr + bool nearfull() const { return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_) || (((wptr_ + 3) % size_) == rptr_) ; } + //Empty buffer is write ptr is same as read ptr bool empty() const { return wptr_ == rptr_; } @@ -47,8 +50,17 @@ namespace trklet { assert(!full()); buffer_[wptr_++] = element; wptr_ = wptr_ % size_; + assert(wptr_!=rptr_); } + unsigned int rptr() const { + return rptr_; + } + + unsigned int wptr() const { + return wptr_; + } + private: std::vector buffer_; diff --git a/L1Trigger/TrackFindingTracklet/interface/DTC.h b/L1Trigger/TrackFindingTracklet/interface/DTC.h deleted file mode 100644 index bbdf38c07636b..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/DTC.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_DTC_h -#define L1Trigger_TrackFindingTracklet_interface_DTC_h - -#include "L1Trigger/TrackFindingTracklet/interface/DTCLink.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" - -namespace trklet { - - class Stub; - class L1TStub; - - class DTC { - public: - DTC(std::string name = ""); - - ~DTC() = default; - - void setName(std::string name); - - void addSec(int sector); - - void addphi(double phi, unsigned int layerdisk); - - void addLink(double phimin, double phimax); - - int addStub(std::pair stub); - - unsigned int nLinks() const { return links_.size(); } - - const DTCLink& link(unsigned int i) const { return links_[i]; } - - void clean(); - - double min(unsigned int i) const { return phimin_[i]; } - double max(unsigned int i) const { return phimax_[i]; } - - private: - std::string name_; - std::vector links_; - std::vector sectors_; - - double phimin_[N_LAYER + N_DISK]; - double phimax_[N_LAYER + N_DISK]; - }; -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/DTCLink.h b/L1Trigger/TrackFindingTracklet/interface/DTCLink.h deleted file mode 100644 index d9f7a0c24bcf5..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/DTCLink.h +++ /dev/null @@ -1,34 +0,0 @@ -// This class holds a list of stubs that are in a given layer and DCT region -#ifndef L1Trigger_TrackFindingTracklet_interface_DTCLink_h -#define L1Trigger_TrackFindingTracklet_interface_DTCLink_h - -#include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h" -#include "L1Trigger/TrackFindingTracklet/interface/Stub.h" - -namespace trklet { - - class DTCLink { - public: - DTCLink(double phimin, double phimax); - - ~DTCLink() = default; - - void addStub(std::pair stub); - - bool inRange(double phi, bool overlaplayer); - - unsigned int nStubs() const { return stubs_.size(); } - - Stub* getFPGAStub(unsigned int i) const { return stubs_[i].first; } - L1TStub* getL1TStub(unsigned int i) const { return stubs_[i].second; } - std::pair getStub(unsigned int i) const { return stubs_[i]; } - - void clean() { stubs_.clear(); } - - private: - double phimin_; - double phimax_; - std::vector > stubs_; - }; -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/DiskProjection.h b/L1Trigger/TrackFindingTracklet/interface/DiskProjection.h index 83784c5ea042b..16b44c487e562 100644 --- a/L1Trigger/TrackFindingTracklet/interface/DiskProjection.h +++ b/L1Trigger/TrackFindingTracklet/interface/DiskProjection.h @@ -63,16 +63,6 @@ namespace trklet { return fpgarprojder_; }; - const FPGAWord& fpgaphiprojvm() const { - assert(valid_); - return fpgaphiprojvm_; - }; - - const FPGAWord& fpgarprojvm() const { - assert(valid_); - return fpgarprojvm_; - }; - double phiproj() const { assert(valid_); return phiproj_; @@ -93,6 +83,11 @@ namespace trklet { return fpgafinervm_; }; + const FPGAWord& fpgafinephivm() const { + assert(valid_); + return fpgafinephivm_; + }; + double rproj() const { assert(valid_); return rproj_; @@ -144,12 +139,10 @@ namespace trklet { FPGAWord fpgaphiprojder_; FPGAWord fpgarprojder_; - FPGAWord fpgaphiprojvm_; - FPGAWord fpgarprojvm_; - FPGAWord fpgarbin1projvm_; FPGAWord fpgarbin2projvm_; FPGAWord fpgafinervm_; + FPGAWord fpgafinephivm_; FPGAWord fpgabendindex_; diff --git a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h index 02879946c8eb7..227753d0b918a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h @@ -21,7 +21,7 @@ namespace trklet { ~InputLinkMemory() override = default; - bool addStub(Settings const& settings, Globals* globals, L1TStub& al1stub, Stub& stub, std::string dtc); + void addStub(const L1TStub& al1stub,const Stub& stub); unsigned int nStubs() const { return stubs_.size(); } diff --git a/L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h b/L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h new file mode 100644 index 0000000000000..82c3c74ae3951 --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h @@ -0,0 +1,53 @@ +// This holds two classes: L1SimTrack (truth level simulated track), and SLHCEvent (support for maintaining standalone running) +#ifndef L1Trigger_TrackFindingTracklet_interface_L1SimTrack_h +#define L1Trigger_TrackFindingTracklet_interface_L1SimTrack_h + +#include +#include +#include +#include +#include +#include + +namespace trklet { + + class L1SimTrack { + public: + L1SimTrack(); + L1SimTrack(int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz); + ~L1SimTrack() = default; + + void write(std::ofstream& out); + void write(std::ostream& out); + + int eventid() const { return eventid_; } + int trackid() const { return trackid_; } + int type() const { return type_; } + double pt() const { return pt_; } + double eta() const { return eta_; } + double phi() const { return phi_; } + double vx() const { return vx_; } + double vy() const { return vy_; } + double vz() const { return vz_; } + double dxy() const { return -vx() * sin(phi()) + vy() * cos(phi()); } + double d0() const { return -dxy(); } + int charge() const { + if (type_ == 11 || type_ == 13 || type_ == -211 || type_ == -321 || type_ == -2212) + return -1; + return 1; + } + + private: + int eventid_; + int trackid_; + int type_; + double pt_; + double eta_; + double phi_; + double vx_; + double vy_; + double vz_; + }; + +}; // namespace trklet +#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h index 2010d1eae1bb6..81a70b5a9e705 100644 --- a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h +++ b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h @@ -12,28 +12,23 @@ namespace trklet { class L1TStub { public: L1TStub(); - L1TStub(int eventid, - std::vector tps, - int iphi, - int iz, - int layer, - int ladder, - int module, - int strip, - double x, - double y, - double z, - double sigmax, - double sigmaz, - double pt, - double bend, - int isPSmodule, - int isFlipped); + + L1TStub(std::string DTClink, + int region, + int layerdisk, + std::string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + std::vector tps); ~L1TStub() = default; void write(std::ofstream& out); - void write(std::ostream& out); double diphi(); @@ -43,10 +38,14 @@ namespace trklet { unsigned int layer() const { return layer_; } int disk() const { - if (z_ < 0.0) { - return -module_; + if (layerdisk_<6) { + return 0; + } + int disk=layerdisk_-5; + if (z_ < 0.0 ) { + return -disk; } - return module_; + return disk; } unsigned int ladder() const { return ladder_; } unsigned int module() const { return module_; } @@ -96,8 +95,29 @@ namespace trklet { bool isTilted() const; bool tpmatch(int tp) const; + bool tpmatch2(int tp) const; + + const std::string& DTClink() const { + return DTClink_; + } + int layerdisk() const { + return layerdisk_; + } + + int region() const { + return region_; + } + + const std::string& stubword() const { + return stubword_; + } + private: + int layerdisk_; + std::string DTClink_; + int region_; + std::string stubword_; int eventid_; std::vector tps_; unsigned int iphi_; diff --git a/L1Trigger/TrackFindingTracklet/interface/LayerProjection.h b/L1Trigger/TrackFindingTracklet/interface/LayerProjection.h index b31854c5adcd2..01a55076838d3 100644 --- a/L1Trigger/TrackFindingTracklet/interface/LayerProjection.h +++ b/L1Trigger/TrackFindingTracklet/interface/LayerProjection.h @@ -15,7 +15,6 @@ namespace trklet { void init(Settings const& settings, int projlayer, - double rproj, int iphiproj, int izproj, int iphider, @@ -37,11 +36,6 @@ namespace trklet { return projlayer_; }; - double rproj() const { - assert(valid_); - return rproj_; - }; - const FPGAWord& fpgaphiproj() const { assert(valid_); return fpgaphiproj_; @@ -62,11 +56,6 @@ namespace trklet { return fpgazprojder_; }; - const FPGAWord& fpgaphiprojvm() const { - assert(valid_); - return fpgaphiprojvm_; - }; - const FPGAWord& fpgazbin1projvm() const { assert(valid_); return fpgazbin1projvm_; @@ -82,9 +71,9 @@ namespace trklet { return fpgafinezvm_; }; - const FPGAWord& fpgazprojvm() const { + const FPGAWord& fpgafinephivm() const { assert(valid_); - return fpgazprojvm_; + return fpgafinephivm_; }; double phiproj() const { @@ -139,12 +128,10 @@ namespace trklet { FPGAWord fpgaphiprojder_; FPGAWord fpgazprojder_; - FPGAWord fpgaphiprojvm_; - FPGAWord fpgazprojvm_; - FPGAWord fpgazbin1projvm_; FPGAWord fpgazbin2projvm_; FPGAWord fpgafinezvm_; + FPGAWord fpgafinephivm_; double phiproj_; double zproj_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h index 4d935e87322c1..69a79284cfa1b 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h @@ -30,13 +30,15 @@ namespace trklet { CandidateMatchMemory* candmatches_; - int layer_; - int disk_; + unsigned int layerdisk_; bool barrel_; int nvm_; int nvmbits_; + unsigned int nfinephibits_; //number of fine phi bits in phi VM bin + unsigned int nrinv_; //number of bits for rinv in stub bend LUT + //used in the layers std::vector table_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index cb84945be1865..2bbf13645b660 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -17,7 +17,7 @@ namespace trklet { class MatchEngineUnit { public: - MatchEngineUnit(bool barrel, std::vector table, std::vector tablePS, std::vector table2S); + MatchEngineUnit(bool barrel, unsigned int layerdisk, std::vector table); ~MatchEngineUnit() = default; @@ -26,6 +26,7 @@ namespace trklet { int projrinv, int projfinerz, int projfinephi, + int shift, bool usesecond, bool isPSseed, Tracklet* proj); @@ -57,16 +58,15 @@ namespace trklet { int projfinephi_; bool usesecond_; bool isPSseed_; + int shift_; Tracklet* proj_; bool idle_; - //used in the layers - std::vector table_; + unsigned int layerdisk_; - //used in the disks - std::vector tablePS_; - std::vector table2S_; + //used for bend consistency with rinv + std::vector table_; //save the candidate matches CircularBuffer > candmatches_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index 5758957ec555b..11572e5760bb4 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -35,8 +35,7 @@ namespace trklet { bool matchCalculator(Tracklet* tracklet, const Stub* fpgastub); private: - int layer_; - int disk_; + unsigned int layerdisk_; bool barrel_; @@ -45,13 +44,12 @@ namespace trklet { int nvm_; //VMs in sector int nvmbits_; //# of bits for VMs in sector int nvmbins_; //VMs in in phi region - - int fact_; + int nrinv_; //# of bits for rinv + + int dzshift_; int icorrshift_; int icorzshift_; - int phi0shift_; - - double phioffset_; + int phishift_; unsigned int phimatchcut_[N_SEED]; unsigned int zmatchcut_[N_SEED]; @@ -61,9 +59,6 @@ namespace trklet { unsigned int rcutPS_[N_SEED]; unsigned int rcut2S_[N_SEED]; - double phifact_; - double rzfact_; - int nrbits_; int nphiderbits_; @@ -77,13 +72,9 @@ namespace trklet { //Memory for the full matches std::vector fullmatches_; - //used in the layers + //used for bend consistency with rinv std::vector table_; - //used in the disks - std::vector tablePS_; - std::vector table2S_; - unsigned int nMatchEngines_; std::vector matchengines_; diff --git a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h index 4b8a445146d96..93a5ae0b4efa8 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h @@ -14,6 +14,7 @@ namespace trklet { int projfinerz, unsigned int projfinephi, unsigned int iphi, + int shift, bool usesecond, bool isPSseed); @@ -27,6 +28,7 @@ namespace trklet { int projfinerz() const { return projfinerz_; } unsigned int projfinephi() const { return projfinephi_; } unsigned int iphi() const { return iphi_; } + unsigned int shift() const { return shift_; } bool usesecond() const { return usesecond_; } bool isPSseed() const { return isPSseed_; } @@ -37,6 +39,7 @@ namespace trklet { unsigned int projfinerz_; unsigned int projfinephi_; unsigned int iphi_; + int shift_; bool usesecond_; bool isPSseed_; }; diff --git a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h index 0ef6024854059..db5a75858c774 100644 --- a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h +++ b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h @@ -10,47 +10,10 @@ #include #include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h" +#include "L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h" namespace trklet { - class L1SimTrack { - public: - L1SimTrack(); - L1SimTrack(int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz); - ~L1SimTrack() = default; - - void write(std::ofstream& out); - void write(std::ostream& out); - - int eventid() const { return eventid_; } - int trackid() const { return trackid_; } - int type() const { return type_; } - double pt() const { return pt_; } - double eta() const { return eta_; } - double phi() const { return phi_; } - double vx() const { return vx_; } - double vy() const { return vy_; } - double vz() const { return vz_; } - double dxy() const { return -vx() * sin(phi()) + vy() * cos(phi()); } - double d0() const { return -dxy(); } - int charge() const { - if (type_ == 11 || type_ == 13 || type_ == -211 || type_ == -321 || type_ == -2212) - return -1; - return 1; - } - - private: - int eventid_; - int trackid_; - int type_; - double pt_; - double eta_; - double phi_; - double vx_; - double vy_; - double vz_; - }; - class SLHCEvent { public: SLHCEvent() { @@ -60,32 +23,32 @@ namespace trklet { SLHCEvent(std::istream& in); ~SLHCEvent() = default; - void setIPx(double x) { x_offset_ = x; } - void setIPy(double y) { y_offset_ = y; } - void setEventNum(int eventnum) { eventnum_ = eventnum; } void addL1SimTrack( int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz); - bool addStub(int layer, - int ladder, - int module, - int strip, - int eventid, - std::vector tps, - double pt, - double bend, - double x, - double y, - double z, - int isPSmodule, - int isFlipped); + bool addStub(std::string DTClink, + int region, + int layerdisk, + std::string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + std::vector tps); const L1TStub& lastStub() const { return stubs_.back(); } + void setIP(double x, double y) { + ipx_=x; + ipy_=y; + } + void write(std::ofstream& out); - void write(std::ostream& out); unsigned int layersHit(int tpid, int& nlayers, int& ndisks); @@ -99,15 +62,14 @@ namespace trklet { int eventnum() const { return eventnum_; } - int getSimtrackFromSimtrackid(int simtrackid, int eventid = 0) const; + //int getSimtrackFromSimtrackid(int simtrackid, int eventid = 0) const; private: int eventnum_; std::vector simtracks_; std::vector stubs_; + double ipx_, ipy_; - double x_offset_{0.0}; - double y_offset_{0.0}; }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/Sector.h b/L1Trigger/TrackFindingTracklet/interface/Sector.h index fdddb08af0055..1247dab0479a0 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Sector.h +++ b/L1Trigger/TrackFindingTracklet/interface/Sector.h @@ -11,6 +11,8 @@ #include #include #include +#include + namespace trklet { @@ -25,6 +27,7 @@ namespace trklet { //Memory modules class InputLinkMemory; class AllStubsMemory; + class AllInnerStubsMemory; class VMStubsTEMemory; class VMStubsMEMemory; class StubPairsMemory; @@ -79,6 +82,7 @@ namespace trklet { void writeVMSTE(bool first); void writeVMSME(bool first); void writeAS(bool first); + void writeAIS(bool first); void writeSP(bool first); void writeST(bool first); void writeTPAR(bool first); @@ -116,18 +120,24 @@ namespace trklet { double phimax() const { return phimax_; } template - void addMemToVec(std::vector >& memvec, const std::string& memName, Args&... args) { + void addMemToVec(std::vector >& memvec, const std::string& memName, Args&... args) { memvec.push_back(std::make_unique(memName, std::forward(args)...)); Memories_[memName] = memvec.back().get(); MemoriesV_.push_back(memvec.back().get()); } template - void addProcToVec(std::vector >& procvec, const std::string& procName, Args&... args) { + void addProcToVec(std::vector >& procvec, const std::string& procName, Args&... args) { procvec.push_back(std::make_unique(procName, std::forward(args)...)); Processes_[procName] = procvec.back().get(); } + void writeLinkNewEvent(int event); + void writeLink(const Stub& fpgastub); + + + + private: int isector_; Settings const& settings_; @@ -135,10 +145,11 @@ namespace trklet { double phimin_; double phimax_; - std::map Memories_; + std::map Memories_; std::vector MemoriesV_; std::vector > IL_; std::vector > AS_; + std::vector > AIS_; std::vector > VMSTE_; std::vector > VMSME_; std::vector > SP_; @@ -152,7 +163,7 @@ namespace trklet { std::vector > TF_; std::vector > CT_; - std::map Processes_; + std::map Processes_; std::vector > VMR_; std::vector > VMRCM_; std::vector > TE_; @@ -167,6 +178,9 @@ namespace trklet { std::vector > MP_; std::vector > FT_; std::vector > PD_; + + std::unordered_map DTCLink_ofstreams_; + }; }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 1e045222c4ada..ee005417ac5ed 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -20,13 +20,20 @@ namespace trklet { constexpr int N_DISK = 5; // # of endcap disks assumed constexpr unsigned int N_PSLAYER = 3; // # of barrel PS layers assumed constexpr unsigned int N_SEED = 12; // # of tracklet+triplet seeds + constexpr unsigned int N_SEED_PROMPT = 8; // # of tracklet (prompt) seeds constexpr unsigned int N_DSS_MOD = 5; // # of rings with 2S modules per disk - constexpr unsigned int NRINVBITS = 5; //number of bit for rinv in bend match table - constexpr unsigned int NFINERZBITS = 3; //number of bit for r or z within a r/z bin + constexpr unsigned int N_BENDBITS_PS = 3; // Number of bend bits for PS modules + constexpr unsigned int N_BENDBITS_2S = 4; // Number of bend bits for 2S modules - constexpr double sixth = 1.0 / 6.0; //Commonly used factor + constexpr unsigned int NRINVBITS = 5; //number of bit for rinv in bend match table + constexpr unsigned int NFINERZBITS = 3; //number of bit for r or z within a r/z bin + constexpr unsigned int NFINEPHIBITS = 3; //number of bits for phi within a vm bin + + constexpr unsigned int N_VMSTUBSMAX = 15; // maximum number of stubs in VM bin + + constexpr double sixth = 1.0/6.0; //Commonly used factor class Settings { public: @@ -117,8 +124,6 @@ namespace trklet { double half2SmoduleWidth() const { return half2SmoduleWidth_; } - double bendcutte(unsigned int inner, unsigned int iSeed) const { return bendcutte_[inner][iSeed]; } - double bendcutme(unsigned int layerdisk) const { return bendcutme_[layerdisk]; } int nfinephi(unsigned int inner, unsigned int iSeed) const { return nfinephi_[inner][iSeed]; } double nphireg(unsigned int inner, unsigned int iSeed) const { if (combined_) { @@ -131,6 +136,16 @@ namespace trklet { return lutwidthtabextended_[inner][iSeed]; } + unsigned int seedlayers(int inner, int seed) const { + int layerdisk=seedlayers_[seed][inner]; + assert(layerdisk>=0); + return layerdisk; + } + + unsigned int NTC(int seed) const { + return ntc_[seed]; + } + unsigned int projlayers(unsigned int iSeed, unsigned int i) const { return projlayers_[iSeed][i]; } unsigned int projdisks(unsigned int iSeed, unsigned int i) const { return projdisks_[iSeed][i]; } double rphimatchcut(unsigned int iSeed, unsigned int ilayer) const { return rphimatchcut_[ilayer][iSeed]; } @@ -166,8 +181,10 @@ namespace trklet { bool writeMem() const { return writeMem_; } bool writeTable() const { return writeTable_; } - std::string const& memPath() const { return memPath_; } - std::string const& tablePath() const { return tablePath_; } + bool writeConfig() const { return writeConfig_; } + + std::string memPath() const { return memPath_; } + std::string tablePath() const { return tablePath_; } bool writeVerilog() const { return writeVerilog_; } bool writeHLS() const { return writeHLS_; } @@ -256,9 +273,10 @@ namespace trklet { void setNbitsseedextended(unsigned int nbitsseed) { nbitsseedextended_ = nbitsseed; } double dphisectorHG() const { + double rsectmin=21.8; + double rsectmax=112.7; return 2 * M_PI / N_SECTOR + - 2 * std::max(std::abs(asin(0.5 * rinvmax() * rmean(0)) - asin(0.5 * rinvmax() * rcrit_)), - std::abs(asin(0.5 * rinvmax() * rmean(5)) - asin(0.5 * rinvmax() * rcrit_))); + rinvmax()*std::max(rcrit_ - rsectmin, rsectmax - rcrit_); } double rcrit() const { return rcrit_; } @@ -272,11 +290,15 @@ namespace trklet { double phicritmaxmc() const { return phicritmax() + dphicritmc_; } double kphi() const { return dphisectorHG() / (1 << nphibitsstub(0)); } - double kphi1() const { return dphisectorHG() / (1 << nphibitsstub(5)); } - - double kz() const { return 2 * zlength_ / (1 << nzbitsstub_[0]); } - double kr() const { return rmaxdisk_ / (1 << nrbitsstub_[6]); } - + double kphi1() const { return dphisectorHG() / (1 << nphibitsstub(N_LAYER-1)); } + double kphi(unsigned int layerdisk) const { return dphisectorHG() / (1 << nphibitsstub(layerdisk)); } + + + double kz() const { return 2.0 * zlength_ / (1 << nzbitsstub_[0]); } + double kz(unsigned int layerdisk) const { return 2.0 * zlength_ / (1 << nzbitsstub_[layerdisk]); } + double kr() const { return rmaxdisk_ / (1 << nrbitsstub_[N_LAYER]); } + double krbarrel() const { return 2.0 * drmax() / (1 <5&&(!isPSmodule)) layerdisk+=5; + double bend=benddecode_[layerdisk][ibend]; + assert(bend<99.0); + return bend; + } + + double bendcut(int ibend, int layerdisk, bool isPSmodule) const { + if (layerdisk>5&&(!isPSmodule)) layerdisk+=5; + double bendcut=bendcut_[layerdisk][ibend]; + if (bendcut<=0.0) std::cout << "bendcut : "<0.0); + return bendcut; + } + + double bendcutte(int ibend, int layerdisk, bool isPSmodule) const { + return bendcut(ibend,layerdisk,isPSmodule); + } + + double bendcutme(int ibend, int layerdisk, bool isPSmodule) const { + //FIXME temporary fix until phiprojderdisk bits adjusted. But requires coordinatin with HLS + double fact=(layerdisk, 2> bendcutte_{ - {{{1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25}}, //inner (2 = #stubs/tracklet) - {{1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25}}}}; //outer - - std::array bendcutme_{{2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5, 1.5, 1.5, 1.5}}; - double rmindiskvm_{22.5}; double rmaxdiskvm_{67.0}; @@ -435,7 +479,7 @@ namespace trklet { double rPS2S_{60.0}; double z0cut_{15.0}; - + double disp_z0cut_{27.0}; unsigned int NLONGVMBITS_{3}; @@ -545,6 +589,25 @@ namespace trklet { {{6, 6, 6, 6, 10, 10, 10, 10, 0, 0, 6, 0}}, {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6}}}}; + + //layers/disks used by each seed + std::array, N_SEED> seedlayers_{{{{0, 1, -1}}, //L1L2 + {{1, 2, -1}}, //1 L2L3 + {{2, 3, -1}}, //2 L3L4 + {{4, 5, -1}}, //3 L5L6 + {{6, 7, -1}}, //4 D1D2 + {{8, 9, -1}}, //5 D3D4 + {{0, 6, -1}}, //6 L1D1 + {{1, 6, -1}}, //7 L2D1 + {{2, 3, 1}}, //8 L2L3L4 + {{4, 5, 3}}, //9 L4L5L6 + {{1, 2, 6}}, //10 L2L3D1 + {{6, 7, 1}}}}; //11 D1D2L2 + + //Number of tracklet calculators for the prompt seeding combinations + std::array ntc_{{12, 4, 4, 4, 4, 4, 8, 4, 0, 0, 0, 0}}; + + //projection layers by seed index. For each seeding index (row) the list of layers that we consider projections to std::array, N_SEED> projlayers_{{{{3, 4, 5, 6}}, //0 L1L2 {{1, 4, 5, 6}}, //1 L2L3 @@ -568,7 +631,7 @@ namespace trklet { {{1, 2, 5}}, //5 D3D4 {{2, 3, 4, 5}}, //6 L1D1 {{2, 3, 4}}, //7 L2D1 - {{1, 2}}, //8 L2L3L4 + {{1, 2, 3}}, //8 L2L3L4 {{}}, //9 L4L5L6 {{2, 3, 4}}, //10 L2L3D1 {{3, 4}}}}; //11 D1D2L2 @@ -623,6 +686,45 @@ namespace trklet { {{3.6, 3.8, 0.0, 0.0, 3.6, 0.0, 3.5, 3.8, 0.0, 0.0, 3.0, 3.0}}, //disk 4 {{0.0, 0.0, 0.0, 0.0, 3.6, 3.4, 3.7, 0.0, 0.0, 0.0, 0.0, 3.0}}}}; //disk 5 + //returns the mean bend (in strips at a 1.8cm separation) for bendcode + std::array, 16> benddecode_{ + {{{0.0, 0.5, 0.7, 0.8, 89.9, -1.0, -0.9, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L1 PS + {{0.0, 0.7, 1.0, 1.5, 89.9, -1.5, -1.0, -0.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L2 PS + {{0.0, 1.0, 1.8, 2.2, 89.9, -2.2, -1.8, -1.0, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L3 PS + {{0.0, 0.7, 1.2, 1.8, 2.1, 2.6, 3.2, 3.5, 89.9, -3.5, -3.2, -2.6, -2.1, -1.8, -1.2, -0.7}}, //L4 2S + {{0.0, 0.8, 1.2, 1.8, 2.2, 3.2, 4.1, 4.4, 89.9, -4.4, -4.1, -3.2, -2.2, -1.8, -1.2, -0.8}}, //L5 2S + {{0.0, 0.9, 1.8, 2.8, 3.8, 4.5, 5.3, 5.9, 89.9, -5.9, -5.3, -4.5, -3.8, -2.8, -1.8, -0.9}}, //L6 2S + {{0.0, 0.8, 1.2, 2.0, 89.9, -2.0, -1.2, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D1 PS + {{0.0, 1.5, 1.8, 2.4, 89.9, -2.4, -1.8, -1.4, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D2 PS + {{0.0, 1.7, 2.0, 2.2, 89.9, -2.2, -2.0, -1.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D3 PS + {{0.0, 1.8, 2.0, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D4 PS + {{0.0, 2.0, 2.2, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D5 PS + {{0.0, 1.8, 2.3, 2.5, 3.0, 3.9, 4.5, 5.2, 89.9, -5.2, -4.5, -3.9, -3.0, -2.5, -2.3, -1.8}}, //D1 2S + {{0.0, 2.0, 2.4, 2.9, 3.2, 4.0, 4.8, 5.2, 89.9, -5.2, -4.8, -4.0, -3.2, -2.9, -2.4, -2.0}}, //D2 2S + {{0.0, 2.0, 2.4, 2.7, 3.6, 3.7, 4.4, 4.6, 89.9, -4.6, -4.4, -3.7, -3.6, -2.7, -2.4, -2.0}}, //D3 2S + {{0.0, 2.0, 2.6, 3.2, 3.8, 4.0, 4.4, 4.4, 89.9, -4.4, -4.4, -4.0, -3.8, -3.2, -2.6, -2.0}}, //D4 2S + {{0.0, 2.0, 3.2, 3.4, 3.9, 3.9, 4.4, 4.4, 89.9, -4.4, -4.4, -3.9, -3.9, -3.4, -3.2, -2.0}}}}; //D5 2S + + //returns the bend 'cut' (in strips at a 1.8cm separation) for bendcode + std::array, 16> bendcut_{ + {{{1.5, 1.2, 0.8, 0.8, 99.9, 0.8, 0.8, 1.2, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L1 PS + {{1.5, 1.3, 1.0, 1.0, 99.9, 1.0, 1.0, 1.3, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L2 PS + {{1.6, 1.5, 1.0, 1.0, 99.9, 1.0, 1.0, 1.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L3 PS + {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L4 2S + {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L5 2S + {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L6 2S + {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D1 PS + {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D2 PS + {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D3 PS + {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D4 PS + {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D5 PS + {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}}, //D1 2S + {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}}, //D2 2S + {{2.2, 1.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5, 1.5}}, //D3 2S + {{2.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5}}, //D4 2S + {{2.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5}}}}; //D5 2S + + // Offset to the maximum number of steps in each processing step: // Set to 0 (default) means standard truncation // Set to large value, e.g. 10000, to disable truncation @@ -649,6 +751,7 @@ namespace trklet { {"Seeds", false}, {"FT", false}, {"Residuals", false}, + {"StubBend", false}, {"MC", false}, {"MP", false}, {"ME", false}, @@ -690,6 +793,7 @@ namespace trklet { //--- These used to create files needed by HLS code. bool writeMem_{false}; //If true will print out content of memories (between algo steps) to files bool writeTable_{false}; //If true will print out content of LUTs to files + bool writeConfig_{false}; //If true will print out the autogenerated configuration as files std::string memPath_{"../data/MemPrints/"}; //path for writing memories std::string tablePath_{"../data/LUTs/"}; //path for writing LUTs diff --git a/L1Trigger/TrackFindingTracklet/interface/Stub.h b/L1Trigger/TrackFindingTracklet/interface/Stub.h index 8b5536d270d84..9874d25c85c7c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Stub.h +++ b/L1Trigger/TrackFindingTracklet/interface/Stub.h @@ -13,11 +13,13 @@ namespace trklet { + class Globals; + class Stub { public: Stub(Settings const& settings); - Stub(L1TStub& stub, Settings const& settings, double phiminsec, double phimaxsec); + Stub(L1TStub& stub, Settings const& settings, Globals& globals); ~Stub() = default; @@ -30,13 +32,21 @@ namespace trklet { if (isPSmodule()) { return r_.str() + "|" + z_.str() + "|" + phi_.str() + "|" + bend_.str(); } else { - return "000" + r_.str() + "|" + z_.str() + "|" + phi_.str() + "|" + alphanew_.str() + "|" + bend_.str(); + return "000" + r_.str() + "|" + z_.str() + "|" + phi_.str() + "|" + alpha_.str() + "|" + bend_.str(); } } } std::string strbare() const { return bend_.str() + r_.str() + z_.str() + phi_.str(); } + std::string strinner() const { + unsigned int nbitsfinephi=8; + FPGAWord finephi(phicorr_.bits(phicorr_.nbits()-nbitsfinephi,nbitsfinephi),nbitsfinephi,true,__LINE__,__FILE__); + return str()+"|"+stubindex_.str()+"|"+finephi.str(); + } + + FPGAWord allStubIndex() const {return stubindex_;} + unsigned int phiregionaddress() const; std::string phiregionaddressstr() const; @@ -50,17 +60,14 @@ namespace trklet { const FPGAWord& z() const { return z_; } const FPGAWord& phi() const { return phi_; } const FPGAWord& phicorr() const { return phicorr_; } - const FPGAWord& alphanew() const { return alphanew_; } + const FPGAWord& alphanew() const { return alpha_; } //FIXME should remove new const FPGAWord& stubindex() const { return stubindex_; } const FPGAWord& layer() const { return layer_; } const FPGAWord& disk() const { return disk_; } unsigned int layerdisk() const; - bool isBarrel() const { return layer_.value() != -1; } - bool isDisk() const { return disk_.value() != 0; } - - bool isPSmodule() const { return isBarrel() ? (layer_.value() < (int)N_PSLAYER) : (r_.value() > 10); } + bool isPSmodule() const { return (layerdisk_ 10); } double rapprox() const; double zapprox() const; @@ -70,13 +77,17 @@ namespace trklet { const L1TStub* l1tstub() const { return l1tstub_; } void setl1tstub(L1TStub* l1tstub) { l1tstub_ = l1tstub; } + bool isBarrel() const { return layerdisk_ #include @@ -21,7 +22,7 @@ namespace trklet { virtual void lookup(int, int) {} - void writeVMTable(std::string name, bool positive = true); + void writeVMTable(const std::string& dir, const std::string& name, bool positive = true); protected: Settings const& settings_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 870dd822bbbd0..929e7b31b4faa 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" @@ -91,115 +92,12 @@ namespace trklet { return layerproj_[layer - 1].valid(); } - const FPGAWord& fpgaphiprojder(int layer) const { + const LayerProjection& layerProj(int layer) const { assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgaphiprojder(); - } - - const FPGAWord& fpgazproj(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgazproj(); - } - - const FPGAWord& fpgaphiproj(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgaphiproj(); - } - - const FPGAWord& fpgazprojder(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgazprojder(); - } - - int zbin1projvm(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgazbin1projvm().value(); - } - - int zbin2projvm(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgazbin2projvm().value(); - } - - int finezvm(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgafinezvm().value(); - } - - int rbin1projvm(int disk) const { - assert(disk > 0 && disk <= N_DISK); - return diskproj_[disk - 1].fpgarbin1projvm().value(); - } - - int rbin2projvm(int disk) const { - assert(disk > 0 && disk <= N_DISK); - return diskproj_[disk - 1].fpgarbin2projvm().value(); - } - - int finervm(int disk) const { - assert(disk > 0 && disk <= N_DISK); - return diskproj_[disk - 1].fpgafinervm().value(); - } - - int phiprojvm(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgaphiprojvm().value(); - } - - int zprojvm(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].fpgazprojvm().value(); - } - - double phiproj(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].phiproj(); - } - - double phiprojder(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].phiprojder(); - } - - double zproj(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].zproj(); - } - - double zprojder(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].zprojder(); - } - - double zprojapprox(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].zprojapprox(); - } - - double zprojderapprox(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].zprojderapprox(); - } - - double phiprojapprox(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].phiprojapprox(); - } - - double phiprojderapprox(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].phiprojderapprox(); - } - - double rproj(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].rproj(); - } - - double rstub(int layer) { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].rstub(); + assert(layerproj_[layer-1].valid()); + return layerproj_[layer-1]; } + //Disks residuals @@ -208,124 +106,22 @@ namespace trklet { return diskproj_[abs(disk) - 1].valid(); } - const FPGAWord& fpgaphiresiddisk(int disk) { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].fpgaphiresid(); - } - - const FPGAWord& fpgarresiddisk(int disk) { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].fpgarresid(); - } - - double phiresiddisk(int disk) { + //Should be const; but setBendIndex method needs to be migrated out of the disk projection + DiskProjection& diskProj(int disk) { assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].phiresid(); + assert(diskproj_[abs(disk) - 1].valid()); + return diskproj_[abs(disk) - 1]; } - double rresiddisk(int disk) { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].rresid(); - } - - double phiresidapproxdisk(int disk) { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].phiresidapprox(); - } - double rresidapproxdisk(int disk) { + bool matchdisk(int disk) const { assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].rresidapprox(); - } - - double zstubdisk(int disk) { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].zstub(); - } - - void setBendIndex(int bendIndex, int disk) { - assert(abs(disk) <= N_DISK); - diskproj_[abs(disk) - 1].setBendIndex(bendIndex); - } - - const FPGAWord& getBendIndex(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].getBendIndex(); - } - - double alphadisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].alpha(); - } - - const FPGAWord& ialphadisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].ialpha(); - } - - const FPGAWord& fpgaphiprojdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].fpgaphiproj(); - } - - const FPGAWord& fpgaphiprojderdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].fpgaphiprojder(); - } - - const FPGAWord& fpgarprojdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].fpgarproj(); - } - - const FPGAWord& fpgarprojderdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].fpgarprojder(); - } - - double phiprojapproxdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].phiprojapprox(); - } - - double phiprojderapproxdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].phiprojderapprox(); - } - - double rprojapproxdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].rprojapprox(); - } - - double rprojderapproxdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].rprojderapprox(); - } - - double phiprojdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].phiproj(); - } - - double phiprojderdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].phiprojder(); - } - - double rprojdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].rproj(); - } - - double rprojderdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].rprojder(); + return diskresid_[abs(disk) - 1].valid(); } - bool matchdisk(int disk) { - assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].valid(); + const DiskResidual& diskResid(int disk) const { + assert(matchdisk(disk)); + return diskresid_[abs(disk)-1]; } void addMatch(int layer, @@ -354,54 +150,21 @@ namespace trklet { int nMatches(); int nMatchesDisk(); - bool match(int layer) { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].valid(); - } - std::string fullmatchstr(int layer); std::string fullmatchdiskstr(int disk); - bool validResid(int layer) const { + bool match(int layer) { assert(layer > 0 && layer <= N_LAYER); return layerresid_[layer - 1].valid(); } - const trklet::Stub* stubptr(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].stubptr(); - } - - double phiresid(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].phiresid(); - } - - double phiresidapprox(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].phiresidapprox(); - } - - double zresid(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].zresid(); - } - - double zresidapprox(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].zresidapprox(); - } - - const FPGAWord& fpgaphiresid(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].fpgaphiresid(); - } - - const FPGAWord& fpgazresid(int layer) const { + const LayerResidual& layerResid(int layer){ assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].fpgazresid(); + assert(layerresid_[layer - 1].valid()); + return layerresid_[layer - 1]; } + std::vector getL1Stubs(); std::map getStubIDs(); diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h b/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h new file mode 100644 index 0000000000000..cc00d184126c1 --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h @@ -0,0 +1,242 @@ +// +// Class to build the configuration for the tracklet based track finding +// +// +// +#ifndef L1Trigger_TrackFindingTracklet_interface_TrackletConfigBuilder_h +#define L1Trigger_TrackFindingTracklet_interface_TrackletConfigBuilder_h + +#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" + +#include +#include +#include +#include +#include +#include + +namespace trklet { + + class TrackletConfigBuilder{ + + public: + + //Builds the configuration for the tracklet based track finding + TrackletConfigBuilder(const Settings& settings); + + //This method writes out the configuration as files + void writeAll(std::ostream& wires, std::ostream& memories, std::ostream& modules); + + private: + + // + // Method to initialize the regions and VM in each layer + // + void initGeom(); + + // + // Builds the list of TE for each seeding combination + // + void buildTE(); + + // + // Builds the lists of TC for each seeding combination + // + void buildTC(); + + // + // Finds the projections needed for each seeding combination + // + void buildProjections(); + + // + // Helper function to determine if a pair of VM memories form valid TE + // + bool validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2); + + // + // Helper fcn. to get the layers/disks for a seed + // + std::pair seedLayers(unsigned int iSeed); + + // + // Helper fcn to get the radii of the two layers in a seed + // + std::pair seedRadii(unsigned int iseed); + + // + // Helper fcn to return the phi range of a projection of a tracklet from a TC + // + std::pair seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC); + + // + // Helper function to calculate the phi position of a seed at radius r that is formed + // by two stubs at (r1,phi1) and (r2, phi2) + // + double phi(double r1, double phi1, double r2, double phi2,double r); + + // + // Helper function to calculate rinv for two stubs at (r1,phi1) and (r2,phi2) + // + double rinv(double r1, double phi1, double r2, double phi2); + + // + // The next group of fcn formats a string to write out names of different + // memories and processing modules + // + std::string iSeedStr(unsigned int iSeed); + + std::string numStr(unsigned int i); + + std::string iTCStr(unsigned int iTC); + + std::string iRegStr(unsigned int iReg, unsigned int iSeed); + + std::string TCName(unsigned int iSeed,unsigned int iTC); + + std::string LayerName(unsigned int ilayer); + + std::string TPROJName(unsigned int iSeed, unsigned int iTC, + unsigned int ilayer, unsigned int ireg); + + std::string PRName(unsigned int ilayer, unsigned int ireg); + + std::string SPName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, + unsigned int l2, unsigned int ireg2, unsigned int ivm2, + unsigned int iseed); + + std::string SPDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, + unsigned int l2, unsigned int ireg2, unsigned int ivm2, + unsigned int l3, unsigned int ireg3, unsigned int ivm3, + unsigned int iseed); + + std::string STName(unsigned int l1, unsigned int ireg1, + unsigned int l2, unsigned int ireg2, + unsigned int l3, unsigned int ireg3, + unsigned int iseed, unsigned int count); + + std::string TEName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, + unsigned int l2, unsigned int ireg2, unsigned int ivm2, + unsigned int iseed); + + std::string TREName(unsigned int l1, unsigned int ireg1, + unsigned int l2, unsigned int ireg2, + unsigned int iseed, unsigned int count); + + std::string TEDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, + unsigned int l2, unsigned int ireg2, unsigned int ivm2, + unsigned int iseed); + + std::string TParName(unsigned int l1, + unsigned int l2, + unsigned int l3, + unsigned int itc); + + std::string TCDName(unsigned int l1, + unsigned int l2, + unsigned int l3, + unsigned int itc); + + std::string TPROJName(unsigned int l1, + unsigned int l2, + unsigned int l3, + unsigned int itc, + unsigned int projlay, + unsigned int projreg); + + std::string FTName(unsigned int l1, + unsigned int l2, + unsigned int l3); + + std::string TCNAme(unsigned int iseed, unsigned int iTC); + + + // + // This group of methods are used to print out the configuration as a file + // + void writeProjectionMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeSPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeSPDMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeAPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeCMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeVMPROJMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeFMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeASMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeVMSMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeTPARMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeTFMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeCTMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + void writeILMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); + + // + // Store constants extracted from Settings + // + unsigned int NSector_; //Number of sectors + double rcrit_; //critical radius that defines the sector + + bool combinedmodules_; //if true write configuration for combined modules + + bool extended_; //if true write configuration for extended configuration + + double rinvmax_; //Max value for valid rinv + double rmaxdisk_; //Maximim disk radius + double zlength_; //Maximim (abslute) z-positon in barrel + double rmean_[N_LAYER]; //Mean layer radius + double zmean_[N_DISK]; //Mean disk z-position + + double dphisectorHG_; //Full sector width + + unsigned int NTC_[N_SEED_PROMPT]; //Number of TC per seeding combination + + unsigned int NRegions_[N_LAYER+N_DISK]; //Regions (all stubs memories 6 layers +5 disks + unsigned int NVMME_[N_LAYER+N_DISK]; //Number of MEs (all stubs memories 6 layers +5 disks + std::pair NVMTE_[N_SEED_PROMPT]; //number of TEs for each seeding combination + + //Min and max phi for a phi region (e.g. all stubs) + std::vector > allStubs_[N_LAYER+N_DISK]; + + //Min and max phi for VM bin + std::vector > VMStubsME_[N_LAYER+N_DISK]; + + //Phi ranges for the stubs in the VM bins used in the pair in th TE + std::pair >, + std::vector > > VMStubsTE_[N_SEED_PROMPT]; + + //List of the TEs and the VM bins for each TE + std::vector > TE_[N_SEED_PROMPT]; + + //The TCs for each seeding combination + std::vector > TC_[N_SEED_PROMPT]; + + //The projections to each layer/disk from a seed and TC + std::vector< std::vector > > projections_[N_LAYER+N_DISK]; + + //Which matches are used for each seeding layer + // L1 L2 L3 L4 L5 L6 D1 D2 D3 D4 D5 + int matchport_[N_SEED_PROMPT][N_LAYER+N_DISK]= { {-1,-1, 1, 2, 3, 4, 4, 3, 2, 1,-1}, //L1L2 + { 1,-1,-1, 2, 3,-1, 4, 3, 2, 1,-1}, //L2L3 + { 1, 2,-1,-1, 3, 4, 4, 3,-1,-1,-1}, //L3L4 + { 1, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1}, //L5L6 + { 1, 2,-1,-1,-1,-1,-1,-1, 2, 3, 4}, //D1D2 + { 1,-1,-1,-1,-1,-1, 2, 3,-1,-1, 4}, //D3D4 + {-1,-1,-1,-1,-1,-1,-1, 1, 2, 3, 4}, //L1D1 + { 1,-1,-1,-1,-1,-1,-1, 2, 3, 4,-1}}; //L2D1 + + //Settings + const Settings& settings_; + + }; +} +#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h index 79eadb944b67e..e4a27da470378 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h @@ -30,7 +30,7 @@ namespace trklet { void readTables(); - const short memNameToIndex(const std::string& name); + short memNameToIndex(const std::string& name); private: int layer1_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h index 120e8891e9c2e..d20d3dc3091a2 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h @@ -7,6 +7,7 @@ #include #include + namespace trklet { class Settings; @@ -14,27 +15,20 @@ namespace trklet { class L1TStub; class FPGAWord; - struct TEData { + struct TEData{ const Stub* stub_; int start_; int rzbinfirst_; int rzdiffmax_; int innerfinephi_; FPGAWord innerbend_; - std::vector > regions_; // next z/r bin; phi-region; nstub + std::vector< std::tuple > regions_; // next z/r bin; phi-region; nstub }; - + + class TrackletEngineUnit { public: - TrackletEngineUnit(const Settings* const settings, - unsigned int nbitsfinephi, - unsigned int layerdisk2, - unsigned int iSeed, - unsigned int nbitsfinephiediff, - unsigned int iAllStub, - std::vector const& pttableinner, - std::vector const& pttableouter, - VMStubsTEMemory* outervmstubs); + TrackletEngineUnit(const Settings* const settings, unsigned int nbitsfinephi, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int iSeed, unsigned int nbitsfinephiediff, unsigned int iAllStub, std::vector const& pttableinner, std::vector const& pttableouter, VMStubsTEMemory* outervmstubs); ~TrackletEngineUnit() = default; @@ -48,36 +42,48 @@ namespace trklet { bool idle() const { return idle_; } + void setNearFull() { nearfull_=candpairs_.nearfull(); } + void reset(); - void step(); + void step(bool print, int istep, int iTE); + + int rptr() const { return candpairs_.rptr(); } + int wptr() const { return candpairs_.wptr(); } + + const Stub* innerStub() const {return tedata_.stub_;} + private: VMStubsTEMemory* outervmstubs_; TEData tedata_; const Settings* settings_; unsigned int nbitsfinephi_; + unsigned int layerdisk1_; unsigned int layerdisk2_; unsigned int iSeed_; unsigned int nbitsfinephidiff_; - + bool nearfull_; //initialized at start of each processing step unsigned int iAllStub_; - + //unsigned int memory slot unsigned int nreg_; unsigned int istub_; unsigned int ireg_; unsigned int next_; unsigned int nstub_; - + bool idle_; std::vector pttableinner_; std::vector pttableouter_; + std::pair candpair_, candpair__; + bool goodpair_, goodpair__; + //save the candidate matches CircularBuffer > candpairs_; - }; // TrackletEngineUnit + }; // TrackletEngineUnit }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h index e46685eaf563c..d00dbab606d7b 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h @@ -17,7 +17,6 @@ namespace trklet { class Sector; class HistBase; class Track; - class Cabling; class TrackletEventProcessor { public: @@ -34,6 +33,9 @@ namespace trklet { std::vector& tracks() { return tracks_; } private: + + void configure(std::istream& inwire, std::istream& inmem, std::istream& inproc); + const Settings* settings_{nullptr}; std::unique_ptr globals_; @@ -44,8 +46,6 @@ namespace trklet { int eventnum_ = {0}; - std::unique_ptr cabling_; - Timer cleanTimer_; Timer addStubTimer_; Timer VMRouterTimer_; @@ -64,7 +64,7 @@ namespace trklet { std::vector tracks_; - std::map > dtclayerdisk_; + //std::map > dtclayerdisk_; }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h index d740b26b8ff35..86f349d4cddb4 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h @@ -8,6 +8,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h" + #include #include #include @@ -18,6 +19,7 @@ namespace trklet { class Globals; class MemoryBase; class AllStubsMemory; + class AllInnerStubsMemory; class VMStubsTEMemory; class TrackletProcessor : public TrackletCalculatorBase { @@ -44,16 +46,13 @@ namespace trklet { VMStubsTEMemory* outervmstubs_; - // The use of a std::tuple here is awkward and should be fixed. This code is slotted for a significant - // overhaul to allign with the HLS implementation. At that point the use fo the tuple should be - // eliminated - // istub imem start imem end imem - std::vector, unsigned int, unsigned int, unsigned int, unsigned int> > - tedatabuffers_; + // istub imem start imem end imem + std::tuple, unsigned int , unsigned int, unsigned int, unsigned int> tebuffer_; std::vector teunits_; - std::vector innerallstubs_; + + std::vector innerallstubs_; std::vector outerallstubs_; std::map > pttableinner_; @@ -62,20 +61,22 @@ namespace trklet { std::vector pttableinnernew_; std::vector pttableouternew_; - std::vector > useregion_; - + std::vector useregion_; + int nbitsfinephi_; int nbitsfinephidiff_; - + int innerphibits_; int outerphibits_; - + unsigned int nbitszfinebintable_; unsigned int nbitsrfinebintable_; unsigned int nbitsrzbin_; + VMRouterTable vmrtable_; + }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/Util.h b/L1Trigger/TrackFindingTracklet/interface/Util.h index 818b548880d98..32bbca367cb4a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Util.h +++ b/L1Trigger/TrackFindingTracklet/interface/Util.h @@ -2,9 +2,13 @@ #define L1Trigger_TrackFindingTracklet_interface_Util_h #include +#include #include #include +#include #include +#include +#include #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" @@ -35,143 +39,16 @@ namespace trklet { return str; } - //Should be optimized by layer - now first implementation to make sure it works OK - inline int bendencode(double bend, bool isPS) { - int ibend = 2.0 * bend; - - assert(std::abs(ibend - 2.0 * bend) < 0.1); - - if (isPS) { - if (ibend == 0 || ibend == 1) - return 0; - if (ibend == 2 || ibend == 3) - return 1; - if (ibend == 4 || ibend == 5) - return 2; - if (ibend >= 6) - return 3; - if (ibend == -1 || ibend == -2) - return 4; - if (ibend == -3 || ibend == -4) - return 5; - if (ibend == -5 || ibend == -6) - return 6; - if (ibend <= -7) - return 7; - - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ - << " Unknown bendencode for PS module for bend = " << bend - << " ibend = " << ibend; - } - - if (ibend == 0 || ibend == 1) - return 0; - if (ibend == 2 || ibend == 3) - return 1; - if (ibend == 4 || ibend == 5) - return 2; - if (ibend == 6 || ibend == 7) - return 3; - if (ibend == 8 || ibend == 9) - return 4; - if (ibend == 10 || ibend == 11) - return 5; - if (ibend == 12 || ibend == 13) - return 6; - if (ibend >= 14) - return 7; - if (ibend == -1 || ibend == -2) - return 8; - if (ibend == -3 || ibend == -4) - return 9; - if (ibend == -5 || ibend == -6) - return 10; - if (ibend == -7 || ibend == -8) - return 11; - if (ibend == -9 || ibend == -10) - return 12; - if (ibend == -11 || ibend == -12) - return 13; - if (ibend == -13 || ibend == -14) - return 14; - if (ibend <= -15) - return 15; - - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ - << " Unknown bendencode for 2S module for bend = " << bend - << " ibend = " << ibend; - } - - //Should be optimized by layer - now first implementation to make sure it works OK - inline double benddecode(int ibend, bool isPS) { - if (isPS) { - if (ibend == 0) - return 0.25; - if (ibend == 1) - return 1.25; - if (ibend == 2) - return 2.25; - if (ibend == 3) - return 3.25; - if (ibend == 4) - return -0.75; - if (ibend == 5) - return -1.75; - if (ibend == 6) - return -2.75; - if (ibend == 7) - return -3.75; - - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ - << " Unknown benddecode for PS module for ibend = " << ibend; - } - - if (ibend == 0) - return 0.25; - if (ibend == 1) - return 1.25; - if (ibend == 2) - return 2.25; - if (ibend == 3) - return 3.25; - if (ibend == 4) - return 4.25; - if (ibend == 5) - return 5.25; - if (ibend == 6) - return 6.25; - if (ibend == 7) - return 7.25; - if (ibend == 8) - return -0.75; - if (ibend == 9) - return -1.75; - if (ibend == 10) - return -2.75; - if (ibend == 11) - return -3.75; - if (ibend == 12) - return -4.75; - if (ibend == 13) - return -5.75; - if (ibend == 14) - return -6.75; - if (ibend == 15) - return -7.75; - - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ - << " Unknown benddecode for 2S module for ibend = " << ibend; - } - - inline double bend(double r, double rinv, double stripPitch) { + inline double bendstrip(double r, double rinv, double stripPitch) { constexpr double dr = 0.18; double delta = r * dr * 0.5 * rinv; - double bend = -delta / stripPitch; + double bend = delta / stripPitch; return bend; } inline double rinv(double phi1, double phi2, double r1, double r2) { - if (r2 <= r1) { //can not form tracklet + + if (r2 <= r1) { //FIXME can not form tracklet should not call function with r2<=r1 return 20.0; } @@ -181,5 +58,110 @@ namespace trklet { return 2.0 * sin(dphi) / dr / sqrt(1.0 + 2 * r1 * r2 * (1.0 - cos(dphi)) / (dr * dr)); } + inline std::string convertHexToBin(const std::string& stubwordhex) { + + std::string stubwordbin=""; + + for(char word:stubwordhex){ + std::string hexword=""; + if (word=='0') hexword="0000"; + if (word=='1') hexword="0001"; + if (word=='2') hexword="0010"; + if (word=='3') hexword="0011"; + if (word=='4') hexword="0100"; + if (word=='5') hexword="0101"; + if (word=='6') hexword="0110"; + if (word=='7') hexword="0111"; + if (word=='8') hexword="1000"; + if (word=='9') hexword="1001"; + if (word=='A') hexword="1010"; + if (word=='B') hexword="1011"; + if (word=='C') hexword="1100"; + if (word=='D') hexword="1101"; + if (word=='E') hexword="1110"; + if (word=='F') hexword="1111"; + if (hexword=="") { + throw cms::Exception("Inconsistency") << __FILE__ << " " << __LINE__ << " hex string format invalid: " << stubwordhex; + } + stubwordbin+=hexword; + } + return stubwordbin; + } + + inline int ilog2(double factor) { + double power=log(factor)/log(2); + int ipower=round(power); + assert(std::abs(power-ipower)<0.1); + return ipower; + } + + +/****************************************************************************** + * Checks to see if a directory exists. Note: This method only checks the + * existence of the full path AND if path leaf is a dir. + * + * @return 1 if dir exists AND is a dir, + * 0 if dir does not exist OR exists but not a dir, + * -1 if an error occurred (errno is also set) + *****************************************************************************/ + inline int dirExists(const std::string& path){ + struct stat info; + + int statRC = stat( path.c_str(), &info ); + if( statRC != 0 ) + { + if (errno == ENOENT) { return 0; } // something along the path does not exist + if (errno == ENOTDIR) { return 0; } // something in path prefix is not a dir + return -1; + } + + return ( info.st_mode & S_IFDIR ) ? 1 : 0; + } + + + //Open file - create directory if not existent. + inline std::ofstream openfile(const std::string& dir, const std::string& fname, const char* file, int line) { + + if (dirExists(dir)!=1) { + std::cout << "Creating directory : "< stubinputs_; //The all stub memories - std::vector > allstubs_; + std::vector allstubs_; + std::vector > allinnerstubs_; //The VM stubs memories used by the MEs std::vector vmstubsMEPHI_; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h b/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h index 08a1ecd198fe2..21298a7b2c132 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h @@ -16,11 +16,11 @@ namespace trklet { class VMRouterTable { public: VMRouterTable(Settings const& settings); - VMRouterTable(Settings const& settings, unsigned int layerdisk, std::string const& name); + VMRouterTable(Settings const& settings, unsigned int layerdisk,std::string const& name); ~VMRouterTable() = default; - void init(unsigned int layerdisk, std::string const& name); + void init(unsigned int layerdisk, std::string const& name=""); // negative return means that seed can not be formed int getLookup(unsigned int layerdisk, double z, double r, int iseed = -1); @@ -30,8 +30,9 @@ namespace trklet { int lookupinner(int zbin, int rbin); int lookupinneroverlap(int zbin, int rbin); int lookupinnerThird(int zbin, int rbin); - void writeVMTable(std::string const& name, std::vector const& table); + void writeVMTable(std::string const& dir, std::string const& name, std::vector const& table); + private: Settings const& settings_; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h b/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h index b494573c7de79..6f974bc86bd75 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h @@ -59,6 +59,7 @@ namespace trklet { private: int layer_; int disk_; + int layerdisk_; int phibin_; VMStubsTEMemory* other_; bool overlap_; diff --git a/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml b/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml index df534e5516622..aeef3736a59d7 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml @@ -1,11 +1,15 @@ + + - - + + + + diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index aa6b5f30f9860..672f4e2305ab5 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -40,7 +40,6 @@ #include "SimDataFormats/Vertex/interface/SimVertex.h" #include "SimDataFormats/Vertex/interface/SimVertexContainer.h" #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" -#include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h" #include "SimTracker/TrackTriggerAssociation/interface/TTStubAssociationMap.h" #include "SimTracker/TrackTriggerAssociation/interface/TTClusterAssociationMap.h" // @@ -52,6 +51,8 @@ #include "DataFormats/L1TrackTrigger/interface/TTTrack.h" #include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h" #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" +#include "DataFormats/L1TrackTrigger/interface/TTDTC.h" +#include "L1Trigger/TrackerDTC/interface/Setup.h" // #include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "DataFormats/Candidate/interface/Candidate.h" @@ -118,14 +119,14 @@ using namespace std; // between different types of stubs struct L1TStubCompare { public: - bool operator()(const trklet::L1TStub& x, const trklet::L1TStub& y) const { - if (x.x() != y.x()) - return (y.x() > x.x()); + bool operator()(const trklet::L1TStub& a, const trklet::L1TStub& b) const { + if (a.x() != b.x()) + return (b.x() > a.x()); else { - if (x.y() != y.y()) - return (y.y() > x.y()); + if (a.y() != b.y()) + return (b.y() > a.y()); else - return (x.z() > y.z()); + return (a.z() > b.z()); } } }; @@ -160,8 +161,6 @@ class L1FPGATrackProducer : public edm::one::EDProducer { string asciiEventOutName_; std::ofstream asciiEventOut_; - string geometryType_; - // settings containing various constants for the tracklet processing trklet::Settings settings; @@ -182,17 +181,19 @@ class L1FPGATrackProducer : public edm::one::EDProducer { edm::InputTag MCTruthClusterInputTag; edm::InputTag MCTruthStubInputTag; edm::InputTag TrackingParticleInputTag; - edm::InputTag TrackingVertexInputTag; - edm::InputTag ttStubSrc_; - edm::InputTag bsSrc_; - const edm::EDGetTokenT>> ttStubToken_; const edm::EDGetTokenT bsToken_; edm::EDGetTokenT> ttClusterMCTruthToken_; - edm::EDGetTokenT> ttStubMCTruthToken_; edm::EDGetTokenT> TrackingParticleToken_; - edm::EDGetTokenT> TrackingVertexToken_; + edm::EDGetTokenT tokenDTC_; + + // helper class to store DTC configuration + trackerDTC::Setup setup_; + + // Setup token + edm::ESGetToken esGetToken_; + /// ///////////////// /// /// MANDATORY METHODS /// @@ -204,26 +205,20 @@ class L1FPGATrackProducer : public edm::one::EDProducer { ////////////// // CONSTRUCTOR L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) - : config(iConfig), - readMoreMcTruth_(iConfig.getParameter("readMoreMcTruth")), - MCTruthClusterInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthClusterInputTag") - : edm::InputTag()), - MCTruthStubInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthStubInputTag") - : edm::InputTag()), - TrackingParticleInputTag(readMoreMcTruth_ ? iConfig.getParameter("TrackingParticleInputTag") - : edm::InputTag()), - TrackingVertexInputTag(readMoreMcTruth_ ? iConfig.getParameter("TrackingVertexInputTag") - : edm::InputTag()), - ttStubSrc_(config.getParameter("TTStubSource")), - bsSrc_(config.getParameter("BeamSpotSource")), - - ttStubToken_(consumes>>(ttStubSrc_)), - bsToken_(consumes(bsSrc_)) { + : config(iConfig), + readMoreMcTruth_(iConfig.getParameter("readMoreMcTruth")), + MCTruthClusterInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthClusterInputTag") + : edm::InputTag()), + MCTruthStubInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthStubInputTag") + : edm::InputTag()), + TrackingParticleInputTag(readMoreMcTruth_ ? iConfig.getParameter("TrackingParticleInputTag") + : edm::InputTag()), + bsToken_(consumes(config.getParameter("BeamSpotSource"))), + tokenDTC_(consumes(edm::InputTag(iConfig.getParameter( "InputTagTTDTC" ) ) ) ) +{ if (readMoreMcTruth_) { ttClusterMCTruthToken_ = consumes>(MCTruthClusterInputTag); - ttStubMCTruthToken_ = consumes>(MCTruthStubInputTag); TrackingParticleToken_ = consumes>(TrackingParticleInputTag); - TrackingVertexToken_ = consumes>(TrackingVertexInputTag); } produces>>("Level1TTTracks").setBranchAlias("Level1TTTracks"); @@ -247,6 +242,9 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) tableTREFile = iConfig.getParameter("tableTREFile"); } + // book ES product + esGetToken_ = esConsumes(); + // -------------------------------------------------------------------------------- // set options in Settings based on inputs from configuration files // -------------------------------------------------------------------------------- @@ -320,6 +318,8 @@ void L1FPGATrackProducer::beginRun(const edm::Run& run, const edm::EventSetup& i double mMagneticFieldStrength = theMagneticField->inTesla(GlobalPoint(0, 0, 0)).z(); settings.setBfield(mMagneticFieldStrength); + setup_ = iSetup.getData(esGetToken_); + // initialize the tracklet event processing (this sets all the processing & memory modules, wiring, etc) eventProcessor.init(settings); } @@ -357,16 +357,12 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe eventnum++; trklet::SLHCEvent ev; ev.setEventNum(eventnum); - ev.setIPx(bsPosition.x()); - ev.setIPy(bsPosition.y()); + ev.setIP(bsPosition.x(),bsPosition.y()); // tracking particles edm::Handle> TrackingParticleHandle; - edm::Handle> TrackingVertexHandle; if (readMoreMcTruth_) iEvent.getByToken(TrackingParticleToken_, TrackingParticleHandle); - if (readMoreMcTruth_) - iEvent.getByToken(TrackingVertexToken_, TrackingVertexHandle); // tracker topology const TrackerTopology* const tTopo = tTopoHandle.product(); @@ -374,18 +370,17 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe //////////////////////// // GET THE PRIMITIVES // - edm::Handle>> Phase2TrackerDigiTTStubHandle; - iEvent.getByToken(ttStubToken_, Phase2TrackerDigiTTStubHandle); + edm::Handle< TTDTC > handleDTC; + iEvent.getByToken< TTDTC >( tokenDTC_, handleDTC ); + // must be defined for code to compile, even if it's not used unless readMoreMcTruth_ is true map, int> translateTP; // MC truth association maps edm::Handle> MCTruthTTClusterHandle; - edm::Handle> MCTruthTTStubHandle; if (readMoreMcTruth_) { iEvent.getByToken(ttClusterMCTruthToken_, MCTruthTTClusterHandle); - iEvent.getByToken(ttStubMCTruthToken_, MCTruthTTStubHandle); //////////////////////////////////////////////// /// LOOP OVER TRACKING PARTICLES & GET SIMTRACKS @@ -427,57 +422,110 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe } // end if (readMoreMcTruth_) - //////////////////////////////// - /// COLLECT STUB INFORMATION /// - //////////////////////////////// - bool firstPS = true; - bool first2S = true; + ///////////////////////////////// + /// READ DTC STUB INFORMATION /// + ///////////////////////////////// - for (const auto& gd : theTrackerGeom->dets()) { - DetId detid = (*gd).geographicalId(); - if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID) - continue; // only run on OT - if (!tTopo->isLower(detid)) - continue; // loop on the stacks: choose the lower arbitrarily - DetId stackDetid = tTopo->stack(detid); // Stub module detid + // Process stubs in each region and channel within that region + for ( const int& region : handleDTC->tfpRegions() ) { + for ( const int& channel : handleDTC->tfpChannels() ) { + + // Get the DTC name form the channel - if (Phase2TrackerDigiTTStubHandle->find(stackDetid) == Phase2TrackerDigiTTStubHandle->end()) - continue; + static string dtcbasenames[12]={"PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", + "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", + "2S_4", "2S_5", "2S_6"}; - // Get the DetSets of the Clusters - edmNew::DetSet> stubs = (*Phase2TrackerDigiTTStubHandle)[stackDetid]; - const GeomDetUnit* det0 = theTrackerGeom->idToDetUnit(detid); - const auto* theGeomDet = dynamic_cast(det0); - const PixelTopology* topol = dynamic_cast(&(theGeomDet->specificTopology())); + string dtcname=dtcbasenames[channel%12]; - bool isPSmodule = theTrackerGeom->getDetectorType(detid) == TrackerGeometry::ModuleType::Ph2PSP; + if (channel%24>=12) dtcname="neg"+dtcname; - // set constants that are common for all modules/stubs of a given type (PS vs 2S) - if (isPSmodule && firstPS) { - settings.setNStrips_PS(topol->nrows()); - settings.setStripPitch_PS(topol->pitch().first); - settings.setStripLength_PS(topol->pitch().second); - firstPS = false; - } - if (!isPSmodule && first2S) { - settings.setNStrips_2S(topol->nrows()); - settings.setStripPitch_2S(topol->pitch().first); - settings.setStripLength_2S(topol->pitch().second); - first2S = false; - } + dtcname+=(channel<24)?"_A":"_B"; - // loop over stubs - for (auto stubIter = stubs.begin(); stubIter != stubs.end(); ++stubIter) { - edm::Ref>, TTStub> tempStubPtr = - edmNew::makeRefTo(Phase2TrackerDigiTTStubHandle, stubIter); + // Get the stubs from the DTC + const TTDTC::Stream& streamFromDTC{ handleDTC->stream( region, channel ) }; - vector assocTPs; + // Prepare the DTC stubs for the IR + for ( size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex ) { + + const TTDTC::Frame& stub{ streamFromDTC[ stubIndex ] }; + + if ( stub.first.isNull() ) { + continue; + } + + const GlobalPoint& ttPos = setup_.stubPos(stub.first); + + //Get the 2 bits for the layercode + string layerword=stub.second.to_string().substr(61,2); + unsigned int layercode=2*(layerword[0]-'0')+layerword[1]-'0'; + assert(layercode<4); + + //translation from the two bit layercode to the layer/disk number of each of the + //12 channels (dtcs) + static int layerdisktab[12][4] = {{0, 6, 8, 10}, + {0, 7, 9, -1}, + {1, 7, -1, -1}, + {6, 8, 10, -1}, + {2, 7, -1, -1}, + {2, 9, -1, -1}, + {3, 4, -1, -1}, + {4, -1, -1, -1}, + {5, -1, -1, -1}, + {5, 8, -1, -1}, + {6, 9, -1, -1}, + {7, 10, -1, -1}}; + + int layerdisk=layerdisktab[channel%12][layercode]; + assert(layerdisk!=-1); + + //Get the 36 bit word - skip the lowest 3 buts (status and layer code) + string stubword=stub.second.to_string().substr(64-36-3,36); + string stubwordhex=""; + + //Loop over the 9 words in the 36 bit stub word + for(unsigned int i=0;i<9;i++){ + bitset<4> bits(stubword.substr(i*4,4)); + ulong val=bits.to_ulong(); + stubwordhex+=((val<10)?('0'+val):('A'+val-10)); + } + + /// Get the Inner and Outer TTCluster + edm::Ref>, TTCluster> innerCluster = + stub.first->clusterRef(0); + edm::Ref>, TTCluster> outerCluster = + stub.first->clusterRef(1); + + // ----------------------------------------------------- + // check module orientation, if flipped, need to store that information for track fit + // ----------------------------------------------------- + + const DetId innerDetId = innerCluster->getDetId(); + const GeomDetUnit* det_inner = theTrackerGeom->idToDetUnit(innerDetId); + const auto* theGeomDet_inner = dynamic_cast(det_inner); + const PixelTopology* topol_inner = dynamic_cast(&(theGeomDet_inner->specificTopology())); + + MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered(); + LocalPoint clustlp_inner = topol_inner->localPosition(coords_inner); + GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner); + + const DetId outerDetId = outerCluster->getDetId(); + const GeomDetUnit* det_outer = theTrackerGeom->idToDetUnit(outerDetId); + const auto* theGeomDet_outer = dynamic_cast(det_outer); + const PixelTopology* topol_outer = dynamic_cast(&(theGeomDet_outer->specificTopology())); + + MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered(); + LocalPoint clustlp_outer = topol_outer->localPosition(coords_outer); + GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer); + + bool isFlipped = (posStub_outer.mag() < posStub_inner.mag()); + + vector assocTPs; - if (readMoreMcTruth_) { for (unsigned int iClus = 0; iClus <= 1; iClus++) { // Loop over both clusters that make up stub. - const TTClusterRef& ttClusterRef = tempStubPtr->clusterRef(iClus); + const TTClusterRef& ttClusterRef = stub.first->clusterRef(iClus); // Now identify all TP's contributing to either cluster in stub. vector> vecTpPtr = MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef); @@ -495,131 +543,34 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe } } } - } // end if (readMoreMcTruth_) - - MeasurementPoint coords = tempStubPtr->clusterRef(0)->findAverageLocalCoordinatesCentered(); - LocalPoint clustlp = topol->localPosition(coords); - GlobalPoint posStub = theGeomDet->surface().toGlobal(clustlp); - - int eventID = -1; - - if (readMoreMcTruth_) { - edm::Ptr my_tp = MCTruthTTStubHandle->findTrackingParticlePtr(tempStubPtr); - } - - int layer = -999999; - int ladder = -999999; - int module = -999999; - - int strip = 460; - if (detid.subdetId() == StripSubdetector::TOB) { - layer = static_cast(tTopo->layer(detid)); - module = static_cast(tTopo->module(detid)); - ladder = static_cast(tTopo->tobRod(detid)); + double stubbend=stub.first->bendFE(); //stub.first->rawBend() + if (ttPos.z()<-120) { + stubbend=-stubbend; + } + + ev.addStub(dtcname, + region, + layerdisk, + stubwordhex, + setup_.psModule(setup_.dtcId(region,channel)), + isFlipped, + ttPos.x(), + ttPos.y(), + ttPos.z(), + stubbend, + stub.first->innerClusterPosition(), + assocTPs); + + const trklet::L1TStub& lastStub = ev.lastStub(); + stubMap[lastStub] = stub.first; - // https://github.com/cms-sw/cmssw/tree/master/Geometry/TrackerNumberingBuilder - // tobSide = 1: ring- (tilted) - // tobSide = 2: ring+ (tilted) - // tobSide = 3: barrel (flat) - enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 }; - const TypeBarrel type = static_cast(tTopo->tobSide(detid)); - - // modules in the flat part of barrel are mounted on planks, while modules in tilted part are on rings - // below, "module" is the module number in the z direction (from minus z to positive), - // while "ladder" is the module number in the phi direction - - if (layer > 0 && layer <= (int)trklet::N_PSLAYER) { - if (type == tiltedMinus) { - module = static_cast(tTopo->tobRod(detid)); - ladder = static_cast(tTopo->module(detid)); - } - if (type == tiltedPlus) { - module = - trklet::N_TILTED_RINGS + trklet::N_MOD_PLANK.at(layer - 1) + static_cast(tTopo->tobRod(detid)); - ladder = static_cast(tTopo->module(detid)); - } - if (type == flat) { - module = trklet::N_TILTED_RINGS + static_cast(tTopo->module(detid)); - } - } - } else if (detid.subdetId() == StripSubdetector::TID) { - layer = 1000 + static_cast(tTopo->tidRing(detid)); - ladder = static_cast(tTopo->module(detid)); - module = static_cast(tTopo->tidWheel(detid)); } - /// Get the Inner and Outer TTCluster - edm::Ref>, TTCluster> innerCluster = - tempStubPtr->clusterRef(0); - edm::Ref>, TTCluster> outerCluster = - tempStubPtr->clusterRef(1); - - std::vector irphi; - std::vector innerrows = innerCluster->getRows(); - irphi.reserve(innerrows.size()); - for (int innerrow : innerrows) { - irphi.push_back(innerrow); - } - std::vector outerrows = outerCluster->getRows(); - for (int outerrow : outerrows) { - irphi.push_back(outerrow); - } - - // ----------------------------------------------------- - // check module orientation, if flipped, need to store that information for track fit - // ----------------------------------------------------- - - const DetId innerDetId = innerCluster->getDetId(); - const GeomDetUnit* det_inner = theTrackerGeom->idToDetUnit(innerDetId); - const auto* theGeomDet_inner = dynamic_cast(det_inner); - const PixelTopology* topol_inner = dynamic_cast(&(theGeomDet_inner->specificTopology())); - - MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered(); - LocalPoint clustlp_inner = topol_inner->localPosition(coords_inner); - GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner); - - const DetId outerDetId = outerCluster->getDetId(); - const GeomDetUnit* det_outer = theTrackerGeom->idToDetUnit(outerDetId); - const auto* theGeomDet_outer = dynamic_cast(det_outer); - const PixelTopology* topol_outer = dynamic_cast(&(theGeomDet_outer->specificTopology())); - - MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered(); - LocalPoint clustlp_outer = topol_outer->localPosition(coords_outer); - GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer); - - bool isFlipped = (posStub_outer.mag() < posStub_inner.mag()); + } + } - // ----------------------------------------------------- - // correct sign for stubs in negative endcap - float stub_bend = tempStubPtr->bendFE(); - float stub_pt = -1; - if (layer > 999 && posStub.z() < 0.0) { - stub_bend = -stub_bend; - } - if (!irphi.empty()) { - strip = irphi[0]; - } - //if module FE inefficiencies are calculated, a stub is thrown out if rawBend > 100 - if ((tempStubPtr->rawBend() < 100.) && (ev.addStub(layer, - ladder, - module, - strip, - eventID, - assocTPs, - stub_pt, - stub_bend, - posStub.x(), - posStub.y(), - posStub.z(), - isPSmodule, - isFlipped))) { - const trklet::L1TStub& lastStub = ev.lastStub(); - stubMap[lastStub] = tempStubPtr; - } - } - } ////////////////////////// // NOW RUN THE L1 tracking @@ -630,8 +581,6 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe std::vector& tracks = eventProcessor.tracks(); - trklet::L1SimTrack simtrk(0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - // this performs the actual tracklet event processing eventProcessor.event(ev); diff --git a/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py b/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py index cab518307ffb2..1300cc7eb8814 100644 --- a/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py @@ -3,13 +3,13 @@ TTTracksFromTrackletEmulation = cms.EDProducer("L1FPGATrackProducer", TTStubSource = cms.InputTag("TTStubsFromPhase2TrackerDigis","StubAccepted"), + InputTagTTDTC = cms.InputTag ( "TrackerDTCProducer", "StubAccepted" ), readMoreMcTruth = cms.bool(True), MCTruthClusterInputTag = cms.InputTag("TTClusterAssociatorFromPixelDigis", "ClusterAccepted"), MCTruthStubInputTag = cms.InputTag("TTStubAssociatorFromPixelDigis", "StubAccepted"), TrackingParticleInputTag = cms.InputTag("mix", "MergedTrackTruth"), - TrackingVertexInputTag = cms.InputTag("mix", "MergedTrackTruth"), BeamSpotSource = cms.InputTag("offlineBeamSpot"), - asciiFileName = cms.untracked.string(""), + asciiFileName = cms.untracked.string("evtlist.txt"), # (if running on CRAB use "../../fitpattern.txt" etc instead) Extended=cms.bool(False), Hnpar=cms.uint32(4), diff --git a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc new file mode 100644 index 0000000000000..a831c4cba239d --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc @@ -0,0 +1,24 @@ +#include "L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h" +#include "L1Trigger/TrackFindingTracklet/interface/Stub.h" +#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" +#include + +using namespace std; +using namespace trklet; + +AllInnerStubsMemory::AllInnerStubsMemory(string name, Settings const& settings, unsigned int iSector) + : MemoryBase(name, settings, iSector) {} + +void AllInnerStubsMemory::writeStubs(bool first) { + const string dirS = settings_.memPath() + "Stubs/"; + openFile(first, dirS, "AllInnerStubs_"); + + for (unsigned int j = 0; j < stubs_.size(); j++) { + string stub = stubs_[j]->strinner(); + out_ << "0x"; + out_ << std::setfill('0') << std::setw(2); + out_ << hex << j << dec; + out_ << " " << stub << " " << hexFormat(stub) << endl; + } + out_.close(); +} diff --git a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc index 2aef2b74ef8ca..aad0969f9dac6 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc @@ -1,6 +1,7 @@ #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 @@ -21,22 +22,8 @@ void AllProjectionsMemory::writeAP(bool first) { oss << dirTP << "AllProj_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirTP)) { - int fail = system((string("mkdir -p ") + dirTP).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirTP; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); - + openfile(out_, first, dirTP, fname, __FILE__, __LINE__); + out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; for (unsigned int j = 0; j < tracklets_.size(); j++) { diff --git a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc index 315b7f668fbc9..3dac87a57a072 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc @@ -7,7 +7,7 @@ using namespace std; using namespace trklet; AllStubsMemory::AllStubsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} + : MemoryBase(name, settings, iSector) {} void AllStubsMemory::writeStubs(bool first) { const string dirS = settings_.memPath() + "Stubs/"; diff --git a/L1Trigger/TrackFindingTracklet/src/Cabling.cc b/L1Trigger/TrackFindingTracklet/src/Cabling.cc deleted file mode 100644 index c0b48b3e494ad..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/Cabling.cc +++ /dev/null @@ -1,126 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/Cabling.h" -#include "L1Trigger/TrackFindingTracklet/interface/DTCLink.h" -#include "L1Trigger/TrackFindingTracklet/interface/DTC.h" -#include "L1Trigger/TrackFindingTracklet/interface/Util.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" -#include "DataFormats/Math/interface/deltaPhi.h" - -using namespace std; -using namespace trklet; - -Cabling::Cabling(string dtcconfig, string moduleconfig, Settings const& settings) : settings_(settings) { - ifstream indtc(dtcconfig.c_str()); - assert(indtc.good()); - - string dtc; - int isec; - - while (indtc.good()) { - indtc >> dtc >> isec; - - if (!indtc.good()) - continue; - - if (dtcs_.find(dtc) == dtcs_.end()) { - dtcs_[dtc].setName(dtc); - } - - dtcs_[dtc].addSec(isec); - - string dtcbase = dtc.substr(2, dtc.size() - 2); - if (dtc[0] == 'n') { - dtcbase = "neg_" + dtc.substr(6, dtc.size() - 6); - } - if (dtcranges_.find(dtcbase) == dtcranges_.end()) { - dtcranges_[dtcbase].setName(dtcbase); - } - } - - ifstream inmodules(moduleconfig.c_str()); - - int layer, ladder, module; - - while (inmodules.good()) { - inmodules >> layer >> ladder >> module >> dtc; - - // in the cabling module map, module# 300+ is flat part of barrel, 200-299 is tilted z-, 100-199 is tilted z+ - if (module > 300) { - if (layer > 0 && layer <= (int)N_PSLAYER) { - module = (module - 300) + N_TILTED_RINGS; - } else if (layer > (int)N_PSLAYER) { - module = (module - 300); - } - } - if (module > 200) { - module = (module - 200); - } - if ((module > 100) && (layer > 0 && layer <= (int)N_PSLAYER)) { - module = (module - 100) + N_TILTED_RINGS + N_MOD_PLANK.at(layer - 1); - } - if (!inmodules.good()) - break; - modules_[layer][ladder][module] = dtc; - } -} - -const string& Cabling::dtc(int layer, int ladder, int module) const { - auto it1 = modules_.find(layer); - assert(it1 != modules_.end()); - auto it2 = it1->second.find(ladder); - assert(it2 != it1->second.end()); - auto it3 = it2->second.find(module); - if (it3 == it2->second.end()) { - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << "Could not find stub " << layer << " " - << ladder << " " << module; - } - return it3->second; -} - -void Cabling::addphi(const string& dtc, double phi, int layer, int module) { - unsigned int layerdisk = layer - 1; - - if (layer > 1000) - layerdisk = module + N_DISK; - - assert(layerdisk < N_LAYER + N_DISK); - - int isec = dtc[0] - '0'; - - string dtcbase = dtc.substr(2, dtc.size() - 2); - if (dtc[0] == 'n') { - dtcbase = "neg_" + dtc.substr(6, dtc.size() - 6); - isec = dtc[4] - '0'; - } - - double phisec = reco::reduceRange(phi - isec * settings_.dphisector()); - - assert(dtcranges_.find(dtcbase) != dtcranges_.end()); - - dtcranges_[dtcbase].addphi(phisec, layerdisk); -} - -void Cabling::writephirange() const { - ofstream out("dtcphirange.txt"); - - for (auto&& it : dtcranges_) { - for (unsigned int i = 0; i < N_LAYER + N_DISK; i++) { - double min = it.second.min(i); - double max = it.second.max(i); - if (min < max) { - out << it.first << " " << i + 1 << " " << min << " " << max << endl; - } - } - } -} - -std::vector Cabling::DTCs() const { - std::vector tmp; - - for (const auto& it : dtcs_) { - tmp.push_back(it.first); - } - - return tmp; -} diff --git a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc index 41b0326f7e5f0..13454266e6f18 100644 --- a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc @@ -36,21 +36,7 @@ void CandidateMatchMemory::writeCM(bool first) { << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirM)) { - int fail = system((string("mkdir -p ") + dirM).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirM; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirM, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc index 9c90b757e7225..b23fc8246f440 100644 --- a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc @@ -21,21 +21,7 @@ void CleanTrackMemory::writeCT(bool first) { oss << dirCT << "CleanTrack_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirCT)) { - int fail = system((string("mkdir -p ") + dirCT).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirCT; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirCT, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/DTC.cc b/L1Trigger/TrackFindingTracklet/src/DTC.cc deleted file mode 100644 index 6fb97d524565e..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/DTC.cc +++ /dev/null @@ -1,52 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/DTC.h" -#include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h" -#include "L1Trigger/TrackFindingTracklet/interface/Stub.h" - -#include "DataFormats/Math/interface/deltaPhi.h" - -using namespace std; -using namespace trklet; - -DTC::DTC(string name) { - name_ = name; - for (unsigned int i = 0; i < N_LAYER + N_DISK; i++) { - phimin_[i] = 10.0; - phimax_[i] = -10.0; - } -} - -void DTC::setName(string name) { name_ = name; } - -void DTC::addSec(int sector) { sectors_.push_back(sector); } - -void DTC::addphi(double phi, unsigned int layerdisk) { - assert(layerdisk < N_LAYER + N_DISK); - if (phi < phimin_[layerdisk]) - phimin_[layerdisk] = phi; - if (phi > phimax_[layerdisk]) - phimax_[layerdisk] = phi; -} - -void DTC::addLink(double phimin, double phimax) { - DTCLink link(phimin, phimax); - links_.push_back(link); -} - -int DTC::addStub(std::pair stub) { - double phi = reco::reduceRange(stub.second->phi()); - bool overlaplayer = ((stub.second->layer() + 1) % 2 == 0); - int added = 0; - for (auto& link : links_) { - if (link.inRange(phi, overlaplayer)) { - added++; - link.addStub(stub); - } - } - return added; -} - -void DTC::clean() { - for (auto& link : links_) { - link.clean(); - } -} diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLink.cc b/L1Trigger/TrackFindingTracklet/src/DTCLink.cc deleted file mode 100644 index 8b5c59c671fd2..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/DTCLink.cc +++ /dev/null @@ -1,29 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/DTCLink.h" - -using namespace std; -using namespace trklet; - -DTCLink::DTCLink(double phimin, double phimax) { - if (phimin > M_PI) { - phimin -= 2 * M_PI; - phimax -= 2 * M_PI; - } - assert(phimax > phimin); - phimin_ = phimin; - phimax_ = phimax; -} - -void DTCLink::addStub(std::pair stub) { stubs_.push_back(stub); } - -bool DTCLink::inRange(double phi, bool overlaplayer) { - double phimax = phimax_; - double phimin = phimin_; - if (overlaplayer) { - double dphi = phimax - phimin; - assert(dphi > 0.0); - assert(dphi < M_PI); - phimin -= dphi / 6.0; - phimax += dphi / 6.0; - } - return (phi < phimax && phi > phimin) || (phi + 2 * M_PI < phimax && phi + 2 * M_PI > phimin); -} diff --git a/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc b/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc index 4fa054be39805..8d2e2964d2fcc 100644 --- a/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc +++ b/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc @@ -24,7 +24,7 @@ void DiskProjection::init(Settings const& settings, double rprojapprox, double phiprojderapprox, double rprojderapprox) { - assert(abs(projdisk) >= 0); + assert(abs(projdisk) > 0); assert(abs(projdisk) <= N_DISK); valid_ = true; @@ -33,25 +33,23 @@ void DiskProjection::init(Settings const& settings, projdisk_ = projdisk; + unsigned int layerdisk = projdisk + N_LAYER - 1; + assert(iphiproj >= 0); - fpgaphiproj_.set(iphiproj, settings.nphibitsstub(0), true, __LINE__, __FILE__); - int iphivm = (iphiproj >> (settings.nphibitsstub(0) - 5)) & 0x7; - if ((abs(projdisk_) % 2) == 1) { - iphivm ^= 4; - } - fpgaphiprojvm_.set(iphivm, 3, true, __LINE__, __FILE__); - fpgarproj_.set(irproj, settings.nrbitsstub(6), false, __LINE__, __FILE__); - int irvm = irproj >> (13 - 7) & 0xf; - fpgarprojvm_.set(irvm, 4, true, __LINE__, __FILE__); + fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); + + fpgarproj_.set(irproj, settings.nrbitsstub(layerdisk), false, __LINE__, __FILE__); + fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); fpgarprojder_.set(irder, settings.nrbitsprojderdisk(), false, __LINE__, __FILE__); //TODO the -3 and +3 should be evaluated and efficiency for matching hits checked. //This code should be migrated in the ProjectionRouter - int rbin1 = 8.0 * (irproj * settings.krprojshiftdisk() - 3 - settings.rmindiskvm()) / + double roffset = 3.0; + int rbin1 = 8.0 * (irproj * settings.krprojshiftdisk() - roffset - settings.rmindiskvm()) / (settings.rmaxdisk() - settings.rmindiskvm()); - int rbin2 = 8.0 * (irproj * settings.krprojshiftdisk() + 3 - settings.rmindiskvm()) / + int rbin2 = 8.0 * (irproj * settings.krprojshiftdisk() + roffset - settings.rmindiskvm()) / (settings.rmaxdisk() - settings.rmindiskvm()); if (irproj * settings.krprojshiftdisk() < 20.0) { @@ -59,8 +57,9 @@ void DiskProjection::init(Settings const& settings, << projdisk_; } - if (rbin1 < 0) + if (rbin1 < 0) { rbin1 = 0; + } rbin2 = clamp(rbin2, 0, 7); assert(rbin1 <= rbin2); @@ -82,6 +81,11 @@ void DiskProjection::init(Settings const& settings, fpgafinervm_.set(finer, 4, true, __LINE__, __FILE__); // fine r postions starting at rbin1 + //fine phi bits + int projfinephi = (fpgaphiproj_.value() >> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(N_LAYER+projdisk_-1) + settings.nbitsvmme(N_LAYER+projdisk_-1) + NFINEPHIBITS ))) & ((1<&, std: continue; } if (tracklet->match(l)) { + const LayerResidual& layerResid = tracklet->layerResid(l); lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - phiresid[nlayers] = tracklet->phiresidapprox(l); - zresid[nlayers] = tracklet->zresidapprox(l); - phiresidexact[nlayers] = tracklet->phiresid(l); - zresidexact[nlayers] = tracklet->zresid(l); - iphiresid[nlayers] = tracklet->fpgaphiresid(l).value(); - izresid[nlayers] = tracklet->fpgazresid(l).value(); + phiresid[nlayers] = layerResid.phiresidapprox(); + zresid[nlayers] = layerResid.zresidapprox(); + phiresidexact[nlayers] = layerResid.phiresid(); + zresidexact[nlayers] = layerResid.zresid(); + iphiresid[nlayers] = layerResid.fpgaphiresid().value(); + izresid[nlayers] = layerResid.fpgazresid().value(); layers[nlayers++] = l; } @@ -224,12 +225,13 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - if (std::abs(tracklet->alphadisk(d)) < 1e-20) { + const DiskResidual& diskResid = tracklet->diskResid(d); + if (std::abs(diskResid.alpha()) < 1e-20) { dmatches.set(2 * d - 1); diskmask |= (1 << (2 * (N_DISK - d) + 1)); } else { - int ialpha = tracklet->ialphadisk(d).value(); - int nalpha = tracklet->ialphadisk(d).nbits(); + int ialpha = diskResid.ialpha().value(); + int nalpha = diskResid.ialpha().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -239,13 +241,13 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: diskmask |= (1 << (2 * (N_DISK - d))); mult = mult << settings_.alphaBitsTable(); } - alpha[ndisks] = tracklet->alphadisk(d); - phiresid[nlayers + ndisks] = tracklet->phiresidapproxdisk(d); - zresid[nlayers + ndisks] = tracklet->rresidapproxdisk(d); - phiresidexact[nlayers + ndisks] = tracklet->phiresiddisk(d); - zresidexact[nlayers + ndisks] = tracklet->rresiddisk(d); - iphiresid[nlayers + ndisks] = tracklet->fpgaphiresiddisk(d).value(); - izresid[nlayers + ndisks] = tracklet->fpgarresiddisk(d).value(); + alpha[ndisks] = diskResid.alpha(); + phiresid[nlayers + ndisks] = diskResid.phiresidapprox(); + zresid[nlayers + ndisks] = diskResid.rresidapprox(); + phiresidexact[nlayers + ndisks] = diskResid.phiresid(); + zresidexact[nlayers + ndisks] = diskResid.rresid(); + iphiresid[nlayers + ndisks] = diskResid.fpgaphiresid().value(); + izresid[nlayers + ndisks] = diskResid.fpgarresid().value(); disks[ndisks++] = d; } @@ -265,13 +267,13 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - - phiresid[nlayers] = tracklet->phiresidapprox(l); - zresid[nlayers] = tracklet->zresidapprox(l); - phiresidexact[nlayers] = tracklet->phiresid(l); - zresidexact[nlayers] = tracklet->zresid(l); - iphiresid[nlayers] = tracklet->fpgaphiresid(l).value(); - izresid[nlayers] = tracklet->fpgazresid(l).value(); + const LayerResidual& layerResid = tracklet->layerResid(l); + phiresid[nlayers] = layerResid.phiresidapprox(); + zresid[nlayers] = layerResid.zresidapprox(); + phiresidexact[nlayers] = layerResid.phiresid(); + zresidexact[nlayers] = layerResid.zresid(); + iphiresid[nlayers] = layerResid.fpgaphiresid().value(); + izresid[nlayers] = layerResid.fpgazresid().value(); layers[nlayers++] = l; } @@ -297,12 +299,13 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - if (std::abs(tracklet->alphadisk(d)) < 1e-20) { + const DiskResidual& diskResid = tracklet->diskResid(d); + if (std::abs(diskResid.alpha()) < 1e-20) { dmatches.set(2 * d1 - 1); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); } else { - int ialpha = tracklet->ialphadisk(d).value(); - int nalpha = tracklet->ialphadisk(d).nbits(); + int ialpha = diskResid.ialpha().value(); + int nalpha = diskResid.ialpha().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -313,15 +316,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: mult = mult << settings_.alphaBitsTable(); } - alpha[ndisks] = tracklet->alphadisk(d); - assert(std::abs(tracklet->phiresidapproxdisk(d)) < 0.2); - phiresid[nlayers + ndisks] = tracklet->phiresidapproxdisk(d); - zresid[nlayers + ndisks] = tracklet->rresidapproxdisk(d); - assert(std::abs(tracklet->phiresiddisk(d)) < 0.2); - phiresidexact[nlayers + ndisks] = tracklet->phiresiddisk(d); - zresidexact[nlayers + ndisks] = tracklet->rresiddisk(d); - iphiresid[nlayers + ndisks] = tracklet->fpgaphiresiddisk(d).value(); - izresid[nlayers + ndisks] = tracklet->fpgarresiddisk(d).value(); + alpha[ndisks] = diskResid.alpha(); + assert(std::abs(diskResid.phiresidapprox()) < 0.2); + phiresid[nlayers + ndisks] = diskResid.phiresidapprox(); + zresid[nlayers + ndisks] = diskResid.rresidapprox(); + assert(std::abs(diskResid.phiresid()) < 0.2); + phiresidexact[nlayers + ndisks] = diskResid.phiresid(); + zresidexact[nlayers + ndisks] = diskResid.rresid(); + iphiresid[nlayers + ndisks] = diskResid.fpgaphiresid().value(); + izresid[nlayers + ndisks] = diskResid.fpgarresid().value(); disks[ndisks++] = d; } @@ -339,14 +342,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (tracklet->match(l)) { lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - assert(std::abs(tracklet->phiresidapprox(l)) < 0.2); - phiresid[nlayers] = tracklet->phiresidapprox(l); - zresid[nlayers] = tracklet->zresidapprox(l); - assert(std::abs(tracklet->phiresid(l)) < 0.2); - phiresidexact[nlayers] = tracklet->phiresid(l); - zresidexact[nlayers] = tracklet->zresid(l); - iphiresid[nlayers] = tracklet->fpgaphiresid(l).value(); - izresid[nlayers] = tracklet->fpgazresid(l).value(); + const LayerResidual& layerResid = tracklet->layerResid(l); + assert(std::abs(layerResid.phiresidapprox()) < 0.2); + phiresid[nlayers] = layerResid.phiresidapprox(); + zresid[nlayers] = layerResid.zresidapprox(); + assert(std::abs(layerResid.phiresid()) < 0.2); + phiresidexact[nlayers] = layerResid.phiresid(); + zresidexact[nlayers] = layerResid.zresid(); + iphiresid[nlayers] = layerResid.fpgaphiresid().value(); + izresid[nlayers] = layerResid.fpgazresid().value(); layers[nlayers++] = l; } @@ -369,14 +373,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - if (std::abs(tracklet->alphadisk(d)) < 1e-20) { + const DiskResidual& diskResid = tracklet->diskResid(d); + if (std::abs(diskResid.alpha()) < 1e-20) { dmatches.set(2 * (N_DISK - d1)); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); FPGAWord tmp; tmp.set(diskmask, 10); } else { - int ialpha = tracklet->ialphadisk(d).value(); - int nalpha = tracklet->ialphadisk(d).nbits(); + int ialpha = diskResid.ialpha().value(); + int nalpha = diskResid.ialpha().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -389,15 +394,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: mult = mult << settings_.alphaBitsTable(); } - alpha[ndisks] = tracklet->alphadisk(d); - assert(std::abs(tracklet->phiresidapproxdisk(d)) < 0.2); - phiresid[nlayers + ndisks] = tracklet->phiresidapproxdisk(d); - zresid[nlayers + ndisks] = tracklet->rresidapproxdisk(d); - assert(std::abs(tracklet->phiresiddisk(d)) < 0.2); - phiresidexact[nlayers + ndisks] = tracklet->phiresiddisk(d); - zresidexact[nlayers + ndisks] = tracklet->rresiddisk(d); - iphiresid[nlayers + ndisks] = tracklet->fpgaphiresiddisk(d).value(); - izresid[nlayers + ndisks] = tracklet->fpgarresiddisk(d).value(); + alpha[ndisks] = diskResid.alpha(); + assert(std::abs(diskResid.phiresidapprox()) < 0.2); + phiresid[nlayers + ndisks] = diskResid.phiresidapprox(); + zresid[nlayers + ndisks] = diskResid.rresidapprox(); + assert(std::abs(diskResid.phiresid()) < 0.2); + phiresidexact[nlayers + ndisks] = diskResid.phiresid(); + zresidexact[nlayers + ndisks] = diskResid.rresid(); + iphiresid[nlayers + ndisks] = diskResid.fpgaphiresid().value(); + izresid[nlayers + ndisks] = diskResid.fpgarresid().value(); disks[ndisks++] = d; } @@ -456,8 +461,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (layers[i] == tracklet->layer() + 1) { realrstub[i] = tracklet->outerStub()->r(); } - if (tracklet->validResid(layers[i]) && layers[i] < 4) { - const Stub* stubptr = tracklet->stubptr(layers[i]); + if (tracklet->match(layers[i]) && layers[i] < 4) { + const Stub* stubptr = tracklet->layerResid(layers[i]).stubptr(); realrstub[i] = stubptr->l1tstub()->r(); assert(std::abs(realrstub[i] - r[i]) < 5.0); } diff --git a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc index 1f43b6a1f0439..68cdd5a6a7473 100644 --- a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc @@ -46,21 +46,7 @@ void FullMatchMemory::writeMC(bool first) { oss << dirM << "FullMatches_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirM)) { - int fail = system((string("mkdir -p ") + dirM).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirM; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirM, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/HybridFit.cc b/L1Trigger/TrackFindingTracklet/src/HybridFit.cc index 5690cfbe8eaa9..656e6e537e291 100644 --- a/L1Trigger/TrackFindingTracklet/src/HybridFit.cc +++ b/L1Trigger/TrackFindingTracklet/src/HybridFit.cc @@ -75,7 +75,7 @@ void HybridFit::Fit(Tracklet* tracklet, std::vector& trackstublist) double alpha = L1stubptr->alpha(settings_.stripPitch(psmodule)); bool isTilted = L1stubptr->isTilted(); - bool isBarrel = trackstublist[k]->isBarrel(); + bool isBarrel = trackstublist[k]->layerdisk() @@ -23,66 +23,34 @@ InputLinkMemory::InputLinkMemory(string name, Settings const& settings, unsigned layerdisk_ = initLayerDisk(3); } -bool InputLinkMemory::addStub( - Settings const& settings, Globals* globals, L1TStub& al1stub, Stub& stub, string dtc = "") { - if (layerdisk_ < N_LAYER && globals->phiCorr(layerdisk_) == nullptr) { - globals->phiCorr(layerdisk_) = new VMRouterPhiCorrTable(settings); - int nbits = 3; - if (layerdisk_ >= N_PSLAYER) - nbits = 4; - globals->phiCorr(layerdisk_)->init(layerdisk_ + 1, nbits, 3); - } +void InputLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { - unsigned int stublayerdisk = stub.layerdisk(); - assert(stublayerdisk < 11); - - if (stublayerdisk != layerdisk_) - return false; - - if (layerdisk_ < N_LAYER) { - FPGAWord r = stub.r(); - int bendbin = stub.bend().value(); - int rbin = (r.value() + (1 << (r.nbits() - 1))) >> (r.nbits() - 3); - const VMRouterPhiCorrTable& phiCorrTable = *globals->phiCorr(layerdisk_); - int iphicorr = phiCorrTable.getphiCorrValue(bendbin, rbin); - stub.setPhiCorr(iphicorr); - } + //Various consistency checks + unsigned int stublayerdisk = stub.layerdisk(); + assert(stublayerdisk == layerdisk_); + FPGAWord iphi = stub.phicorr(); unsigned int nallbits = settings_.nbitsallstubs(layerdisk_); int phibin = iphi.bits(iphi.nbits() - nallbits, nallbits); int iphivmRaw = iphi.bits(iphi.nbits() - 5, 5); - if (phibin != phiregion_) - return false; - - if (getName().substr(10, dtc.size()) != dtc) - return false; - - string half = getName().substr(getName().size() - 3, 3); - if (half[1] != 'n') { - half = getName().substr(getName().size() - 1, 1); - } - - assert(half[0] == 'A' || half[0] == 'B'); - - if (half[0] == 'B' && iphivmRaw <= 15) - return false; - if (half[0] == 'A' && iphivmRaw > 15) - return false; + assert ( phibin==phiregion_); if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Will add stub in " << getName() << " " << "iphiwmRaw = " << iphivmRaw << " phi=" << al1stub.phi() << " z=" << al1stub.z() << " r=" << al1stub.r(); } + + //Make new objects owned by the inputlink memory and save in list of stubs if (stubs_.size() < settings_.maxStep("Link")) { Stub* stubptr = new Stub(stub); stubptr->setl1tstub(new L1TStub(al1stub)); stubs_.emplace_back(stubptr); } - return true; + } void InputLinkMemory::writeStubs(bool first) { diff --git a/L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc b/L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc new file mode 100644 index 0000000000000..a44c84135da00 --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc @@ -0,0 +1,38 @@ +#include "L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +using namespace std; +using namespace trklet; + +L1SimTrack::L1SimTrack() { + eventid_ = -1; + trackid_ = -1; +} + +L1SimTrack::L1SimTrack( + int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz) { + eventid_ = eventid; + trackid_ = trackid; + type_ = type; + pt_ = pt; + eta_ = eta; + phi_ = phi; + vx_ = vx; + vy_ = vy; + vz_ = vz; +} + +void L1SimTrack::write(ofstream& out) { + if (pt_ > -2.0) { + out << "SimTrack: " << eventid_ << "\t" << trackid_ << "\t" << type_ << "\t" << pt_ << "\t" << eta_ << "\t" << phi_ + << "\t" << vx_ << "\t" << vy_ << "\t" << vz_ << "\t" << endl; + } +} + +void L1SimTrack::write(ostream& out) { + if (pt_ > -2) { + out << "SimTrack: " << eventid_ << "\t" << trackid_ << "\t" << type_ << "\t" << pt_ << "\t" << eta_ << "\t" << phi_ + << "\t" << vx_ << "\t" << vy_ << "\t" << vz_ << "\t" << endl; + } +} + diff --git a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc index 1ae8497e75396..798945775f13b 100644 --- a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc +++ b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc @@ -6,58 +6,53 @@ using namespace trklet; L1TStub::L1TStub() {} -L1TStub::L1TStub(int eventid, - vector tps, - int iphi, - int iz, - int layer, - int ladder, - int module, - int strip, - double x, - double y, - double z, - double sigmax, - double sigmaz, - double pt, - double bend, - int isPSmodule, - int isFlipped) { - eventid_ = eventid; +L1TStub::L1TStub(std::string DTClink, + int region, + int layerdisk, + std::string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + std::vector tps){ + DTClink_=DTClink; + layerdisk_=layerdisk; + region_=region; + stubword_ = stubword; + eventid_ = -1; tps_ = tps; - iphi_ = iphi; - iz_ = iz; - layer_ = layer; - ladder_ = ladder; - module_ = module; + iphi_ = -1; + iz_ = -1; + layer_ = layerdisk; + if (layerdisk>5) { + layer_=1000+layerdisk-5; + if (z<0.0) layer_+=1000; + } + + ladder_ = -1; + module_ = -1; strip_ = strip; x_ = x; y_ = y; z_ = z; - sigmax_ = sigmax; - sigmaz_ = sigmaz; - pt_ = pt; + sigmax_ = -1.0; + sigmaz_ = -1.0; + pt_ = -1.0; bend_ = bend; isPSmodule_ = isPSmodule; isFlipped_ = isFlipped; allstubindex_ = 999; -} -void L1TStub::write(ofstream& out) { - out << "Stub: " << layer_ + 1 << "\t" << ladder_ << "\t" << module_ << "\t" << strip_ << "\t" << eventid_ << "\t" - << pt_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << isPSmodule_ << "\t" << isFlipped_ - << "\t" << tps_.size() << " \t"; - for (int itp : tps_) { - out << itp << " \t"; - } - out << endl; } -void L1TStub::write(ostream& out) { - out << "Stub: " << layer_ + 1 << "\t" << ladder_ << "\t" << module_ << "\t" << strip_ << "\t" << eventid_ << "\t" - << pt_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << isPSmodule_ << "\t" << isFlipped_ - << "\t" << tps_.size() << " \t"; + +void L1TStub::write(ofstream& out) { + out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_ << "\t" << isFlipped_ << "\t" + << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t" << "\t" << tps_.size() << " \t"; for (int itp : tps_) { out << itp << " \t"; } @@ -107,13 +102,28 @@ void L1TStub::setXY(double x, double y) { bool L1TStub::tpmatch(int tp) const { for (int itp : tps_) { - if (tp == itp) + if (tp == std::abs(itp)) return true; } return false; } +bool L1TStub::tpmatch2(int tp) const { + bool match1=false; + bool match2=false; + for (int itp : tps_) { + if (tp == itp) { + match1=true; + } + if (tp == -itp) { + match2=true; + } + } + + return match1&&match2; +} + bool L1TStub::isTilted() const { //here layer_ runs 0-5 for barrel, >1000 for disk //disk modules and outer barrel modules are not tilted by construction diff --git a/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc b/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc index 83cb116eacb6a..67a50bb9af916 100644 --- a/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc +++ b/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc @@ -1,3 +1,4 @@ + #include "L1Trigger/TrackFindingTracklet/interface/LayerProjection.h" #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" @@ -8,7 +9,6 @@ using namespace trklet; void LayerProjection::init(Settings const& settings, int projlayer, - double rproj, int iphiproj, int izproj, int iphider, @@ -26,35 +26,18 @@ void LayerProjection::init(Settings const& settings, assert(projlayer <= N_LAYER); valid_ = true; - - rproj_ = rproj; - + projlayer_ = projlayer; + unsigned int layerdisk = projlayer-1; + + fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); + fpgazproj_.set(izproj, settings.nzbitsstub(layerdisk), false, __LINE__, __FILE__); - assert(iphiproj >= 0); - if (rproj < settings.rPS2S()) { - fpgaphiproj_.set(iphiproj, settings.nphibitsstub(0), true, __LINE__, __FILE__); - int iphivm = (iphiproj >> (settings.nphibitsstub(0) - 5)) & 0x7; - if ((projlayer_ % 2) == 1) { - iphivm ^= 4; - } - fpgaphiprojvm_.set(iphivm, 3, true, __LINE__, __FILE__); - fpgazproj_.set(izproj, settings.nzbitsstub(0), false, __LINE__, __FILE__); - int izvm = izproj >> (12 - 7) & 0xf; - fpgazprojvm_.set(izvm, 4, true, __LINE__, __FILE__); + if (layerdisk < N_PSLAYER) { fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); fpgazprojder_.set(izder, settings.nbitszprojderL123(), false, __LINE__, __FILE__); } else { - fpgaphiproj_.set(iphiproj, settings.nphibitsstub(5), true, __LINE__, __FILE__); - int iphivm = (iphiproj >> (settings.nphibitsstub(5) - 5)) & 0x7; - if ((projlayer_ % 2) == 1) { - iphivm ^= 4; - } - fpgaphiprojvm_.set(iphivm, 3, true, __LINE__, __FILE__); - fpgazproj_.set(izproj, settings.nzbitsstub(5), false, __LINE__, __FILE__); - int izvm = izproj >> (8 - 7) & 0xf; - fpgazprojvm_.set(izvm, 4, true, __LINE__, __FILE__); fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL456(), false, __LINE__, __FILE__); fpgazprojder_.set(izder, settings.nbitszprojderL456(), false, __LINE__, __FILE__); } @@ -63,34 +46,37 @@ void LayerProjection::init(Settings const& settings, ////This determines the central bin: ////int zbin=4+(zproj.value()>>(zproj.nbits()-3)); ////But we need some range (particularly for L5L6 seed projecting to L1-L3): - int offset = 4; - if (isPSseed) { - offset = 1; - } - unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + - (((fpgazproj_.value() >> (fpgazproj_.nbits() - settings.MEBinsBits() - 3)) - offset) >> 3); - unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + - (((fpgazproj_.value() >> (fpgazproj_.nbits() - settings.MEBinsBits() - 3)) + offset) >> 3); + int offset = isPSseed?1:4; + + int ztemp = fpgazproj_.value() >> (fpgazproj_.nbits() - settings.MEBinsBits() - NFINERZBITS); + unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp - offset) >> NFINERZBITS); + unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp + offset) >> NFINERZBITS); + if (zbin1 >= settings.MEBins()) { zbin1 = 0; //note that zbin1 is unsigned } - if (zbin2 >= settings.MEBins()) + if (zbin2 >= settings.MEBins()) { zbin2 = settings.MEBins() - 1; + } + assert(zbin1 <= zbin2); assert(zbin2 - zbin1 <= 1); + fpgazbin1projvm_.set(zbin1, settings.MEBinsBits(), true, __LINE__, __FILE__); // first z bin - if (zbin1 == zbin2) - fpgazbin2projvm_.set(0, 1, true, __LINE__, __FILE__); // don't need to check adjacent z bin - else - fpgazbin2projvm_.set(1, 1, true, __LINE__, __FILE__); // do need to check next z bin - //fine vm z bits. Use 4 bits for fine position. starting at zbin 1 - int finez = ((1 << (settings.MEBinsBits() + 2)) + - (fpgazproj_.value() >> (fpgazproj_.nbits() - (settings.MEBinsBits() + 3)))) - - (zbin1 << 3); + int nextbin = zbin1 != zbin2; + fpgazbin2projvm_.set(nextbin, 1, true, __LINE__, __FILE__); // need to check adjacent z bin? - fpgafinezvm_.set(finez, 4, true, __LINE__, __FILE__); // fine z postions starting at zbin1 //FIXME using 3 bits + //fine vm z bits. Use 4 bits for fine position. starting at zbin 1 + int finez = ((1 << (settings.MEBinsBits() + NFINERZBITS - 1)) + ztemp) - (zbin1 << NFINERZBITS); + + fpgafinezvm_.set(finez, NFINERZBITS+1, true, __LINE__, __FILE__); // fine z postions starting at zbin1 + //fine phi bits + int projfinephi = (fpgaphiproj_.value() >> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(projlayer_) + settings.nbitsvmme(projlayer_) + NFINEPHIBITS ))) & ((1<= N_LAYER && settings_.writeTable()) { - if (not std::filesystem::exists(settings_.tablePath())) { - int fail = system((string("mkdir -p ") + settings_.tablePath()).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " - << settings_.tablePath(); - } - const string filePSphicut = settings_.tablePath() + getName() + "_PSphicut.tab"; - ofstream outPSphicut(filePSphicut); - if (outPSphicut.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << filePSphicut; + ofstream outPSphicut=openfile(settings_.tablePath(), getName() + "_PSphicut.tab", __FILE__, __LINE__); + outPSphicut << "{" << endl; for (unsigned int seedindex = 0; seedindex < N_SEED; seedindex++) { if (seedindex != 0) @@ -116,10 +99,8 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* outPSphicut << endl << "};" << endl; outPSphicut.close(); - const string file2Sphicut = settings_.tablePath() + getName() + "_2Sphicut.tab"; - ofstream out2Sphicut(file2Sphicut); - if (out2Sphicut.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << file2Sphicut; + ofstream out2Sphicut=openfile(settings_.tablePath(), getName() + "_2Sphicut.tab", __FILE__, __LINE__); + out2Sphicut << "{" << endl; for (unsigned int seedindex = 0; seedindex < N_SEED; seedindex++) { if (seedindex != 0) @@ -236,13 +217,15 @@ void MatchCalculator::execute() { if (layerdisk_ < N_LAYER) { //Integer calculation + const LayerProjection& layerProj = tracklet->layerProj(layerdisk_+1); + int ir = fpgastub->r().value(); - int iphi = tracklet->fpgaphiproj(layerdisk_ + 1).value(); - int icorr = (ir * tracklet->fpgaphiprojder(layerdisk_ + 1).value()) >> icorrshift_; + int iphi = layerProj.fpgaphiproj().value(); + int icorr = (ir * layerProj.fpgaphiprojder().value()) >> icorrshift_; iphi += icorr; - int iz = tracklet->fpgazproj(layerdisk_ + 1).value(); - int izcor = (ir * tracklet->fpgazprojder(layerdisk_ + 1).value() + (1 << (icorzshift_ - 1))) >> icorzshift_; + int iz = layerProj.fpgazproj().value(); + int izcor = (ir * layerProj.fpgazprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_; iz += izcor; int ideltaz = fpgastub->z().value() - iz; @@ -265,18 +248,18 @@ void MatchCalculator::execute() { if (phi < 0) phi += 2 * M_PI; - double dr = r - tracklet->rproj(layerdisk_ + 1); + double dr = r - settings_.rmean(layerdisk_); assert(std::abs(dr) < settings_.drmax()); double dphi = - reco::reduceRange(phi - (tracklet->phiproj(layerdisk_ + 1) + dr * tracklet->phiprojder(layerdisk_ + 1))); + reco::reduceRange(phi - (layerProj.phiproj() + dr * layerProj.phiprojder())); - double dz = z - (tracklet->zproj(layerdisk_ + 1) + dr * tracklet->zprojder(layerdisk_ + 1)); + double dz = z - (layerProj.zproj() + dr * layerProj.zprojder()); double dphiapprox = reco::reduceRange( - phi - (tracklet->phiprojapprox(layerdisk_ + 1) + dr * tracklet->phiprojderapprox(layerdisk_ + 1))); + phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); - double dzapprox = z - (tracklet->zprojapprox(layerdisk_ + 1) + dr * tracklet->zprojderapprox(layerdisk_ + 1)); + double dzapprox = z - (layerProj.zprojapprox() + dr * layerProj.zprojderapprox()); int seedindex = tracklet->getISeed(); @@ -296,13 +279,26 @@ void MatchCalculator::execute() { truthmatch); } - if (std::abs(dphi) > 0.2 || std::abs(dphiapprox) > 0.2) { - edm::LogProblem("Tracklet") << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox - << endl; + + //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_) << " " + << phimatchcut_[seedindex] * settings_.kphi1() * settings_.rmean(layerdisk_) << " " + << ideltaz * fact_ * settings_.kz() << " " << dz << " " << zmatchcut_[seedindex] * settings_.kz() << endl; } bool imatch = false; - if (std::abs(dphi) < 0.2 && std::abs(dphiapprox) < 0.2) { //Changed the Asserts into if statements + if(std::abs(dphi) < 0.2 && std::abs(dphiapprox) < 0.2){ //Changed the Asserts into if statements if (settings_.writeMonitorData("Residuals")) { double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); @@ -314,8 +310,8 @@ void MatchCalculator::execute() { << ideltaz * fact_ * settings_.kz() << " " << dz << " " << zmatchcut_[seedindex] * settings_.kz() << endl; } - imatch = (std::abs(ideltaphi) <= (int)phimatchcut_[seedindex]) && - (std::abs(ideltaz * fact_) <= (int)zmatchcut_[seedindex]); + imatch = (std::abs(ideltaphi) <= (int)phimatchcut_[seedindex]) && + (std::abs(ideltaz * fact_) <= (int)zmatchcut_[seedindex]); } if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " ideltaphi cut " << ideltaphi << " " @@ -355,20 +351,22 @@ void MatchCalculator::execute() { //Perform integer calculations here + const DiskProjection& diskProj = tracklet->diskProj(disk); + int iz = fpgastub->z().value(); - int iphi = tracklet->fpgaphiprojdisk(disk).value(); + int iphi = diskProj.fpgaphiproj().value(); //TODO - need to express interms of constants int shifttmp = 6; - int iphicorr = (iz * tracklet->fpgaphiprojderdisk(disk).value()) >> shifttmp; + int iphicorr = (iz * diskProj.fpgaphiprojder().value()) >> shifttmp; iphi += iphicorr; - int ir = tracklet->fpgarprojdisk(disk).value(); + int ir = diskProj.fpgarproj().value(); //TODO - need to express interms of constants int shifttmp2 = 7; - int ircorr = (iz * tracklet->fpgarprojderdisk(disk).value()) >> shifttmp2; + int ircorr = (iz * diskProj.fpgarprojder().value()) >> shifttmp2; ir += ircorr; @@ -421,9 +419,9 @@ void MatchCalculator::execute() { << "\n stub " << stub->z() << " disk " << disk << " " << dz; } - double phiproj = tracklet->phiprojdisk(disk) + dz * tracklet->phiprojderdisk(disk); + double phiproj = diskProj.phiproj() + dz * diskProj.phiprojder(); - double rproj = tracklet->rprojdisk(disk) + dz * tracklet->rprojderdisk(disk); + double rproj = diskProj.rproj() + dz * diskProj.rprojder(); double deltar = r - rproj; @@ -432,9 +430,9 @@ void MatchCalculator::execute() { double dphi = reco::reduceRange(phi - phiproj); double dphiapprox = - reco::reduceRange(phi - (tracklet->phiprojapproxdisk(disk) + dz * tracklet->phiprojderapproxdisk(disk))); + reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); - double drapprox = stub->r() - (tracklet->rprojapproxdisk(disk) + dz * tracklet->rprojderapproxdisk(disk)); + double drapprox = stub->r() - (diskProj.rprojapprox() + dz * diskProj.rprojderapprox()); double drphi = dphi * stub->r(); double drphiapprox = dphiapprox * stub->r(); @@ -461,7 +459,7 @@ void MatchCalculator::execute() { double drcut = idrcut * settings_.krprojshiftdisk(); bool match, imatch; - if (std::abs(dphi) < 0.25 && std::abs(dphiapprox) < 0.25) { //Changed the Asserts into if statements + if(std::abs(dphi) < 0.25 && std::abs(dphiapprox) < 0.25){ //Changed the Asserts into if statements if (settings_.writeMonitorData("Residuals")) { double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); @@ -474,9 +472,10 @@ void MatchCalculator::execute() { match = (std::abs(drphi) < drphicut) && (std::abs(deltar) < drcut); imatch = (std::abs(ideltaphi * irstub) < idrphicut) && (std::abs(ideltar) < idrcut); - } else { + } + else{ edm::LogProblem("Tracklet") << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox - << "dphi " << dphi << " Seed / ISeed " << tracklet->getISeed() << endl; + << "dphi " << dphi << " Seed / ISeed " << tracklet->getISeed()<< endl; match = false; imatch = false; } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index 0e528803e2747..1a50d89369906 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -17,62 +17,46 @@ using namespace trklet; MatchEngine::MatchEngine(string name, Settings const& settings, Globals* global, unsigned int iSector) : ProcessBase(name, settings, global, iSector) { - layer_ = 0; - disk_ = 0; - string subname = name.substr(3, 2); - if (subname.substr(0, 1) == "L") - layer_ = stoi(subname.substr(1, 1)); - else if (subname.substr(0, 1) == "D") - disk_ = stoi(subname.substr(1, 1)); - else - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " " << name << " subname = " << subname << " " - << layer_ << " " << disk_; - - barrel_ = layer_ > 0; - - nvm_ = barrel_ ? settings_.nvmme(layer_ - 1) * settings_.nallstubs(layer_ - 1) - : settings_.nvmme(disk_ + N_LAYER - 1) * settings_.nallstubs(disk_ + N_LAYER - 1); - - if (nvm_ == 32) - nvmbits_ = 5; - else if (nvm_ == 16) - nvmbits_ = 4; - - if (layer_ > 0) { - unsigned int nbits = 3; - if (layer_ >= 4) - nbits = 4; - - for (unsigned int irinv = 0; irinv < 32; irinv++) { - double rinv = (irinv - 15.5) * (1 << (settings_.nbitsrinv() - 5)) * settings_.krinvpars(); - - double stripPitch = - (settings_.rmean(layer_ - 1) < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double projbend = bend(settings_.rmean(layer_ - 1), rinv, stripPitch); - for (unsigned int ibend = 0; ibend < (unsigned int)(1 << nbits); ibend++) { - double stubbend = benddecode(ibend, layer_ <= 3); - bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(layer_ - 1); + + layerdisk_ = initLayerDisk(3); + + barrel_ = layerdisk_ < N_LAYER; + + nvm_=settings_.nvmme(layerdisk_)*settings_.nallstubs(layerdisk_); + + nvmbits_=settings_.nbitsvmme(layerdisk_)+settings_.nbitsallstubs(layerdisk_); + + nrinv_=NRINVBITS; + double rinvhalf=0.5*((1< 0) { - for (unsigned int iprojbend = 0; iprojbend < 32; iprojbend++) { - double projbend = 0.5 * (iprojbend - 15.0); - for (unsigned int ibend = 0; ibend < 8; ibend++) { - double stubbend = benddecode(ibend, true); - bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(disk_ + 5); + if (layerdisk_ >= N_LAYER) { + for (unsigned int iprojbend = 0; iprojbend < (1u<zbin1projvm(layer_) : proj->rbin1projvm(disk_); + unsigned int rzfirst = barrel_ ? proj->layerProj(layerdisk_+1).fpgazbin1projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin1projvm().value(); unsigned int rzlast = rzfirst; - bool second = (barrel_ ? proj->zbin2projvm(layer_) : proj->rbin2projvm(disk_)) == 1; + bool second = barrel_ ? proj->layerProj(layerdisk_+1).fpgazbin2projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin2projvm().value(); if (second) rzlast += 1; + if (print) { + cout << "istep rzfirst rzlast : "<nStubsBin(rzfirst); int nstublast = vmstubs_->nStubsBin(rzlast); @@ -247,31 +238,32 @@ void MatchEngine::execute() { Tracklet* proj = vmprojs_->getTracklet(projindex); - FPGAWord fpgaphi = barrel_ ? proj->fpgaphiproj(layer_) : proj->fpgaphiprojdisk(disk_); - projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + 3))) & 7; + FPGAWord fpgafinephi = barrel_ ? proj->layerProj(layerdisk_+1).fpgafinephivm() : proj->diskProj(layerdisk_-5).fpgafinephivm(); + + projfinephi = fpgafinephi.value(); nstubs = vmstubs_->nStubsBin(rzbin); - projfinerz = barrel_ ? proj->finezvm(layer_) : proj->finervm(disk_); + projfinerz = barrel_ ? proj->layerProj(layerdisk_+1).fpgafinezvm().value() : proj->diskProj(layerdisk_-5).fpgafinervm().value(); projrinv = barrel_ - ? (16 + (((-2) * proj->fpgaphiprojder(layer_).value()) >> (proj->fpgaphiprojder(layer_).nbits() - 4))) - : proj->getBendIndex(disk_).value(); + ? ((1<<(nrinv_-1)) + ((-2*proj->layerProj(layerdisk_+1).fpgaphiprojder().value()) >> (proj->layerProj(layerdisk_+1).fpgaphiprojder().nbits() - (nrinv_-1)))) + : proj->diskProj(layerdisk_-5).getBendIndex().value(); assert(projrinv >= 0); - if (settings_.extended() && projrinv == 32) { + if (settings_.extended() && projrinv == (1<PSseed() == 1; + isPSseed = proj->PSseed(); //Calculate fine z position if (second) { - projfinerzadj = projfinerz - 8; + projfinerzadj = projfinerz - (1< 5); + 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 (layerdisk_>5) { + // cout << "layerdisk: "<= -2 && idrz <= 2; + constexpr int drzcut=1; + passz = std::abs(idrz) <= drzcut; } else { - passz = idrz >= -5 && idrz <= 5; + constexpr int drzcut=5; + passz = std::abs(idrz) <= drzcut; } } else { if (isPSmodule) { - passz = idrz >= -1 && idrz <= 1; + constexpr int drzcut=1; + passz = std::abs(idrz) <= drzcut; } else { - passz = idrz >= -5 && idrz <= 5; + constexpr int drzcut=3; + passz = std::abs(idrz) <= drzcut; } } + if (print) { + cout << "istep index : "< table, vector tablePS, vector table2S) +MatchEngineUnit::MatchEngineUnit(bool barrel, unsigned int layerdisk, vector table) : candmatches_(5) { idle_ = true; barrel_ = barrel; table_ = table; - tablePS_ = tablePS; - table2S_ = table2S; slot_ = 1; //This makes it idle until initialized + layerdisk_=layerdisk; } void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, @@ -18,6 +17,7 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, int projrinv, int projfinerz, int projfinephi, + int shift, bool usesecond, bool isPSseed, Tracklet* proj) { @@ -28,6 +28,7 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, projrinv_ = projrinv; projfinerz_ = projfinerz; projfinephi_ = projfinephi; + shift_ = shift; usesecond_ = usesecond; isPSseed_ = isPSseed; proj_ = proj; @@ -43,13 +44,15 @@ void MatchEngineUnit::step() { int stubfinerz = vmstub.finerz().value(); int stubfinephi = vmstub.finephi().value(); - int deltaphi = stubfinephi - projfinephi_; + int deltaphi = stubfinephi - projfinephi_ + (1< 5); //TODO - need better implementations + bool dphicut = (abs(deltaphi) < 3); int nbits = isPSmodule ? 3 : 4; - unsigned int index = (projrinv_ << nbits) + vmstub.bend().value(); + int diskps = (!barrel_)&&isPSmodule; + + unsigned int index = (diskps<<(4+5)) + (projrinv_ << nbits) + vmstub.bend().value(); //Check if stub z position consistent int idrz = stubfinerz - projfinerz_; @@ -70,7 +73,7 @@ void MatchEngineUnit::step() { } //Check if stub bend and proj rinv consistent - if ((pass && dphicut) && (barrel_ ? table_[index] : (isPSmodule ? tablePS_[index] : table2S_[index]))) { + if ((pass && dphicut) && table_[index] ) { std::pair tmp(proj_, vmstub.stub()); candmatches_.store(tmp); } @@ -81,7 +84,7 @@ void MatchEngineUnit::step() { usesecond_ = false; istub_ = 0; slot_++; - projfinerz_ -= (1 << NFINERZBITS); + projfinerz_ -= (1<= 4) { - fact_ = (1 << (settings_.nzbitsstub(0) - settings_.nzbitsstub(5))); - icorrshift_ -= (10 - settings_.nrbitsstub(layer_ - 1)); - icorzshift_ += (settings_.nzbitsstub(0) - settings_.nzbitsstub(5) + settings_.nrbitsstub(layer_ - 1) - - settings_.nrbitsstub(0)); - phi0shift_ = 0; - } - + nrbits_ = 5; nphiderbits_ = 6; - //to adjust globaly the phi and rz matching cuts - phifact_ = 1.0; - rzfact_ = 1.0; + nrinv_=NRINVBITS; + double rinvhalf=0.5*((1< 0) { + if (layerdisk_ < N_LAYER) { phimatchcut_[iSeed] = - settings_.rphimatchcut(iSeed, layer_ - 1) / (settings_.kphi1() * settings_.rmean(layer_ - 1)); - zmatchcut_[iSeed] = settings_.zmatchcut(iSeed, layer_ - 1) / settings_.kz(); - } - if (disk_ != 0) { - rphicutPS_[iSeed] = settings_.rphicutPS(iSeed, abs(disk_) - 1) / (settings_.kphi() * settings_.kr()); - rphicut2S_[iSeed] = settings_.rphicut2S(iSeed, abs(disk_) - 1) / (settings_.kphi() * settings_.kr()); - rcut2S_[iSeed] = settings_.rcut2S(iSeed, abs(disk_) - 1) / settings_.krprojshiftdisk(); - rcutPS_[iSeed] = settings_.rcutPS(iSeed, abs(disk_) - 1) / settings_.krprojshiftdisk(); + settings_.rphimatchcut(iSeed, layerdisk_) / (settings_.kphi1() * settings_.rmean(layerdisk_)); + zmatchcut_[iSeed] = settings_.zmatchcut(iSeed, layerdisk_) / settings_.kz(); + } else { + rphicutPS_[iSeed] = settings_.rphicutPS(iSeed, layerdisk_ - N_LAYER) / (settings_.kphi() * settings_.kr()); + rphicut2S_[iSeed] = settings_.rphicut2S(iSeed, layerdisk_ - N_LAYER) / (settings_.kphi() * settings_.kr()); + rcut2S_[iSeed] = settings_.rcut2S(iSeed, layerdisk_ - N_LAYER) / settings_.krprojshiftdisk(); + rcutPS_[iSeed] = settings_.rcutPS(iSeed, layerdisk_ - N_LAYER) / settings_.krprojshiftdisk(); } } - if (iSector_ == 0 && layer_ > 0 && settings_.writeTable()) { - if (not std::filesystem::exists(settings_.tablePath())) { - int fail = system((string("mkdir -p ") + settings_.tablePath()).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " - << settings_.tablePath(); - } + if (iSector_ == 0 && barrel_ && settings_.writeTable()) { - const string filephicut = settings_.tablePath() + getName() + "_phicut.tab"; - ofstream outphicut(filephicut); - if (outphicut.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << filephicut; + ofstream outphicut=openfile(settings_.tablePath(), getName() + "_phicut.tab", __FILE__, __LINE__); outphicut << "{" << endl; for (unsigned int seedindex = 0; seedindex < 12; seedindex++) { @@ -83,10 +65,7 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g outphicut << endl << "};" << endl; outphicut.close(); - const string filezcut = settings_.tablePath() + getName() + "_zcut.tab"; - ofstream outzcut(filezcut); - if (outzcut.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << filezcut; + ofstream outzcut=openfile(settings_.tablePath(), getName() + "_zcut.tab", __FILE__, __LINE__); outzcut << "{" << endl; for (unsigned int seedindex = 0; seedindex < N_SEED; seedindex++) { @@ -98,68 +77,56 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g outzcut.close(); } - if (layer_ > 0) { - unsigned int nbits = 3; - if (layer_ >= 4) - nbits = 4; - - for (unsigned int irinv = 0; irinv < 32; irinv++) { - double rinv = (irinv - 15.5) * (1 << (settings_.nbitsrinv() - 5)) * settings_.krinvpars(); - double stripPitch = - (settings_.rmean(layer_ - 1) < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double projbend = bend(settings_.rmean(layer_ - 1), rinv, stripPitch); + if (barrel_) { + unsigned int nbits = (layerdisk_ < N_PSLAYER) ? N_BENDBITS_PS : N_BENDBITS_2S; + + for (unsigned int irinv = 0; irinv < (1u< 0) { + } else { + table_.resize(32*16*2,false); for (unsigned int iprojbend = 0; iprojbend < 32; iprojbend++) { - double projbend = 0.5 * (iprojbend - 15.0); + double projbend = 0.5 * (iprojbend - rinvhalf); for (unsigned int ibend = 0; ibend < 8; ibend++) { - double stubbend = benddecode(ibend, true); - bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(disk_ + 5); - tablePS_.push_back(pass); + double stubbend = settings_.benddecode(ibend, layerdisk_, true); + bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk_, true); + table_[512+8*iprojbend+ibend]=pass; } for (unsigned int ibend = 0; ibend < 16; ibend++) { - double stubbend = benddecode(ibend, false); - bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(disk_ + 5); - table2S_.push_back(pass); + double stubbend = settings_.benddecode(ibend, layerdisk_, false); + bool pass = std::abs(stubbend - projbend) < settings_.bendcutme(ibend, layerdisk_, false); + table_[16*iprojbend+ibend]=pass; } } } + + if (settings_.writeTable()) { + + char layerdisk = barrel_ ? '0' + layerdisk_ + 1 : '0' + layerdisk_ - N_LAYER + 1; + string fname = barrel_ ? "METable_L" : "METable_D"; + fname += layerdisk; + fname += ".tab"; + + ofstream out=openfile(settings_.tablePath(), fname, __FILE__, __LINE__); + out << "{" << endl; + for (unsigned int i = 0; i < table_.size(); i++) { + if (i != 0) { + out << "," << endl; + } + out << table_[i]; + } + out << "};" << endl; + out.close(); + } + 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)) / @@ -169,23 +136,22 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g settings_.kphi(); } - barrel_ = layer_ > 0; - - nvm_ = barrel_ ? settings_.nvmme(layer_ - 1) * settings_.nallstubs(layer_ - 1) - : settings_.nvmme(disk_ + 5) * settings_.nallstubs(disk_ + 5); - nvmbins_ = barrel_ ? settings_.nvmme(layer_ - 1) : settings_.nvmme(disk_ + 5); - - if (nvm_ == 32) - nvmbits_ = 5; - if (nvm_ == 16) - nvmbits_ = 4; - assert(nvmbits_ != -1); + nvm_ = settings_.nvmme(layerdisk_) * settings_.nallstubs(layerdisk_); + nvmbins_ = settings_.nvmme(layerdisk_); + nvmbits_ = settings_.nbitsvmme(layerdisk_)+settings_.nbitsallstubs(layerdisk_); nMatchEngines_ = 4; for (unsigned int iME = 0; iME < nMatchEngines_; iME++) { - MatchEngineUnit tmpME(barrel_, table_, tablePS_, table2S_); + MatchEngineUnit tmpME(barrel_, layerdisk_, table_); matchengines_.push_back(tmpME); } + + if (globals_->projectionRouterBendTable() == nullptr) { + auto* bendTablePtr = new ProjectionRouterBendTable(); + bendTablePtr->init(settings_, globals_, nrbits_, nphiderbits_); + globals_->projectionRouterBendTable() = bendTablePtr; + } + } void MatchProcessor::addOutput(MemoryBase* memory, string output) { @@ -234,12 +200,6 @@ void MatchProcessor::addInput(MemoryBase* memory, string input) { void MatchProcessor::execute() { assert(vmstubs_.size() == 1); - if (globals_->projectionRouterBendTable() == nullptr) { // move to constructor?! - auto* bendTablePtr = new ProjectionRouterBendTable(); - bendTablePtr->init(settings_, globals_, nrbits_, nphiderbits_); - globals_->projectionRouterBendTable() = bendTablePtr; - } - /* The code is organized in three 'steps' corresponding to the PR, ME, and MC functions. The output from the PR step is buffered in a 'circular' buffer, and similarly the ME output is put in a circular buffer. @@ -254,6 +214,8 @@ void MatchProcessor::execute() { */ + //bool print = getName()=="MP_L3PHIC" && iSector_==3; + Tracklet* oldTracklet = nullptr; unsigned int countme = 0; @@ -274,10 +236,7 @@ void MatchProcessor::execute() { matchengines_[iME].reset(); } - unsigned int step2delay = 0; - unsigned int step3delay = 0; - - for (unsigned int istep = 0; istep < settings_.maxStep("MP") + step3delay; istep++) { + for (unsigned int istep = 0; istep < settings_.maxStep("MP") ; istep++) { bool projdone = false; bool medone = true; //Step 1 @@ -296,60 +255,91 @@ void MatchProcessor::execute() { } Tracklet* proj = projMem->getTracklet(iproj); - FPGAWord fpgaphi = barrel_ ? proj->fpgaphiproj(layer_) : proj->fpgaphiprojdisk(disk_); - - int iphi = (fpgaphi.value() >> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); + FPGAWord fpgaphi = barrel_ ? proj->layerProj(layerdisk_+1).fpgaphiproj() : proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiproj(); + + unsigned int iphi = (fpgaphi.value() >> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); + + int nextrabits = 2; + int overlapbits = nvmbits_+nextrabits; + + unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits, nextrabits); + + unsigned int ivmPlus = iphi; + + int plusShift=0; + int negShift=0; + + + if (extrabits == ((1U << nextrabits) - 1) && iphi != ((1U << settings_.nbitsvmme(layerdisk_)) - 1)) { + plusShift = 1; + ivmPlus++; + } + unsigned int ivmMinus = iphi; + if (extrabits == 0 && iphi != 0){ + negShift = -1; + ivmMinus--; + } int projrinv = -1; if (barrel_) { - projrinv = (1 << (NRINVBITS - 1)) + (proj->fpgarinv().value() >> (proj->fpgarinv().nbits() - NRINVBITS)); + projrinv = (1<<(nrinv_-1)) + (proj->fpgarinv().value() >> (proj->fpgarinv().nbits() - nrinv_)); } else { //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->fpgarprojdisk(disk_).value() >> (proj->fpgarprojdisk(disk_).nbits() - nrbits_)) & + int rindex = (proj->diskProj(layerdisk_-N_LAYER+1).fpgarproj().value() >> (proj->diskProj(layerdisk_-N_LAYER+1).fpgarproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (proj->fpgaphiprojderdisk(disk_).value() >> - (proj->fpgaphiprojderdisk(disk_).nbits() - nphiderbits_)) & + int phiderindex = (proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiprojder().value() >> + (proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); - - int signindex = (proj->fpgarprojderdisk(disk_).value() < 0); + + int signindex = proj->diskProj(layerdisk_-N_LAYER+1).fpgarprojder().value() < 0; int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex; - projrinv = globals_->projectionRouterBendTable()->bendLoookup(abs(disk_) - 1, bendindex); + projrinv = globals_->projectionRouterBendTable()->bendLoookup(layerdisk_-N_LAYER, bendindex); - proj->setBendIndex(projrinv, disk_); + proj->diskProj(layerdisk_-N_LAYER+1).setBendIndex(projrinv); } assert(projrinv >= 0); - unsigned int slot = barrel_ ? proj->zbin1projvm(layer_) : proj->rbin1projvm(disk_); - bool second = (barrel_ ? proj->zbin2projvm(layer_) : proj->rbin2projvm(disk_)); + unsigned int slot = barrel_ ? proj->layerProj(layerdisk_+1).fpgazbin1projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin1projvm().value(); + bool second = (barrel_ ? proj->layerProj(layerdisk_+1).fpgazbin2projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin2projvm().value()); - int nfinephi = 3; - unsigned int projfinephi = - (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + nfinephi))) & ((1 << nfinephi) - 1); - int projfinerz = barrel_ ? proj->finezvm(layer_) : proj->finervm(disk_); + int nfinephi=3; + unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + nfinephi))) & ((1<layerProj(layerdisk_+1).fpgafinezvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgafinervm().value(); - bool isPSseed = proj->PSseed() == 1; + bool isPSseed = proj->PSseed(); int nbins = 8; if (layerdisk_ >= 6) nbins = 16; VMStubsMEMemory* stubmem = vmstubs_[0]; - bool usefirst = stubmem->nStubsBin(iphi * nbins + slot) != 0; - bool usesecond = (second && (stubmem->nStubsBin(iphi * nbins + slot + 1) != 0)); + bool usefirstPlus = stubmem->nStubsBin(ivmPlus * nbins + slot) != 0; + bool usesecondPlus = (second && (stubmem->nStubsBin(ivmPlus * nbins + slot + 1) != 0)); + bool usefirstMinus = stubmem->nStubsBin(ivmMinus * nbins + slot) != 0; + bool usesecondMinus = (second && (stubmem->nStubsBin(ivmMinus * nbins + slot + 1) != 0)); - if (usefirst) { - ProjectionTemp tmpProj(proj, slot, projrinv, projfinerz, projfinephi, iphi, usesecond, isPSseed); + if (usefirstPlus) { + ProjectionTemp tmpProj(proj, slot, projrinv, projfinerz, projfinephi, ivmPlus, plusShift, usesecondPlus, isPSseed); inputProjBuffer_.store(tmpProj); - } else if (usesecond) { - ProjectionTemp tmpProj(proj, slot + 1, projrinv, projfinerz - 8, projfinephi, iphi, false, isPSseed); + } else if (usesecondPlus) { + ProjectionTemp tmpProj(proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmPlus, plusShift, false, isPSseed); inputProjBuffer_.store(tmpProj); } + if (ivmPlus!=ivmMinus) { + if (usefirstMinus) { + ProjectionTemp tmpProj(proj, slot, projrinv, projfinerz, projfinephi, ivmMinus, negShift, usesecondMinus, isPSseed); + inputProjBuffer_.store(tmpProj); + } else if (usesecondMinus) { + ProjectionTemp tmpProj(proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmMinus, negShift, false, isPSseed); + inputProjBuffer_.store(tmpProj); + } + } iproj++; if (iproj == projMem->nTracklets()) { iproj = 0; @@ -365,57 +355,67 @@ void MatchProcessor::execute() { //Step 2 //Check if we have ME that can process projection - if (istep >= step2delay && istep < settings_.maxStep("MP") + step2delay) { - bool addedProjection = false; - for (unsigned int iME = 0; iME < nMatchEngines_; iME++) { - if (!matchengines_[iME].idle()) - countme++; - matchengines_[iME].step(); - //if match engine empty and we have queued projections add to match engine - if ((!addedProjection) && matchengines_[iME].idle() && (!inputProjBuffer_.empty())) { - ProjectionTemp tmpProj = inputProjBuffer_.read(); - VMStubsMEMemory* stubmem = vmstubs_[0]; - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " adding projection to match engine"; - } - - int nbins = 8; - if (layerdisk_ >= 6) - nbins = 16; - - matchengines_[iME].init(stubmem, - tmpProj.iphi() * nbins + tmpProj.slot(), - tmpProj.projrinv(), - tmpProj.projfinerz(), - tmpProj.projfinephi(), - tmpProj.usesecond(), - tmpProj.isPSseed(), - tmpProj.proj()); - addedProjection = true; - } + bool addedProjection = false; + for (unsigned int iME = 0; iME < nMatchEngines_; iME++) { + if (!matchengines_[iME].idle()) + countme++; + matchengines_[iME].step(); + //if match engine empty and we have queued projections add to match engine + if ((!addedProjection) && matchengines_[iME].idle() && (!inputProjBuffer_.empty())) { + ProjectionTemp tmpProj = inputProjBuffer_.read(); + VMStubsMEMemory* stubmem = vmstubs_[0]; + + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " adding projection to match engine"; + } + + int nbins = 8; + if (layerdisk_ >= 6) + nbins = 16; + + matchengines_[iME].init(stubmem, + tmpProj.iphi() * nbins + tmpProj.slot(), + tmpProj.projrinv(), + tmpProj.projfinerz(), + tmpProj.projfinephi(), + tmpProj.shift(), + tmpProj.usesecond(), + tmpProj.isPSseed(), + tmpProj.proj()); + addedProjection = true; } } //Step 3 //Check if we have candidate match to process - - if (istep >= step3delay) { - unsigned int iMEbest = nMatchEngines_; - int bestTCID = -1; - bool bestInPipeline = false; - for (unsigned int iME = 0; iME < nMatchEngines_; iME++) { - bool empty = matchengines_[iME].empty(); - medone = medone && (empty && matchengines_[iME].idle()); - if (empty && matchengines_[iME].idle()) - continue; - int currentTCID = empty ? matchengines_[iME].currentProj()->TCID() : matchengines_[iME].peek().first->TCID(); - if ((iMEbest == nMatchEngines_) || (currentTCID < bestTCID)) { - iMEbest = iME; - bestTCID = currentTCID; - bestInPipeline = empty; - } + + unsigned int iMEbest = nMatchEngines_; + int bestTCID = -1; + bool bestInPipeline = false; + for (unsigned int iME = 0; iME < nMatchEngines_; iME++) { + bool empty = matchengines_[iME].empty(); + medone = medone && (empty && matchengines_[iME].idle()); + if (empty && matchengines_[iME].idle()) + continue; + int currentTCID = empty ? matchengines_[iME].currentProj()->TCID() : matchengines_[iME].peek().first->TCID(); + if ((iMEbest == nMatchEngines_) || (currentTCID < bestTCID)) { + iMEbest = iME; + bestTCID = currentTCID; + bestInPipeline = empty; } +<<<<<<< HEAD + } + + if (iMEbest != nMatchEngines_ && (!bestInPipeline)) { + std::pair candmatch = matchengines_[iMEbest].read(); + + const Stub* fpgastub = candmatch.second; + Tracklet* tracklet = candmatch.first; + + if (oldTracklet != nullptr) { + //allow equal here since we can have more than one cadidate match per tracklet projection + assert(oldTracklet->TCID() <= tracklet->TCID()); +======= if (iMEbest != nMatchEngines_ && (!bestInPipeline)) { const std::pair& candmatch = matchengines_[iMEbest].read(); @@ -438,15 +438,30 @@ void MatchProcessor::execute() { countall++; if (match) countsel++; +>>>>>>> ca9f4d8d9ec... Various fixes to comment on pull request (#68) } + oldTracklet = tracklet; + + bool match = matchCalculator(tracklet, fpgastub); + + if (settings_.debugTracklet() && match) { + edm::LogVerbatim("Tracklet") << getName() << " have match"; + } + + countall++; + if (match) + countsel++; } - if ((projdone && medone) || (istep == settings_.maxStep("MP") + step3delay - 1)) { - globals_->ofstream("matchprocessor.txt") << getName() << " " << istep << " " << countall << " " << countsel << " " - << countme << " " << countinputproj << endl; + + if ((projdone && medone) || (istep == settings_.maxStep("MP") - 1)) { + if (settings_.writeMonitorData("MP")) { + globals_->ofstream("matchprocessor.txt") << getName() << " " << istep << " " << countall << " " << countsel << " " + << countme << " " << countinputproj << endl; + } break; } } - + if (settings_.writeMonitorData("MC")) { globals_->ofstream("matchcalculator.txt") << getName() << " " << countall << " " << countsel << endl; } @@ -455,18 +470,20 @@ void MatchProcessor::execute() { bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { const L1TStub* stub = fpgastub->l1tstub(); - if (layer_ != 0) { + if (layerdisk_ < N_LAYER) { + const LayerProjection& layerProj = tracklet->layerProj(layerdisk_+1); int ir = fpgastub->r().value(); - int iphi = tracklet->fpgaphiproj(layer_).value(); - int icorr = (ir * tracklet->fpgaphiprojder(layer_).value()) >> icorrshift_; + int iphi = layerProj.fpgaphiproj().value(); + int icorr = (ir * layerProj.fpgaphiprojder().value()) >> icorrshift_; iphi += icorr; - int iz = tracklet->fpgazproj(layer_).value(); - int izcor = (ir * tracklet->fpgazprojder(layer_).value() + (1 << (icorzshift_ - 1))) >> icorzshift_; + int iz = layerProj.fpgazproj().value(); + int izcor = (ir * layerProj.fpgazprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_; iz += izcor; int ideltaz = fpgastub->z().value() - iz; - int ideltaphi = (fpgastub->phi().value() << phi0shift_) - (iphi << (settings_.phi0bitshift() - 1 + phi0shift_)); + int ideltaphi = (fpgastub->phi().value() - iphi) << phishift_; + //Floating point calculations @@ -484,19 +501,19 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { if (phi < 0) phi += 2 * M_PI; - phi -= phioffset_; + phi -= phimin_; - double dr = r - tracklet->rproj(layer_); + double dr = r - settings_.rmean(layerdisk_); assert(std::abs(dr) < settings_.drmax()); - double dphi = reco::reduceRange(phi - (tracklet->phiproj(layer_) + dr * tracklet->phiprojder(layer_))); + double dphi = reco::reduceRange(phi - (layerProj.phiproj() + dr * layerProj.phiprojder())); - double dz = z - (tracklet->zproj(layer_) + dr * tracklet->zprojder(layer_)); + double dz = z - (layerProj.zproj() + dr * layerProj.zprojder()); double dphiapprox = - reco::reduceRange(phi - (tracklet->phiprojapprox(layer_) + dr * tracklet->phiprojderapprox(layer_))); + reco::reduceRange(phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); - double dzapprox = z - (tracklet->zprojapprox(layer_) + dr * tracklet->zprojderapprox(layer_)); + double dzapprox = z - (layerProj.zprojapprox() + dr * layerProj.zprojderapprox()); int seedindex = tracklet->getISeed(); @@ -507,11 +524,11 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { bool truthmatch = tracklet->stubtruthmatch(stub); HistBase* hists = globals_->histograms(); - hists->FillLayerResidual(layer_, + hists->FillLayerResidual(layerdisk_+1, seedindex, - dphiapprox * settings_.rmean(layer_ - 1), - ideltaphi * settings_.kphi1() * settings_.rmean(layer_ - 1), - ideltaz * fact_ * settings_.kz(), + dphiapprox * settings_.rmean(layerdisk_), + ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_), + (ideltaz << dzshift_ ) * settings_.kz(), dz, truthmatch); } @@ -520,31 +537,30 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); globals_->ofstream("layerresiduals.txt") - << layer_ << " " << seedindex << " " << pt << " " - << ideltaphi * settings_.kphi1() * settings_.rmean(layer_ - 1) << " " - << dphiapprox * settings_.rmean(layer_ - 1) << " " - << phimatchcut_[seedindex] * settings_.kphi1() * settings_.rmean(layer_ - 1) << " " - << ideltaz * fact_ * settings_.kz() << " " << dz << " " << zmatchcut_[seedindex] * settings_.kz() << endl; + << layerdisk_+1 << " " << seedindex << " " << pt << " " + << ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_) << " " + << dphiapprox * settings_.rmean(layerdisk_) << " " + << phimatchcut_[seedindex] * settings_.kphi1() * settings_.rmean(layerdisk_) << " " + << (ideltaz << dzshift_) * settings_.kz() << " " << dz << " " << zmatchcut_[seedindex] * settings_.kz() << endl; } - bool imatch = (std::abs(ideltaphi) <= phifact_ * phimatchcut_[seedindex]) && - (std::abs(ideltaz * fact_) <= rzfact_ * zmatchcut_[seedindex]); + bool imatch = ((unsigned int)std::abs(ideltaphi) <= phimatchcut_[seedindex]) && + ((unsigned int)std::abs(ideltaz << dzshift_) <= zmatchcut_[seedindex]); if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " ideltaphi cut " << ideltaphi << " " - << phimatchcut_[seedindex] << " ideltaz*fact cut " << ideltaz * fact_ << " " + << phimatchcut_[seedindex] << " ideltaz< 0.2 || std::abs(dphiapprox) > 0.2) { - edm::LogPrint("Tracklet") << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox; + //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; } - assert(std::abs(dphi) < 0.2); - assert(std::abs(dphiapprox) < 0.2); - if (imatch) { - tracklet->addMatch(layer_, + tracklet->addMatch(layerdisk_+1, ideltaphi, ideltaz, dphi, @@ -574,35 +590,30 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { assert(stub->z() * tracklet->t() > 0.0); int sign = (tracklet->t() > 0.0) ? 1 : -1; - int disk = sign * disk_; + int disk = sign * (layerdisk_-N_LAYER+1); assert(disk != 0); //Perform integer calculations here int iz = fpgastub->z().value(); - int iphi = tracklet->fpgaphiprojdisk(disk).value(); - - int shifttmp = 6; //TODO - express in terms of constants - assert(shifttmp >= 0); - int iphicorr = (iz * tracklet->fpgaphiprojderdisk(disk).value()) >> shifttmp; + const DiskProjection& diskProj = tracklet->diskProj(disk); + + int iphi = diskProj.fpgaphiproj().value(); + int iphicorr = (iz * diskProj.fpgaphiprojder().value()) >> icorrshift_; iphi += iphicorr; - int ir = tracklet->fpgarprojdisk(disk).value(); - - int shifttmp2 = 7; //TODO - express in terms of constants - assert(shifttmp2 >= 0); - int ircorr = (iz * tracklet->fpgarprojderdisk(disk).value()) >> shifttmp2; - + int ir = diskProj.fpgarproj().value(); + int ircorr = (iz * diskProj.fpgarprojder().value()) >> icorzshift_; ir += ircorr; - int ideltaphi = fpgastub->phi().value() * settings_.kphi() / settings_.kphi() - iphi; + int ideltaphi = fpgastub->phi().value() - iphi; int irstub = fpgastub->r().value(); int ialphafact = 0; if (!stub->isPSmodule()) { assert(irstub < (int)N_DSS_MOD * 2); - if (disk_ <= 2) { + if (layerdisk_-N_LAYER <= 1) { ialphafact = ialphafactinner_[irstub]; irstub = settings_.rDSSinner(irstub) / settings_.kr(); } else { @@ -635,9 +646,9 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { if (phi < 0) phi += 2 * M_PI; - phi -= phioffset_; + phi -= phimin_; - double dz = z - sign * settings_.zmean(disk_ - 1); + double dz = z - sign * settings_.zmean(layerdisk_ - N_LAYER); if (std::abs(dz) > settings_.dzmax()) { edm::LogProblem("Tracklet") << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " @@ -646,16 +657,16 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { assert(std::abs(dz) < settings_.dzmax()); } - double phiproj = tracklet->phiprojdisk(disk) + dz * tracklet->phiprojderdisk(disk); - double rproj = tracklet->rprojdisk(disk) + dz * tracklet->rprojderdisk(disk); + double phiproj = diskProj.phiproj() + dz * diskProj.phiprojder(); + double rproj = diskProj.rproj() + dz * diskProj.rprojder(); double deltar = r - rproj; double dr = stub->r() - rproj; - double drapprox = stub->r() - (tracklet->rprojapproxdisk(disk) + dz * tracklet->rprojderapproxdisk(disk)); + double drapprox = stub->r() - (diskProj.rprojapprox() + dz * diskProj.rprojderapprox()); double dphi = reco::reduceRange(phi - phiproj); double dphiapprox = - reco::reduceRange(phi - (tracklet->phiprojapproxdisk(disk) + dz * tracklet->phiprojderapproxdisk(disk))); + reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); double drphi = dphi * stub->r(); double drphiapprox = dphiapprox * stub->r(); @@ -686,7 +697,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { 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 + << layerdisk_-N_LAYER+1 << " " << stub->isPSmodule() << " " << tracklet->layer() << " " << abs(tracklet->disk()) << " " << pt << " " << ideltaphi * settings_.kphi() * stub->r() << " " << drphiapprox << " " << drphicut << " " << ideltar * settings_.krprojshiftdisk() << " " << deltar << " " << drcut << " " << endl; } diff --git a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc index e7c0ee7b241ec..38cb88e9cfc55 100644 --- a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc @@ -1,4 +1,5 @@ #include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" +#include "L1Trigger/TrackFindingTracklet/interface/Util.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" @@ -71,14 +72,9 @@ void MemoryBase::findAndReplaceAll(std::string& data, std::string toSearch, std: } void MemoryBase::openFile(bool first, std::string dirName, std::string filebase) { - if (not std::filesystem::exists(dirName)) { - int fail = system((string("mkdir -p ") + dirName).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirName; - } - std::string fname = dirName + filebase; - fname += getName(); + + std::string fname = filebase + getName(); findAndReplaceAll(fname, "PHIa", "PHIaa"); findAndReplaceAll(fname, "PHIb", "PHIbb"); @@ -96,17 +92,8 @@ void MemoryBase::openFile(bool first, std::string dirName, std::string filebase) fname += std::to_string(iSector_ + 1); fname += ".dat"; - if (first) { - bx_ = 0; - event_ = 1; - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else { - out_.open(fname, std::ofstream::app); - } - + openfile(out_, first, dirName, dirName+fname, __FILE__, __LINE__); + out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; bx_++; diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc index 06856031b1e1d..b2b36ed012754 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc @@ -89,29 +89,30 @@ void ProjectionRouter::execute() { FPGAWord fpgaphi; if (layerdisk_ < N_LAYER) { - fpgaphi = tracklet->fpgaphiproj(layerdisk_ + 1); + fpgaphi = tracklet->layerProj(layerdisk_ + 1).fpgaphiproj(); } else { int disk = layerdisk_ - (N_LAYER - 1); - fpgaphi = tracklet->fpgaphiprojdisk(disk); + DiskProjection& diskProj = tracklet->diskProj(disk); + fpgaphi = diskProj.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 = (tracklet->fpgarprojdisk(disk).value() >> (tracklet->fpgarprojdisk(disk).nbits() - nrbits_)) & + int rindex = (diskProj.fpgarproj().value() >> (diskProj.fpgarproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (tracklet->fpgaphiprojderdisk(disk).value() >> - (tracklet->fpgaphiprojderdisk(disk).nbits() - nphiderbits_)) & + int phiderindex = (diskProj.fpgaphiprojder().value() >> + (diskProj.fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); - int signindex = (tracklet->fpgarprojderdisk(disk).value() < 0); + int signindex = (diskProj.fpgarprojder().value() < 0); int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex; int ibendproj = globals_->projectionRouterBendTable()->bendLoookup(disk - 1, bendindex); - tracklet->setBendIndex(ibendproj, disk); + diskProj.setBendIndex(ibendproj); } unsigned int iphivm = diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc index 6ddbcc3628cf2..922b2535528a6 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc @@ -25,7 +25,7 @@ void ProjectionRouterBendTable::init(Settings const& settings, if (iphider > (1 << (nphiderbits - 1))) iphider -= (1 << nphiderbits); iphider = iphider << (settings.nbitsphiprojderL123() - nphiderbits); - + double rproj = ir * settings.krprojshiftdisk(); double phider = iphider * globals->ITC_L1L2()->der_phiD_final.K(); double t = settings.zmean(idisk) / rproj; @@ -36,7 +36,7 @@ void ProjectionRouterBendTable::init(Settings const& settings, double rinv = -phider * (2.0 * t); double stripPitch = (rproj < settings.rcrit()) ? settings.stripPitch(true) : settings.stripPitch(false); - double bendproj = 0.5 * bend(rproj, rinv, stripPitch); + double bendproj = bendstrip(rproj, rinv, stripPitch); int ibendproj = 2.0 * bendproj + 15.5; if (ibendproj < 0) diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc index e8f902f1dd27d..637985d12a796 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc @@ -9,6 +9,7 @@ ProjectionTemp::ProjectionTemp(Tracklet* proj, int projfinerz, unsigned int projfinephi, unsigned int iphi, + int shift, bool usesecond, bool isPSseed) { proj_ = proj; @@ -17,6 +18,7 @@ ProjectionTemp::ProjectionTemp(Tracklet* proj, projfinerz_ = projfinerz; projfinephi_ = projfinephi; iphi_ = iphi; + shift_ = shift; usesecond_ = usesecond; isPSseed_ = isPSseed; } @@ -28,6 +30,7 @@ ProjectionTemp::ProjectionTemp() { projfinerz_ = 0; projfinephi_ = 0; iphi_ = 0; + shift_ = 0; usesecond_ = false; isPSseed_ = false; } diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 7f66f5d53329e..b442182e93ca4 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -483,8 +483,14 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { // Get phi position of stub stubphi = curStub->l1tstub()->phi(); // Get region that the stub is in (Layer 1->6, Disk 1->5) - int Layer = curStub->layer().value() + 1; - int Disk = curStub->disk().value(); + int Layer = curStub->layerdisk() + 1; + if (Layer>6) { + Layer=0; + } + int Disk = curStub->layerdisk()-5; + if (Disk<0) { + Disk=0; + } // Get phi projection of tracklet int seedindex = curTracklet->seedIndex(); // If this stub is a seed stub, set projection=phi, so that res=0 @@ -500,9 +506,9 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { phiproj = stubphi; // Otherwise, get projection of tracklet } else if (Layer != 0) { - phiproj = curTracklet->phiproj(Layer); + phiproj = curTracklet->layerProj(Layer).phiproj(); } else if (Disk != 0) { - phiproj = curTracklet->phiprojdisk(Disk); + phiproj = curTracklet->diskProj(Disk).phiproj(); } else { throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Layer: " << Layer << " -- Disk: " << Disk << " Stub is not layer or disk in getPhiRes"; diff --git a/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc b/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc index 966bc40bca0e6..3779ea1b7232d 100644 --- a/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc +++ b/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc @@ -1,73 +1,30 @@ #include "L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h" - #include "FWCore/MessageLogger/interface/MessageLogger.h" using namespace std; using namespace trklet; -L1SimTrack::L1SimTrack() { - eventid_ = -1; - trackid_ = -1; -} - -L1SimTrack::L1SimTrack( - int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz) { - eventid_ = eventid; - trackid_ = trackid; - type_ = type; - pt_ = pt; - eta_ = eta; - phi_ = phi; - vx_ = vx; - vy_ = vy; - vz_ = vz; -} - -void L1SimTrack::write(ofstream& out) { - if (pt_ > -2.0) { - out << "SimTrack: " << eventid_ << "\t" << trackid_ << "\t" << type_ << "\t" << pt_ << "\t" << eta_ << "\t" << phi_ - << "\t" << vx_ << "\t" << vy_ << "\t" << vz_ << "\t" << endl; - } -} - -void L1SimTrack::write(ostream& out) { - if (pt_ > -2) { - out << "SimTrack: " << eventid_ << "\t" << trackid_ << "\t" << type_ << "\t" << pt_ << "\t" << eta_ << "\t" << phi_ - << "\t" << vx_ << "\t" << vy_ << "\t" << vz_ << "\t" << endl; - } -} - void SLHCEvent::addL1SimTrack( int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz) { - vx -= x_offset_; - vy -= y_offset_; L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz); simtracks_.push_back(simtrack); } -bool SLHCEvent::addStub(int layer, - int ladder, - int module, - int strip, - int eventid, - vector tps, - double pt, - double bend, - double x, - double y, - double z, - int isPSmodule, - int isFlipped) { - if (layer > 999 && layer < 1999 && z < 0.0) { - layer += 1000; - } - - layer--; - x -= x_offset_; - y -= y_offset_; - - L1TStub stub( - eventid, tps, -1, -1, layer, ladder, module, strip, x, y, z, -1.0, -1.0, pt, bend, isPSmodule, isFlipped); +bool SLHCEvent::addStub(string DTClink, + int region, + int layerdisk, + string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + vector tps +) { + + L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps); stubs_.push_back(stub); return true; @@ -76,13 +33,6 @@ bool SLHCEvent::addStub(int layer, SLHCEvent::SLHCEvent(istream& in) { string tmp; in >> tmp; - while (tmp == "Map:") { - in >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp; - in >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp >> tmp; - } - if (tmp == "EndMap") { - in >> tmp; - } if (tmp != "Event:") { edm::LogVerbatim("Tracklet") << "Expected to read 'Event:' but found:" << tmp; if (tmp.empty()) { @@ -105,67 +55,44 @@ SLHCEvent::SLHCEvent(istream& in) { int eventid; int trackid; int type; - string pt_str; - string eta_str; - string phi_str; - string vx_str; - string vy_str; - string vz_str; double pt; double eta; double phi; double vx; double vy; double vz; - in >> eventid >> trackid >> type >> pt_str >> eta_str >> phi_str >> vx_str >> vy_str >> vz_str; - pt = strtod(pt_str.c_str(), nullptr); - eta = strtod(eta_str.c_str(), nullptr); - phi = strtod(phi_str.c_str(), nullptr); - vx = strtod(vx_str.c_str(), nullptr); - vy = strtod(vy_str.c_str(), nullptr); - vz = strtod(vz_str.c_str(), nullptr); - vx -= x_offset_; - vy -= y_offset_; + in >> eventid >> trackid >> type >> pt >> eta >> phi >> vx >> vy >> vz; L1SimTrack simtrack(eventid, trackid, type, pt, eta, phi, vx, vy, vz); simtracks_.push_back(simtrack); in >> tmp; } - int oldlayer = 0; - int oldladder = 0; - int oldmodule = 0; - int oldcbc = -1; - int count = 1; - double oldz = -1000.0; - //read stubs in >> tmp; - while (tmp != "StubEnd") { + while (tmp != "Stubend") { if (!in.good()) { - edm::LogVerbatim("Tracklet") << "File not good"; + edm::LogVerbatim("Tracklet") << "File not good (SLHCEvent)"; abort(); }; - if (!(tmp == "Stub:" || tmp == "StubEnd")) { + if (!(tmp == "Stub:" || tmp == "Stubend")) { edm::LogVerbatim("Tracklet") << "Expected to read 'Stub:' or 'StubEnd' but found:" << tmp; abort(); } - int layer; - int ladder; - int module; - int eventid; - vector tps; - int strip; - double pt; + string DTClink; + int region; + int layerdisk; + string stubword; + int isPSmodule; + int isFlipped; double x; double y; double z; double bend; - int isPSmodule; - int isFlipped; - + double strip; unsigned int ntps; + vector tps; - in >> layer >> ladder >> module >> strip >> eventid >> pt >> x >> y >> z >> bend >> isPSmodule >> isFlipped >> ntps; + in >> DTClink >> region >> layerdisk >> stubword >> isPSmodule >> isFlipped >> x >> y >> z >> bend >> strip >> ntps; for (unsigned int itps = 0; itps < ntps; itps++) { int tp; @@ -173,36 +100,14 @@ SLHCEvent::SLHCEvent(istream& in) { tps.push_back(tp); } - if (layer > 999 && layer < 1999 && z < 0.0) { //negative disk - layer += 1000; - } - - int cbc = strip / 126; - if (layer > 3 && layer == oldlayer && ladder == oldladder && module == oldmodule && cbc == oldcbc && - std::abs(oldz - z) < 1.0) { - count++; - } else { - oldlayer = layer; - oldladder = ladder; - oldmodule = module; - oldcbc = cbc; - oldz = z; - count = 1; - } - - layer--; - x -= x_offset_; - y -= y_offset_; - - L1TStub stub( - eventid, tps, -1, -1, layer, ladder, module, strip, x, y, z, -1.0, -1.0, pt, bend, isPSmodule, isFlipped); + L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps); in >> tmp; double t = std::abs(stub.z()) / stub.r(); double eta = asinh(t); - if (std::abs(eta) < 2.6 && count <= 100) { + if (std::abs(eta) < 2.6) { stubs_.push_back(stub); } } @@ -219,21 +124,7 @@ void SLHCEvent::write(ofstream& out) { for (auto& stub : stubs_) { stub.write(out); } - out << "StubEnd" << endl; -} - -void SLHCEvent::write(ostream& out) { - out << "Event: " << eventnum_ << endl; - - for (auto& simtrack : simtracks_) { - simtrack.write(out); - } - out << "SimTrackEnd" << endl; - - for (auto& stub : stubs_) { - stub.write(out); - } - out << "StubEnd" << endl; + out << "Stubend" << endl; } unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) { @@ -284,10 +175,3 @@ unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) { return l1 + 2 * l2 + 4 * l3 + 8 * l4 + 16 * l5 + 32 * l6 + 64 * d1 + 128 * d2 + 256 * d3 + 512 * d4 + 1024 * d5; } -int SLHCEvent::getSimtrackFromSimtrackid(int simtrackid, int eventid) const { - for (unsigned int i = 0; i < simtracks_.size(); i++) { - if (simtracks_[i].trackid() == simtrackid && simtracks_[i].eventid() == eventid) - return i; - } - return -1; -} diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 9ecef0c857f3e..681cf22c46b98 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -5,6 +5,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h" +#include "L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h" @@ -37,6 +38,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" #include "DataFormats/Math/interface/deltaPhi.h" +#include "L1Trigger/TrackFindingTracklet/interface/VMRouterPhiCorrTable.h" using namespace std; using namespace trklet; @@ -51,44 +53,136 @@ Sector::Sector(unsigned int i, Settings const& settings, Globals* globals) : set phimax_ -= M_PI / N_SECTOR; phimin_ = reco::reduceRange(phimin_); phimax_ = reco::reduceRange(phimax_); - if (phimin_ > phimax_) + if (phimin_ > phimax_) { phimin_ -= 2 * M_PI; -} - -Sector::~Sector() { - for (auto& mem : MemoriesV_) { - mem->clean(); } } +Sector::~Sector() = default; + bool Sector::addStub(L1TStub stub, string dtc) { - bool add = false; - double phi = stub.phi(); - double dphi = 0.5 * settings_.dphisectorHG() - M_PI / N_SECTOR; + unsigned int layerdisk=stub.layerdisk(); + + double stubphi = stub.phi(); + if (stubphi-phimin_>M_PI){ + stubphi-=2*M_PI; + } + + if (layerdisk < N_LAYER && globals_->phiCorr(layerdisk) == nullptr) { + globals_->phiCorr(layerdisk) = new VMRouterPhiCorrTable(settings_); + + int nbits = 3; + if (layerdisk >= N_PSLAYER) + nbits = 4; + globals_->phiCorr(layerdisk)->init(layerdisk + 1, nbits, 3); + } + + Stub fpgastub(stub, settings_, *globals_); + + if (layerdisk < N_LAYER) { + FPGAWord r = fpgastub.r(); + int bendbin = fpgastub.bend().value(); + int rbin = (r.value() + (1 << (r.nbits() - 1))) >> (r.nbits() - 3); + const VMRouterPhiCorrTable& phiCorrTable = *globals_->phiCorr(layerdisk); + int iphicorr = phiCorrTable.getphiCorrValue(bendbin, rbin); + fpgastub.setPhiCorr(iphicorr); + } + + FPGAWord phi=fpgastub.phicorr(); + int ireg=phi.value()>>(phi.nbits()-settings_.nbitsallstubs(layerdisk)); + + int nadd=0; + for (unsigned int i = 0; i < IL_.size(); i++) { + const string& name=IL_[i]->getName(); + if (name.find("_" + dtc) == string::npos) continue; + if ( (name[3]=='L' && name[4]-'1'==(int)layerdisk) || (name[3]=='D' && name[4]-'1'==(int)layerdisk-6) ) { + if (name[8]-'A'==ireg){ + IL_[i]->addStub(stub, fpgastub); + nadd++; + } + } + } + + assert(nadd==1); + + if (settings_.writeMem() && isector_ == (int)settings_.writememsect() ) { + writeLink(fpgastub); + } + + return true; +} + +void Sector::writeLinkNewEvent(int event) { - std::map >& ILindex = globals_->ILindex(); - std::vector& tmp = ILindex[dtc]; - if (tmp.empty()) { - for (unsigned int i = 0; i < IL_.size(); i++) { - if (IL_[i]->getName().find("_" + dtc) != string::npos) { - tmp.push_back(i); + if (DTCLink_ofstreams_.size()==0) { + //FIXME should be in settings + static string dtcbasenames[12]={"PS10G_1","PS10G_2","PS10G_3","PS10G_4","PS_1","PS_2","2S_1","2S_2","2S_3","2S_4","2S_5","2S_6"}; + for (const auto& dtcbasename: dtcbasenames) { + for (int neg=0;neg<2;neg++) { + string dtcnametmp=(neg==0?"":"neg")+dtcbasename; + for (int ab=0;ab<2;ab++) { + string dtcname=dtcnametmp+(ab==0?"_A":"_B"); + string fname = "../data/MemPrints/InputStubs/Link_"+dtcname+"_"+to_string(isector_+1)+".dat"; + ofstream* out = new ofstream; + out->open(fname.c_str()); + DTCLink_ofstreams_[dtcname] = out; + } } } } - if (((phi > phimin_ - dphi) && (phi < phimax_ + dphi)) || - ((phi > 2 * M_PI + phimin_ - dphi) && (phi < 2 * M_PI + phimax_ + dphi))) { - Stub fpgastub(stub, settings_, phimin_, phimax_); - std::vector& tmp = ILindex[dtc]; - assert(!tmp.empty()); - for (int i : tmp) { - if (IL_[i]->addStub(settings_, globals_, stub, fpgastub, dtc)) - add = true; + for(auto& out:DTCLink_ofstreams_){ + FPGAWord bx(event%8,3,true); + (*out.second) << "BX "< > dtclayers{ + {"PS10G_1", {0,6,8,10}}, + {"PS10G_2", {0,7,9}}, + {"PS10G_3", {1,7}}, + {"PS10G_4", {6,8,10}}, + {"PS_1", {2,7}}, + {"PS_2", {2,9}}, + {"2S_1", {3,4}}, + {"2S_2", {4}}, + {"2S_3", {5}}, + {"2S_4", {5,8}}, + {"2S_5", {6,9}}, + {"2S_6", {7,10}} + }; + + string dtcname=fpgastub.l1tstub()->DTClink(); + int layerdisk=fpgastub.l1tstub()->layerdisk(); + + int start=dtcname.substr(0,3)=="neg"?3:0; + + string dtcbase=dtcname.substr(start,dtcname.size()-2-start); + + vector layers=dtclayers[dtcbase]; + + int lcode=-1; + for(unsigned int index=0;indexsecond) << dataword << " " << trklet::hexFormat(dataword) << endl; - return add; + } void Sector::addMem(string memType, string memName) { @@ -96,6 +190,8 @@ void Sector::addMem(string memType, string memName) { addMemToVec(IL_, memName, settings_, isector_, phimin_, phimax_); } else if (memType == "AllStubs:") { addMemToVec(AS_, memName, settings_, isector_); + } else if (memType == "AllInnerStubs:") { + addMemToVec(AIS_, memName, settings_, isector_); } else if (memType == "VMStubsTE:") { addMemToVec(VMSTE_, memName, settings_, isector_); } else if (memType == "VMStubsME:") { @@ -230,6 +326,12 @@ void Sector::writeAS(bool first) { } } +void Sector::writeAIS(bool first) { + for (auto& i : AIS_) { + i->writeStubs(first); + } +} + void Sector::writeSP(bool first) { for (auto& i : SP_) { i->writeSP(first); diff --git a/L1Trigger/TrackFindingTracklet/src/Stub.cc b/L1Trigger/TrackFindingTracklet/src/Stub.cc index 449b17fe79238..4a2c53ae0ba53 100644 --- a/L1Trigger/TrackFindingTracklet/src/Stub.cc +++ b/L1Trigger/TrackFindingTracklet/src/Stub.cc @@ -1,172 +1,117 @@ #include "L1Trigger/TrackFindingTracklet/interface/Stub.h" +#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" +#include "L1Trigger/TrackFindingTracklet/interface/SLHCEvent.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; Stub::Stub(Settings const& settings) : settings_(settings) {} -Stub::Stub(L1TStub& stub, Settings const& settings, double phiminsec, double phimaxsec) : settings_(settings) { - double r = stub.r(); - double z = stub.z(); - double sbend = stub.bend(); +Stub::Stub(L1TStub& stub, Settings const& settings, Globals& globals) : settings_(settings) { - l1tstub_ = &stub; - - int bendbits = 4; - if (stub.isPSmodule()) - bendbits = 3; - - int ibend = bendencode(sbend, stub.isPSmodule()); - - bend_.set(ibend, bendbits, true, __LINE__, __FILE__); - - int layer = stub.layer() + 1; - - // hold the real values from L1Stub - double stubphi = stub.phi(); + const string& stubwordhex=stub.stubword(); - if (layer < 999) { - disk_.set(0, 4, false, __LINE__, __FILE__); + const string stubwordbin=convertHexToBin(stubwordhex); + + layerdisk_=stub.layerdisk(); - assert(layer > 0 && layer <= N_LAYER); - double rmin = settings_.rmean(layer - 1) - settings_.drmax(); - double rmax = settings_.rmean(layer - 1) + settings_.drmax(); + int nbendbits = 4; + if (stub.isPSmodule()) + nbendbits = 3; - if (r < rmin || r > rmax) { - edm::LogProblem("Tracklet") << "Error r, rmin, rmeas, rmax :" << r << " " << rmin << " " << 0.5 * (rmin + rmax) - << " " << rmax; - } + int nalphabits=0; - int irbits = settings_.nrbitsstub(layer - 1); + int nrbits=settings_.nrbitsstub(layerdisk_); + int nzbits=settings_.nzbitsstub(layerdisk_); + int nphibits=settings_.nphibitsstub(layerdisk_); - int ir = lround((1 << irbits) * ((r - settings_.rmean(layer - 1)) / (rmax - rmin))); + if (layerdisk_>=N_LAYER && !stub.isPSmodule()) { + nalphabits=settings.nbitsalpha(); + nrbits=7; + } - double zmin = -settings_.zlength(); - double zmax = settings_.zlength(); + int layer = stub.layer() + 1; - if (z < zmin || z > zmax) { - edm::LogProblem("Tracklet") << "Error z, zmin, zmax :" << z << " " << zmin << " " << zmax; - } + assert(nbendbits+nalphabits+nrbits+nzbits+nphibits==36); + + bitset<32> rbits(stubwordbin.substr(0,nrbits)); + bitset<32> zbits(stubwordbin.substr(nrbits,nzbits)); + bitset<32> phibits(stubwordbin.substr(nrbits+nzbits,nphibits)); + bitset<32> alphabits(stubwordbin.substr(nphibits+nzbits+nrbits,nalphabits)); + bitset<32> bendbits(stubwordbin.substr(nphibits+nzbits+nrbits+nalphabits,nbendbits)); + + int newbend=bendbits.to_ulong(); + + int newr=rbits.to_ulong(); + if (layerdisk_=(1<<(nrbits-1))) newr=newr-(1<=(1<<(nzbits-1))) newz=newz-(1< zmax) { - edm::LogProblem("Tracklet") << "Error z, zmin, zmax :" << z << " " << zmin << " " << zmax; - } + int newalpha=alphabits.to_ulong();//-(1<<(nalphabits-1)); + if (newalpha>=(1<<(nalphabits-1))) newalpha=newalpha-(1< 0.0); + l1tstub_ = &stub; - if (stubphi < phiminsec - (phimaxsec - phiminsec) / 6.0) { - stubphi += 2 * M_PI; + //int ibendnew = bendencode(newbend*bendfact, stub.isPSmodule()); + + bend_.set(newbend, nbendbits, true, __LINE__, __FILE__); + + phi_.set(newphi, nphibits, true, __LINE__, __FILE__); + phicorr_.set(newphi, nphibits, true, __LINE__, __FILE__); + bool pos=false; + if (layerdisk_>5) { + pos=true; + int disk=layerdisk_-5; + if (stub.z()<0.0) disk=-disk; + disk_.set(disk, 4, false, __LINE__, __FILE__); + if (!stub.isPSmodule()) { + alpha_.set(newalpha, nalphabits, false, __LINE__, __FILE__); + nrbits=4; } - assert((phimaxsec - phiminsec) > 0.0); - - int iphibits = settings_.nphibitsstub(layer - 1); - - double deltaphi = reco::reduceRange(stubphi - phiminsec); - - int iphi = (1 << iphibits) * deltaphi / (phimaxsec - phiminsec); - - layer_.set(layer - 1, 3, true, __LINE__, __FILE__); - r_.set(ir, irbits, false, __LINE__, __FILE__); - z_.set(iz, izbits, false, __LINE__, __FILE__); - phi_.set(iphi, iphibits, true, __LINE__, __FILE__); - - phicorr_.set(iphi, iphibits, true, __LINE__, __FILE__); - } else { - // Here we handle the hits on disks. - - int disk = stub.module(); - assert(disk > 0 && disk <= N_DISK); - int sign = 1; - if (z < 0.0) - sign = -1; - - double zmin = sign * (settings_.zmean(disk - 1) - sign * settings_.dzmax()); - double zmax = sign * (settings_.zmean(disk - 1) + sign * settings_.dzmax()); - - if ((z > zmax) || (z < zmin)) { - edm::LogProblem("Tracklet") << "Error disk z, zmax, zmin: " << z << " " << zmax << " " << zmin; - } - - int iz = - (1 << settings.nzbitsstub(disk + N_DISK)) * ((z - sign * settings_.zmean(disk - 1)) / std::abs(zmax - zmin)); - - assert(phimaxsec - phiminsec > 0.0); - if (stubphi < phiminsec - (phimaxsec - phiminsec) / 6.0) { - stubphi += 2 * M_PI; - } - - assert(phimaxsec - phiminsec > 0.0); - if (stubphi < phiminsec - (phimaxsec - phiminsec) / 6.0) { - stubphi += 2 * M_PI; - } - - int iphibits = settings_.nphibitsstub(disk + 5); - - double deltaphi = reco::reduceRange(stubphi - phiminsec); + disk_.set(0, 4, false, __LINE__, __FILE__); + layer_.set(layer - 1, 3, true, __LINE__, __FILE__); + } + r_.set(newr, nrbits, pos, __LINE__, __FILE__); + z_.set(newz, nzbits, false, __LINE__, __FILE__); - int iphi = (1 << iphibits) * deltaphi / (phimaxsec - phiminsec); + if (settings.writeMonitorData("StubBend")) { - double rmin = 0; - double rmax = settings_.rmaxdisk(); + + unsigned int nsimtrks=globals.event()->nsimtracks(); - if (r < rmin || r > rmax) { - edm::LogProblem("Tracklet") << "Error disk r, rmin, rmax :" << r << " " << rmin << " " << rmax; - } + //cout << "Have L1 stub" << endl; + + for (unsigned int isimtrk=0;isimtrksimtrack(isimtrk); + if (stub.tpmatch2(simtrk.trackid())) { - int ir = (1 << settings_.nrbitsstub(disk + 5)) * (r - rmin) / (rmax - rmin); + double dr=0.18; + double rinv=simtrk.charge()*0.01*settings_.c()*settings_.bfield()/simtrk.pt(); + double pitch=settings_.stripPitch(stub.isPSmodule()); + double bend=stub.r()*dr*0.5*rinv/pitch; - int irSS = -1; - if (!stub.isPSmodule()) { - for (unsigned int i = 0; i < N_DSS_MOD * 2; ++i) { - if (disk <= 2) { - if (std::abs(r - settings_.rDSSinner(i)) < 0.2) { - irSS = i; - break; - } - } else { - if (std::abs(r - settings_.rDSSouter(i)) < 0.2) { - irSS = i; - break; - } - } + globals.ofstream("stubbend.dat") << layerdisk_ << " "<= -(1 << (settings.nbitsalpha() - 1))); - alphanew_.set(ialphanew, settings.nbitsalpha(), false, __LINE__, __FILE__); } + } FPGAWord Stub::iphivmFineBins(int VMbits, int finebits) const { diff --git a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc index 4e882c62789c8..2ac672646e4b3 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc @@ -16,21 +16,7 @@ void StubPairsMemory::writeSP(bool first) { oss << dirSP << "StubPairs_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirSP)) { - int fail = system((string("mkdir -p ") + dirSP).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirSP; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirSP, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc index cd6f8dcbb1cf1..8ac743534d2cf 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc @@ -17,21 +17,7 @@ void StubTripletsMemory::writeST(bool first) { oss << dirSP << "StubTriplets_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirSP)) { - int fail = system((string("mkdir -p ") + dirSP).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirSP; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirSP, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/TETableBase.cc b/L1Trigger/TrackFindingTracklet/src/TETableBase.cc index 6ece1f83d3b35..aeca99c2fc326 100644 --- a/L1Trigger/TrackFindingTracklet/src/TETableBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TETableBase.cc @@ -1,16 +1,15 @@ #include "L1Trigger/TrackFindingTracklet/interface/TETableBase.h" +#include "L1Trigger/TrackFindingTracklet/interface/Util.h" using namespace std; using namespace trklet; TETableBase::TETableBase(Settings const& settings) : settings_(settings) {} -void TETableBase::writeVMTable(std::string name, bool positive) { +void TETableBase::writeVMTable(const std::string& dir, const std::string& name, bool positive) { // Write LUT table. - ofstream out(name); - if (out.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << name; + ofstream out=openfile(dir, name, __FILE__, __LINE__); out << "{" << endl; for (unsigned int i = 0; i < table_.size(); i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc b/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc index 03cac8804cbd3..b3791a5f74e49 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc @@ -1,11 +1,10 @@ #include "L1Trigger/TrackFindingTracklet/interface/TrackDerTable.h" #include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" #include "L1Trigger/TrackFindingTracklet/interface/Globals.h" +#include "L1Trigger/TrackFindingTracklet/interface/Util.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include - using namespace std; using namespace trklet; @@ -359,19 +358,10 @@ void TrackDerTable::fillTable() { } if (settings_.writeTable()) { - if (not std::filesystem::exists(settings_.tablePath())) { - int fail = system((string("mkdir -p ") + settings_.tablePath()).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " - << settings_.tablePath(); - } - - const string fnameL = settings_.tablePath() + "FitDerTableNew_LayerMem.tab"; - ofstream outL(fnameL); - if (outL.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fnameL; - - int nbits = 6; + + ofstream outL=openfile(settings_.tablePath(), "FitDerTableNew_LayerMem.tab", __FILE__, __LINE__); + + int nbits=6; for (unsigned int i = 0; i < LayerMem_.size(); i++) { FPGAWord tmp; int tmp1 = LayerMem_[i]; @@ -382,12 +372,9 @@ void TrackDerTable::fillTable() { } outL.close(); - const string fnameD = settings_.tablePath() + "FitDerTableNew_DiskMem.tab"; - ofstream outD(fnameD); - if (outD.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fnameD; + ofstream outD=openfile(settings_.tablePath(), "FitDerTableNew_DiskMem.tab", __FILE__, __LINE__); - nbits = 7; + nbits=7; for (int tmp1 : DiskMem_) { if (tmp1 < 0) tmp1 = (1 << nbits) - 1; @@ -397,12 +384,9 @@ void TrackDerTable::fillTable() { } outD.close(); - const string fnameLD = settings_.tablePath() + "FitDerTableNew_LayerDiskMem.tab"; - ofstream outLD(fnameLD); - if (outLD.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fnameLD; + ofstream outLD=openfile(settings_.tablePath(), "FitDerTableNew_LayerDiskMem.tab", __FILE__, __LINE__); - nbits = 15; + nbits=15; for (int tmp1 : LayerDiskMem_) { if (tmp1 < 0) tmp1 = (1 << nbits) - 1; @@ -631,79 +615,79 @@ void TrackDerTable::fillTable() { } // if (goodseed) FPGAWord tmprinvdphi[N_PROJ]; - int nbits = 16; + int nbits=16; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmprinvdphi[j] > (1 << nbits)) itmprinvdphi[j] = (1 << nbits) - 1; - tmprinvdphi[j].set(itmprinvdphi[j], nbits + 1, false, __LINE__, __FILE__); + tmprinvdphi[j].set(itmprinvdphi[j], nbits+1, false, __LINE__, __FILE__); } outrinvdphi[i] << tmprinvdphi[0].str() << tmprinvdphi[1].str() << tmprinvdphi[2].str() << tmprinvdphi[3].str() << endl; FPGAWord tmprinvdzordr[N_PROJ]; - nbits = 15; + nbits=15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmprinvdzordr[j] > (1 << nbits)) itmprinvdzordr[j] = (1 << nbits) - 1; - tmprinvdzordr[j].set(itmprinvdzordr[j], nbits + 1, false, __LINE__, __FILE__); + tmprinvdzordr[j].set(itmprinvdzordr[j], nbits+1, false, __LINE__, __FILE__); } outrinvdzordr[i] << tmprinvdzordr[0].str() << tmprinvdzordr[1].str() << tmprinvdzordr[2].str() << tmprinvdzordr[3].str() << endl; FPGAWord tmpphi0dphi[N_PROJ]; - nbits = 13; + nbits=13; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpphi0dphi[j] > (1 << nbits)) itmpphi0dphi[j] = (1 << nbits) - 1; - tmpphi0dphi[j].set(itmpphi0dphi[j], nbits + 1, false, __LINE__, __FILE__); + tmpphi0dphi[j].set(itmpphi0dphi[j], nbits+1, false, __LINE__, __FILE__); } outphi0dphi[i] << tmpphi0dphi[0].str() << tmpphi0dphi[1].str() << tmpphi0dphi[2].str() << tmpphi0dphi[3].str() << endl; FPGAWord tmpphi0dzordr[N_PROJ]; - nbits = 15; + nbits=15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpphi0dzordr[j] > (1 << nbits)) itmpphi0dzordr[j] = (1 << nbits) - 1; - tmpphi0dzordr[j].set(itmpphi0dzordr[j], nbits + 1, false, __LINE__, __FILE__); + tmpphi0dzordr[j].set(itmpphi0dzordr[j], nbits+1, false, __LINE__, __FILE__); } outphi0dzordr[i] << tmpphi0dzordr[0].str() << tmpphi0dzordr[1].str() << tmpphi0dzordr[2].str() << tmpphi0dzordr[3].str() << endl; FPGAWord tmptdphi[N_PROJ]; - nbits = 14; + nbits=14; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmptdphi[j] > (1 << nbits)) itmptdphi[j] = (1 << nbits) - 1; - tmptdphi[j].set(itmptdphi[j], nbits + 1, false, __LINE__, __FILE__); + tmptdphi[j].set(itmptdphi[j], nbits+1, false, __LINE__, __FILE__); } outtdphi[i] << tmptdphi[0].str() << tmptdphi[1].str() << tmptdphi[2].str() << tmptdphi[3].str() << endl; FPGAWord tmptdzordr[N_PROJ]; - nbits = 15; + nbits=15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmptdzordr[j] > (1 << nbits)) itmptdzordr[j] = (1 << nbits) - 1; - tmptdzordr[j].set(itmptdzordr[j], nbits + 1, false, __LINE__, __FILE__); + tmptdzordr[j].set(itmptdzordr[j], nbits+1, false, __LINE__, __FILE__); } outtdzordr[i] << tmptdzordr[0].str() << tmptdzordr[1].str() << tmptdzordr[2].str() << tmptdzordr[3].str() << endl; FPGAWord tmpz0dphi[N_PROJ]; - nbits = 13; + nbits=13; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpz0dphi[j] > (1 << nbits)) itmpz0dphi[j] = (1 << nbits) - 1; - tmpz0dphi[j].set(itmpz0dphi[j], nbits + 1, false, __LINE__, __FILE__); + tmpz0dphi[j].set(itmpz0dphi[j], nbits+1, false, __LINE__, __FILE__); } outz0dphi[i] << tmpz0dphi[0].str() << tmpz0dphi[1].str() << tmpz0dphi[2].str() << tmpz0dphi[3].str() << endl; FPGAWord tmpz0dzordr[N_PROJ]; - nbits = 15; + nbits=15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpz0dzordr[j] > (1 << nbits)) itmpz0dzordr[j] = (1 << nbits) - 1; - tmpz0dzordr[j].set(itmpz0dzordr[j], nbits + 1, false, __LINE__, __FILE__); + tmpz0dzordr[j].set(itmpz0dzordr[j], nbits+1, false, __LINE__, __FILE__); } outz0dzordr[i] << tmpz0dzordr[0].str() << tmpz0dzordr[1].str() << tmpz0dzordr[2].str() << tmpz0dzordr[3].str() << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc index 63505b224f8a1..0caa8faf35288 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc @@ -20,21 +20,7 @@ void TrackFitMemory::writeTF(bool first) { oss << dirFT << "TrackFit_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirFT)) { - int fail = system((string("mkdir -p ") + dirFT).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirFT; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirFT, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index a116a646fb23c..11e2fcef97b63 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -249,8 +249,8 @@ std::string Tracklet::vmstrlayer(int layer, unsigned int allstubindex) { FPGAWord tmp; tmp.set(irinvvm, 5, true, __LINE__, __FILE__); std::string oss = index.str() + "|" + layerproj_[layer - 1].fpgazbin1projvm().str() + "|" + - layerproj_[layer - 1].fpgazbin2projvm().str() + "|" + layerproj_[layer - 1].fpgafinezvm().str() + - "|" + tmp.str() + "|" + std::to_string(PSseed()); + layerproj_[layer - 1].fpgazbin2projvm().str() + "|" + layerproj_[layer - 1].fpgafinezvm().str() + + "|" + layerproj_[layer-1].fpgafinephivm().str() + "|" + tmp.str() + "|" + std::to_string(PSseed()); return oss; } @@ -263,8 +263,8 @@ std::string Tracklet::vmstrdisk(int disk, unsigned int allstubindex) { index.set(allstubindex, 7, true, __LINE__, __FILE__); } std::string oss = index.str() + "|" + diskproj_[disk - 1].fpgarbin1projvm().str() + "|" + - diskproj_[disk - 1].fpgarbin2projvm().str() + "|" + diskproj_[disk - 1].fpgafinervm().str() + "|" + - diskproj_[disk - 1].getBendIndex().str(); + diskproj_[disk - 1].fpgarbin2projvm().str() + "|" + diskproj_[disk - 1].fpgafinervm().str() + + "|" + diskproj_[disk-1].fpgafinephivm().str() + "|" + diskproj_[disk - 1].getBendIndex().str(); return oss; } @@ -822,16 +822,16 @@ Track Tracklet::makeTrack(const vector& l1stubs) { } int Tracklet::layer() const { - int l1 = (innerFPGAStub_ && innerFPGAStub_->isBarrel()) ? innerStub_->layer() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->isBarrel()) ? middleStub_->layer() + 1 : 999, - l3 = (outerFPGAStub_ && outerFPGAStub_->isBarrel()) ? outerStub_->layer() + 1 : 999, l = min(min(l1, l2), l3); + int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk()layerdisk() + 1 : 999, + l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk()layerdisk() + 1 : 999, + l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk()layerdisk() + 1 : 999, l = min(min(l1, l2), l3); return (l < 999 ? l : 0); } int Tracklet::disk() const { - int d1 = (innerFPGAStub_ && innerFPGAStub_->isDisk()) ? innerStub_->disk() : 999, - d2 = (middleFPGAStub_ && middleFPGAStub_->isDisk()) ? middleStub_->disk() : 999, - d3 = (outerFPGAStub_ && outerFPGAStub_->isDisk()) ? outerStub_->disk() : 999, d = 999; + int d1 = (innerFPGAStub_ && (innerFPGAStub_->layerdisk()>=N_LAYER)) ? innerStub_->disk() : 999, + d2 = (middleFPGAStub_ && (middleFPGAStub_->layerdisk()>=N_LAYER)) ? middleStub_->disk() : 999, + d3 = (outerFPGAStub_ && (outerFPGAStub_->layerdisk()>=N_LAYER)) ? outerStub_->disk() : 999, d = 999; if (abs(d1) < min(abs(d2), abs(d3))) d = d1; if (abs(d2) < min(abs(d1), abs(d3))) @@ -900,9 +900,9 @@ unsigned int Tracklet::calcSeedIndex() const { assert(innerFPGAStub_ != nullptr); assert(outerFPGAStub_ != nullptr); if (middleFPGAStub_ && seedlayer == 2 && abs(seeddisk) == 1) { - int l1 = (innerFPGAStub_ && innerFPGAStub_->isBarrel()) ? innerStub_->layer() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->isBarrel()) ? middleStub_->layer() + 1 : 999, - l3 = (outerFPGAStub_ && outerFPGAStub_->isBarrel()) ? outerStub_->layer() + 1 : 999; + int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk()layerdisk() + 1 : 999, + l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk()layerdisk() + 1 : 999, + l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk()layerdisk() + 1 : 999; if (l1 + l2 + l3 < 1998) { // If two stubs are layer stubs seedindex = 10; // L2L3D1 } else { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc index edf75772c4758..5800d9b7c8c08 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc @@ -43,7 +43,7 @@ TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Gl } // write the drinv and invt inverse tables - if ((settings_.writeInvTable() || settings_.writeHLSInvTable()) && iTC_ == 0 && iSector_ == 0) { + if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable() ) && iTC_ == 0 && iSector_ == 0) { void (*writeLUT)(const VarInv&, const string&) = nullptr; if (settings.writeInvTable()) { // Verilog version writeLUT = [](const VarInv& x, const string& basename) -> void { @@ -155,6 +155,9 @@ void TrackletCalculator::execute() { unsigned int countall = 0; unsigned int countsel = 0; + 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(); @@ -172,8 +175,8 @@ void TrackletCalculator::execute() { edm::LogVerbatim("Tracklet") << "TrackletCalculator execute " << getName() << "[" << iSector_ << "]"; } - if (innerFPGAStub->isBarrel() && (getName() != "TC_D1L2A" && getName() != "TC_D1L2B")) { - if (outerFPGAStub->isDisk()) { + if (innerFPGAStub->layerdisk()layerdisk()>=N_LAYER) { //overlap seeding bool accept = overlapSeeding(outerFPGAStub, outerStub, innerFPGAStub, innerStub); if (accept) @@ -181,16 +184,20 @@ void TrackletCalculator::execute() { } else { //barrel+barrel seeding bool accept = barrelSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); + if (print) { + cout << stubpair->getName()<<" i inner outer : "<allStubIndex().value()<<" " + <allStubIndex().value()<<" accept = "<isDisk()) { + if (outerFPGAStub->layerdisk()>=N_LAYER) { //disk+disk seeding bool accept = diskSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); if (accept) countsel++; - } else if (innerFPGAStub->isDisk()) { + } else if (innerFPGAStub->layerdisk()>=N_LAYER) { //layer+disk seeding bool accept = overlapSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); if (accept) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index 86299e4ce3293..4a889b8506b27 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -211,14 +211,14 @@ void TrackletCalculatorBase::exactprojdisk(double zproj, } void TrackletCalculatorBase::addDiskProj(Tracklet* tracklet, int disk) { - FPGAWord fpgar = tracklet->fpgarprojdisk(disk); + FPGAWord fpgar = tracklet->diskProj(disk).fpgarproj(); if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm()) return; if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk()) return; - FPGAWord fpgaphi = tracklet->fpgaphiprojdisk(disk); + FPGAWord fpgaphi = tracklet->diskProj(disk).fpgaphiproj(); int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5); @@ -230,8 +230,8 @@ void TrackletCalculatorBase::addDiskProj(Tracklet* tracklet, int disk) { bool TrackletCalculatorBase::addLayerProj(Tracklet* tracklet, int layer) { assert(layer > 0); - FPGAWord fpgaz = tracklet->fpgazproj(layer); - FPGAWord fpgaphi = tracklet->fpgaphiproj(layer); + FPGAWord fpgaz = tracklet->layerProj(layer).fpgazproj(); + FPGAWord fpgaphi = tracklet->layerProj(layer).fpgaphiproj(); if (fpgaphi.atExtreme()) edm::LogProblem("Tracklet") << "at extreme! " << fpgaphi.value(); @@ -333,12 +333,12 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, const Stub* outerFPGAStub, const L1TStub* outerStub) { if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "TrackletCalculator " << getName() + edm::LogVerbatim("Tracklet") << "TrackletCalculatorBase " << getName() << " trying stub pair in layer (inner outer): " << innerFPGAStub->layer().value() << " " << outerFPGAStub->layer().value(); } - assert(outerFPGAStub->isBarrel()); + assert(outerFPGAStub->layerdisk()layer().value()); assert(layerdisk1_ < N_LAYER && layerdisk2_ < N_LAYER); @@ -561,11 +561,18 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, izproj[3] = ITC->zL_3_final.ival(); if (!goodTrackPars(ITC->rinv_final.local_passes(), ITC->z0_final.local_passes())) { + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " Failed rinv or z0 cut"; + } return false; } - if (!inSector(iphi0, irinv, phi0approx, rinvapprox)) + if (!inSector(iphi0, irinv, phi0approx, rinvapprox)) { + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " Failed in sector check"; + } return false; + } for (unsigned int i = 0; i < N_LAYER - 2; ++i) { //reject projection if z is out of range @@ -589,7 +596,6 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, layerprojs[i].init(settings_, settings_.projlayers(iSeed_, i), - settings_.rmean(settings_.projlayers(iSeed_, i) - 1), iphiproj[i], izproj[i], ITC->der_phiL_final.ival(), @@ -602,7 +608,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, zprojapprox[i], ITC->der_phiL_final.fval(), ITC->der_zL_final.fval(), - !(iSeed_ == 1 || iSeed_ == 2)); + !(iSeed_ == 2 || iSeed_ == 3)); } iphiprojdisk[0] = ITC->phiD_0_final.ival(); @@ -991,7 +997,6 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, layerprojs[i].init(settings_, i + 1, - settings_.rmean(i), iphiproj[i], izproj[i], ITC->der_phiL_final.ival(), @@ -1027,7 +1032,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, continue; diskprojs[i].init(settings_, - i + 1, + settings_.projdisks(iSeed_, i), settings_.zmean(settings_.projdisks(iSeed_, i) - 1), iphiprojdisk[i], irprojdisk[i], @@ -1113,9 +1118,9 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, const Stub* outerFPGAStub, const L1TStub* outerStub) { //Deal with overlap stubs here - assert(outerFPGAStub->isBarrel()); + assert(outerFPGAStub->layerdisk()isDisk()); + assert(innerFPGAStub->layerdisk()>=N_LAYER); int disk = innerFPGAStub->disk().value(); @@ -1365,7 +1370,6 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, layerprojs[i].init(settings_, i + 1, - settings_.rmean(i), iphiproj[i], izproj[i], ITC->der_phiL_final.ival(), @@ -1393,8 +1397,8 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, continue; diskprojs[i].init(settings_, - i + 1, - settings_.zmean(i), + i + 2, + settings_.zmean(i+1), iphiprojdisk[i], irprojdisk[i], ITC->der_phiD_final.ival(), diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 5c99dfd6238a4..d51c3fe3b9b82 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -244,20 +244,20 @@ void TrackletCalculatorDisplaced::execute() { if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced execute " << getName() << "[" << iSector_ << "]"; - if (innerFPGAStub->isBarrel() && middleFPGAStub->isBarrel() && outerFPGAStub->isBarrel()) { + if (innerFPGAStub->layerdisk()layerdisk()layerdisk()isDisk() && middleFPGAStub->isDisk() && outerFPGAStub->isDisk()) { + } else if (innerFPGAStub->layerdisk()>=N_LAYER && middleFPGAStub->layerdisk()>=N_LAYER && outerFPGAStub->layerdisk()>=N_LAYER) { throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Invalid seeding!"; } else { //layer+disk seeding - if (innerFPGAStub->isBarrel() && middleFPGAStub->isDisk() && outerFPGAStub->isDisk()) { //D1D2L2 + if (innerFPGAStub->layerdisk()layerdisk()>=N_LAYER && outerFPGAStub->layerdisk()>=N_LAYER) { //D1D2L2 bool accept = DDLSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub); if (accept) countsel++; - } else if (innerFPGAStub->isDisk() && middleFPGAStub->isBarrel() && outerFPGAStub->isBarrel()) { //L2L3D1 + } else if (innerFPGAStub->layerdisk()>=N_LAYER && middleFPGAStub->layerdisk()layerdisk()fpgarprojdisk(disk); + FPGAWord fpgar = tracklet->diskProj(disk).fpgarproj(); if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm()) return; if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk()) return; - FPGAWord fpgaphi = tracklet->fpgaphiprojdisk(disk); + FPGAWord fpgaphi = tracklet->diskProj(disk).fpgaphiproj(); int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5); int iphi = iphivmRaw / (32 / settings_.nallstubs(abs(disk) + N_DISK)); @@ -310,8 +310,8 @@ void TrackletCalculatorDisplaced::addDiskProj(Tracklet* tracklet, int disk) { bool TrackletCalculatorDisplaced::addLayerProj(Tracklet* tracklet, int layer) { assert(layer > 0); - FPGAWord fpgaz = tracklet->fpgazproj(layer); - FPGAWord fpgaphi = tracklet->fpgaphiproj(layer); + FPGAWord fpgaz = tracklet->layerProj(layer).fpgazproj(); + FPGAWord fpgaphi = tracklet->layerProj(layer).fpgaphiproj(); if (fpgaz.atExtreme()) return false; @@ -372,7 +372,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, << " trying stub triplet in layer (L L L): " << innerFPGAStub->layer().value() << " " << middleFPGAStub->layer().value() << " " << outerFPGAStub->layer().value(); - assert(outerFPGAStub->isBarrel()); + assert(outerFPGAStub->layerdisk()r(); double z1 = innerStub->z(); @@ -454,32 +454,33 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK]; //TODO: implement the actual integer calculation - if (settings_.useapprox()) { + if(settings_.useapprox()){ approxtracklet(r1, - z1, - phi1, - r2, - z2, - phi2, - r3, - z3, - phi3, - take3, - ndisks, - rinvapprox, - phi0approx, - d0approx, - tapprox, - z0approx, - phiprojapprox, - zprojapprox, - phiderapprox, - zderapprox, - phiprojdiskapprox, - rprojdiskapprox, - phiderdiskapprox, - rderdiskapprox); - } else { + z1, + phi1, + r2, + z2, + phi2, + r3, + z3, + phi3, + take3, + ndisks, + rinvapprox, + phi0approx, + d0approx, + tapprox, + z0approx, + phiprojapprox, + zprojapprox, + phiderapprox, + zderapprox, + phiprojdiskapprox, + rprojdiskapprox, + phiderdiskapprox, + rderdiskapprox); + } + else{ rinvapprox = rinv; phi0approx = phi0; d0approx = d0; @@ -870,32 +871,33 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK]; //TODO: implement the actual integer calculation - if (settings_.useapprox()) { + if(settings_.useapprox()){ approxtracklet(r1, - z1, - phi1, - r2, - z2, - phi2, - r3, - z3, - phi3, - take3, - ndisks, - rinvapprox, - phi0approx, - d0approx, - tapprox, - z0approx, - phiprojapprox, - zprojapprox, - phiderapprox, - zderapprox, - phiprojdiskapprox, - rprojdiskapprox, - phiderdiskapprox, - rderdiskapprox); - } else { + z1, + phi1, + r2, + z2, + phi2, + r3, + z3, + phi3, + take3, + ndisks, + rinvapprox, + phi0approx, + d0approx, + tapprox, + z0approx, + phiprojapprox, + zprojapprox, + phiderapprox, + zderapprox, + phiprojdiskapprox, + rprojdiskapprox, + phiderdiskapprox, + rderdiskapprox); + } + else{ rinvapprox = rinv; phi0approx = phi0; d0approx = d0; @@ -1270,32 +1272,33 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK]; //TODO: implement the actual integer calculation - if (settings_.useapprox()) { + if(settings_.useapprox()){ approxtracklet(r1, - z1, - phi1, - r2, - z2, - phi2, - r3, - z3, - phi3, - take3, - ndisks, - rinvapprox, - phi0approx, - d0approx, - tapprox, - z0approx, - phiprojapprox, - zprojapprox, - phiderapprox, - zderapprox, - phiprojdiskapprox, - rprojdiskapprox, - phiderdiskapprox, - rderdiskapprox); - } else { + z1, + phi1, + r2, + z2, + phi2, + r3, + z3, + phi3, + take3, + ndisks, + rinvapprox, + phi0approx, + d0approx, + tapprox, + z0approx, + phiprojapprox, + zprojapprox, + phiderapprox, + zderapprox, + phiprojdiskapprox, + rprojdiskapprox, + phiderdiskapprox, + rderdiskapprox); + } + else{ rinvapprox = rinv; phi0approx = phi0; d0approx = d0; @@ -1679,8 +1682,16 @@ void TrackletCalculatorDisplaced::exacttracklet(double r1, double y2 = r2 * sin(phi2); double y3 = r3 * sin(phi3); - double k1 = -(x2 - x1) / (y2 - y1); - double k2 = -(x3 - x2) / (y3 - y2); + double dy21=y2-y1; + double dy32=y3-y2; + + //Hack to protect against dividing by zero + //code should be rewritten to avoid this + if (dy21==0.0) dy21=1e-9; + if (dy32==0.0) dy32=1e-9; + + double k1 = -(x2 - x1) / dy21; + double k2 = -(x3 - x2) / dy32; double b1 = 0.5 * (y2 + y1) - 0.5 * (x1 + x2) * k1; double b2 = 0.5 * (y3 + y2) - 0.5 * (x2 + x3) * k2; //their intersection gives the center of the circle @@ -1885,9 +1896,10 @@ void TrackletCalculatorDisplaced::approxtracklet(double r1, phi0 = -phi1c * r1 * (r2 + r3) * a + phi2c * r2 * (r1 + r3) * b - phi3c * r3 * (r1 + r2) * c; d0 = r1 * r2 * r3 * (-phi1c * a + phi2c * b - phi3c * c); - t = ((z - z1) / (r - r1)) * - (1. + d0 * halfRinv - 0.5 * d0OverR1 * d0OverR - sixth * (r1 * r1 + r2 * r2 + r1 * r2) * halfRinv_0 * halfRinv_0); - z0 = z1 - t * r1 * (1.0 - d0_0 * halfRinv_0 - 0.5 * d0OverR1 * d0OverR1 + sixth * r1 * r1 * halfRinv_0 * halfRinv_0); + t = ((z - z1) / (r - r1)) * (1. + d0 * halfRinv - 0.5 * d0OverR1 * d0OverR - + sixth * (r1 * r1 + r2 * r2 + r1 * r2) * halfRinv_0 * halfRinv_0); + z0 = z1 - + t * r1 * (1.0 - d0_0 * halfRinv_0 - 0.5 * d0OverR1 * d0OverR1 + sixth * r1 * r1 * halfRinv_0 * halfRinv_0); rinv = 2.0 * halfRinv; phi0 += -phimin_; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc new file mode 100644 index 0000000000000..2636ea1b1d6cb --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc @@ -0,0 +1,1264 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h" +#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" + +using namespace std; +using namespace trklet; + +TrackletConfigBuilder::TrackletConfigBuilder(const Settings& settings): + settings_(settings){ + + NSector_=N_SECTOR; + rcrit_=settings.rcrit(); + + combinedmodules_=settings.combined(); + + extended_=settings.extended(); + + rinvmax_=settings.rinvmax(); + + rmaxdisk_=settings.rmaxdisk(); + zlength_=settings.zlength(); + + for (int i=0;i(settings.nvmte(0,iseed),settings.nvmte(1,iseed)); + NTC_[iseed]=settings.NTC(iseed); + } + + initGeom(); + + buildTE(); + + buildTC(); + + buildProjections(); + +} + +std::pair TrackletConfigBuilder::seedLayers(unsigned int iSeed) { + + return std::pair(settings_.seedlayers(0,iSeed),settings_.seedlayers(1,iSeed)); + +} + + +void TrackletConfigBuilder::initGeom(){ + + for(unsigned int ilayer=0;ilayer > emptyVec; + projections_[ilayer].push_back(emptyVec); + double phimin=dphi*iReg; + double phimax=phimin+dphi; + std::pair tmp(phimin,phimax); + allStubs_[ilayer].push_back(tmp); + double dphiVM=dphi/NVMME_[ilayer]; + for(unsigned int iVM=0;iVM tmp(phivmmin,phivmmax); + VMStubsME_[ilayer].push_back(tmp); + } + } + } + for(unsigned int iseed=0;iseed tmp(phivmmin,phivmmax); + VMStubsTE_[iseed].first.push_back(tmp); + } + dphiVM=dphisectorHG_/(nVM2*NRegions_[l2]); + for(unsigned int iVM=0;iVM tmp(phivmmin,phivmmax); + VMStubsTE_[iseed].second.push_back(tmp); + } + } +} + +std::pair TrackletConfigBuilder::seedRadii(unsigned int iseed) { + + std::pair seedlayers=seedLayers(iseed); + + unsigned int l1=seedlayers.first; + unsigned int l2=seedlayers.second; + + double r1,r2; + + if (iseed<4) { //barrel seeding + r1=rmean_[l1]; + r2=rmean_[l2]; + } else if (iseed<6) { //disk seeding + r1=rmean_[0]+40.0; //Somwwhat of a hack - but allows finding all the regions + //when projecting to L1 + r2=r1*zmean_[l2-6]/zmean_[l1-6]; + } else { //overlap seeding + r1=rmean_[l1]; + r2=r1*zmean_[l2-6]/zlength_; + } + + return std::pair(r1,r2); +} + + +bool TrackletConfigBuilder::validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2){ + + double rinvmin=999.9; + double rinvmax=-999.9; + + double phi1[2]={VMStubsTE_[iseed].first[iTE1].first,VMStubsTE_[iseed].first[iTE1].second}; + double phi2[2]={VMStubsTE_[iseed].second[iTE2].first,VMStubsTE_[iseed].second[iTE2].second}; + + std::pair seedradii=seedRadii(iseed); + + for (unsigned int i1=0;i1<2;i1++) { + for (unsigned int i2=0;i2<2;i2++) { + double arinv=rinv(seedradii.first,phi1[i1],seedradii.second,phi2[i2]); + if (arinvrinvmax) rinvmax=arinv; + } + } + + if (rinvmin>rinvmax_) return false; + if (rinvmax<-rinvmax_) return false; + + return true; + +} + +void TrackletConfigBuilder::buildTE() { + + for(unsigned int iseed=0;iseed tmp(i1,i2); + TE_[iseed].push_back(tmp); + } + } + } + } +} + + +void TrackletConfigBuilder::buildTC(){ + + for(unsigned int iSeed=0;iSeed >& TEs=TE_[iSeed]; + std::vector >& TCs=TC_[iSeed]; + + //Very naive method to group TEs in TC + + double invnTC=nTC*(1.0/TEs.size()); + + for(unsigned int iTE=0;iTE=(int)TCs.size()) { + std::vector tmp; + tmp.push_back(iTE); + TCs.push_back(tmp); + } else { + TCs[iTC].push_back(iTE); + } + } + } +} + +std::pair TrackletConfigBuilder::seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC){ + + std::vector >& TCs=TC_[iSeed]; + + std::pair seedradii=seedRadii(iSeed); + + double phimin=999.0; + double phimax=-999.0; + for (unsigned int iTE=0;iTEphimax) phimax=aphi; + } + } + } + return std::pair(phimin,phimax); +} + +void TrackletConfigBuilder::buildProjections(){ + + + for(unsigned int iseed=0;iseed >& TCs=TC_[iseed]; + + for (unsigned int ilayer=0;ilayer phiRange=seedPhiRange(rproj,iseed,iTC); + if (phiRange.firstallStubs_[ilayer][iReg].first) { + std::pair tmp(iseed,iTC); //seedindex and TC + projections_[ilayer][iReg].push_back(tmp); + } + } + } + } + } +} + + +double TrackletConfigBuilder::phi(double r1, double phi1, double r2, double phi2,double r) { + + double rhoinv=rinv(r1,phi1,r2,phi2); + if (fabs(rhoinv)>rinvmax_) { + rhoinv=rinvmax_*rhoinv/fabs(rhoinv); + } + return phi1+asin(0.5*r*rhoinv)-asin(0.5*r1*rhoinv); + +} + + + +double TrackletConfigBuilder::rinv(double r1, double phi1, double r2, double phi2) { + + double deltaphi=phi1-phi2; + return 2*sin(deltaphi)/sqrt(r2*r2+r1*r1-2*r1*r2*cos(deltaphi)); + +} + +std::string TrackletConfigBuilder::iSeedStr(unsigned int iSeed) { + + static std::string name[8]={"L1L2","L2L3","L3L4","L5L6","D1D2","D3D4","L1D1","L2D1"}; + + assert(iSeed<8); + return name[iSeed]; + +} + + +std::string TrackletConfigBuilder::numStr(unsigned int i) { + + static std::string num[32]={"1","2","3","4","5","6","7","8","9","10", + "11","12","13","14","15","16","17","18","19","20", + "21","22","23","24","25","26","27","28","29","30","31","32"}; + assert(i<32); + return num[i]; + +} + +std::string TrackletConfigBuilder::iTCStr(unsigned int iTC) { + + static std::string name[12]={"A","B","C","D","E","F","G","H","I","J","K","L"}; + + assert(iTC<12); + return name[iTC]; + +} + +std::string TrackletConfigBuilder::iRegStr(unsigned int iReg, unsigned int iSeed) { + + static std::string name[8]={"A","B","C","D","E","F","G","H"}; + + static std::string nameOverlap[8]={"X","Y","Z","W","Q","R","S","T"}; + + static std::string nameL2L3[4]={"I","J","K","L"}; + + if (iSeed==1) { + assert(iReg<4); + return nameL2L3[iReg]; + } + if (iSeed==6||iSeed==7) { + assert(iReg<8); + return nameOverlap[iReg]; + } + assert(iReg<8); + return name[iReg]; + +} + + + +std::string TrackletConfigBuilder::TCName(unsigned int iSeed,unsigned int iTC){ + if (combinedmodules_) { + return "TP_"+iSeedStr(iSeed)+iTCStr(iTC); + } else { + return "TC_"+iSeedStr(iSeed)+iTCStr(iTC); + } +} + +std::string TrackletConfigBuilder::LayerName(unsigned int ilayer) { + return ilayer<6?("L"+numStr(ilayer)):("D"+numStr(ilayer-6)); +} + +std::string TrackletConfigBuilder::TPROJName(unsigned int iSeed, unsigned int iTC, + unsigned int ilayer, unsigned int ireg) { + return "TPROJ_"+iSeedStr(iSeed)+iTCStr(iTC)+"_"+LayerName(ilayer)+"PHI"+iTCStr(ireg); +} + +std::string TrackletConfigBuilder::PRName(unsigned int ilayer, unsigned int ireg) { + if (combinedmodules_) { + return "MP_"+LayerName(ilayer)+"PHI"+iTCStr(ireg); + } else { + return "PR_"+LayerName(ilayer)+"PHI"+iTCStr(ireg); + } +} + +void TrackletConfigBuilder::writeProjectionMemories(std::ostream& os, std::ostream& memories, std::ostream&){ + + for(unsigned int ilayer=0;ilayer "< "< "< "< stubTriplets[N_SEED]; + + for(unsigned int iSeed=N_SEED_PROMPT;iSeed "< " + <0) { + unsigned int nallstub = settings_.nallstubs(ilay-1); + for (unsigned int ireg=0;ireg0) { + unsigned int nallstub = settings_.nallstubs(idisk+5); + for (unsigned int ireg=0;ireg "<< TCDName(layerdisk1,layerdisk2,layerdisk3,itc)<<".projout"< "<< "PR_"< " << trename << ".stubtripout output=> " + << TCDName(layerdisk1,layerdisk2,layerdisk3,iTC) << ".stubtriplet"<<((iST*nTC)%nST)<<"in"< PR_"< MC_"< ME_"< MC_"< PR_"< ME_" + << LayerName(ilayer)<<"PHI"< MP_"< FT_"< MC_"< FT_"< VMR_"< MP_"<max) + continue; + + if (max-min>=2) { + ext="M"; + if (iReg==min) + ext="R"; + if (iReg==max) + ext="L"; + } + + if (max-min==1) { + if (nTCReg==2) { + assert(0); + if (jTCReg==0){ + if (iReg==min) + ext="R"; + if (iReg==max) + ext="B"; + } + if (jTCReg==1){ + if (iReg==min) + ext="A"; + if (iReg==max) + ext="L"; + } + } + if (nTCReg==3) { + if (jTCReg==0){ + if (iReg==min) + ext="A"; + if (iReg==max) + ext="F"; + } + if (jTCReg==1){ + if (iReg==min) + ext="E"; + if (iReg==max) + ext="D"; + } + if (jTCReg==2){ + if (iReg==min) + ext="C"; + if (iReg==max) + ext="B"; + } + } + } + //cout << "iseed ratio max min : "<5) { + ext="_O"+ext; + } else { + ext="_D"+ext; + } + + nmem++; + if (inner) { + memories << "AllInnerStubs: "; + } else { + memories << "AllStubs: "; + } + memories << "AS_"< VMR_"< TP_"< VMR_"< MC_"< VMR_"< TC_"< VMR_"< MP_"< VMR_"< TP_"< VMR_"< ME_"< VMR_"< TE_"< TP_"< FT_"< TC_"< FT_"< FT_"< PD.trackin"< PD.trackout output=>"<phimaxtmp && + allStubs_[layerdisk[i]][iReg].second output=> VMR_"<phimintmp) { + memories << "InputLink: IL_"< output=> VMR_"< bendinnermax) @@ -237,20 +237,20 @@ void TrackletEngine::setVMPhiBin() { bool passptcut = rinvmin < settings_.rinvcutte(); for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) { - double bend = benddecode(ibend, nbendbitsinner == 3); + double bend = settings_.benddecode(ibend, layerdisk1_, nbendbitsinner == 3); - bool passinner = bend - bendinnermin > -settings_.bendcutte(0, iSeed_) && - bend - bendinnermax < settings_.bendcutte(0, iSeed_); + bool passinner = bend > bendinnermin - settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3) && + bend < bendinnermax + settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3); if (passinner) vmbendinner[ibend] = true; pttableinner_.push_back(passinner && passptcut); } for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) { - double bend = benddecode(ibend, nbendbitsouter == 3); + double bend = settings_.benddecode(ibend, layerdisk2_, nbendbitsouter == 3); - bool passouter = bend - bendoutermin > -settings_.bendcutte(1, iSeed_) && - bend - bendoutermax < settings_.bendcutte(1, iSeed_); + bool passouter = bend > bendoutermin - settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3) && + bend < bendoutermax + settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3); if (passouter) vmbendouter[ibend] = true; pttableouter_.push_back(passouter && passptcut); @@ -267,18 +267,9 @@ void TrackletEngine::setVMPhiBin() { } void TrackletEngine::writeTETable() { - if (not std::filesystem::exists(settings_.tablePath())) { - int fail = system((string("mkdir -p ") + settings_.tablePath()).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " - << settings_.tablePath(); - } - - const string fnameI = settings_.tablePath() + getName() + "_stubptinnercut.tab"; - ofstream outstubptinnercut(fnameI); - if (outstubptinnercut.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fnameI; + ofstream outstubptinnercut=openfile(settings_.tablePath(), getName() + "_stubptinnercut.tab", __FILE__, __LINE__); + outstubptinnercut << "{" << endl; for (unsigned int i = 0; i < pttableinner_.size(); i++) { if (i != 0) @@ -288,10 +279,7 @@ void TrackletEngine::writeTETable() { outstubptinnercut << endl << "};" << endl; outstubptinnercut.close(); - const string fnameO = settings_.tablePath() + getName() + "_stubptoutercut.tab"; - ofstream outstubptoutercut(fnameO); - if (outstubptoutercut.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fnameI; + ofstream outstubptoutercut=openfile(settings_.tablePath(), getName() + "_stubptoutercut.tab", __FILE__, __LINE__); outstubptoutercut << "{" << endl; for (unsigned int i = 0; i < pttableouter_.size(); i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc index 201b0b9b99723..850244d4985c8 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc @@ -175,17 +175,21 @@ void TrackletEngineDisplaced::execute() { (index >= table_.size() || table_.at(index).empty())) { if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : " - << benddecode(firstvmstub.bend().value(), firstvmstub.isPSmodule()) << " " - << benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule()); + << settings_.benddecode(firstvmstub.bend().value(),layer1_-1, firstvmstub.isPSmodule()) << " " + << settings_.benddecode(secondvmstub.bend().value(),layer2_-1, secondvmstub.isPSmodule()); } - continue; + + //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()) || - (index < table_.size() && table_.at(index).count(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_ << "_" << iSector_ << " " << iSeed_ << endl; @@ -255,8 +259,8 @@ void TrackletEngineDisplaced::execute() { (index >= table_.size() || table_.at(index).empty())) { if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : " - << benddecode(firstvmstub.bend().value(), firstvmstub.isPSmodule()) << " " - << benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule()); + << settings_.benddecode(firstvmstub.bend().value(), layer1_-1, firstvmstub.isPSmodule()) << " " + << settings_.benddecode(secondvmstub.bend().value(), layer2_-1, secondvmstub.isPSmodule()); } continue; } @@ -335,8 +339,8 @@ void TrackletEngineDisplaced::execute() { (index >= table_.size() || table_.at(index).empty())) { if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : " - << benddecode(firstvmstub.bend().value(), firstvmstub.isPSmodule()) << " " - << benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule()); + << settings_.benddecode(firstvmstub.bend().value(), disk1_+5, firstvmstub.isPSmodule()) << " " + << settings_.benddecode(secondvmstub.bend().value(), disk2_+5, secondvmstub.isPSmodule()); } continue; } @@ -412,7 +416,7 @@ void TrackletEngineDisplaced::readTables() { fin.close(); } -const short TrackletEngineDisplaced::memNameToIndex(const string& name) { +short TrackletEngineDisplaced::memNameToIndex(const string& name) { for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) if (stubpairs_.at(isp)->getName() == name) return isp; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc index 10bc49cad08a9..b1c2eae99af54 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc @@ -5,106 +5,142 @@ using namespace std; using namespace trklet; -TrackletEngineUnit::TrackletEngineUnit(const Settings* const settings, - unsigned int nbitsfinephi, - unsigned int layerdisk2, - unsigned int iSeed, - unsigned int nbitsfinephidiff, - unsigned int iAllStub, - std::vector const& pttableinner, - std::vector const& pttableouter, - VMStubsTEMemory* outervmstubs) - : settings_(settings), candpairs_(5) { - idle_ = true; - nbitsfinephi_ = nbitsfinephi; - layerdisk2_ = layerdisk2; - iSeed_ = iSeed; - nbitsfinephidiff_ = nbitsfinephidiff; - iAllStub_ = iAllStub; - pttableinner_ = pttableinner; - pttableouter_ = pttableouter; - outervmstubs_ = outervmstubs; +TrackletEngineUnit::TrackletEngineUnit(const Settings* const settings, unsigned int nbitsfinephi, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int iSeed, unsigned int nbitsfinephidiff, unsigned int iAllStub, std::vector const& pttableinner, std::vector const& pttableouter, VMStubsTEMemory* outervmstubs) + : settings_(settings), candpairs_(3) { + idle_=true; + nbitsfinephi_=nbitsfinephi; + layerdisk2_=layerdisk2; + layerdisk1_=layerdisk1; + iSeed_=iSeed; + nbitsfinephidiff_=nbitsfinephidiff; + iAllStub_=iAllStub; + pttableinner_=pttableinner; + pttableouter_=pttableouter; + outervmstubs_=outervmstubs; } -void TrackletEngineUnit::init(const TEData& tedata) { - tedata_ = tedata; - nreg_ = 0; - istub_ = 0; - idle_ = false; - assert(!tedata_.regions_.empty()); - std::tie(next_, ireg_, nstub_) = tedata_.regions_[0]; + +void TrackletEngineUnit::init(const TEData& tedata){ + tedata_=tedata; + nreg_=0; + istub_=0; + idle_=false; + assert(tedata_.regions_.size()>0); + std::tie(next_,ireg_,nstub_) = tedata_.regions_[0]; } -void TrackletEngineUnit::reset() { - idle_ = true; +void TrackletEngineUnit::reset(){ + idle_=true; + goodpair_=false; + goodpair__=false; candpairs_.reset(); } -void TrackletEngineUnit::step() { - if (candpairs_.full()) - return; +void TrackletEngineUnit::step(bool print, int istep,int iTE){ - int ibin = tedata_.start_ + next_; - int nbins = (1 << NFINERZBITS); + //if (print) cout << "istep="<nVMStubsBinned(ireg_ * nbins + ibin)); + if (goodpair__) { + if (print) cout << "istep="<allStubIndex().value()<<" "<allStubIndex().value()<nVMStubsBinned(ireg_*nbins+ibin)); + const VMStubTE& outervmstub = outervmstubs_->getVMStubTEBinned(ireg_ * nbins + ibin, istub_); - int rzbin = (outervmstub.vmbits().value() & (nbins - 1)); + int rzbin = (outervmstub.vmbits().value() & (nbins-1)); FPGAWord iphiouterbin = outervmstub.finephi(); assert(iphiouterbin == outervmstub.finephi()); - + //New code to calculate lut value int outerfinephi = iAllStub_ * (1 << (nbitsfinephi_ - settings_->nbitsallstubs(layerdisk2_))) + - ireg_ * (1 << settings_->nfinephi(1, iSeed_)) + iphiouterbin.value(); + ireg_ * (1 << settings_->nfinephi(1,iSeed_)) + iphiouterbin.value(); int idphi = outerfinephi - tedata_.innerfinephi_; - bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_ - 1))); - if (idphi < 0) - idphi = idphi + (1 << nbitsfinephidiff_); - unsigned int firstDiskSeed = 4; + bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_- 1 ))); + + idphi = idphi & ((1 << nbitsfinephidiff_) - 1); + + if (iSeed_ >= 4) { //Also use r-position + int ir = ((ibin & 3) << 1) + (rzbin >> 2); + idphi = (idphi << 3) + ir; + } + + if (next_!=0) + rzbin += 8; + + + unsigned int firstDiskSeed=4; if (iSeed_ >= firstDiskSeed) { //Also use r-position - int ibinMask = 3; //Get two least sign. bits - int ir = ((ibin & ibinMask) << 1) + (rzbin >> (NFINERZBITS - 1)); - int nrbits = 3; + int ibinMask=3; //Get two least sign. bits + int ir = ((ibin & ibinMask) << 1) + (rzbin >> (NFINERZBITS-1)); + int nrbits=3; idphi = (idphi << nrbits) + ir; } if (next_ != 0) - rzbin += (1 << NFINERZBITS); + rzbin += (1<>>>>>> ca9f4d8d9ec... Various fixes to comment on pull request (#68) if ((rzbin < tedata_.rzbinfirst_) || (rzbin - tedata_.rzbinfirst_ > tedata_.rzdiffmax_)) { if (settings_->debugTracklet()) { - edm::LogVerbatim("Tracklet") << " layer-disk stub pair rejected because rbin cut : " << rzbin << " " - << tedata_.rzbinfirst_ << " " << tedata_.rzdiffmax_; + edm::LogVerbatim("Tracklet") + << " layer-disk stub pair rejected because rbin cut : " << rzbin << " " << tedata_.rzbinfirst_ + << " " << tedata_.rzdiffmax_; } } else { - FPGAWord outerbend = outervmstub.bend(); + FPGAWord outerbend = outervmstub.bend(); + int ptinnerindex = (idphi << tedata_.innerbend_.nbits()) + tedata_.innerbend_.value(); int ptouterindex = (idphi << outerbend.nbits()) + outerbend.value(); if (!(inrange && pttableinner_[ptinnerindex] && pttableouter_[ptouterindex])) { if (settings_->debugTracklet()) { - edm::LogVerbatim("Tracklet") << " Stub pair rejected because of stub pt cut bends : " - << benddecode(tedata_.innerbend_.value(), tedata_.stub_->isPSmodule()) << " " - << benddecode(outerbend.value(), outervmstub.isPSmodule()); + edm::LogVerbatim("Tracklet") <<" Stub pair rejected because of stub pt cut bends : " + << settings_->benddecode(tedata_.innerbend_.value(), layerdisk1_, tedata_.stub_->isPSmodule()) << " " + << settings_->benddecode(outerbend.value(), layerdisk2_, outervmstub.isPSmodule()); } } else { - candpairs_.store(pair(tedata_.stub_, outervmstub.stub())); + candpair_=pair(tedata_.stub_, outervmstub.stub()); + goodpair_=true; } } + if (print) cout << "istep="<allStubIndex().value()<<" "<= nstub_) { - istub_ = 0; + assert(nstub_<=N_VMSTUBSMAX); + if (istub_>=nstub_) { + istub_=0; nreg_++; - if (nreg_ >= tedata_.regions_.size()) { - nreg_ = 0; - idle_ = true; + if (nreg_>=tedata_.regions_.size()) { + nreg_=0; + idle_=true; } else { - std::tie(next_, ireg_, nstub_) = tedata_.regions_[nreg_]; + std::tie(next_,ireg_,nstub_) = tedata_.regions_[nreg_]; } } + + } + diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index 77dc376c1e9e0..eeff1268a2af7 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -1,11 +1,12 @@ #include "L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h" +#include "L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h" #include "L1Trigger/TrackFindingTracklet/interface/Globals.h" #include "L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h" #include "L1Trigger/TrackFindingTracklet/interface/Sector.h" #include "L1Trigger/TrackFindingTracklet/interface/HistBase.h" #include "L1Trigger/TrackFindingTracklet/interface/Track.h" +#include "L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h" #include "L1Trigger/TrackFindingTracklet/interface/IMATH_TrackletCalculator.h" -#include "L1Trigger/TrackFindingTracklet/interface/Cabling.h" #include "DataFormats/Math/interface/deltaPhi.h" @@ -41,6 +42,12 @@ void TrackletEventProcessor::init(Settings const& theSettings) { throw cms::Exception("Inconsistency") << "t conversion parameter inconsistency\n"; } + if (settings_->kphider() != globals_->ITC_L1L2()->der_phiL_final.K()) { + throw cms::Exception("Inconsistency") << "t conversion parameter inconsistency:" + <kphider()/globals_->ITC_L1L2()->der_phiL_final.K()<<"\n"; + } + + if (settings_->debugTracklet()) { edm::LogVerbatim("Tracklet") << "========================================================= \n" << "Conversion factors for global coordinates: \n" @@ -78,14 +85,50 @@ void TrackletEventProcessor::init(Settings const& theSettings) { sectors_[i] = make_unique(i, *settings_, globals_.get()); } + if (settings_->extended()) { + + ifstream inmem(settings_->memoryModulesFile().c_str()); + assert(inmem.good()); + + ifstream inproc(settings_->processingModulesFile().c_str()); + assert(inproc.good()); + + ifstream inwire(settings_->wiresFile().c_str()); + assert(inwire.good()); + + configure(inwire,inmem,inproc); + + } else { + TrackletConfigBuilder config(*settings_); + + //Write configurations to file. + if (settings_->writeConfig()){ + std::ofstream wires=openfile(settings_->tablePath(), "wires.dat", __FILE__, __LINE__); + std::ofstream memories=openfile(settings_->tablePath(), "memories.dat", __FILE__, __LINE__); + std::ofstream modules=openfile(settings_->tablePath(), "modules.dat", __FILE__, __LINE__); + + config.writeAll(wires,memories,modules); + } + + std::stringstream wires; + std::stringstream memories; + std::stringstream modules; + + config.writeAll(wires,memories,modules); + configure(wires,memories,modules); + + } + +} + + +void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& inproc) { + // get the memory modules if (settings_->debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Will read memory modules file"; + edm::LogVerbatim("Tracklet") << "Will read memory modules"; } - ifstream inmem(settings_->memoryModulesFile().c_str()); - assert(inmem.good()); - while (inmem.good()) { string memType, memName, size; inmem >> memType >> memName >> size; @@ -101,11 +144,9 @@ void TrackletEventProcessor::init(Settings const& theSettings) { // get the processing modules if (settings_->debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Will read processing modules file"; + edm::LogVerbatim("Tracklet") << "Will read processing modules"; } - ifstream inproc(settings_->processingModulesFile().c_str()); - assert(inproc.good()); while (inproc.good()) { string procType, procName; @@ -125,8 +166,6 @@ void TrackletEventProcessor::init(Settings const& theSettings) { edm::LogVerbatim("Tracklet") << "Will read wiring information"; } - ifstream inwire(settings_->wiresFile().c_str()); - assert(inwire.good()); while (inwire.good()) { string line; @@ -151,27 +190,11 @@ void TrackletEventProcessor::init(Settings const& theSettings) { } } - // get the DTC/cabling information - ifstream indtc(settings_->DTCLinkLayerDiskFile()); - assert(indtc.good()); - string dtc; - indtc >> dtc; - while (indtc.good()) { - vector tmp; - dtclayerdisk_[dtc] = tmp; - int layerdisk; - indtc >> layerdisk; - while (layerdisk > 0) { - dtclayerdisk_[dtc].push_back(layerdisk); - indtc >> layerdisk; - } - indtc >> dtc; - } - - cabling_ = make_unique(settings_->DTCLinkFile(), settings_->moduleCablingFile(), *settings_); } + void TrackletEventProcessor::event(SLHCEvent& ev) { + globals_->event() = &ev; tracks_.clear(); @@ -185,127 +208,38 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { } cleanTimer_.stop(); + if (settings_->writeMem()) { + sectors_[settings_->writememsect()]->writeLinkNewEvent(eventnum_); + } + addStubTimer_.start(); + vector layerstubs(N_LAYER+N_DISK,0); + vector layerstubssector(N_SECTOR*(N_LAYER+N_DISK),0); + for (int j = 0; j < ev.nstubs(); j++) { L1TStub stub = ev.stub(j); - int layer = stub.layer() + 1; - int ladder = stub.ladder(); - int module = stub.module(); - - string dtc = cabling_->dtc(layer, ladder, module); - string dtcbase = dtc.substr(2, dtc.size() - 2); - if (dtc[0] == 'n') { - dtcbase = dtc.substr(0, 4) + dtc.substr(6, dtc.size() - 6); - } - - cabling_->addphi(dtc, stub.phi(), layer, module); + string dtc=stub.DTClink(); + unsigned int isector = stub.region(); - double phi = angle0to2pi::make0To2pi(stub.phi() + 0.5 * settings_->dphisectorHG()); - - unsigned int isector = N_SECTOR * phi / (2 * M_PI); + layerstubs[stub.layerdisk()]++; + layerstubssector[isector*(N_LAYER+N_DISK)+stub.layerdisk()]++; + + sectors_[isector]->addStub(stub, dtc); + } - for (unsigned int k = 0; k < N_SECTOR; k++) { - int diff = k - isector; - if (diff > (int)N_SECTOR / 2) - diff -= (int)N_SECTOR; - if (diff < (-1) * (int)N_SECTOR / 2) - diff += (int)N_SECTOR; - if (abs(diff) > 1) - continue; - double phiminsect = - k * 2 * M_PI / N_SECTOR - 0.5 * (settings_->dphisectorHG() - 2 * M_PI / N_SECTOR) - M_PI / N_SECTOR; - double dphi = stub.phi() - phiminsect; - if (dphi > M_PI) - dphi -= 2 * M_PI; - while (dphi < 0.0) - dphi += 2 * M_PI; - if (dphi > settings_->dphisectorHG()) - continue; - bool add = sectors_[k]->addStub(stub, dtcbase); - - static std::map dtcstubs; - - if (settings_->writeMem()) { - vector dtcs = cabling_->DTCs(); - for (const auto& dtc : dtcs) { - string dtcbase = dtc.substr(2, dtc.size() - 2); - if (dtc[0] == 'n') { - dtcbase = dtc.substr(0, 4) + dtc.substr(6, dtc.size() - 6); - } - - const string dirIS = settings_->memPath() + "InputStubs/"; - string fname = dirIS + "Link_"; - fname += dtcbase; - if (dtcstubs.find(dtcbase + "A") != dtcstubs.end()) - continue; - fname += "_A.dat"; - - if (not std::filesystem::exists(dirIS)) { - int fail = system((string("mkdir -p ") + dirIS).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirIS; - } - - ofstream* out = new ofstream; - out->open(fname); - if (out->fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - dtcstubs[dtcbase + "A"] = out; - - fname = dirIS + "Link_"; - fname += dtcbase; - if (dtcstubs.find(dtcbase + "B") != dtcstubs.end()) - continue; - fname += "_B.dat"; - out = new ofstream; - out->open(fname); - if (out->fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - dtcstubs[dtcbase + "B"] = out; - } - - static int oldevent = -1; - if (eventnum_ != oldevent) { - oldevent = eventnum_; - for (auto& dtcstub : dtcstubs) { - FPGAWord tmp; - tmp.set(eventnum_ % 8, 3); - (*(dtcstub.second)) << "BX " << tmp.str() << " Event : " << eventnum_ + 1 << endl; - } - } - } + if (settings_->writeMonitorData("StubsLayerSector")) { + for (unsigned int index=0;indexofstream("stubslayersector.txt") << layerdisk << " " << sector << " " << layerstubssector[index] << endl; + } + } - if (add && settings_->writeMem() && k == settings_->writememsect()) { - Stub fpgastub(stub, *settings_, sectors_[k]->phimin(), sectors_[k]->phimax()); - FPGAWord phi = fpgastub.phi(); - int topbit = phi.value() >> (phi.nbits() - 1); - std::vector tmp = dtclayerdisk_[dtcbase]; - int layerdisk = stub.layer() + 1; - if (layerdisk > 999) { - layerdisk = 10 + abs(stub.disk()); - } - int layerdiskcode = -1; - for (unsigned int i = 0; i < tmp.size(); i++) { - if (tmp[i] == layerdisk) - layerdiskcode = i; - } - if (layerdiskcode == -1) { - edm::LogVerbatim("Tracklet") << "dtcbase layerdisk layer disk : " << dtcbase << " " << layerdisk << " " - << stub.layer() + 1 << " " << stub.disk(); - } - assert(layerdiskcode >= 0); - assert(layerdiskcode < 4); - FPGAWord ldcode; - ldcode.set(layerdiskcode, 2); - string dataword = fpgastub.str() + "|" + ldcode.str() + "|1"; - if (topbit == 0) { - (*dtcstubs[dtcbase + "A"]) << dataword << " " << trklet::hexFormat(dataword) << endl; - } else { - (*dtcstubs[dtcbase + "B"]) << dataword << " " << trklet::hexFormat(dataword) << endl; - } - } + if (settings_->writeMonitorData("StubsLayer")) { + for (unsigned int layerdisk=0;layerdiskofstream("stubslayer.txt") << layerdisk << " " << layerstubs[layerdisk] << endl; } } @@ -323,6 +257,7 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { sectors_[k]->writeVMSTE(first); sectors_[k]->writeVMSME(first); sectors_[k]->writeAS(first); + sectors_[k]->writeAIS(first); } } VMRouterTimer_.stop(); @@ -489,12 +424,13 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { } } PDTimer_.stop(); + } void TrackletEventProcessor::printSummary() { - if (settings_->writeMonitorData("Cabling")) { - cabling_->writephirange(); - } + //if (settings_->writeMonitorData("Cabling")) { + // cabling_->writephirange(); + //} if (settings_->bookHistos()) { globals_->histograms()->close(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc index dbba44f2b361a..77392b49e62f9 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc @@ -42,21 +42,7 @@ void TrackletParametersMemory::writeTPAR(bool first) { << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirTP)) { - int fail = system((string("mkdir -p ") + dirTP).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirTP; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirTP, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index de95f8c19bedf..140f2e20f6aa8 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -1,8 +1,8 @@ - #include "L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h" #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" #include "L1Trigger/TrackFindingTracklet/interface/Globals.h" #include "L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h" +#include "L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/Util.h" #include "L1Trigger/TrackFindingTracklet/interface/IMATH_TrackletCalculator.h" @@ -16,9 +16,12 @@ using namespace std; using namespace trklet; + + TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Globals* globals, unsigned int iSector) - : TrackletCalculatorBase(name, settings, globals, iSector), vmrtable_(settings) { - iAllStub_ = -1; + : TrackletCalculatorBase(name, settings, globals, iSector), tebuffer_(CircularBuffer(3),0,0,0,0), vmrtable_(settings) { + + iAllStub_=-1; for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) { vector tmp(settings_.nallstubs(ilayer), nullptr); @@ -30,28 +33,30 @@ TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Glob trackletprojdisks_.push_back(tmp); } - outervmstubs_ = nullptr; - + outervmstubs_=nullptr; + initLayerDisksandISeed(layerdisk1_, layerdisk2_, iSeed_); nbitszfinebintable_ = settings_.vmrlutzbits(layerdisk1_); nbitsrfinebintable_ = settings_.vmrlutrbits(layerdisk1_); - vmrtable_.init(layerdisk1_, getName()); + vmrtable_.init(layerdisk1_); nbitsrzbin_ = NFINERZBITS; if (iSeed_ == 4 || iSeed_ == 5) nbitsrzbin_ = 2; - + + innerphibits_ = settings_.nfinephi(0, iSeed_); outerphibits_ = settings_.nfinephi(1, iSeed_); - + // set TC index - iTC_ = name_[7] - 'A'; - assert(iTC_ >= 0 && iTC_ < 14); + iTC_=name_[7] -'A'; + assert(iTC_ >=0 && iTC_<14); TCIndex_ = (iSeed_ << 4) + iTC_; assert(TCIndex_ >= 0 && TCIndex_ <= (int)settings_.ntrackletmax()); + } void TrackletProcessor::addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory) { @@ -110,53 +115,45 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { if (input == "outervmstubin") { auto* tmp = dynamic_cast(memory); assert(tmp != nullptr); - outervmstubs_ = tmp; - iAllStub_ = tmp->getName()[11] - 'A'; - if (iSeed_ == 1) - iAllStub_ = tmp->getName()[11] - 'I'; - if (iSeed_ == 6 || iSeed_ == 7) { - if (tmp->getName()[11] == 'X') - iAllStub_ = 0; - if (tmp->getName()[11] == 'Y') - iAllStub_ = 1; - if (tmp->getName()[11] == 'Z') - iAllStub_ = 2; - if (tmp->getName()[11] == 'W') - iAllStub_ = 3; + outervmstubs_=tmp; + iAllStub_=tmp->getName()[11]-'A'; + if (iSeed_==1) iAllStub_=tmp->getName()[11]-'I'; + if (iSeed_==6||iSeed_==7){ + if (tmp->getName()[11]=='X') + iAllStub_=0; + if (tmp->getName()[11]=='Y') + iAllStub_=1; + if (tmp->getName()[11]=='Z') + iAllStub_=2; + if (tmp->getName()[11]=='W') + iAllStub_=3; } - buildLUT(); //need iAllStub_ set before building the table //FIXME should be in initiall - - TrackletEngineUnit teunit(&settings_, - nbitsfinephi_, - layerdisk2_, - iSeed_, - nbitsfinephidiff_, - iAllStub_, - pttableinnernew_, - pttableouternew_, - outervmstubs_); - teunits_.resize(6, teunit); - + buildLUT(); //need iAllStub_ set before building the table //FIXME should be in initiall + + TrackletEngineUnit teunit(&settings_,nbitsfinephi_,layerdisk1_,layerdisk2_,iSeed_,nbitsfinephidiff_,iAllStub_,pttableinnernew_,pttableouternew_,outervmstubs_); + if (iSeed_==0) teunits_.resize(5,teunit); + if (iSeed_==1) teunits_.resize(2,teunit); + if (iSeed_==2) teunits_.resize(5,teunit); + if (iSeed_==3) teunits_.resize(3,teunit); + if (iSeed_==4) teunits_.resize(3,teunit); + if (iSeed_==5) teunits_.resize(2,teunit); + if (iSeed_==6) teunits_.resize(3,teunit); + if (iSeed_==7) teunits_.resize(2,teunit); + return; } if (input == "innerallstubin") { - auto* tmp = dynamic_cast(memory); + auto* tmp = dynamic_cast(memory); assert(tmp != nullptr); - if (innerallstubs_.size() == 2) { //FIXME this should be done with better logic with reading the input stubs - innerallstubs_.insert(innerallstubs_.begin(), tmp); + if (innerallstubs_.size()==2) { //FIXME this should be done with better logic with reading the input stubs + innerallstubs_.insert(innerallstubs_.begin(),tmp); } else { innerallstubs_.push_back(tmp); } //FIXME should be done once after all inputs are added - tedatabuffers_.clear(); - CircularBuffer tedatabuffertmp(5); - tedatabuffertmp.reset(); - - tedatabuffers_.emplace_back(tedatabuffertmp, 0, 0, 0, (innerallstubs_.size() + 1) / 2); - tedatabuffers_.emplace_back( - tedatabuffertmp, 0, (innerallstubs_.size() + 1) / 2, (innerallstubs_.size() + 1) / 2, innerallstubs_.size()); + tebuffer_ = tuple, unsigned int , unsigned int, unsigned int, unsigned int>(CircularBuffer(3),0,0,0,innerallstubs_.size()); return; } @@ -166,17 +163,25 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { outerallstubs_.push_back(tmp); return; } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; + throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ + << " Could not find input : " << input; } void TrackletProcessor::execute() { + + bool print=(iSector_==3)&&(getName()=="TP_L1L2D"); + print=false; + if (!settings_.useSeed(iSeed_)) return; + //Not most elegant solution; but works + int donecount=0; + //Consistency checks - assert(iAllStub_ >= 0); - assert(iAllStub_ < (int)settings_.nallstubs(layerdisk2_)); - assert(outervmstubs_ != nullptr); + assert(iAllStub_>=0); + assert(iAllStub_<(int)settings_.nallstubs(layerdisk2_)); + assert(outervmstubs_!=nullptr); //used to collect performance data unsigned int countall = 0; @@ -186,217 +191,325 @@ void TrackletProcessor::execute() { unsigned int stubpairs = 0; unsigned int ntedata = 0; - + unsigned int ninnerstubs = 0; //Actual implemenation starts here - - //Reset the tebuffers - for (auto& tebuffer : tedatabuffers_) { - std::get<0>(tebuffer).reset(); - std::get<1>(tebuffer) = 0; - std::get<2>(tebuffer) = std::get<3>(tebuffer); - } - + + //Reset the tebuffer + std::get<0>(tebuffer_).reset(); + std::get<1>(tebuffer_) = 0; + std::get<2>(tebuffer_) = std::get<3>(tebuffer_); + //Reset the teunits - for (auto& teunit : teunits_) { + for(auto& teunit:teunits_) { teunit.reset(); } - for (unsigned int istep = 0; istep < settings_.maxStep("TP"); istep++) { - for (auto& tebuffer : tedatabuffers_) { - CircularBuffer& tedatabuffer = std::get<0>(tebuffer); - unsigned int& istub = std::get<1>(tebuffer); - unsigned int& imem = std::get<2>(tebuffer); - unsigned int imemend = std::get<4>(tebuffer); - - if ((!tedatabuffer.full()) && imem < imemend && istub < innerallstubs_[imem]->nStubs()) { - ninnerstubs++; - - const Stub* stub = innerallstubs_[imem]->getStub(istub); - - bool negdisk = (stub->disk().value() < 0); //FIXME stub needs to contain bit for +/- z disk - - FPGAWord phicorr = stub->phicorr(); - int innerfinephi = phicorr.bits(phicorr.nbits() - nbitsfinephi_, nbitsfinephi_); - FPGAWord innerbend = stub->bend(); - - //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 (layerdisk1_ > (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 - indexr = (((1 << (stub->r().nbits() - 1)) + stub->r().value()) >> (stub->r().nbits() - nbitsrfinebintable_)); - } - - int lutval = -1; - if (iSeed_ < 6) { //FIXME should only be one table... - lutval = vmrtable_.lookupinner(indexz, indexr); - } else { - lutval = vmrtable_.lookupinneroverlap(indexz, indexr); - } - - if (lutval != -1) { - unsigned int lutwidth = settings_.lutwidthtab(0, iSeed_); - FPGAWord lookupbits(lutval, lutwidth, true, __LINE__, __FILE__); - - int rzfinebinfirst = lookupbits.bits(0, 3); //finephi - int next = lookupbits.bits(3, 1); //next r/z bin - int start = lookupbits.bits(4, nbitsrzbin_); - int rzdiffmax = lookupbits.bits(lookupbits.nbits() - 3, 3); - - if ((iSeed_ == 4 || iSeed_ == 5) && negdisk) { //TODO - need to store negative disk - start += 4; - } - int last = start + next; - - int nbins = 8; - - unsigned int useregindex = (innerfinephi << innerbend.nbits()) + innerbend.value(); - if (iSeed_ >= 4) { - //FIXME If the lookupbits were rationally organized this would be much simpler - int ir = ((start & 3) << 1) + (rzfinebinfirst >> 2); - useregindex = (useregindex << 3) + ir; - } - - assert(useregindex < useregion_.size()); - vector usereg = useregion_[useregindex]; - - TEData tedata; - tedata.stub_ = stub; - tedata.rzbinfirst_ = rzfinebinfirst; - tedata.start_ = start; - tedata.innerfinephi_ = innerfinephi; - tedata.rzdiffmax_ = rzdiffmax; - tedata.innerbend_ = innerbend; - - for (unsigned int ireg = 0; ireg < settings_.nvmte(1, iSeed_); ireg++) { - assert(ireg < usereg.size()); - if (!usereg[ireg]) - continue; - - for (int ibin = start; ibin <= last; ibin++) { - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " looking for matching stub in bin " << ibin << " with " - << outervmstubs_->nVMStubsBinned(ireg * nbins + ibin) << " stubs"; - } - assert(ireg * nbins + ibin < outervmstubs_->nBin()); - int nstubs = outervmstubs_->nVMStubsBinned(ireg * nbins + ibin); - if (nstubs > 0) { - tedata.regions_.emplace_back(tuple(ibin - start, ireg, nstubs)); - countteall += nstubs; - } - } - } - - if (!tedata.regions_.empty()) { - ntedata++; - //cout << getName() << " adding TE data" << endl; - tedatabuffer.store(tedata); - } - } - istub++; - if (istub >= innerallstubs_[imem]->nStubs()) { - istub = 0; - imem++; - } + TEData tedata; + TEData tedata__; + TEData tedata___; + bool goodtedata = false; + bool goodtedata__ = false; + bool goodtedata___ = false; + + + bool tebuffernearfull; + + for(unsigned int istep=0;istep& tedatabuffer=std::get<0>(tebuffer_); + unsigned int& istub=std::get<1>(tebuffer_); + unsigned int& imem=std::get<2>(tebuffer_); + cout << "istep="<& tedatabuffer = std::get<0>(tebuffer); - tedatabuffersdone &= tedatabuffer.empty(); //buffer empty - tedatabuffersdone &= (std::get<2>(tebuffer) == std::get<4>(tebuffer)); //buffer processed all stubs - if (!tedatabuffer.empty()) { - for (auto& teunit : teunits_) { - if (teunit.empty() && teunit.idle()) { - teunit.init(tedatabuffer.read()); - break; - } - } - } - } + CircularBuffer& tedatabuffer=std::get<0>(tebuffer_); + tebuffernearfull=tedatabuffer.nearfull(); - bool teunitsdone = true; - TrackletEngineUnit* teunitptr = nullptr; - for (auto& teunit : teunits_) { - if (!teunit.idle()) { - teunit.step(); - teunitsdone = false; - } - if (!teunit.empty()) { - teunitptr = &teunit; - teunitsdone = false; + // + // First block here checks if there is a teunit with data that should should be used + // to calculate the tracklet parameters + // + + TrackletEngineUnit* teunitptr=nullptr; + + int iTE=0; + int icount=-1; + for (auto& teunit:teunits_) { + teunit.setNearFull(); + icount++; + if (!teunit.empty()){ + teunitptr=&teunit; + iTE=icount; } } - - if (teunitptr != nullptr) { - auto stubpair = teunitptr->read(); + + if (teunitptr!=nullptr) { + auto stubpair=teunitptr->read(); stubpairs++; - + if (trackletpars_->nTracklets() >= settings_.ntrackletmax()) { - edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName(); - break; + edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName(); + break; } countall++; const Stub* innerFPGAStub = stubpair.first; const L1TStub* innerStub = innerFPGAStub->l1tstub(); - + const Stub* outerFPGAStub = stubpair.second; const L1TStub* outerStub = outerFPGAStub->l1tstub(); - + if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "TrackletProcessor execute " << getName() << "[" << iSector_ << "]"; + edm::LogVerbatim("Tracklet") << "TrackletProcessor execute " << getName() << "[" << iSector_ << "]"; } + + + bool accept = false; - if (iSeed_ < 4) { - accept = barrelSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); - } else if (iSeed_ < 6) { + if (iSeed_<4) { + if (print) cout << "istep="<(tebuffer_).read()); + if (print) std::cout << "istep="<allStubIndex().value()<(tebuffer_); + unsigned int& imem=std::get<2>(tebuffer_); + unsigned int imemend=std::get<4>(tebuffer_); + + //if (print) cout << "istep="<getName(); + } + + bool negdisk = (stub->disk().value() < 0); //FIXME stub needs to contain bit for +/- z disk + + FPGAWord phicorr=stub->phicorr(); + int innerfinephi=phicorr.bits(phicorr.nbits()-nbitsfinephi_,nbitsfinephi_); + FPGAWord innerbend = stub->bend(); + + //Take the top nbitszfinebintable_ bits of the z coordinate + int indexz = (stub->z().value() >> (stub->z().nbits() - nbitszfinebintable_))&((1< (N_LAYER - 1)) { + if (negdisk) { + indexz = ((1 << nbitszfinebintable_) - 1 ) - indexz; + } + indexr = stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_); + } else { //Take the top nbitsfinebintable_ bits of the z coordinate + indexr = (stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_))&((1<=4) { + //FIXME If the lookupbits were rationally organized this would be much simpler + int ir = ((start & 3) << 1) + (rzfinebinfirst >> 2); + useregindex=(useregindex<<3)+ir; + } + + assert(useregindexnVMStubsBinned(ireg*nbins+ibin) << " stubs"; + } + assert(ireg*nbins+ibinnBin()); + int nstubs=outervmstubs_->nVMStubsBinned(ireg*nbins+ibin); + + if (print) cout << "Add to TEBuffer stub ibin ireg nstubs: "<allStubIndex().value() + <<" "<0) { + mask="1"+mask; + tedata.regions_.emplace_back(tuple(ibin-start,ireg,nstubs)); + countteall+=nstubs; + } else { + mask="0"+mask; + } + + } + } + + if (tedata.regions_.size()>0) { + //if (print) cout << "Add to TEBuffer stub : "<allStubIndex().value()<= innerallstubs_[imem]->nStubs()) { + istub=0; + imem++; + } + } else if ((!tebuffernearfull) && imem < imemend && istub==0) { + imem++; } - if (settings_.writeMonitorData("TP")) { - globals_->ofstream("trackletprocessor.txt") << getName() << " " << ninnerstubs //# inner stubs - << " " << outervmstubs_->nVMStubs() //# outer stubs - << " " << countteall //# pairs tried in TE - << " " << stubpairs //# stubs pairs - << " " << countsel //# tracklets found - << endl; + goodtedata___ = goodtedata__; + goodtedata__ = goodtedata; + + tedata___ = tedata__; + tedata__ = tedata; + + // + // stop looping over istep if done + // + + bool done=true; + + if (imem4) { break; } + } -} +<<<<<<< HEAD + + // + // Done with processing - collect performance statistics + // + + if (settings_.writeMonitorData("TP")) { + globals_->ofstream("trackletprocessor.txt") << getName() + << " " << ninnerstubs //# inner stubs + << " " << outervmstubs_->nVMStubs() //# outer stubs + << " " << countteall //# pairs tried in TE + << " " << stubpairs //# stubs pairs + << " " << countsel //# tracklets found + << endl; + } + + +======= void TrackletProcessor::writeTETable() { ofstream outstubptinnercut; outstubptinnercut.open(getName() + "_stubptinnercut.tab"); @@ -419,41 +532,53 @@ void TrackletProcessor::writeTETable() { //} outstubptoutercut << endl << "};" << endl; outstubptoutercut.close(); +>>>>>>> fd1f230d81e... part one of PR review fixes for TrackFindingTracklet package } -void TrackletProcessor::buildLUT() { - //number of fine phi bins in sector - int nfinephibins = - settings_.nallstubs(layerdisk2_) * settings_.nvmte(1, iSeed_) * (1 << settings_.nfinephi(1, iSeed_)); - double dfinephi = settings_.dphisectorHG() / nfinephibins; - double rmin = -1.0; - double rmax = -1.0; - if (iSeed_ < 4) { - rmin = settings_.rmean(layerdisk1_); - rmax = settings_.rmean(layerdisk2_); +void TrackletProcessor::buildLUT() { + + //number of fine phi bins in sector + int nfinephibins=settings_.nallstubs(layerdisk2_)*settings_.nvmte(1,iSeed_)*(1<5) { + if (iSeed_==6) { + rmax=settings_.rmaxdiskl1overlapvm(); + } + if (iSeed_==7) { + rmax=settings_.rmaxdiskvm(); +======= if (iSeed_ > 5) { if (iSeed_ == 6) { rmax = settings_.rmaxdiskl1overlapvm(); } else if (iSeed_ == 7) { rmax = settings_.rmaxdiskvm(); +>>>>>>> fd1f230d81e... part one of PR review fixes for TrackFindingTracklet package } - rmin = settings_.rmean(layerdisk1_); + rmin=settings_.rmean(layerdisk1_); } else { - rmax = settings_.rmaxdiskvm(); - rmin = rmax * settings_.zmean(layerdisk2_ - 6 - 1) / settings_.zmean(layerdisk2_ - 6); + rmax=settings_.rmaxdiskvm(); + rmin=rmax*settings_.zmean(layerdisk2_-6-1)/settings_.zmean(layerdisk2_-6); } } - double dphimax = asin(0.5 * settings_.maxrinv() * rmax) - asin(0.5 * settings_.maxrinv() * rmin); - - int nbins = 2.0 * (dphimax / dfinephi + 1.0); + double dphimax=asin(0.5*settings_.maxrinv()*rmax)-asin(0.5*settings_.maxrinv()*rmin); - nbitsfinephidiff_ = log(nbins) / log(2.0) + 1; - - nbitsfinephi_ = settings_.nbitsallstubs(layerdisk2_) + settings_.nbitsvmte(1, iSeed_) + settings_.nfinephi(1, iSeed_); + int nbins=2.0*(dphimax/dfinephi+1.0); + + nbitsfinephidiff_=log(nbins)/log(2.0)+1; + + nbitsfinephi_=settings_.nbitsallstubs(layerdisk2_)+settings_.nbitsvmte(1,iSeed_)+settings_.nfinephi(1,iSeed_); int outerrbits = 3; if (iSeed_ < 4) { @@ -461,10 +586,10 @@ void TrackletProcessor::buildLUT() { } int outerrbins = (1 << outerrbits); - + double dphi[2]; double router[2]; - + unsigned int nbendbitsinner = 3; unsigned int nbendbitsouter = 3; if (iSeed_ == 2) { @@ -473,116 +598,157 @@ void TrackletProcessor::buildLUT() { nbendbitsinner = 4; nbendbitsouter = 4; } - - int nbinsfinephidiff = (1 << nbitsfinephidiff_); - + + int nbinsfinephidiff = (1<= nbinsfinephidiff / 2) { - iphidiff = iphibin - nbinsfinephidiff; + int iphidiff=iphibin; + if (iphibin>=nbinsfinephidiff/2) { + iphidiff=iphibin-nbinsfinephidiff; } //min and max dphi - dphi[0] = (iphidiff - 1.5) * dfinephi; - dphi[1] = (iphidiff + 1.5) * dfinephi; + dphi[0] = (iphidiff-1.5)*dfinephi; + dphi[1] = (iphidiff+1.5)*dfinephi; for (int irouterbin = 0; irouterbin < outerrbins; irouterbin++) { if (iSeed_ >= 4) { - router[0] = - settings_.rmindiskvm() + irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; - router[1] = - settings_.rmindiskvm() + (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; + router[0] = settings_.rmindiskvm() + + irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; + router[1] = settings_.rmindiskvm() + + (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; } else { - router[0] = settings_.rmean(layerdisk2_); - router[1] = settings_.rmean(layerdisk2_); + router[0] = settings_.rmean(layerdisk2_); + router[1] = settings_.rmean(layerdisk2_); } - + double bendinnermin = 20.0; double bendinnermax = -20.0; double bendoutermin = 20.0; double bendoutermax = -20.0; double rinvmin = 1.0; for (int i2 = 0; i2 < 2; i2++) { - for (int i3 = 0; i3 < 2; i3++) { - double rinner = 0.0; - if (iSeed_ == 4 || iSeed_ == 5) { - rinner = router[i3] * settings_.zmean(layerdisk1_ - N_LAYER) / settings_.zmean(layerdisk2_ - N_LAYER); - } else { - rinner = settings_.rmean(layerdisk1_); - } - double rinv1 = rinv(0.0, dphi[i2], rinner, router[i3]); - double pitchinner = (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double pitchouter = - (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double abendinner = -bend(rinner, rinv1, pitchinner); - double abendouter = -bend(router[i3], rinv1, pitchouter); - if (abendinner < bendinnermin) - bendinnermin = abendinner; - if (abendinner > bendinnermax) - bendinnermax = abendinner; - if (abendouter < bendoutermin) - bendoutermin = abendouter; - if (abendouter > bendoutermax) - bendoutermax = abendouter; - if (std::abs(rinv1) < rinvmin) { - rinvmin = std::abs(rinv1); - } - } + for (int i3 = 0; i3 < 2; i3++) { + double rinner = 0.0; + if (iSeed_ == 4 || iSeed_ == 5) { + rinner = router[i3] * settings_.zmean(layerdisk1_ - N_LAYER) / settings_.zmean(layerdisk2_ - N_LAYER); + } else { + rinner = settings_.rmean(layerdisk1_); + } + double rinv1 = rinv(0.0, -dphi[i2], rinner, router[i3]); + double pitchinner = + (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); + double pitchouter = + (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); + double abendinner = bendstrip(rinner, rinv1, pitchinner); + double abendouter = bendstrip(router[i3], rinv1, pitchouter); + if (abendinner < bendinnermin) + bendinnermin = abendinner; + if (abendinner > bendinnermax) + bendinnermax = abendinner; + if (abendouter < bendoutermin) + bendoutermin = abendouter; + if (abendouter > bendoutermax) + bendoutermax = abendouter; + if (std::abs(rinv1) < rinvmin) { + rinvmin = std::abs(rinv1); + } + } } - + bool passptcut = rinvmin < settings_.rinvcutte(); - + for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) { - double bend = benddecode(ibend, nbendbitsinner == 3); - - bool passinner = bend - bendinnermin > -settings_.bendcutte(0, iSeed_) && - bend - bendinnermax < settings_.bendcutte(0, iSeed_); - pttableinnernew_.push_back(passinner && passptcut); + double bend = settings_.benddecode(ibend, layerdisk1_, nbendbitsinner == 3); + + bool passinner = bend <= bendinnermax + settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3) && + bend >= bendinnermin - settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3); + pttableinnernew_.push_back(passinner && passptcut); } - + for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) { - double bend = benddecode(ibend, nbendbitsouter == 3); - - bool passouter = bend - bendoutermin > -settings_.bendcutte(1, iSeed_) && - bend - bendoutermax < settings_.bendcutte(1, iSeed_); - pttableouternew_.push_back(passouter && passptcut); + double bend = settings_.benddecode(ibend, layerdisk2_, nbendbitsouter == 3); + + bool passouter = bend <= bendoutermax + settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3) && + bend >= bendoutermin - settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3); + pttableouternew_.push_back(passouter && passptcut); } } } - int nirbits = 0; - if (iSeed_ >= 4) - nirbits = 3; - - int nregmax = 0; - - for (int innerfinephi = 0; innerfinephi < (1 << nbitsfinephi_); innerfinephi++) { - for (int innerbend = 0; innerbend < (1 << nbendbitsinner); innerbend++) { - for (int ir = 0; ir < (1 << nirbits); ir++) { - int nreg = 0; - vector usereg; - for (unsigned int ireg = 0; ireg < settings_.nvmte(1, iSeed_); ireg++) { - bool match = false; - for (int ifinephiouter = 0; ifinephiouter < (1 << settings_.nfinephi(1, iSeed_)); ifinephiouter++) { - int outerfinephi = iAllStub_ * (1 << (nbitsfinephi_ - settings_.nbitsallstubs(layerdisk2_))) + - ireg * (1 << settings_.nfinephi(1, iSeed_)) + ifinephiouter; - int idphi = outerfinephi - innerfinephi; - bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_ - 1))); - if (idphi < 0) - idphi = idphi + (1 << nbitsfinephidiff_); - int idphi1 = idphi; - if (iSeed_ >= 4) - idphi1 = (idphi << 3) + ir; - int ptinnerindexnew = (idphi1 << nbendbitsinner) + innerbend; - match = match || (inrange && pttableinnernew_[ptinnerindexnew]); - } - if (match && ir < 3) - nreg++; - usereg.push_back(match); - } - - useregion_.push_back(usereg); - if (nreg > nregmax) - nregmax = nreg; + int nirbits=0; + if (iSeed_>=4) + nirbits=3; + + int nregmax=0; + + for(int innerfinephi=0;innerfinephi<(1<=-(1<<(nbitsfinephidiff_-1))); + if (idphi<0) idphi=idphi+(1<=4) + idphi1=(idphi<<3)+ir; + int ptinnerindexnew = (idphi1 << nbendbitsinner) + innerbend; + match=match||(inrange && pttableinnernew_[ptinnerindexnew]); + } + if (match&&ir<3) + nreg++; + if (match) { + usereg=usereg|(1<nregmax) + nregmax=nreg; + } + } + } + + if (settings_.writeTable()) { + ofstream out; + out.open(settings_.tablePath()+getName() +"_usereg.tab"); + + out << "{" << endl; + for (unsigned int i = 0; i < useregion_.size(); i++) { + if (i != 0) { + out << "," << endl; } + out << useregion_[i]; } + out << endl << "};" << endl; + out.close(); + + + ofstream outstubptinnercut; + outstubptinnercut.open(settings_.tablePath()+getName() + "_stubptinnercut.tab"); + outstubptinnercut << "{" << endl; + for(unsigned int i=0;i= table_.size()) @@ -290,8 +293,8 @@ void TripletEngine::execute() { if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Stub triplet rejected because of stub pt cut bends : " - << benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule()) << " " - << benddecode(thirdvmstub.bend().value(), thirdvmstub.isPSmodule()); + << settings_.benddecode(secondvmstub.bend().value(), disk2_+5, secondvmstub.isPSmodule()) << " " + << settings_.benddecode(thirdvmstub.bend().value(), layer3_-1, thirdvmstub.isPSmodule()); } continue; } @@ -374,8 +377,8 @@ void TripletEngine::execute() { if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : " - << benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule()) << " " - << benddecode(thirdvmstub.bend().value(), thirdvmstub.isPSmodule()); + << settings_.benddecode(secondvmstub.bend().value(), layer2_-1, secondvmstub.isPSmodule()) << " " + << settings_.benddecode(thirdvmstub.bend().value(), disk3_+5, thirdvmstub.isPSmodule()); } continue; } diff --git a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc index 9ff195063fb54..e8f7d260c94e7 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc @@ -34,21 +34,7 @@ void VMProjectionsMemory::writeVMPROJ(bool first) { oss << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirVM)) { - int fail = system((string("mkdir -p ") + dirVM).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirVM; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirVM, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc index dd3015ea1e75f..f85efb57999b2 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc @@ -14,7 +14,7 @@ using namespace std; using namespace trklet; VMRouter::VMRouter(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector), vmrtable_(settings) { + : ProcessBase(name, settings, global, iSector), vmrtable_(settings) { layerdisk_ = initLayerDisk(4); vmstubsMEPHI_.resize(settings_.nvmme(layerdisk_), nullptr); @@ -22,7 +22,7 @@ VMRouter::VMRouter(string name, Settings const& settings, Globals* global, unsig overlapbits_ = 7; nextrabits_ = overlapbits_ - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_)); - vmrtable_.init(layerdisk_, getName()); + vmrtable_.init(layerdisk_,name); nbitszfinebintable_ = settings_.vmrlutzbits(layerdisk_); nbitsrfinebintable_ = settings_.vmrlutrbits(layerdisk_); @@ -224,14 +224,15 @@ void VMRouter::execute() { // 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) + 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); + 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); assert(vmstubsMEPHI_[ivmPlus] != nullptr); vmstubsMEPHI_[ivmPlus]->addStub(vmstub, vmbin); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc index f6ce34e3badc6..25ea37c2b4255 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc @@ -4,6 +4,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/VMStubTE.h" #include "L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h" +#include "L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h" @@ -22,12 +23,13 @@ VMRouterCM::VMRouterCM(string name, Settings const& settings, Globals* global, u overlapbits_ = 7; nextrabits_ = overlapbits_ - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_)); - vmrtable_.init(layerdisk_, getName()); + vmrtable_.init(layerdisk_); nbitszfinebintable_ = settings_.vmrlutzbits(layerdisk_); nbitsrfinebintable_ = settings_.vmrlutrbits(layerdisk_); - nvmmebins_ = settings_.NLONGVMBINS() * ((layerdisk_ >= 6) ? 2 : 1); //number of long z/r bins in VM + nvmmebins_=settings_.NLONGVMBINS()*((layerdisk_>=6)?2:1); //number of long z/r bins in VM + } void VMRouterCM::addOutput(MemoryBase* memory, string output) { @@ -36,14 +38,17 @@ void VMRouterCM::addOutput(MemoryBase* memory, string output) { << output; } + if (output == "allinnerstubout") { + AllInnerStubsMemory* tmp = dynamic_cast(memory); + assert(tmp != nullptr); + char memtype=memory->getName().back(); + allinnerstubs_.emplace_back(memtype,tmp); + return; + } + if (output.substr(0, 10) == "allstubout") { AllStubsMemory* tmp = dynamic_cast(memory); - assert(tmp != nullptr); - char memtype = 0; - if (output.size() > 10) { - memtype = output[11]; - } - allstubs_.emplace_back(memtype, tmp); + allstubs_.push_back(tmp); return; } @@ -53,42 +58,42 @@ void VMRouterCM::addOutput(MemoryBase* memory, string output) { 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++; + vmbin = vmbin * 10 + memory->getName().substr(pos, 1)[0] - '0'; + pos++; } } if (memory->getName().substr(3, 2) == "TE") { VMStubsTEMemory* tmp = dynamic_cast(memory); - int iseed = output[output.size() - 1] - '0'; - assert(iseed >= 0); - assert(iseed < 8); - + int iseed = output[output.size()-1]-'0'; + assert(iseed>=0); + assert(iseed<8); + int seedindex = -1; for (unsigned int k = 0; k < vmstubsTEPHI_.size(); k++) { - if (vmstubsTEPHI_[k].seednumber == (unsigned int)iseed) { - seedindex = k; - } + if (vmstubsTEPHI_[k].seednumber == (unsigned int)iseed) { + seedindex = k; + } } if (seedindex == -1) { - seedindex = vmstubsTEPHI_.size(); - vector vectmp; - VMStubsTEPHICM atmp(iseed, vectmp); - vmstubsTEPHI_.push_back(atmp); + seedindex = vmstubsTEPHI_.size(); + vector vectmp; + VMStubsTEPHICM atmp(iseed, vectmp); + vmstubsTEPHI_.push_back(atmp); } - tmp->resize(settings_.NLONGVMBINS() * settings_.nvmte(1, iseed)); + tmp->resize(settings_.NLONGVMBINS()*settings_.nvmte(1,iseed)); vmstubsTEPHI_[seedindex].vmstubmem.push_back(tmp); - + } else if (memory->getName().substr(3, 2) == "ME") { VMStubsMEMemory* tmp = dynamic_cast(memory); assert(tmp != nullptr); - tmp->resize(nvmmebins_ * settings_.nvmme(layerdisk_)); + tmp->resize(nvmmebins_*settings_.nvmme(layerdisk_)); assert(vmstubsMEPHI_[0] == nullptr); - vmstubsMEPHI_[0] = tmp; + vmstubsMEPHI_[0] = tmp; } else { throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " memory: " << memory->getName() << " => should never get here!"; } - + return; } @@ -112,6 +117,7 @@ void VMRouterCM::addInput(MemoryBase* memory, string input) { } void VMRouterCM::execute() { + unsigned int allStubCounter = 0; //Loop over the input stubs @@ -139,41 +145,72 @@ void VMRouterCM::execute() { allStubCounter++; + for (auto& allstub : allstubs_) { + allstub->addStub(stub); + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " adding stub to " + << allstub->getName(); + } + + } + FPGAWord iphi = stub->phicorr(); - unsigned int iphipos = iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + 3), 3); + unsigned int iphipos = iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + 3),3); + + unsigned int phicutmax=4; + unsigned int phicutmin=4; + + if (layerdisk_!=0) { + phicutmax=6; + phicutmin=2; + } + + //Fill inner allstubs memories - in HLS this is the same write to multiple memories + for (auto& allstub : allinnerstubs_) { + char memtype=allstub.first; + if (memtype=='R' && iphipos=phicutmin) continue; + if (memtype=='A' && iphipos<4) continue; + if (memtype=='B' && iphipos>=4) continue; + if (memtype=='E' && iphipos>=4) continue; + if (memtype=='F' && iphipos<4) continue; + if (memtype=='C' && iphipos>=4) continue; + if (memtype=='D' && iphipos<4) continue; + + int absz = std::abs(stub->z().value()); + if (layerdisk_==1 && absz<50.0/settings_.kz(layerdisk_)) continue; + if ((layerdisk_==2 || layerdisk_==4) && absz>95.0/settings_.kz(layerdisk_)) continue; + if ((layerdisk_==6 || layerdisk_==8) && stub->r().value()>55.0/settings_.kr()) continue; + if ((layerdisk_==6 || layerdisk_==8) && stub->r().value()<2*int(N_DSS_MOD)) continue; + if (layerdisk_==0) { + if (memtype=='M'||memtype=='R'||memtype=='L') { + if (absz<70.0/settings_.kz(layerdisk_)) continue; + } else { + if (absz>95.0/settings_.kz(layerdisk_)) continue; + } + } + + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " adding stub to " + << allstub.second->getName(); + } - //Fill allstubs memories - in HLS this is the same write to multiple memories - for (auto& allstub : allstubs_) { - char memtype = allstub.first; - if ((memtype == 'R' && iphipos < 5) || (memtype == 'L' && iphipos >= 3) || (memtype == 'A' && iphipos < 4) || - (memtype == 'B' && iphipos >= 4) || (memtype == 'E' && iphipos >= 4) || (memtype == 'F' && iphipos < 4) || - (memtype == 'C' && iphipos >= 4) || (memtype == 'D' && iphipos < 4)) - continue; allstub.second->addStub(stub); } //Fill all the ME VM memories 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--; + iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_)), + settings_.nbitsvmme(layerdisk_)); //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 indexz = (stub->z().value() >> (stub->z().nbits() - nbitszfinebintable_))&((1< (N_LAYER - 1)) { if (negdisk) { - indexz = (1 << nbitszfinebintable_) - indexz; + indexz = ((1 << nbitszfinebintable_) -1 ) - indexz; } indexr = stub->r().value(); if (stub->isPSmodule()) { @@ -181,7 +218,7 @@ void VMRouterCM::execute() { } } 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_)); + indexr = (stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_))&((1<= 0); @@ -195,47 +232,46 @@ void VMRouterCM::execute() { int vmbin = melut >> NFINERZBITS; if (negdisk) - vmbin += (1 << NFINERZBITS); - int rzfine = melut & ((1 << NFINERZBITS) - 1); + vmbin += (1<bend().nbits(); - if (layerdisk_ >= N_LAYER) + if (layerdisk_ >= N_LAYER) nbendbits = settings_.nbendbitsmedisk(); VMStubME vmstub( stub, - stub->iphivmFineBins(settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_), NFINERZBITS), + stub->iphivmFineBins(settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_),NFINERZBITS), FPGAWord(rzfine, NFINERZBITS, true, __LINE__, __FILE__), FPGAWord(stub->bend().value(), nbendbits, true, __LINE__, __FILE__), allStubIndex); - + assert(vmstubsMEPHI_[0] != nullptr); - vmstubsMEPHI_[0]->addStub(vmstub, ivmPlus * nvmmebins_ + vmbin); - if (ivmMinus != ivmPlus) { - vmstubsMEPHI_[0]->addStub(vmstub, ivmMinus * nvmmebins_ + vmbin); - } + vmstubsMEPHI_[0]->addStub(vmstub, ivm*nvmmebins_+vmbin); //Fill the TE VM memories - if (layerdisk_ >= 6 && (!stub->isPSmodule())) - continue; - + if (layerdisk_>=6&&(!stub->isPSmodule())) + continue; + for (auto& ivmstubTEPHI : vmstubsTEPHI_) { + unsigned int iseed = ivmstubTEPHI.seednumber; unsigned int lutwidth = settings_.lutwidthtab(1, iseed); int lutval = -999; - if (layerdisk_ < N_LAYER) { - lutval = melut; - } else { - lutval = vmrtable_.lookupdisk(indexz, indexr); - } - if (lutval == -1) - continue; + if (layerdisk_ < N_LAYER) { + lutval = melut; + } else { + lutval = vmrtable_.lookupdisk(indexz, indexr); + if (lutval == 0) { + continue; + } + } - assert(lutval >= 0); + assert(lutval >= 0); FPGAWord binlookup(lutval, lutwidth, true, __LINE__, __FILE__); @@ -246,9 +282,9 @@ void VMRouterCM::execute() { iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmte(1, iseed)), settings_.nbitsvmte(1, iseed)); - int 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__); + int 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(1, iseed), settings_.nfinephi(1, iseed)); @@ -259,12 +295,12 @@ void VMRouterCM::execute() { for (unsigned int l = 0; l < nmem; l++) { if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " try adding stub to " << ivmstubTEPHI.vmstubmem[l]->getName() - << " bin=" << bin << " ivmte " << ivmte << " finephi " << finephi.value() - << " regions bits " << settings_.nphireg(1, iseed) << " finephibits " - << settings_.nfinephi(1, iseed); - } - ivmstubTEPHI.vmstubmem[l]->addVMStub(tmpstub, ivmte * settings_.NLONGVMBINS() + bin); + edm::LogVerbatim("Tracklet") << getName() << " try adding stub to " + << ivmstubTEPHI.vmstubmem[l]->getName() + << " bin=" << bin << " ivmte " << ivmte << " finephi " << finephi.value() + << " regions bits " << settings_.nphireg(1, iseed)<<" finephibits "<addVMStub(tmpstub, ivmte*settings_.NLONGVMBINS()+bin); } } } diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc index 257843cd5c49b..11d11768aad3a 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc @@ -33,25 +33,20 @@ void VMRouterPhiCorrTable::init(int layer, int bendbits, int rbits) { } if (settings_.writeTable()) { - if (not std::filesystem::exists(settings_.tablePath())) { - int fail = system((string("mkdir -p ") + settings_.tablePath()).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " - << settings_.tablePath(); - } - - writeVMTable(settings_.tablePath() + "VMPhiCorrL" + std::to_string(layer_) + ".tab", false); + writeVMTable(settings_.tablePath(), "VMPhiCorrL" + std::to_string(layer_) + ".tab", false); } } int VMRouterPhiCorrTable::getphiCorrValue(int ibend, int irbin) const { - double bend = trklet::benddecode(ibend, layer_ <= (int)N_PSLAYER); + + assert(layer_>0.0&&layer_<=(int)N_LAYER); + double bend = - settings_.benddecode(ibend, layer_-1, layer_ <= (int)N_PSLAYER); //for the rbin - calculate the distance to the nominal layer radius double Delta = (irbin + 0.5) * dr_ - settings_.drmax(); //calculate the phi correction - this is a somewhat approximate formula - double dphi = (Delta / 0.18) * (bend * settings_.stripPitch(false)) / rmean_; + double dphi = (Delta / 0.18) * (bend * settings_.stripPitch(layer_ <= (int)N_PSLAYER)) / rmean_; int idphi = 0; diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc index 3605f8aadbae0..8dfe4ef1e7d45 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc @@ -1,6 +1,7 @@ // VMRouterTable: Lookup table used by the VMRouter to route stubs and provide information about which VMStubs are needed by the TrackletEngine #include "L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h" #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" +#include "L1Trigger/TrackFindingTracklet/interface/Util.h" #include #include @@ -9,9 +10,8 @@ using namespace trklet; VMRouterTable::VMRouterTable(Settings const& settings) : settings_(settings) {} -VMRouterTable::VMRouterTable(Settings const& settings, unsigned int layerdisk, std::string const& name) - : settings_(settings) { - init(layerdisk, name); +VMRouterTable::VMRouterTable(Settings const& settings, unsigned int layerdisk, std::string const& name) : settings_(settings) { + init(layerdisk,name); } void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { @@ -43,6 +43,23 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { double r = rmin_ + (irbin + 0.5) * dr_; double z = zmin_ + (izbin + 0.5) * dz_; + if (settings_.combined()) { + int iznew=izbin-(1<<(zbits_-1)); + if (iznew<0) + iznew+=(1<=0); + assert(iznew<(1<=0); + assert(irnew<(1< (N_LAYER - 1) && irbin < 10) //special case for the tabulated radii in 2S disks r = (layerdisk <= 7) ? settings_.rDSSinner(irbin) : settings_.rDSSouter(irbin); @@ -63,10 +80,12 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { if (layerdisk >= N_LAYER) { double rproj = r * settings_.zmean(layerdisk - N_LAYER) / z; bin = 0.5 * NBINS * (rproj - settings_.rmindiskvm()) / (settings_.rmaxdiskvm() - settings_.rmindiskvm()); + //bin value of zero indicates that stub is out of range if (bin < 0) bin = 0; if (bin >= NBINS / 2) - bin = NBINS / 2 - 1; + //bin = NBINS / 2 - 1; + bin = 0; vmrtabletedisk_.push_back(bin); } @@ -101,41 +120,75 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { } if (settings_.writeTable()) { - if (not std::filesystem::exists(settings_.tablePath())) { - int fail = system((string("mkdir -p ") + settings_.tablePath()).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " - << settings_.tablePath(); - } - // write finebin tables - writeVMTable(settings_.tablePath() + name + "_finebin.tab", vmrtable_); - // write barrel seed teinner tables (L1L2, L2L3, L3L4, L5L6) - if (layerdisk == 0 || layerdisk == 1 || layerdisk == 2 || layerdisk == 4) { - std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "L" + std::to_string(layerdisk + 2); - writeVMTable(settings_.tablePath() + "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); - } - // write disk seed teinner tables (D1D2, D3D4) - if (layerdisk == 6 || layerdisk == 8) { - std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1) + "D" + to_string(layerdisk - N_LAYER + 2); - writeVMTable(settings_.tablePath() + "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); - } - // write overlap seed teinner tables (L1D1, L2D1) - if (layerdisk == 0 || layerdisk == 1) { - std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "D1"; - writeVMTable(settings_.tablePath() + "VMTableInner" + fnamesuffix + ".tab", vmrtableteinneroverlap_); - } - // write barrel teouter tables (L2, L3, L4, L6, same as finebin tables) - if (layerdisk == 1 || layerdisk == 2 || layerdisk == 3 || layerdisk == 5) { - std::string fnamesuffix = "L" + to_string(layerdisk + 1); - writeVMTable(settings_.tablePath() + "VMTableOuter" + fnamesuffix + ".tab", vmrtable_); - } - // write disk teouter tables (D1, D2, D4) - if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { - std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); - writeVMTable(settings_.tablePath() + "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); + if (!settings_.combined()) { + // write finebin tables + writeVMTable(settings_.tablePath(), name + "_finebin.tab", vmrtable_); + // write barrel seed teinner tables (L1L2, L2L3, L3L4, L5L6) + if (layerdisk == 0 || layerdisk == 1 || layerdisk == 2 || layerdisk == 4) { + std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "L" + std::to_string(layerdisk + 2); + writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); + } + // write disk seed teinner tables (D1D2, D3D4) + if (layerdisk == 6 || layerdisk == 8) { + std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1) + "D" + to_string(layerdisk - N_LAYER + 2); + writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); + } + // write overlap seed teinner tables (L1D1, L2D1) + if (layerdisk == 0 || layerdisk == 1) { + std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "D1"; + writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinneroverlap_); + } + // write barrel teouter tables (L2, L3, L4, L6, same as finebin tables) + if (layerdisk == 1 || layerdisk == 2 || layerdisk == 3 || layerdisk == 5) { + std::string fnamesuffix = "L" + to_string(layerdisk + 1); + writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtable_); + // write disk teouter tables (D1, D2, D4) + if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { + std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); + writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); + } + } + } else { + + std::string fname = "VMRME_"; + if (layerdisk<6) { + fname+="L" + std::to_string(layerdisk+1) +".tab"; + } else { + fname+="D" + std::to_string(layerdisk-5) +".tab"; + } + writeVMTable(settings_.tablePath(),fname,vmrtable_); + + if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { + std::string fname = "VMRTE_D" + to_string(layerdisk - N_LAYER + 1)+".tab"; + writeVMTable(settings_.tablePath(), fname, vmrtabletedisk_); + } + + if (vmrtableteinner_.size()>0) { + ofstream out; + if (layerdisk<6) { + out.open(settings_.tablePath()+"TP_L" + std::to_string(layerdisk+1) +".tab"); + } else { + out.open(settings_.tablePath()+"TP_D" + std::to_string(layerdisk-5) +".tab"); + } + out << "{" << endl; + for (unsigned int i = 0; i < vmrtableteinner_.size(); i++) { + if (i != 0) { + out << "," << endl; + } + if (vmrtableteinner_[i]==-1) { + out << 1023; + } else { + out << vmrtableteinner_[i]; + } + } + out << endl << "};" << endl; + out.close(); + } } } + + } int VMRouterTable::getLookup(unsigned int layerdisk, double z, double r, int iseed) { @@ -325,10 +378,9 @@ int VMRouterTable::lookupinnerThird(int zbin, int rbin) { return vmrtableteinnerThird_[index]; } -void VMRouterTable::writeVMTable(std::string const& name, std::vector const& table) { - ofstream out(name); - if (out.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << name; +void VMRouterTable::writeVMTable(std::string const& dir, std::string const& name, std::vector const& table) { + + ofstream out=openfile(dir,name,__FILE__,__LINE__); out << "{" << endl; for (unsigned int i = 0; i < table.size(); i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc index 275a73aca4213..b3d67f896b4fd 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc @@ -30,21 +30,7 @@ void VMStubsMEMemory::writeStubs(bool first) { oss << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat"; auto const& fname = oss.str(); - if (first) { - bx_ = 0; - event_ = 1; - - if (not std::filesystem::exists(dirVM)) { - int fail = system((string("mkdir -p ") + dirVM).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirVM; - } - out_.open(fname); - if (out_.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; - - } else - out_.open(fname, std::ofstream::app); + openfile(out_, first, dirVM, fname, __FILE__, __LINE__); out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; @@ -53,6 +39,8 @@ void VMStubsMEMemory::writeStubs(bool first) { string stub = binnedstubs_[i][j].stubindex().str(); stub += "|" + binnedstubs_[i][j].bend().str(); + FPGAWord finephipos = binnedstubs_[i][j].finephi(); + stub += "|" + finephipos.str(); FPGAWord finepos = binnedstubs_[i][j].finerz(); stub += "|" + finepos.str(); out_ << hex << i << " " << j << dec << " " << stub << " " << trklet::hexFormat(stub) << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc index be05d40c9536a..156d0184b5407 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc @@ -11,6 +11,8 @@ VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings, unsigned //set the layer or disk that the memory is in initLayerDisk(6, layer_, disk_); + layerdisk_=initLayerDisk(6); + //Pointer to other VMStub memory for creating stub pairs other_ = nullptr; @@ -57,31 +59,35 @@ VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings, unsigned isinner_ = false; stubsbinnedvm_.resize(settings_.NLONGVMBINS()); + } bool VMStubsTEMemory::addVMStub(VMStubTE vmstub, int bin) { //If the pt of the stub is consistent with the allowed pt of tracklets //in that can be formed in this VM and the other VM used in the TE. - if (settings_.combined()) { - if (disk_ > 0) { + + if (settings_.combined()){ + if (disk_>0) { assert(vmstub.stub()->isPSmodule()); } bool negdisk = vmstub.stub()->disk().value() < 0.0; if (negdisk) - bin += 4; - assert(bin < (int)stubsbinnedvm_.size()); - stubsbinnedvm_[bin].push_back(vmstub); - stubsvm_.push_back(vmstub); + bin+=4; + assert(bin<(int)stubsbinnedvm_.size()); + if (stubsbinnedvm_[bin].size() vmbendtable) { } void VMStubsTEMemory::writeVMBendTable() { - if (not std::filesystem::exists(settings_.tablePath())) { - int fail = system((string("mkdir -p ") + settings_.tablePath()).c_str()); - if (fail) - throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " - << settings_.tablePath(); - } - - const string fname = settings_.tablePath() + getName() + "_vmbendcut.tab"; - ofstream outvmbendcut(fname); - if (outvmbendcut.fail()) - throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname; + ofstream outvmbendcut=openfile(settings_.tablePath(), getName() + "_vmbendcut.tab", __FILE__, __LINE__); + outvmbendcut << "{" << endl; unsigned int vmbendtableSize = vmbendtable_.size(); assert(vmbendtableSize == 16 || vmbendtableSize == 8); diff --git a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml index 29aaa5e4ee8ec..aee5c63f06ded 100644 --- a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml @@ -7,9 +7,15 @@ + + + + - + + + @@ -18,8 +24,18 @@ + + + + + + + + + + diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index aea44217dbdff..ade9bd3bb2e4d 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -28,7 +28,8 @@ process.load('Configuration.StandardSequences.MagneticField_cff') process.load('FWCore.MessageService.MessageLogger_cfi') -process.MessageLogger.L1track=dict() +process.MessageLogger.categories.append('Tracklet') +process.MessageLogger.categories.append('L1track') process.MessageLogger.Tracklet = cms.untracked.PSet(limit = cms.untracked.int32(-1)) if GEOMETRY == "D49": @@ -86,7 +87,7 @@ # L1 tracking: remake stubs? ############################################################ -#process.load('L1Trigger.TrackTrigger.TrackTrigger_cff') +process.load('L1Trigger.TrackTrigger.TrackTrigger_cff') #from L1Trigger.TrackTrigger.TTStubAlgorithmRegister_cfi import * #process.load("SimTracker.TrackTriggerAssociation.TrackTriggerAssociator_cff") @@ -96,6 +97,7 @@ #process.TTClusterStub = cms.Path(process.TrackTriggerClustersStubs) #process.TTClusterStubTruth = cms.Path(process.TrackTriggerAssociatorClustersStubs) + ############################################################ # L1 tracking ############################################################ @@ -189,6 +191,23 @@ process.ana = cms.Path(process.L1TrackNtuple) +process.load( 'L1Trigger.TrackerDTC.ProducerED_cff' ) +process.load( 'L1Trigger.TrackerDTC.ProducerES_cff' ) + +#--- Load code that produces DTCStubs +# load Track Trigger Configuration +process.load( 'L1Trigger.TrackerDTC.ProducerES_cff' ) +# load code that produces DTCStubs +process.load( 'L1Trigger.TrackerDTC.ProducerED_cff' ) +# load code that analyzes DTCStubs +process.load( 'L1Trigger.TrackerDTC.Analyzer_cff' ) +#process.TrackTriggerSetup.FrontEnd.BendCut=5.0 +#process.TrackTriggerSetup.Hybrid.MinPt=1.0 +process.dtc = cms.Path( process.TrackerDTCProducer )#* process.TrackerDTCAnalyzer ) + + + + # use this if you want to re-run the stub making # process.schedule = cms.Schedule(process.TTClusterStub,process.TTClusterStubTruth,process.TTTracksEmulationWithTruth,process.ana) @@ -196,7 +215,7 @@ # process.schedule = cms.Schedule(process.TTClusterStubTruth,process.TTTracksEmulationWithTruth,process.ana) # use this to only run tracking + track associator -process.schedule = cms.Schedule(process.TTTracksEmulationWithTruth,process.ana) +process.schedule = cms.Schedule(process.dtc,process.TTTracksEmulationWithTruth,process.ana) ############################################################ diff --git a/L1Trigger/TrackFindingTracklet/test/Makefile b/L1Trigger/TrackFindingTracklet/test/Makefile index 263ae484f31ac..0288bbb14082e 100644 --- a/L1Trigger/TrackFindingTracklet/test/Makefile +++ b/L1Trigger/TrackFindingTracklet/test/Makefile @@ -57,6 +57,7 @@ $(shell touch dummyIncl/ctime) $(shell touch dummyIncl/cstdlib) $(shell touch dummyIncl/cmath) $(shell touch dummyIncl/exception) +$(shell touch dummyIncl/filesystem) $(shell touch dummyIncl/fstream) $(shell touch dummyIncl/iomanip) $(shell touch dummyIncl/iostream) @@ -66,6 +67,7 @@ $(shell touch dummyIncl/memory) $(shell touch dummyIncl/set) $(shell touch dummyIncl/sstream) $(shell touch dummyIncl/string) +$(shell touch dummyIncl/tuple) $(shell touch dummyIncl/vector) $(shell touch dummyIncl/unordered_map) $(shell touch dummyIncl/unordered_set) @@ -73,6 +75,8 @@ $(shell touch dummyIncl/utility) $(shell touch dummyIncl/algorithm) $(shell touch dummyIncl/ext/hash_set) $(shell touch dummyIncl/sys/time.h) +$(shell touch dummyIncl/sys/stat.h) +$(shell touch dummyIncl/sys/types.h) $(shell touch dummyIncl/ctime) $(shell touch dummyIncl/chrono) endif @@ -165,10 +169,23 @@ $(shell echo " while (phi > M_PI) { phi -= 2 * M_PI; }" >> DataFormats/Math/i $(shell echo " return phi; } " >> DataFormats/Math/interface/deltaPhi.h) $(shell echo "};" >> DataFormats/Math/interface/deltaPhi.h) $(shell echo "namespace angle0to2pi {" >> DataFormats/Math/interface/deltaPhi.h) -$(shell echo " inline double make0To2pi(double phi) { assert(std::abs(phi) < 100.0); " >> DataFormats/Math/interface/deltaPhi.h) -$(shell echo " while (phi < 0.0) { phi += 2 * M_PI; }" >> DataFormats/Math/interface/deltaPhi.h) -$(shell echo " while (phi > 2 * M_PI) { phi -= 2 * M_PI; }" >> DataFormats/Math/interface/deltaPhi.h) -$(shell echo " return phi; } " >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " template " >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " inline constexpr valType make0To2pi(valType angle) {" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " constexpr valType twoPi = 2*M_PI;" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " constexpr valType oneOverTwoPi = 1. / twoPi;" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " constexpr valType epsilon = 1.e-13;" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " if ((std::abs(angle) <= epsilon) || (std::abs(twoPi - std::abs(angle)) <= epsilon))" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " return (0.);" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " if (std::abs(angle) > twoPi) { " >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " valType nFac = trunc(angle * oneOverTwoPi);" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " angle -= (nFac * twoPi);" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " if (std::abs(angle) <= epsilon)" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " return (0.);" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " } " >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " if (angle < 0.)" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " angle += twoPi;" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " return (angle);" >> DataFormats/Math/interface/deltaPhi.h) +$(shell echo " }" >> DataFormats/Math/interface/deltaPhi.h) $(shell echo "};" >> DataFormats/Math/interface/deltaPhi.h) $(shell echo "#endif" >> DataFormats/Math/interface/deltaPhi.h) endif @@ -188,13 +205,14 @@ CXXFLAGS += -std=c++17 #fix, otherwise ROOT cflags overrule c++11 LIBS = -lHtml - ifneq ($(CMSSW_BASE),) ROOTFIT_INCLUDE := $(shell cd $(CMSSW_BASE); scram tool info roofitcore | grep INCLUDE= | sed 's|INCLUDE=||') ROOTFIT_LIBDIR := $(shell cd $(CMSSW_BASE); scram tool info roofitcore | grep LIBDIR= | sed 's|LIBDIR=||') CINTINCLUDES := -I$(ROOTFIT_INCLUDE) +ifneq ($(ROOTFIT_INCLUDE),) CXXFLAGS += -I$(ROOTFIT_INCLUDE) +endif LDFLAGS += -L$(ROOTFIT_LIBDIR) endif diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index b9c1786f4549f..76e74a68ab041 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -116,8 +116,28 @@ int main(const int argc, const char **argv) { for (int eventnum = 0; eventnum < nevents && !in->eof(); eventnum++) { SLHCEvent ev(*in); + + /* + L1SimTrack simtrk; + if (ev.nsimtracks()==0) { + continue; + } + + simtrk=ev.simtrack(0); + + double eta=simtrk.eta(); + + if (std::abs(std::abs(eta)-1.45)>0.15) { + continue; + } + if (simtrk.pt()<5.0) continue; + if (simtrk.pt()<2.0) continue; + + cout << "x,y,z : "< Date: Tue, 2 Mar 2021 19:43:07 +0100 Subject: [PATCH 02/45] propagate buildfile fixes --- L1Trigger/TrackFindingTracklet/BuildFile.xml | 31 ------------------- .../plugins/BuildFile.xml | 7 ++--- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/BuildFile.xml b/L1Trigger/TrackFindingTracklet/BuildFile.xml index 93be87c2f1d1e..9ca0665e2be06 100644 --- a/L1Trigger/TrackFindingTracklet/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/BuildFile.xml @@ -3,41 +3,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml b/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml index aeef3736a59d7..c9303f449c53b 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/plugins/BuildFile.xml @@ -1,15 +1,12 @@ - - - - - + + From 650ff58df462c190dc218d7edad38bae744a68b7 Mon Sep 17 00:00:00 2001 From: Louise Skinnari Date: Tue, 2 Mar 2021 19:45:16 +0100 Subject: [PATCH 03/45] code formats --- .../interface/CircularBuffer.h | 18 +- .../interface/InputLinkMemory.h | 2 +- .../TrackFindingTracklet/interface/L1TStub.h | 52 +- .../interface/MatchEngine.h | 4 +- .../interface/MatchEngineUnit.h | 2 +- .../interface/MatchProcessor.h | 5 +- .../interface/ProjectionTemp.h | 2 +- .../interface/SLHCEvent.h | 29 +- .../TrackFindingTracklet/interface/Sector.h | 13 +- .../TrackFindingTracklet/interface/Settings.h | 237 +- .../TrackFindingTracklet/interface/Stub.h | 23 +- .../TrackFindingTracklet/interface/Tracklet.h | 11 +- .../interface/TrackletConfigBuilder.h | 237 +- .../interface/TrackletEngineUnit.h | 37 +- .../interface/TrackletEventProcessor.h | 1 - .../interface/TrackletProcessor.h | 12 +- .../TrackFindingTracklet/interface/Util.h | 128 +- .../interface/VMRouterCM.h | 2 +- .../interface/VMRouterTable.h | 6 +- .../plugins/L1FPGATrackProducer.cc | 234 +- .../src/AllInnerStubsMemory.cc | 4 +- .../src/AllProjectionsMemory.cc | 2 +- .../src/AllStubsMemory.cc | 2 +- .../src/DiskProjection.cc | 9 +- .../TrackFindingTracklet/src/FitTrack.cc | 12 +- .../TrackFindingTracklet/src/HybridFit.cc | 2 +- .../src/InputLinkMemory.cc | 7 +- .../TrackFindingTracklet/src/L1SimTrack.cc | 1 - L1Trigger/TrackFindingTracklet/src/L1TStub.cc | 54 +- .../src/LayerProjection.cc | 31 +- .../src/MatchCalculator.cc | 43 +- .../TrackFindingTracklet/src/MatchEngine.cc | 83 +- .../src/MatchEngineUnit.cc | 19 +- .../src/MatchProcessor.cc | 277 +-- .../TrackFindingTracklet/src/MemoryBase.cc | 6 +- .../src/ProjectionRouter.cc | 8 +- .../src/ProjectionRouterBendTable.cc | 2 +- .../src/ProjectionTemp.cc | 2 +- .../src/PurgeDuplicate.cc | 10 +- .../TrackFindingTracklet/src/SLHCEvent.cc | 25 +- L1Trigger/TrackFindingTracklet/src/Sector.cc | 133 +- L1Trigger/TrackFindingTracklet/src/Stub.cc | 108 +- .../TrackFindingTracklet/src/TETableBase.cc | 2 +- .../TrackFindingTracklet/src/TrackDerTable.cc | 47 +- .../TrackFindingTracklet/src/Tracklet.cc | 28 +- .../src/TrackletCalculator.cc | 26 +- .../src/TrackletCalculatorBase.cc | 8 +- .../src/TrackletCalculatorDisplaced.cc | 186 +- .../src/TrackletConfigBuilder.cc | 2045 +++++++++-------- .../src/TrackletEngine.cc | 12 +- .../src/TrackletEngineDisplaced.cc | 25 +- .../src/TrackletEngineUnit.cc | 161 +- .../src/TrackletEventProcessor.cc | 64 +- .../src/TrackletProcessor.cc | 773 ++++--- .../TrackFindingTracklet/src/TripletEngine.cc | 14 +- .../TrackFindingTracklet/src/VMRouter.cc | 17 +- .../TrackFindingTracklet/src/VMRouterCM.cc | 200 +- .../src/VMRouterPhiCorrTable.cc | 5 +- .../TrackFindingTracklet/src/VMRouterTable.cc | 126 +- .../src/VMStubsTEMemory.cc | 23 +- L1Trigger/TrackFindingTracklet/test/fpga.cc | 1 - 61 files changed, 2813 insertions(+), 2845 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h b/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h index 1480b6204e1fe..267013d1783a3 100644 --- a/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h +++ b/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h @@ -29,7 +29,9 @@ namespace trklet { bool almostfull() const { return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_); } //Almost full if writer ptr incremented by 1 or 2 is same as read ptr - bool nearfull() const { return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_) || (((wptr_ + 3) % size_) == rptr_) ; } + bool nearfull() const { + return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_) || (((wptr_ + 3) % size_) == rptr_); + } //Empty buffer is write ptr is same as read ptr bool empty() const { return wptr_ == rptr_; } @@ -50,17 +52,13 @@ namespace trklet { assert(!full()); buffer_[wptr_++] = element; wptr_ = wptr_ % size_; - assert(wptr_!=rptr_); + assert(wptr_ != rptr_); } - unsigned int rptr() const { - return rptr_; - } - - unsigned int wptr() const { - return wptr_; - } - + unsigned int rptr() const { return rptr_; } + + unsigned int wptr() const { return wptr_; } + private: std::vector buffer_; diff --git a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h index 227753d0b918a..9f1c3839630a2 100644 --- a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h @@ -21,7 +21,7 @@ namespace trklet { ~InputLinkMemory() override = default; - void addStub(const L1TStub& al1stub,const Stub& stub); + void addStub(const L1TStub& al1stub, const Stub& stub); unsigned int nStubs() const { return stubs_.size(); } diff --git a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h index 81a70b5a9e705..830ba732ed094 100644 --- a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h +++ b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h @@ -14,17 +14,17 @@ namespace trklet { L1TStub(); L1TStub(std::string DTClink, - int region, - int layerdisk, - std::string stubword, - int isPSmodule, - int isFlipped, - double x, - double y, - double z, - double bend, - double strip, - std::vector tps); + int region, + int layerdisk, + std::string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + std::vector tps); ~L1TStub() = default; @@ -38,12 +38,12 @@ namespace trklet { unsigned int layer() const { return layer_; } int disk() const { - if (layerdisk_<6) { - return 0; + if (layerdisk_ < 6) { + return 0; } - int disk=layerdisk_-5; - if (z_ < 0.0 ) { - return -disk; + int disk = layerdisk_ - 5; + if (z_ < 0.0) { + return -disk; } return disk; } @@ -97,22 +97,14 @@ namespace trklet { bool tpmatch(int tp) const; bool tpmatch2(int tp) const; - const std::string& DTClink() const { - return DTClink_; - } + const std::string& DTClink() const { return DTClink_; } - int layerdisk() const { - return layerdisk_; - } - - int region() const { - return region_; - } + int layerdisk() const { return layerdisk_; } + + int region() const { return region_; } + + const std::string& stubword() const { return stubword_; } - const std::string& stubword() const { - return stubword_; - } - private: int layerdisk_; std::string DTClink_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h index 69a79284cfa1b..84f3ab53fad15 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h @@ -36,8 +36,8 @@ namespace trklet { int nvm_; int nvmbits_; - unsigned int nfinephibits_; //number of fine phi bits in phi VM bin - unsigned int nrinv_; //number of bits for rinv in stub bend LUT + unsigned int nfinephibits_; //number of fine phi bits in phi VM bin + unsigned int nrinv_; //number of bits for rinv in stub bend LUT //used in the layers std::vector table_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index 2bbf13645b660..3cef2a1c0b2ad 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -26,7 +26,7 @@ namespace trklet { int projrinv, int projfinerz, int projfinephi, - int shift, + int shift, bool usesecond, bool isPSseed, Tracklet* proj); diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index 11572e5760bb4..691c470d67b0e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -35,7 +35,6 @@ namespace trklet { bool matchCalculator(Tracklet* tracklet, const Stub* fpgastub); private: - unsigned int layerdisk_; bool barrel_; @@ -45,7 +44,7 @@ namespace trklet { int nvmbits_; //# of bits for VMs in sector int nvmbins_; //VMs in in phi region int nrinv_; //# of bits for rinv - + int dzshift_; int icorrshift_; int icorzshift_; @@ -72,7 +71,7 @@ namespace trklet { //Memory for the full matches std::vector fullmatches_; - //used for bend consistency with rinv + //used for bend consistency with rinv std::vector table_; unsigned int nMatchEngines_; diff --git a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h index 93a5ae0b4efa8..6d418058a842e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h @@ -14,7 +14,7 @@ namespace trklet { int projfinerz, unsigned int projfinephi, unsigned int iphi, - int shift, + int shift, bool usesecond, bool isPSseed); diff --git a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h index db5a75858c774..29f8768fb1455 100644 --- a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h +++ b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h @@ -29,23 +29,23 @@ namespace trklet { int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz); bool addStub(std::string DTClink, - int region, - int layerdisk, - std::string stubword, - int isPSmodule, - int isFlipped, - double x, - double y, - double z, - double bend, - double strip, - std::vector tps); + int region, + int layerdisk, + std::string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + std::vector tps); const L1TStub& lastStub() const { return stubs_.back(); } - void setIP(double x, double y) { - ipx_=x; - ipy_=y; + void setIP(double x, double y) { + ipx_ = x; + ipy_ = y; } void write(std::ofstream& out); @@ -69,7 +69,6 @@ namespace trklet { std::vector simtracks_; std::vector stubs_; double ipx_, ipy_; - }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/Sector.h b/L1Trigger/TrackFindingTracklet/interface/Sector.h index 1247dab0479a0..ddb0dc539dc03 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Sector.h +++ b/L1Trigger/TrackFindingTracklet/interface/Sector.h @@ -13,7 +13,6 @@ #include #include - namespace trklet { class Settings; @@ -120,14 +119,14 @@ namespace trklet { double phimax() const { return phimax_; } template - void addMemToVec(std::vector >& memvec, const std::string& memName, Args&... args) { + void addMemToVec(std::vector >& memvec, const std::string& memName, Args&... args) { memvec.push_back(std::make_unique(memName, std::forward(args)...)); Memories_[memName] = memvec.back().get(); MemoriesV_.push_back(memvec.back().get()); } template - void addProcToVec(std::vector >& procvec, const std::string& procName, Args&... args) { + void addProcToVec(std::vector >& procvec, const std::string& procName, Args&... args) { procvec.push_back(std::make_unique(procName, std::forward(args)...)); Processes_[procName] = procvec.back().get(); } @@ -135,9 +134,6 @@ namespace trklet { void writeLinkNewEvent(int event); void writeLink(const Stub& fpgastub); - - - private: int isector_; Settings const& settings_; @@ -145,7 +141,7 @@ namespace trklet { double phimin_; double phimax_; - std::map Memories_; + std::map Memories_; std::vector MemoriesV_; std::vector > IL_; std::vector > AS_; @@ -163,7 +159,7 @@ namespace trklet { std::vector > TF_; std::vector > CT_; - std::map Processes_; + std::map Processes_; std::vector > VMR_; std::vector > VMRCM_; std::vector > TE_; @@ -180,7 +176,6 @@ namespace trklet { std::vector > PD_; std::unordered_map DTCLink_ofstreams_; - }; }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index ee005417ac5ed..f1ed3fdc2d3b2 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -16,24 +16,24 @@ namespace trklet { constexpr unsigned int N_SECTOR = 9; // # of phi sectors for L1TK processing - constexpr int N_LAYER = 6; // # of barrel layers assumed - constexpr int N_DISK = 5; // # of endcap disks assumed - constexpr unsigned int N_PSLAYER = 3; // # of barrel PS layers assumed - constexpr unsigned int N_SEED = 12; // # of tracklet+triplet seeds + constexpr int N_LAYER = 6; // # of barrel layers assumed + constexpr int N_DISK = 5; // # of endcap disks assumed + constexpr unsigned int N_PSLAYER = 3; // # of barrel PS layers assumed + constexpr unsigned int N_SEED = 12; // # of tracklet+triplet seeds constexpr unsigned int N_SEED_PROMPT = 8; // # of tracklet (prompt) seeds constexpr unsigned int N_DSS_MOD = 5; // # of rings with 2S modules per disk - constexpr unsigned int N_BENDBITS_PS = 3; // Number of bend bits for PS modules - constexpr unsigned int N_BENDBITS_2S = 4; // Number of bend bits for 2S modules + constexpr unsigned int N_BENDBITS_PS = 3; // Number of bend bits for PS modules + constexpr unsigned int N_BENDBITS_2S = 4; // Number of bend bits for 2S modules + + constexpr unsigned int NRINVBITS = 5; //number of bit for rinv in bend match table + constexpr unsigned int NFINERZBITS = 3; //number of bit for r or z within a r/z bin + constexpr unsigned int NFINEPHIBITS = 3; //number of bits for phi within a vm bin - constexpr unsigned int NRINVBITS = 5; //number of bit for rinv in bend match table - constexpr unsigned int NFINERZBITS = 3; //number of bit for r or z within a r/z bin - constexpr unsigned int NFINEPHIBITS = 3; //number of bits for phi within a vm bin - constexpr unsigned int N_VMSTUBSMAX = 15; // maximum number of stubs in VM bin - constexpr double sixth = 1.0/6.0; //Commonly used factor + constexpr double sixth = 1.0 / 6.0; //Commonly used factor class Settings { public: @@ -137,14 +137,12 @@ namespace trklet { } unsigned int seedlayers(int inner, int seed) const { - int layerdisk=seedlayers_[seed][inner]; - assert(layerdisk>=0); + int layerdisk = seedlayers_[seed][inner]; + assert(layerdisk >= 0); return layerdisk; } - unsigned int NTC(int seed) const { - return ntc_[seed]; - } + unsigned int NTC(int seed) const { return ntc_[seed]; } unsigned int projlayers(unsigned int iSeed, unsigned int i) const { return projlayers_[iSeed][i]; } unsigned int projdisks(unsigned int iSeed, unsigned int i) const { return projdisks_[iSeed][i]; } @@ -273,10 +271,9 @@ namespace trklet { void setNbitsseedextended(unsigned int nbitsseed) { nbitsseedextended_ = nbitsseed; } double dphisectorHG() const { - double rsectmin=21.8; - double rsectmax=112.7; - return 2 * M_PI / N_SECTOR + - rinvmax()*std::max(rcrit_ - rsectmin, rsectmax - rcrit_); + double rsectmin = 21.8; + double rsectmax = 112.7; + return 2 * M_PI / N_SECTOR + rinvmax() * std::max(rcrit_ - rsectmin, rsectmax - rcrit_); } double rcrit() const { return rcrit_; } @@ -290,15 +287,14 @@ namespace trklet { double phicritmaxmc() const { return phicritmax() + dphicritmc_; } double kphi() const { return dphisectorHG() / (1 << nphibitsstub(0)); } - double kphi1() const { return dphisectorHG() / (1 << nphibitsstub(N_LAYER-1)); } + double kphi1() const { return dphisectorHG() / (1 << nphibitsstub(N_LAYER - 1)); } double kphi(unsigned int layerdisk) const { return dphisectorHG() / (1 << nphibitsstub(layerdisk)); } - double kz() const { return 2.0 * zlength_ / (1 << nzbitsstub_[0]); } double kz(unsigned int layerdisk) const { return 2.0 * zlength_ / (1 << nzbitsstub_[layerdisk]); } double kr() const { return rmaxdisk_ / (1 << nrbitsstub_[N_LAYER]); } - double krbarrel() const { return 2.0 * drmax() / (1 <5&&(!isPSmodule)) layerdisk+=5; - double bend=benddecode_[layerdisk][ibend]; - assert(bend<99.0); + if (layerdisk > 5 && (!isPSmodule)) + layerdisk += 5; + double bend = benddecode_[layerdisk][ibend]; + assert(bend < 99.0); return bend; } - + double bendcut(int ibend, int layerdisk, bool isPSmodule) const { - if (layerdisk>5&&(!isPSmodule)) layerdisk+=5; - double bendcut=bendcut_[layerdisk][ibend]; - if (bendcut<=0.0) std::cout << "bendcut : "<0.0); + if (layerdisk > 5 && (!isPSmodule)) + layerdisk += 5; + double bendcut = bendcut_[layerdisk][ibend]; + if (bendcut <= 0.0) + std::cout << "bendcut : " << layerdisk << " " << ibend << " " << isPSmodule << std::endl; + assert(bendcut > 0.0); return bendcut; } - - double bendcutte(int ibend, int layerdisk, bool isPSmodule) const { - return bendcut(ibend,layerdisk,isPSmodule); - } + + double bendcutte(int ibend, int layerdisk, bool isPSmodule) const { return bendcut(ibend, layerdisk, isPSmodule); } double bendcutme(int ibend, int layerdisk, bool isPSmodule) const { //FIXME temporary fix until phiprojderdisk bits adjusted. But requires coordinatin with HLS - double fact=(layerdisk, N_SEED> seedlayers_{{{{0, 1, -1}}, //L1L2 - {{1, 2, -1}}, //1 L2L3 - {{2, 3, -1}}, //2 L3L4 - {{4, 5, -1}}, //3 L5L6 - {{6, 7, -1}}, //4 D1D2 - {{8, 9, -1}}, //5 D3D4 - {{0, 6, -1}}, //6 L1D1 - {{1, 6, -1}}, //7 L2D1 - {{2, 3, 1}}, //8 L2L3L4 - {{4, 5, 3}}, //9 L4L5L6 - {{1, 2, 6}}, //10 L2L3D1 - {{6, 7, 1}}}}; //11 D1D2L2 + std::array, N_SEED> seedlayers_{{{{0, 1, -1}}, //L1L2 + {{1, 2, -1}}, //1 L2L3 + {{2, 3, -1}}, //2 L3L4 + {{4, 5, -1}}, //3 L5L6 + {{6, 7, -1}}, //4 D1D2 + {{8, 9, -1}}, //5 D3D4 + {{0, 6, -1}}, //6 L1D1 + {{1, 6, -1}}, //7 L2D1 + {{2, 3, 1}}, //8 L2L3L4 + {{4, 5, 3}}, //9 L4L5L6 + {{1, 2, 6}}, //10 L2L3D1 + {{6, 7, 1}}}}; //11 D1D2L2 //Number of tracklet calculators for the prompt seeding combinations std::array ntc_{{12, 4, 4, 4, 4, 4, 8, 4, 0, 0, 0, 0}}; - - + //projection layers by seed index. For each seeding index (row) the list of layers that we consider projections to std::array, N_SEED> projlayers_{{{{3, 4, 5, 6}}, //0 L1L2 {{1, 4, 5, 6}}, //1 L2L3 @@ -631,7 +625,7 @@ namespace trklet { {{1, 2, 5}}, //5 D3D4 {{2, 3, 4, 5}}, //6 L1D1 {{2, 3, 4}}, //7 L2D1 - {{1, 2, 3}}, //8 L2L3L4 + {{1, 2, 3}}, //8 L2L3L4 {{}}, //9 L4L5L6 {{2, 3, 4}}, //10 L2L3D1 {{3, 4}}}}; //11 D1D2L2 @@ -688,43 +682,42 @@ namespace trklet { //returns the mean bend (in strips at a 1.8cm separation) for bendcode std::array, 16> benddecode_{ - {{{0.0, 0.5, 0.7, 0.8, 89.9, -1.0, -0.9, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L1 PS - {{0.0, 0.7, 1.0, 1.5, 89.9, -1.5, -1.0, -0.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L2 PS - {{0.0, 1.0, 1.8, 2.2, 89.9, -2.2, -1.8, -1.0, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L3 PS - {{0.0, 0.7, 1.2, 1.8, 2.1, 2.6, 3.2, 3.5, 89.9, -3.5, -3.2, -2.6, -2.1, -1.8, -1.2, -0.7}}, //L4 2S - {{0.0, 0.8, 1.2, 1.8, 2.2, 3.2, 4.1, 4.4, 89.9, -4.4, -4.1, -3.2, -2.2, -1.8, -1.2, -0.8}}, //L5 2S - {{0.0, 0.9, 1.8, 2.8, 3.8, 4.5, 5.3, 5.9, 89.9, -5.9, -5.3, -4.5, -3.8, -2.8, -1.8, -0.9}}, //L6 2S - {{0.0, 0.8, 1.2, 2.0, 89.9, -2.0, -1.2, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D1 PS - {{0.0, 1.5, 1.8, 2.4, 89.9, -2.4, -1.8, -1.4, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D2 PS - {{0.0, 1.7, 2.0, 2.2, 89.9, -2.2, -2.0, -1.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D3 PS - {{0.0, 1.8, 2.0, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D4 PS - {{0.0, 2.0, 2.2, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D5 PS - {{0.0, 1.8, 2.3, 2.5, 3.0, 3.9, 4.5, 5.2, 89.9, -5.2, -4.5, -3.9, -3.0, -2.5, -2.3, -1.8}}, //D1 2S - {{0.0, 2.0, 2.4, 2.9, 3.2, 4.0, 4.8, 5.2, 89.9, -5.2, -4.8, -4.0, -3.2, -2.9, -2.4, -2.0}}, //D2 2S - {{0.0, 2.0, 2.4, 2.7, 3.6, 3.7, 4.4, 4.6, 89.9, -4.6, -4.4, -3.7, -3.6, -2.7, -2.4, -2.0}}, //D3 2S - {{0.0, 2.0, 2.6, 3.2, 3.8, 4.0, 4.4, 4.4, 89.9, -4.4, -4.4, -4.0, -3.8, -3.2, -2.6, -2.0}}, //D4 2S - {{0.0, 2.0, 3.2, 3.4, 3.9, 3.9, 4.4, 4.4, 89.9, -4.4, -4.4, -3.9, -3.9, -3.4, -3.2, -2.0}}}}; //D5 2S + {{{0.0, 0.5, 0.7, 0.8, 89.9, -1.0, -0.9, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L1 PS + {{0.0, 0.7, 1.0, 1.5, 89.9, -1.5, -1.0, -0.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L2 PS + {{0.0, 1.0, 1.8, 2.2, 89.9, -2.2, -1.8, -1.0, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //L3 PS + {{0.0, 0.7, 1.2, 1.8, 2.1, 2.6, 3.2, 3.5, 89.9, -3.5, -3.2, -2.6, -2.1, -1.8, -1.2, -0.7}}, //L4 2S + {{0.0, 0.8, 1.2, 1.8, 2.2, 3.2, 4.1, 4.4, 89.9, -4.4, -4.1, -3.2, -2.2, -1.8, -1.2, -0.8}}, //L5 2S + {{0.0, 0.9, 1.8, 2.8, 3.8, 4.5, 5.3, 5.9, 89.9, -5.9, -5.3, -4.5, -3.8, -2.8, -1.8, -0.9}}, //L6 2S + {{0.0, 0.8, 1.2, 2.0, 89.9, -2.0, -1.2, -0.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D1 PS + {{0.0, 1.5, 1.8, 2.4, 89.9, -2.4, -1.8, -1.4, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D2 PS + {{0.0, 1.7, 2.0, 2.2, 89.9, -2.2, -2.0, -1.7, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D3 PS + {{0.0, 1.8, 2.0, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D4 PS + {{0.0, 2.0, 2.2, 2.4, 89.9, -2.4, -2.0, -1.8, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9}}, //D5 PS + {{0.0, 1.8, 2.3, 2.5, 3.0, 3.9, 4.5, 5.2, 89.9, -5.2, -4.5, -3.9, -3.0, -2.5, -2.3, -1.8}}, //D1 2S + {{0.0, 2.0, 2.4, 2.9, 3.2, 4.0, 4.8, 5.2, 89.9, -5.2, -4.8, -4.0, -3.2, -2.9, -2.4, -2.0}}, //D2 2S + {{0.0, 2.0, 2.4, 2.7, 3.6, 3.7, 4.4, 4.6, 89.9, -4.6, -4.4, -3.7, -3.6, -2.7, -2.4, -2.0}}, //D3 2S + {{0.0, 2.0, 2.6, 3.2, 3.8, 4.0, 4.4, 4.4, 89.9, -4.4, -4.4, -4.0, -3.8, -3.2, -2.6, -2.0}}, //D4 2S + {{0.0, 2.0, 3.2, 3.4, 3.9, 3.9, 4.4, 4.4, 89.9, -4.4, -4.4, -3.9, -3.9, -3.4, -3.2, -2.0}}}}; //D5 2S //returns the bend 'cut' (in strips at a 1.8cm separation) for bendcode std::array, 16> bendcut_{ - {{{1.5, 1.2, 0.8, 0.8, 99.9, 0.8, 0.8, 1.2, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L1 PS - {{1.5, 1.3, 1.0, 1.0, 99.9, 1.0, 1.0, 1.3, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L2 PS - {{1.6, 1.5, 1.0, 1.0, 99.9, 1.0, 1.0, 1.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L3 PS - {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L4 2S - {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L5 2S - {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L6 2S - {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D1 PS - {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D2 PS - {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D3 PS - {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D4 PS - {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D5 PS - {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}}, //D1 2S - {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}}, //D2 2S - {{2.2, 1.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5, 1.5}}, //D3 2S - {{2.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5}}, //D4 2S - {{2.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5}}}}; //D5 2S - - + {{{1.5, 1.2, 0.8, 0.8, 99.9, 0.8, 0.8, 1.2, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L1 PS + {{1.5, 1.3, 1.0, 1.0, 99.9, 1.0, 1.0, 1.3, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L2 PS + {{1.6, 1.5, 1.0, 1.0, 99.9, 1.0, 1.0, 1.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //L3 PS + {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L4 2S + {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L5 2S + {{1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 99.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}}, //L6 2S + {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D1 PS + {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D2 PS + {{1.8, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D3 PS + {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D4 PS + {{2.2, 1.6, 1.6, 1.6, 99.9, 1.6, 1.6, 1.6, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}}, //D5 PS + {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}}, //D1 2S + {{2.0, 1.2, 1.2, 1.2, 1.5, 1.5, 1.5, 1.5, 99.9, 1.5, 1.5, 1.5, 1.5, 1.2, 1.2, 1.2}}, //D2 2S + {{2.2, 1.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5, 1.5}}, //D3 2S + {{2.5, 1.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5, 1.5}}, //D4 2S + {{2.5, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 99.9, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.5}}}}; //D5 2S + // Offset to the maximum number of steps in each processing step: // Set to 0 (default) means standard truncation // Set to large value, e.g. 10000, to disable truncation @@ -732,7 +725,7 @@ namespace trklet { //Number of processing steps for one event (108=18TM*240MHz/40MHz) std::unordered_map maxstep_{{"Link", 108}, - {"VMR", 108}, + {"VMR", 108}, {"TE", 108}, {"TC", 108}, {"PR", 108}, @@ -743,38 +736,18 @@ namespace trklet { {"TRE", 108}}; // If set to true this will generate debub printout in text files - std::unordered_map writeMonitorData_{{"IL", false}, - {"TE", false}, - {"CT", false}, - {"HitPattern", false}, - {"ChiSq", false}, - {"Seeds", false}, - {"FT", false}, - {"Residuals", false}, - {"StubBend", false}, - {"MC", false}, - {"MP", false}, - {"ME", false}, - {"AP", false}, - {"VMP", false}, - {"NMatches", false}, - {"TrackProjOcc", false}, - {"TC", false}, - {"Pars", false}, - {"TPars", false}, - {"TPD", false}, - {"TrackletPars", false}, - {"TED", false}, - {"TP", false}, - {"TRE", false}, - {"VMR", false}, - {"StubsLayer", false}, - {"StubsLayerSector", false}, - {"HitEff", false}, - {"MatchEff", false}, - {"Cabling", false}, - {"IFit", false}, - {"AS", false}}; + std::unordered_map writeMonitorData_{ + {"IL", false}, {"TE", false}, {"CT", false}, + {"HitPattern", false}, {"ChiSq", false}, {"Seeds", false}, + {"FT", false}, {"Residuals", false}, {"StubBend", false}, + {"MC", false}, {"MP", false}, {"ME", false}, + {"AP", false}, {"VMP", false}, {"NMatches", false}, + {"TrackProjOcc", false}, {"TC", false}, {"Pars", false}, + {"TPars", false}, {"TPD", false}, {"TrackletPars", false}, + {"TED", false}, {"TP", false}, {"TRE", false}, + {"VMR", false}, {"StubsLayer", false}, {"StubsLayerSector", false}, + {"HitEff", false}, {"MatchEff", false}, {"Cabling", false}, + {"IFit", false}, {"AS", false}}; std::array rDSSinner_mod_{{68.9391, 78.7750, 85.4550, 96.3150, 102.3160}}; std::array rDSSouter_mod_{{66.4903, 76.7750, 84.4562, 94.9920, 102.3160}}; @@ -791,9 +764,9 @@ namespace trklet { bool warnNoDer_{false}; //If true will print out warnings about missing track fit derivatives //--- These used to create files needed by HLS code. - bool writeMem_{false}; //If true will print out content of memories (between algo steps) to files - bool writeTable_{false}; //If true will print out content of LUTs to files - bool writeConfig_{false}; //If true will print out the autogenerated configuration as files + bool writeMem_{false}; //If true will print out content of memories (between algo steps) to files + bool writeTable_{false}; //If true will print out content of LUTs to files + bool writeConfig_{false}; //If true will print out the autogenerated configuration as files std::string memPath_{"../data/MemPrints/"}; //path for writing memories std::string tablePath_{"../data/LUTs/"}; //path for writing LUTs diff --git a/L1Trigger/TrackFindingTracklet/interface/Stub.h b/L1Trigger/TrackFindingTracklet/interface/Stub.h index 9874d25c85c7c..35f9a3dbfc206 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Stub.h +++ b/L1Trigger/TrackFindingTracklet/interface/Stub.h @@ -14,7 +14,7 @@ namespace trklet { class Globals; - + class Stub { public: Stub(Settings const& settings); @@ -40,13 +40,14 @@ namespace trklet { std::string strbare() const { return bend_.str() + r_.str() + z_.str() + phi_.str(); } std::string strinner() const { - unsigned int nbitsfinephi=8; - FPGAWord finephi(phicorr_.bits(phicorr_.nbits()-nbitsfinephi,nbitsfinephi),nbitsfinephi,true,__LINE__,__FILE__); - return str()+"|"+stubindex_.str()+"|"+finephi.str(); + unsigned int nbitsfinephi = 8; + FPGAWord finephi( + phicorr_.bits(phicorr_.nbits() - nbitsfinephi, nbitsfinephi), nbitsfinephi, true, __LINE__, __FILE__); + return str() + "|" + stubindex_.str() + "|" + finephi.str(); } - FPGAWord allStubIndex() const {return stubindex_;} - + FPGAWord allStubIndex() const { return stubindex_; } + unsigned int phiregionaddress() const; std::string phiregionaddressstr() const; @@ -60,14 +61,14 @@ namespace trklet { const FPGAWord& z() const { return z_; } const FPGAWord& phi() const { return phi_; } const FPGAWord& phicorr() const { return phicorr_; } - const FPGAWord& alphanew() const { return alpha_; } //FIXME should remove new + const FPGAWord& alphanew() const { return alpha_; } //FIXME should remove new const FPGAWord& stubindex() const { return stubindex_; } const FPGAWord& layer() const { return layer_; } const FPGAWord& disk() const { return disk_; } unsigned int layerdisk() const; - bool isPSmodule() const { return (layerdisk_ 10); } + bool isPSmodule() const { return (layerdisk_ < N_LAYER) ? (layerdisk_ < N_PSLAYER) : (r_.value() > 10); } double rapprox() const; double zapprox() const; @@ -77,11 +78,11 @@ namespace trklet { const L1TStub* l1tstub() const { return l1tstub_; } void setl1tstub(L1TStub* l1tstub) { l1tstub_ = l1tstub; } - bool isBarrel() const { return layerdisk_ 0 && layer <= N_LAYER); - assert(layerproj_[layer-1].valid()); - return layerproj_[layer-1]; + assert(layerproj_[layer - 1].valid()); + return layerproj_[layer - 1]; } - //Disks residuals @@ -113,7 +112,6 @@ namespace trklet { return diskproj_[abs(disk) - 1]; } - bool matchdisk(int disk) const { assert(abs(disk) <= N_DISK); return diskresid_[abs(disk) - 1].valid(); @@ -121,7 +119,7 @@ namespace trklet { const DiskResidual& diskResid(int disk) const { assert(matchdisk(disk)); - return diskresid_[abs(disk)-1]; + return diskresid_[abs(disk) - 1]; } void addMatch(int layer, @@ -158,13 +156,12 @@ namespace trklet { return layerresid_[layer - 1].valid(); } - const LayerResidual& layerResid(int layer){ + const LayerResidual& layerResid(int layer) { assert(layer > 0 && layer <= N_LAYER); assert(layerresid_[layer - 1].valid()); return layerresid_[layer - 1]; } - std::vector getL1Stubs(); std::map getStubIDs(); diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h b/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h index cc00d184126c1..509e777326813 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h @@ -17,18 +17,15 @@ namespace trklet { - class TrackletConfigBuilder{ - + class TrackletConfigBuilder { public: - //Builds the configuration for the tracklet based track finding TrackletConfigBuilder(const Settings& settings); //This method writes out the configuration as files void writeAll(std::ostream& wires, std::ostream& memories, std::ostream& modules); - + private: - // // Method to initialize the regions and VM in each layer // @@ -57,12 +54,12 @@ namespace trklet { // // Helper fcn. to get the layers/disks for a seed // - std::pair seedLayers(unsigned int iSeed); + std::pair seedLayers(unsigned int iSeed); - // + // // Helper fcn to get the radii of the two layers in a seed // - std::pair seedRadii(unsigned int iseed); + std::pair seedRadii(unsigned int iseed); // // Helper fcn to return the phi range of a projection of a tracklet from a TC @@ -73,7 +70,7 @@ namespace trklet { // Helper function to calculate the phi position of a seed at radius r that is formed // by two stubs at (r1,phi1) and (r2, phi2) // - double phi(double r1, double phi1, double r2, double phi2,double r); + double phi(double r1, double phi1, double r2, double phi2, double r); // // Helper function to calculate rinv for two stubs at (r1,phi1) and (r2,phi2) @@ -85,158 +82,172 @@ namespace trklet { // memories and processing modules // std::string iSeedStr(unsigned int iSeed); - + std::string numStr(unsigned int i); - + std::string iTCStr(unsigned int iTC); - + std::string iRegStr(unsigned int iReg, unsigned int iSeed); - - std::string TCName(unsigned int iSeed,unsigned int iTC); - + + std::string TCName(unsigned int iSeed, unsigned int iTC); + std::string LayerName(unsigned int ilayer); - - std::string TPROJName(unsigned int iSeed, unsigned int iTC, - unsigned int ilayer, unsigned int ireg); - + + std::string TPROJName(unsigned int iSeed, unsigned int iTC, unsigned int ilayer, unsigned int ireg); + std::string PRName(unsigned int ilayer, unsigned int ireg); - - std::string SPName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, - unsigned int l2, unsigned int ireg2, unsigned int ivm2, - unsigned int iseed); - - std::string SPDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, - unsigned int l2, unsigned int ireg2, unsigned int ivm2, - unsigned int l3, unsigned int ireg3, unsigned int ivm3, - unsigned int iseed); - - std::string STName(unsigned int l1, unsigned int ireg1, - unsigned int l2, unsigned int ireg2, - unsigned int l3, unsigned int ireg3, - unsigned int iseed, unsigned int count); - - std::string TEName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, - unsigned int l2, unsigned int ireg2, unsigned int ivm2, - unsigned int iseed); - - std::string TREName(unsigned int l1, unsigned int ireg1, - unsigned int l2, unsigned int ireg2, - unsigned int iseed, unsigned int count); - - std::string TEDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, - unsigned int l2, unsigned int ireg2, unsigned int ivm2, - unsigned int iseed); - - std::string TParName(unsigned int l1, - unsigned int l2, - unsigned int l3, - unsigned int itc); - - std::string TCDName(unsigned int l1, - unsigned int l2, - unsigned int l3, - unsigned int itc); + + std::string SPName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int iseed); + + std::string SPDName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int l3, + unsigned int ireg3, + unsigned int ivm3, + unsigned int iseed); + + std::string STName(unsigned int l1, + unsigned int ireg1, + unsigned int l2, + unsigned int ireg2, + unsigned int l3, + unsigned int ireg3, + unsigned int iseed, + unsigned int count); + + std::string TEName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int iseed); + + std::string TREName(unsigned int l1, + unsigned int ireg1, + unsigned int l2, + unsigned int ireg2, + unsigned int iseed, + unsigned int count); + + std::string TEDName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int iseed); + + std::string TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc); + + std::string TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc); std::string TPROJName(unsigned int l1, - unsigned int l2, - unsigned int l3, - unsigned int itc, - unsigned int projlay, - unsigned int projreg); - - std::string FTName(unsigned int l1, - unsigned int l2, - unsigned int l3); - - std::string TCNAme(unsigned int iseed, unsigned int iTC); + unsigned int l2, + unsigned int l3, + unsigned int itc, + unsigned int projlay, + unsigned int projreg); + + std::string FTName(unsigned int l1, unsigned int l2, unsigned int l3); + std::string TCNAme(unsigned int iseed, unsigned int iTC); // // This group of methods are used to print out the configuration as a file // void writeProjectionMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeSPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); void writeSPDMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeAPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeCMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeVMPROJMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeFMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeASMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeVMSMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); void writeTPARMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); void writeTFMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeCTMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); - + void writeILMemories(std::ostream& os, std::ostream& memories, std::ostream& modules); // // Store constants extracted from Settings // - unsigned int NSector_; //Number of sectors - double rcrit_; //critical radius that defines the sector - - bool combinedmodules_; //if true write configuration for combined modules - - bool extended_; //if true write configuration for extended configuration - - double rinvmax_; //Max value for valid rinv - double rmaxdisk_; //Maximim disk radius - double zlength_; //Maximim (abslute) z-positon in barrel - double rmean_[N_LAYER]; //Mean layer radius - double zmean_[N_DISK]; //Mean disk z-position - - double dphisectorHG_; //Full sector width - - unsigned int NTC_[N_SEED_PROMPT]; //Number of TC per seeding combination - - unsigned int NRegions_[N_LAYER+N_DISK]; //Regions (all stubs memories 6 layers +5 disks - unsigned int NVMME_[N_LAYER+N_DISK]; //Number of MEs (all stubs memories 6 layers +5 disks - std::pair NVMTE_[N_SEED_PROMPT]; //number of TEs for each seeding combination - + unsigned int NSector_; //Number of sectors + double rcrit_; //critical radius that defines the sector + + bool combinedmodules_; //if true write configuration for combined modules + + bool extended_; //if true write configuration for extended configuration + + double rinvmax_; //Max value for valid rinv + double rmaxdisk_; //Maximim disk radius + double zlength_; //Maximim (abslute) z-positon in barrel + double rmean_[N_LAYER]; //Mean layer radius + double zmean_[N_DISK]; //Mean disk z-position + + double dphisectorHG_; //Full sector width + + unsigned int NTC_[N_SEED_PROMPT]; //Number of TC per seeding combination + + unsigned int NRegions_[N_LAYER + N_DISK]; //Regions (all stubs memories 6 layers +5 disks + unsigned int NVMME_[N_LAYER + N_DISK]; //Number of MEs (all stubs memories 6 layers +5 disks + std::pair NVMTE_[N_SEED_PROMPT]; //number of TEs for each seeding combination + //Min and max phi for a phi region (e.g. all stubs) - std::vector > allStubs_[N_LAYER+N_DISK]; + std::vector > allStubs_[N_LAYER + N_DISK]; //Min and max phi for VM bin - std::vector > VMStubsME_[N_LAYER+N_DISK]; + std::vector > VMStubsME_[N_LAYER + N_DISK]; //Phi ranges for the stubs in the VM bins used in the pair in th TE - std::pair >, - std::vector > > VMStubsTE_[N_SEED_PROMPT]; + std::pair >, std::vector > > + VMStubsTE_[N_SEED_PROMPT]; //List of the TEs and the VM bins for each TE - std::vector > TE_[N_SEED_PROMPT]; + std::vector > TE_[N_SEED_PROMPT]; //The TCs for each seeding combination std::vector > TC_[N_SEED_PROMPT]; //The projections to each layer/disk from a seed and TC - std::vector< std::vector > > projections_[N_LAYER+N_DISK]; + std::vector > > projections_[N_LAYER + N_DISK]; //Which matches are used for each seeding layer - // L1 L2 L3 L4 L5 L6 D1 D2 D3 D4 D5 - int matchport_[N_SEED_PROMPT][N_LAYER+N_DISK]= { {-1,-1, 1, 2, 3, 4, 4, 3, 2, 1,-1}, //L1L2 - { 1,-1,-1, 2, 3,-1, 4, 3, 2, 1,-1}, //L2L3 - { 1, 2,-1,-1, 3, 4, 4, 3,-1,-1,-1}, //L3L4 - { 1, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1}, //L5L6 - { 1, 2,-1,-1,-1,-1,-1,-1, 2, 3, 4}, //D1D2 - { 1,-1,-1,-1,-1,-1, 2, 3,-1,-1, 4}, //D3D4 - {-1,-1,-1,-1,-1,-1,-1, 1, 2, 3, 4}, //L1D1 - { 1,-1,-1,-1,-1,-1,-1, 2, 3, 4,-1}}; //L2D1 + // L1 L2 L3 L4 L5 L6 D1 D2 D3 D4 D5 + int matchport_[N_SEED_PROMPT][N_LAYER + N_DISK] = {{-1, -1, 1, 2, 3, 4, 4, 3, 2, 1, -1}, //L1L2 + {1, -1, -1, 2, 3, -1, 4, 3, 2, 1, -1}, //L2L3 + {1, 2, -1, -1, 3, 4, 4, 3, -1, -1, -1}, //L3L4 + {1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1}, //L5L6 + {1, 2, -1, -1, -1, -1, -1, -1, 2, 3, 4}, //D1D2 + {1, -1, -1, -1, -1, -1, 2, 3, -1, -1, 4}, //D3D4 + {-1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4}, //L1D1 + {1, -1, -1, -1, -1, -1, -1, 2, 3, 4, -1}}; //L2D1 //Settings const Settings& settings_; - }; -} +} // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h index d20d3dc3091a2..dd12be6851287 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h @@ -7,7 +7,6 @@ #include #include - namespace trklet { class Settings; @@ -15,20 +14,28 @@ namespace trklet { class L1TStub; class FPGAWord; - struct TEData{ + struct TEData { const Stub* stub_; int start_; int rzbinfirst_; int rzdiffmax_; int innerfinephi_; FPGAWord innerbend_; - std::vector< std::tuple > regions_; // next z/r bin; phi-region; nstub + std::vector > regions_; // next z/r bin; phi-region; nstub }; - - + class TrackletEngineUnit { public: - TrackletEngineUnit(const Settings* const settings, unsigned int nbitsfinephi, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int iSeed, unsigned int nbitsfinephiediff, unsigned int iAllStub, std::vector const& pttableinner, std::vector const& pttableouter, VMStubsTEMemory* outervmstubs); + TrackletEngineUnit(const Settings* const settings, + unsigned int nbitsfinephi, + unsigned int layerdisk1, + unsigned int layerdisk2, + unsigned int iSeed, + unsigned int nbitsfinephiediff, + unsigned int iAllStub, + std::vector const& pttableinner, + std::vector const& pttableouter, + VMStubsTEMemory* outervmstubs); ~TrackletEngineUnit() = default; @@ -42,7 +49,7 @@ namespace trklet { bool idle() const { return idle_; } - void setNearFull() { nearfull_=candpairs_.nearfull(); } + void setNearFull() { nearfull_ = candpairs_.nearfull(); } void reset(); @@ -51,9 +58,9 @@ namespace trklet { int rptr() const { return candpairs_.rptr(); } int wptr() const { return candpairs_.wptr(); } - - const Stub* innerStub() const {return tedata_.stub_;} - + + const Stub* innerStub() const { return tedata_.stub_; } + private: VMStubsTEMemory* outervmstubs_; TEData tedata_; @@ -63,16 +70,16 @@ namespace trklet { unsigned int layerdisk2_; unsigned int iSeed_; unsigned int nbitsfinephidiff_; - bool nearfull_; //initialized at start of each processing step + bool nearfull_; //initialized at start of each processing step unsigned int iAllStub_; - + //unsigned int memory slot unsigned int nreg_; unsigned int istub_; unsigned int ireg_; unsigned int next_; unsigned int nstub_; - + bool idle_; std::vector pttableinner_; @@ -80,10 +87,10 @@ namespace trklet { std::pair candpair_, candpair__; bool goodpair_, goodpair__; - + //save the candidate matches CircularBuffer > candpairs_; - }; // TrackletEngineUnit + }; // TrackletEngineUnit }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h index d00dbab606d7b..e30273bac4a01 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h @@ -33,7 +33,6 @@ namespace trklet { std::vector& tracks() { return tracks_; } private: - void configure(std::istream& inwire, std::istream& inmem, std::istream& inproc); const Settings* settings_{nullptr}; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h index 86f349d4cddb4..80c3d7dcb6f45 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h @@ -8,7 +8,6 @@ #include "L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h" - #include #include #include @@ -47,11 +46,10 @@ namespace trklet { VMStubsTEMemory* outervmstubs_; // istub imem start imem end imem - std::tuple, unsigned int , unsigned int, unsigned int, unsigned int> tebuffer_; + std::tuple, unsigned int, unsigned int, unsigned int, unsigned int> tebuffer_; std::vector teunits_; - std::vector innerallstubs_; std::vector outerallstubs_; @@ -62,21 +60,19 @@ namespace trklet { std::vector pttableouternew_; std::vector useregion_; - + int nbitsfinephi_; int nbitsfinephidiff_; - + int innerphibits_; int outerphibits_; - + unsigned int nbitszfinebintable_; unsigned int nbitsrfinebintable_; unsigned int nbitsrzbin_; - VMRouterTable vmrtable_; - }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/Util.h b/L1Trigger/TrackFindingTracklet/interface/Util.h index 32bbca367cb4a..41ed3a8e25390 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Util.h +++ b/L1Trigger/TrackFindingTracklet/interface/Util.h @@ -47,7 +47,6 @@ namespace trklet { } inline double rinv(double phi1, double phi2, double r1, double r2) { - if (r2 <= r1) { //FIXME can not form tracklet should not call function with r2<=r1 return 20.0; } @@ -59,44 +58,59 @@ namespace trklet { } inline std::string convertHexToBin(const std::string& stubwordhex) { - - std::string stubwordbin=""; - - for(char word:stubwordhex){ - std::string hexword=""; - if (word=='0') hexword="0000"; - if (word=='1') hexword="0001"; - if (word=='2') hexword="0010"; - if (word=='3') hexword="0011"; - if (word=='4') hexword="0100"; - if (word=='5') hexword="0101"; - if (word=='6') hexword="0110"; - if (word=='7') hexword="0111"; - if (word=='8') hexword="1000"; - if (word=='9') hexword="1001"; - if (word=='A') hexword="1010"; - if (word=='B') hexword="1011"; - if (word=='C') hexword="1100"; - if (word=='D') hexword="1101"; - if (word=='E') hexword="1110"; - if (word=='F') hexword="1111"; - if (hexword=="") { - throw cms::Exception("Inconsistency") << __FILE__ << " " << __LINE__ << " hex string format invalid: " << stubwordhex; + std::string stubwordbin = ""; + + for (char word : stubwordhex) { + std::string hexword = ""; + if (word == '0') + hexword = "0000"; + if (word == '1') + hexword = "0001"; + if (word == '2') + hexword = "0010"; + if (word == '3') + hexword = "0011"; + if (word == '4') + hexword = "0100"; + if (word == '5') + hexword = "0101"; + if (word == '6') + hexword = "0110"; + if (word == '7') + hexword = "0111"; + if (word == '8') + hexword = "1000"; + if (word == '9') + hexword = "1001"; + if (word == 'A') + hexword = "1010"; + if (word == 'B') + hexword = "1011"; + if (word == 'C') + hexword = "1100"; + if (word == 'D') + hexword = "1101"; + if (word == 'E') + hexword = "1110"; + if (word == 'F') + hexword = "1111"; + if (hexword == "") { + throw cms::Exception("Inconsistency") + << __FILE__ << " " << __LINE__ << " hex string format invalid: " << stubwordhex; } - stubwordbin+=hexword; + stubwordbin += hexword; } return stubwordbin; } inline int ilog2(double factor) { - double power=log(factor)/log(2); - int ipower=round(power); - assert(std::abs(power-ipower)<0.1); + double power = log(factor) / log(2); + int ipower = round(power); + assert(std::abs(power - ipower) < 0.1); return ipower; } - -/****************************************************************************** + /****************************************************************************** * Checks to see if a directory exists. Note: This method only checks the * existence of the full path AND if path leaf is a dir. * @@ -104,62 +118,62 @@ namespace trklet { * 0 if dir does not exist OR exists but not a dir, * -1 if an error occurred (errno is also set) *****************************************************************************/ - inline int dirExists(const std::string& path){ + inline int dirExists(const std::string& path) { struct stat info; - int statRC = stat( path.c_str(), &info ); - if( statRC != 0 ) - { - if (errno == ENOENT) { return 0; } // something along the path does not exist - if (errno == ENOTDIR) { return 0; } // something in path prefix is not a dir - return -1; + int statRC = stat(path.c_str(), &info); + if (statRC != 0) { + if (errno == ENOENT) { + return 0; + } // something along the path does not exist + if (errno == ENOTDIR) { + return 0; + } // something in path prefix is not a dir + return -1; } - - return ( info.st_mode & S_IFDIR ) ? 1 : 0; - } + return (info.st_mode & S_IFDIR) ? 1 : 0; + } //Open file - create directory if not existent. inline std::ofstream openfile(const std::string& dir, const std::string& fname, const char* file, int line) { - - if (dirExists(dir)!=1) { - std::cout << "Creating directory : "< allstubs_; - std::vector > allinnerstubs_; + std::vector > allinnerstubs_; //The VM stubs memories used by the MEs std::vector vmstubsMEPHI_; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h b/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h index 21298a7b2c132..b376c5d712c79 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMRouterTable.h @@ -16,11 +16,11 @@ namespace trklet { class VMRouterTable { public: VMRouterTable(Settings const& settings); - VMRouterTable(Settings const& settings, unsigned int layerdisk,std::string const& name); + VMRouterTable(Settings const& settings, unsigned int layerdisk, std::string const& name); ~VMRouterTable() = default; - void init(unsigned int layerdisk, std::string const& name=""); + void init(unsigned int layerdisk, std::string const& name = ""); // negative return means that seed can not be formed int getLookup(unsigned int layerdisk, double z, double r, int iseed = -1); @@ -32,7 +32,7 @@ namespace trklet { int lookupinnerThird(int zbin, int rbin); void writeVMTable(std::string const& dir, std::string const& name, std::vector const& table); - + private: Settings const& settings_; diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 672f4e2305ab5..1161be2d4fad6 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -194,7 +194,6 @@ class L1FPGATrackProducer : public edm::one::EDProducer { // Setup token edm::ESGetToken esGetToken_; - /// ///////////////// /// /// MANDATORY METHODS /// void beginRun(const edm::Run& run, const edm::EventSetup& iSetup) override; @@ -205,17 +204,16 @@ class L1FPGATrackProducer : public edm::one::EDProducer { ////////////// // CONSTRUCTOR L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) - : config(iConfig), - readMoreMcTruth_(iConfig.getParameter("readMoreMcTruth")), - MCTruthClusterInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthClusterInputTag") - : edm::InputTag()), - MCTruthStubInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthStubInputTag") - : edm::InputTag()), - TrackingParticleInputTag(readMoreMcTruth_ ? iConfig.getParameter("TrackingParticleInputTag") - : edm::InputTag()), - bsToken_(consumes(config.getParameter("BeamSpotSource"))), - tokenDTC_(consumes(edm::InputTag(iConfig.getParameter( "InputTagTTDTC" ) ) ) ) -{ + : config(iConfig), + readMoreMcTruth_(iConfig.getParameter("readMoreMcTruth")), + MCTruthClusterInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthClusterInputTag") + : edm::InputTag()), + MCTruthStubInputTag(readMoreMcTruth_ ? config.getParameter("MCTruthStubInputTag") + : edm::InputTag()), + TrackingParticleInputTag(readMoreMcTruth_ ? iConfig.getParameter("TrackingParticleInputTag") + : edm::InputTag()), + bsToken_(consumes(config.getParameter("BeamSpotSource"))), + tokenDTC_(consumes(edm::InputTag(iConfig.getParameter("InputTagTTDTC")))) { if (readMoreMcTruth_) { ttClusterMCTruthToken_ = consumes>(MCTruthClusterInputTag); TrackingParticleToken_ = consumes>(TrackingParticleInputTag); @@ -357,7 +355,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe eventnum++; trklet::SLHCEvent ev; ev.setEventNum(eventnum); - ev.setIP(bsPosition.x(),bsPosition.y()); + ev.setIP(bsPosition.x(), bsPosition.y()); // tracking particles edm::Handle> TrackingParticleHandle; @@ -370,9 +368,8 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe //////////////////////// // GET THE PRIMITIVES // - edm::Handle< TTDTC > handleDTC; - iEvent.getByToken< TTDTC >( tokenDTC_, handleDTC ); - + edm::Handle handleDTC; + iEvent.getByToken(tokenDTC_, handleDTC); // must be defined for code to compile, even if it's not used unless readMoreMcTruth_ is true map, int> translateTP; @@ -422,106 +419,103 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe } // end if (readMoreMcTruth_) - ///////////////////////////////// /// READ DTC STUB INFORMATION /// ///////////////////////////////// // Process stubs in each region and channel within that region - for ( const int& region : handleDTC->tfpRegions() ) { - for ( const int& channel : handleDTC->tfpChannels() ) { - + for (const int& region : handleDTC->tfpRegions()) { + for (const int& channel : handleDTC->tfpChannels()) { // Get the DTC name form the channel - static string dtcbasenames[12]={"PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", - "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", - "2S_4", "2S_5", "2S_6"}; + static string dtcbasenames[12] = { + "PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", "2S_4", "2S_5", "2S_6"}; - string dtcname=dtcbasenames[channel%12]; + string dtcname = dtcbasenames[channel % 12]; - if (channel%24>=12) dtcname="neg"+dtcname; + if (channel % 24 >= 12) + dtcname = "neg" + dtcname; - dtcname+=(channel<24)?"_A":"_B"; + dtcname += (channel < 24) ? "_A" : "_B"; // Get the stubs from the DTC - const TTDTC::Stream& streamFromDTC{ handleDTC->stream( region, channel ) }; + const TTDTC::Stream& streamFromDTC{handleDTC->stream(region, channel)}; // Prepare the DTC stubs for the IR - for ( size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex ) { + for (size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) { + const TTDTC::Frame& stub{streamFromDTC[stubIndex]}; - const TTDTC::Frame& stub{ streamFromDTC[ stubIndex ] }; + if (stub.first.isNull()) { + continue; + } - if ( stub.first.isNull() ) { - continue; + const GlobalPoint& ttPos = setup_.stubPos(stub.first); + + //Get the 2 bits for the layercode + string layerword = stub.second.to_string().substr(61, 2); + unsigned int layercode = 2 * (layerword[0] - '0') + layerword[1] - '0'; + assert(layercode < 4); + + //translation from the two bit layercode to the layer/disk number of each of the + //12 channels (dtcs) + static int layerdisktab[12][4] = {{0, 6, 8, 10}, + {0, 7, 9, -1}, + {1, 7, -1, -1}, + {6, 8, 10, -1}, + {2, 7, -1, -1}, + {2, 9, -1, -1}, + {3, 4, -1, -1}, + {4, -1, -1, -1}, + {5, -1, -1, -1}, + {5, 8, -1, -1}, + {6, 9, -1, -1}, + {7, 10, -1, -1}}; + + int layerdisk = layerdisktab[channel % 12][layercode]; + assert(layerdisk != -1); + + //Get the 36 bit word - skip the lowest 3 buts (status and layer code) + string stubword = stub.second.to_string().substr(64 - 36 - 3, 36); + string stubwordhex = ""; + + //Loop over the 9 words in the 36 bit stub word + for (unsigned int i = 0; i < 9; i++) { + bitset<4> bits(stubword.substr(i * 4, 4)); + ulong val = bits.to_ulong(); + stubwordhex += ((val < 10) ? ('0' + val) : ('A' + val - 10)); } - const GlobalPoint& ttPos = setup_.stubPos(stub.first); - - //Get the 2 bits for the layercode - string layerword=stub.second.to_string().substr(61,2); - unsigned int layercode=2*(layerword[0]-'0')+layerword[1]-'0'; - assert(layercode<4); - - //translation from the two bit layercode to the layer/disk number of each of the - //12 channels (dtcs) - static int layerdisktab[12][4] = {{0, 6, 8, 10}, - {0, 7, 9, -1}, - {1, 7, -1, -1}, - {6, 8, 10, -1}, - {2, 7, -1, -1}, - {2, 9, -1, -1}, - {3, 4, -1, -1}, - {4, -1, -1, -1}, - {5, -1, -1, -1}, - {5, 8, -1, -1}, - {6, 9, -1, -1}, - {7, 10, -1, -1}}; - - int layerdisk=layerdisktab[channel%12][layercode]; - assert(layerdisk!=-1); - - //Get the 36 bit word - skip the lowest 3 buts (status and layer code) - string stubword=stub.second.to_string().substr(64-36-3,36); - string stubwordhex=""; - - //Loop over the 9 words in the 36 bit stub word - for(unsigned int i=0;i<9;i++){ - bitset<4> bits(stubword.substr(i*4,4)); - ulong val=bits.to_ulong(); - stubwordhex+=((val<10)?('0'+val):('A'+val-10)); - } - - /// Get the Inner and Outer TTCluster - edm::Ref>, TTCluster> innerCluster = - stub.first->clusterRef(0); - edm::Ref>, TTCluster> outerCluster = - stub.first->clusterRef(1); - - // ----------------------------------------------------- - // check module orientation, if flipped, need to store that information for track fit - // ----------------------------------------------------- - - const DetId innerDetId = innerCluster->getDetId(); - const GeomDetUnit* det_inner = theTrackerGeom->idToDetUnit(innerDetId); - const auto* theGeomDet_inner = dynamic_cast(det_inner); - const PixelTopology* topol_inner = dynamic_cast(&(theGeomDet_inner->specificTopology())); - - MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered(); - LocalPoint clustlp_inner = topol_inner->localPosition(coords_inner); - GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner); - - const DetId outerDetId = outerCluster->getDetId(); - const GeomDetUnit* det_outer = theTrackerGeom->idToDetUnit(outerDetId); - const auto* theGeomDet_outer = dynamic_cast(det_outer); - const PixelTopology* topol_outer = dynamic_cast(&(theGeomDet_outer->specificTopology())); - - MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered(); - LocalPoint clustlp_outer = topol_outer->localPosition(coords_outer); - GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer); - - bool isFlipped = (posStub_outer.mag() < posStub_inner.mag()); - - vector assocTPs; + /// Get the Inner and Outer TTCluster + edm::Ref>, TTCluster> + innerCluster = stub.first->clusterRef(0); + edm::Ref>, TTCluster> + outerCluster = stub.first->clusterRef(1); + + // ----------------------------------------------------- + // check module orientation, if flipped, need to store that information for track fit + // ----------------------------------------------------- + + const DetId innerDetId = innerCluster->getDetId(); + const GeomDetUnit* det_inner = theTrackerGeom->idToDetUnit(innerDetId); + const auto* theGeomDet_inner = dynamic_cast(det_inner); + const PixelTopology* topol_inner = dynamic_cast(&(theGeomDet_inner->specificTopology())); + + MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered(); + LocalPoint clustlp_inner = topol_inner->localPosition(coords_inner); + GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner); + + const DetId outerDetId = outerCluster->getDetId(); + const GeomDetUnit* det_outer = theTrackerGeom->idToDetUnit(outerDetId); + const auto* theGeomDet_outer = dynamic_cast(det_outer); + const PixelTopology* topol_outer = dynamic_cast(&(theGeomDet_outer->specificTopology())); + + MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered(); + LocalPoint clustlp_outer = topol_outer->localPosition(coords_outer); + GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer); + + bool isFlipped = (posStub_outer.mag() < posStub_inner.mag()); + + vector assocTPs; for (unsigned int iClus = 0; iClus <= 1; iClus++) { // Loop over both clusters that make up stub. @@ -544,34 +538,30 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe } } - double stubbend=stub.first->bendFE(); //stub.first->rawBend() - if (ttPos.z()<-120) { - stubbend=-stubbend; - } - - ev.addStub(dtcname, - region, - layerdisk, - stubwordhex, - setup_.psModule(setup_.dtcId(region,channel)), - isFlipped, - ttPos.x(), - ttPos.y(), - ttPos.z(), - stubbend, - stub.first->innerClusterPosition(), - assocTPs); - - const trklet::L1TStub& lastStub = ev.lastStub(); - stubMap[lastStub] = stub.first; + double stubbend = stub.first->bendFE(); //stub.first->rawBend() + if (ttPos.z() < -120) { + stubbend = -stubbend; + } + ev.addStub(dtcname, + region, + layerdisk, + stubwordhex, + setup_.psModule(setup_.dtcId(region, channel)), + isFlipped, + ttPos.x(), + ttPos.y(), + ttPos.z(), + stubbend, + stub.first->innerClusterPosition(), + assocTPs); + + const trklet::L1TStub& lastStub = ev.lastStub(); + stubMap[lastStub] = stub.first; } - - } + } } - - ////////////////////////// // NOW RUN THE L1 tracking diff --git a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc index a831c4cba239d..f5724e72fb735 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc @@ -7,14 +7,14 @@ using namespace std; using namespace trklet; AllInnerStubsMemory::AllInnerStubsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} + : MemoryBase(name, settings, iSector) {} void AllInnerStubsMemory::writeStubs(bool first) { const string dirS = settings_.memPath() + "Stubs/"; openFile(first, dirS, "AllInnerStubs_"); for (unsigned int j = 0; j < stubs_.size(); j++) { - string stub = stubs_[j]->strinner(); + string stub = stubs_[j]->strinner(); out_ << "0x"; out_ << std::setfill('0') << std::setw(2); out_ << hex << j << dec; diff --git a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc index aad0969f9dac6..ff558f542fd00 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc @@ -23,7 +23,7 @@ void AllProjectionsMemory::writeAP(bool first) { 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++) { diff --git a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc index 3dac87a57a072..315b7f668fbc9 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc @@ -7,7 +7,7 @@ using namespace std; using namespace trklet; AllStubsMemory::AllStubsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} + : MemoryBase(name, settings, iSector) {} void AllStubsMemory::writeStubs(bool first) { const string dirS = settings_.memPath() + "Stubs/"; diff --git a/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc b/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc index 8d2e2964d2fcc..3fe5e7af15861 100644 --- a/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc +++ b/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc @@ -34,7 +34,7 @@ void DiskProjection::init(Settings const& settings, projdisk_ = projdisk; unsigned int layerdisk = projdisk + N_LAYER - 1; - + assert(iphiproj >= 0); fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); @@ -82,10 +82,13 @@ void DiskProjection::init(Settings const& settings, fpgafinervm_.set(finer, 4, true, __LINE__, __FILE__); // fine r postions starting at rbin1 //fine phi bits - int projfinephi = (fpgaphiproj_.value() >> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(N_LAYER+projdisk_-1) + settings.nbitsvmme(N_LAYER+projdisk_-1) + NFINEPHIBITS ))) & ((1<> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(N_LAYER + projdisk_ - 1) + + settings.nbitsvmme(N_LAYER + projdisk_ - 1) + NFINEPHIBITS))) & + ((1 << NFINEPHIBITS) - 1); fpgafinephivm_.set(projfinephi, NFINEPHIBITS, true, __LINE__, __FILE__); // fine phi postions - + phiproj_ = phiproj; rproj_ = rproj; phiprojder_ = phiprojder; diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index fb3405e66353d..7d0fa0468e355 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -201,7 +201,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: continue; } if (tracklet->match(l)) { - const LayerResidual& layerResid = tracklet->layerResid(l); + const LayerResidual& layerResid = tracklet->layerResid(l); lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); phiresid[nlayers] = layerResid.phiresidapprox(); @@ -225,7 +225,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - const DiskResidual& diskResid = tracklet->diskResid(d); + const DiskResidual& diskResid = tracklet->diskResid(d); if (std::abs(diskResid.alpha()) < 1e-20) { dmatches.set(2 * d - 1); diskmask |= (1 << (2 * (N_DISK - d) + 1)); @@ -267,7 +267,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const LayerResidual& layerResid = tracklet->layerResid(l); + const LayerResidual& layerResid = tracklet->layerResid(l); phiresid[nlayers] = layerResid.phiresidapprox(); zresid[nlayers] = layerResid.zresidapprox(); phiresidexact[nlayers] = layerResid.phiresid(); @@ -299,7 +299,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - const DiskResidual& diskResid = tracklet->diskResid(d); + const DiskResidual& diskResid = tracklet->diskResid(d); if (std::abs(diskResid.alpha()) < 1e-20) { dmatches.set(2 * d1 - 1); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); @@ -342,7 +342,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (tracklet->match(l)) { lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const LayerResidual& layerResid = tracklet->layerResid(l); + const LayerResidual& layerResid = tracklet->layerResid(l); assert(std::abs(layerResid.phiresidapprox()) < 0.2); phiresid[nlayers] = layerResid.phiresidapprox(); zresid[nlayers] = layerResid.zresidapprox(); @@ -373,7 +373,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - const DiskResidual& diskResid = tracklet->diskResid(d); + const DiskResidual& diskResid = tracklet->diskResid(d); if (std::abs(diskResid.alpha()) < 1e-20) { dmatches.set(2 * (N_DISK - d1)); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); diff --git a/L1Trigger/TrackFindingTracklet/src/HybridFit.cc b/L1Trigger/TrackFindingTracklet/src/HybridFit.cc index 656e6e537e291..23aaa0fa246e9 100644 --- a/L1Trigger/TrackFindingTracklet/src/HybridFit.cc +++ b/L1Trigger/TrackFindingTracklet/src/HybridFit.cc @@ -75,7 +75,7 @@ void HybridFit::Fit(Tracklet* tracklet, std::vector& trackstublist) double alpha = L1stubptr->alpha(settings_.stripPitch(psmodule)); bool isTilted = L1stubptr->isTilted(); - bool isBarrel = trackstublist[k]->layerdisk()layerdisk() < N_LAYER; int kflayer; if (isBarrel) { // Barrel-specific diff --git a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc index 99b7868bc74c1..6d08588d0068f 100644 --- a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc @@ -24,18 +24,16 @@ InputLinkMemory::InputLinkMemory(string name, Settings const& settings, unsigned } void InputLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { - - //Various consistency checks unsigned int stublayerdisk = stub.layerdisk(); assert(stublayerdisk == layerdisk_); - + FPGAWord iphi = stub.phicorr(); unsigned int nallbits = settings_.nbitsallstubs(layerdisk_); int phibin = iphi.bits(iphi.nbits() - nallbits, nallbits); int iphivmRaw = iphi.bits(iphi.nbits() - 5, 5); - assert ( phibin==phiregion_); + assert(phibin == phiregion_); if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Will add stub in " << getName() << " " @@ -50,7 +48,6 @@ void InputLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { stubs_.emplace_back(stubptr); } - } void InputLinkMemory::writeStubs(bool first) { diff --git a/L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc b/L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc index a44c84135da00..e0744ff66763c 100644 --- a/L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/L1SimTrack.cc @@ -35,4 +35,3 @@ void L1SimTrack::write(ostream& out) { << "\t" << vx_ << "\t" << vy_ << "\t" << vz_ << "\t" << endl; } } - diff --git a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc index 798945775f13b..f46b219d4364b 100644 --- a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc +++ b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc @@ -7,31 +7,32 @@ using namespace trklet; L1TStub::L1TStub() {} L1TStub::L1TStub(std::string DTClink, - int region, - int layerdisk, - std::string stubword, - int isPSmodule, - int isFlipped, - double x, - double y, - double z, - double bend, - double strip, - std::vector tps){ - DTClink_=DTClink; - layerdisk_=layerdisk; - region_=region; + int region, + int layerdisk, + std::string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + std::vector tps) { + DTClink_ = DTClink; + layerdisk_ = layerdisk; + region_ = region; stubword_ = stubword; eventid_ = -1; tps_ = tps; iphi_ = -1; iz_ = -1; layer_ = layerdisk; - if (layerdisk>5) { - layer_=1000+layerdisk-5; - if (z<0.0) layer_+=1000; + if (layerdisk > 5) { + layer_ = 1000 + layerdisk - 5; + if (z < 0.0) + layer_ += 1000; } - + ladder_ = -1; module_ = -1; strip_ = strip; @@ -46,13 +47,12 @@ L1TStub::L1TStub(std::string DTClink, isFlipped_ = isFlipped; allstubindex_ = 999; - } - void L1TStub::write(ofstream& out) { - out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_ << "\t" << isFlipped_ << "\t" - << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t" << "\t" << tps_.size() << " \t"; + out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_ + << "\t" << isFlipped_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t" + << "\t" << tps_.size() << " \t"; for (int itp : tps_) { out << itp << " \t"; } @@ -110,18 +110,18 @@ bool L1TStub::tpmatch(int tp) const { } bool L1TStub::tpmatch2(int tp) const { - bool match1=false; - bool match2=false; + bool match1 = false; + bool match2 = false; for (int itp : tps_) { if (tp == itp) { - match1=true; + match1 = true; } if (tp == -itp) { - match2=true; + match2 = true; } } - return match1&&match2; + return match1 && match2; } bool L1TStub::isTilted() const { diff --git a/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc b/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc index 67a50bb9af916..5ffb4060ce2eb 100644 --- a/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc +++ b/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc @@ -26,14 +26,13 @@ void LayerProjection::init(Settings const& settings, assert(projlayer <= N_LAYER); valid_ = true; - + projlayer_ = projlayer; - unsigned int layerdisk = projlayer-1; - + unsigned int layerdisk = projlayer - 1; + fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); fpgazproj_.set(izproj, settings.nzbitsstub(layerdisk), false, __LINE__, __FILE__); - if (layerdisk < N_PSLAYER) { fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); fpgazprojder_.set(izder, settings.nbitszprojderL123(), false, __LINE__, __FILE__); @@ -46,11 +45,11 @@ void LayerProjection::init(Settings const& settings, ////This determines the central bin: ////int zbin=4+(zproj.value()>>(zproj.nbits()-3)); ////But we need some range (particularly for L5L6 seed projecting to L1-L3): - int offset = isPSseed?1:4; + int offset = isPSseed ? 1 : 4; int ztemp = fpgazproj_.value() >> (fpgazproj_.nbits() - settings.MEBinsBits() - NFINERZBITS); - unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp - offset) >> NFINERZBITS); - unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp + offset) >> NFINERZBITS); + unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp - offset) >> NFINERZBITS); + unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp + offset) >> NFINERZBITS); if (zbin1 >= settings.MEBins()) { zbin1 = 0; //note that zbin1 is unsigned @@ -58,25 +57,27 @@ void LayerProjection::init(Settings const& settings, if (zbin2 >= settings.MEBins()) { zbin2 = settings.MEBins() - 1; } - + assert(zbin1 <= zbin2); assert(zbin2 - zbin1 <= 1); - + fpgazbin1projvm_.set(zbin1, settings.MEBinsBits(), true, __LINE__, __FILE__); // first z bin - int nextbin = zbin1 != zbin2; + int nextbin = zbin1 != zbin2; fpgazbin2projvm_.set(nextbin, 1, true, __LINE__, __FILE__); // need to check adjacent z bin? //fine vm z bits. Use 4 bits for fine position. starting at zbin 1 int finez = ((1 << (settings.MEBinsBits() + NFINERZBITS - 1)) + ztemp) - (zbin1 << NFINERZBITS); - - fpgafinezvm_.set(finez, NFINERZBITS+1, true, __LINE__, __FILE__); // fine z postions starting at zbin1 + + fpgafinezvm_.set(finez, NFINERZBITS + 1, true, __LINE__, __FILE__); // fine z postions starting at zbin1 //fine phi bits - int projfinephi = (fpgaphiproj_.value() >> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(projlayer_) + settings.nbitsvmme(projlayer_) + NFINEPHIBITS ))) & ((1<> + (fpgaphiproj_.nbits() - (settings.nbitsallstubs(projlayer_) + settings.nbitsvmme(projlayer_) + NFINEPHIBITS))) & + ((1 << NFINEPHIBITS) - 1); fpgafinephivm_.set(projfinephi, NFINEPHIBITS, true, __LINE__, __FILE__); // fine phi postions - - + phiproj_ = phiproj; zproj_ = zproj; phiprojder_ = phiprojder; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 0cf7ba106ffd5..b30894aad7a88 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -59,8 +59,7 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* } if (iSector_ == 0 && layerdisk_ < N_LAYER && settings_.writeTable()) { - - ofstream outphicut=openfile(settings_.tablePath(), getName() + "_phicut.tab", __FILE__, __LINE__); + ofstream outphicut = openfile(settings_.tablePath(), getName() + "_phicut.tab", __FILE__, __LINE__); outphicut << "{" << endl; for (unsigned int seedindex = 0; seedindex < N_SEED; seedindex++) { @@ -87,8 +86,7 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* } if (iSector_ == 0 && layerdisk_ >= N_LAYER && settings_.writeTable()) { - - ofstream outPSphicut=openfile(settings_.tablePath(), getName() + "_PSphicut.tab", __FILE__, __LINE__); + ofstream outPSphicut = openfile(settings_.tablePath(), getName() + "_PSphicut.tab", __FILE__, __LINE__); outPSphicut << "{" << endl; for (unsigned int seedindex = 0; seedindex < N_SEED; seedindex++) { @@ -99,7 +97,7 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* outPSphicut << endl << "};" << endl; outPSphicut.close(); - ofstream out2Sphicut=openfile(settings_.tablePath(), getName() + "_2Sphicut.tab", __FILE__, __LINE__); + ofstream out2Sphicut = openfile(settings_.tablePath(), getName() + "_2Sphicut.tab", __FILE__, __LINE__); out2Sphicut << "{" << endl; for (unsigned int seedindex = 0; seedindex < N_SEED; seedindex++) { @@ -217,8 +215,8 @@ void MatchCalculator::execute() { if (layerdisk_ < N_LAYER) { //Integer calculation - const LayerProjection& layerProj = tracklet->layerProj(layerdisk_+1); - + const LayerProjection& layerProj = tracklet->layerProj(layerdisk_ + 1); + int ir = fpgastub->r().value(); int iphi = layerProj.fpgaphiproj().value(); int icorr = (ir * layerProj.fpgaphiprojder().value()) >> icorrshift_; @@ -251,13 +249,11 @@ void MatchCalculator::execute() { double dr = r - settings_.rmean(layerdisk_); assert(std::abs(dr) < settings_.drmax()); - double dphi = - reco::reduceRange(phi - (layerProj.phiproj() + dr * layerProj.phiprojder())); + double dphi = reco::reduceRange(phi - (layerProj.phiproj() + dr * layerProj.phiprojder())); double dz = z - (layerProj.zproj() + dr * layerProj.zprojder()); - double dphiapprox = reco::reduceRange( - phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); double dzapprox = z - (layerProj.zprojapprox() + dr * layerProj.zprojderapprox()); @@ -279,11 +275,10 @@ void MatchCalculator::execute() { 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 (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")) { @@ -298,7 +293,7 @@ void MatchCalculator::execute() { } bool imatch = false; - if(std::abs(dphi) < 0.2 && std::abs(dphiapprox) < 0.2){ //Changed the Asserts into if statements + if (std::abs(dphi) < 0.2 && std::abs(dphiapprox) < 0.2) { //Changed the Asserts into if statements if (settings_.writeMonitorData("Residuals")) { double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); @@ -310,8 +305,8 @@ void MatchCalculator::execute() { << ideltaz * fact_ * settings_.kz() << " " << dz << " " << zmatchcut_[seedindex] * settings_.kz() << endl; } - imatch = (std::abs(ideltaphi) <= (int)phimatchcut_[seedindex]) && - (std::abs(ideltaz * fact_) <= (int)zmatchcut_[seedindex]); + imatch = (std::abs(ideltaphi) <= (int)phimatchcut_[seedindex]) && + (std::abs(ideltaz * fact_) <= (int)zmatchcut_[seedindex]); } if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " ideltaphi cut " << ideltaphi << " " @@ -352,7 +347,7 @@ void MatchCalculator::execute() { //Perform integer calculations here const DiskProjection& diskProj = tracklet->diskProj(disk); - + int iz = fpgastub->z().value(); int iphi = diskProj.fpgaphiproj().value(); @@ -429,8 +424,7 @@ void MatchCalculator::execute() { double dphi = reco::reduceRange(phi - phiproj); - double dphiapprox = - reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); double drapprox = stub->r() - (diskProj.rprojapprox() + dz * diskProj.rprojderapprox()); @@ -459,7 +453,7 @@ void MatchCalculator::execute() { double drcut = idrcut * settings_.krprojshiftdisk(); bool match, imatch; - if(std::abs(dphi) < 0.25 && std::abs(dphiapprox) < 0.25){ //Changed the Asserts into if statements + if (std::abs(dphi) < 0.25 && std::abs(dphiapprox) < 0.25) { //Changed the Asserts into if statements if (settings_.writeMonitorData("Residuals")) { double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); @@ -472,10 +466,9 @@ void MatchCalculator::execute() { match = (std::abs(drphi) < drphicut) && (std::abs(deltar) < drcut); imatch = (std::abs(ideltaphi * irstub) < idrphicut) && (std::abs(ideltar) < idrcut); - } - else{ + } else { edm::LogProblem("Tracklet") << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox - << "dphi " << dphi << " Seed / ISeed " << tracklet->getISeed()<< endl; + << "dphi " << dphi << " Seed / ISeed " << tracklet->getISeed() << endl; match = false; imatch = false; } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index 1a50d89369906..bd7f3c933d640 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -17,27 +17,25 @@ using namespace trklet; MatchEngine::MatchEngine(string name, Settings const& settings, Globals* global, unsigned int iSector) : ProcessBase(name, settings, global, iSector) { - layerdisk_ = initLayerDisk(3); - + barrel_ = layerdisk_ < N_LAYER; - nvm_=settings_.nvmme(layerdisk_)*settings_.nallstubs(layerdisk_); + nvm_ = settings_.nvmme(layerdisk_) * settings_.nallstubs(layerdisk_); + + nvmbits_ = settings_.nbitsvmme(layerdisk_) + settings_.nbitsallstubs(layerdisk_); - nvmbits_=settings_.nbitsvmme(layerdisk_)+settings_.nbitsallstubs(layerdisk_); + nrinv_ = NRINVBITS; + double rinvhalf = 0.5 * ((1 << nrinv_) - 1); - nrinv_=NRINVBITS; - double rinvhalf=0.5*((1<= N_LAYER) { - for (unsigned int iprojbend = 0; iprojbend < (1u<layerProj(layerdisk_+1).fpgazbin1projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin1projvm().value(); + unsigned int rzfirst = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin1projvm().value() + : proj->diskProj(layerdisk_ - 5).fpgarbin1projvm().value(); unsigned int rzlast = rzfirst; - bool second = barrel_ ? proj->layerProj(layerdisk_+1).fpgazbin2projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin2projvm().value(); + bool second = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin2projvm().value() + : proj->diskProj(layerdisk_ - 5).fpgarbin2projvm().value(); if (second) rzlast += 1; if (print) { - cout << "istep rzfirst rzlast : "<getTracklet(projindex); - FPGAWord fpgafinephi = barrel_ ? proj->layerProj(layerdisk_+1).fpgafinephivm() : proj->diskProj(layerdisk_-5).fpgafinephivm(); + FPGAWord fpgafinephi = + barrel_ ? proj->layerProj(layerdisk_ + 1).fpgafinephivm() : proj->diskProj(layerdisk_ - 5).fpgafinephivm(); projfinephi = fpgafinephi.value(); nstubs = vmstubs_->nStubsBin(rzbin); - projfinerz = barrel_ ? proj->layerProj(layerdisk_+1).fpgafinezvm().value() : proj->diskProj(layerdisk_-5).fpgafinervm().value(); + projfinerz = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgafinezvm().value() + : proj->diskProj(layerdisk_ - 5).fpgafinervm().value(); projrinv = barrel_ - ? ((1<<(nrinv_-1)) + ((-2*proj->layerProj(layerdisk_+1).fpgaphiprojder().value()) >> (proj->layerProj(layerdisk_+1).fpgaphiprojder().nbits() - (nrinv_-1)))) - : proj->diskProj(layerdisk_-5).getBendIndex().value(); + ? ((1 << (nrinv_ - 1)) + ((-2 * proj->layerProj(layerdisk_ + 1).fpgaphiprojder().value()) >> + (proj->layerProj(layerdisk_ + 1).fpgaphiprojder().nbits() - (nrinv_ - 1)))) + : proj->diskProj(layerdisk_ - 5).getBendIndex().value(); assert(projrinv >= 0); - if (settings_.extended() && projrinv == (1<PSseed(); //Calculate fine z position if (second) { - projfinerzadj = projfinerz - (1< maxdeltaphicut); unsigned int index = (projrinv << nbits) + vmstub.bend().value(); @@ -303,36 +305,35 @@ void MatchEngine::execute() { //if (layerdisk_>5) { // cout << "layerdisk: "< table) - : candmatches_(5) { +MatchEngineUnit::MatchEngineUnit(bool barrel, unsigned int layerdisk, vector table) : candmatches_(5) { idle_ = true; barrel_ = barrel; table_ = table; slot_ = 1; //This makes it idle until initialized - layerdisk_=layerdisk; + layerdisk_ = layerdisk; } void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, @@ -17,7 +16,7 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, int projrinv, int projfinerz, int projfinephi, - int shift, + int shift, bool usesecond, bool isPSseed, Tracklet* proj) { @@ -44,15 +43,15 @@ void MatchEngineUnit::step() { int stubfinerz = vmstub.finerz().value(); int stubfinephi = vmstub.finephi().value(); - int deltaphi = stubfinephi - projfinephi_ + (1< tmp(proj_, vmstub.stub()); candmatches_.store(tmp); } @@ -84,7 +83,7 @@ void MatchEngineUnit::step() { usesecond_ = false; istub_ = 0; slot_++; - projfinerz_ -= (1<projectionRouterBendTable() == nullptr) { + if (globals_->projectionRouterBendTable() == nullptr) { auto* bendTablePtr = new ProjectionRouterBendTable(); bendTablePtr->init(settings_, globals_, nrbits_, nphiderbits_); globals_->projectionRouterBendTable() = bendTablePtr; } - } void MatchProcessor::addOutput(MemoryBase* memory, string output) { @@ -236,7 +231,7 @@ void MatchProcessor::execute() { matchengines_[iME].reset(); } - for (unsigned int istep = 0; istep < settings_.maxStep("MP") ; istep++) { + for (unsigned int istep = 0; istep < settings_.maxStep("MP"); istep++) { bool projdone = false; bool medone = true; //Step 1 @@ -255,62 +250,67 @@ void MatchProcessor::execute() { } Tracklet* proj = projMem->getTracklet(iproj); - FPGAWord fpgaphi = barrel_ ? proj->layerProj(layerdisk_+1).fpgaphiproj() : proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiproj(); + FPGAWord fpgaphi = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgaphiproj() + : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgaphiproj(); unsigned int iphi = (fpgaphi.value() >> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); - int nextrabits = 2; - int overlapbits = nvmbits_+nextrabits; - - unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits, nextrabits); - - unsigned int ivmPlus = iphi; - - int plusShift=0; - int negShift=0; - - - if (extrabits == ((1U << nextrabits) - 1) && iphi != ((1U << settings_.nbitsvmme(layerdisk_)) - 1)) { - plusShift = 1; - ivmPlus++; - } - unsigned int ivmMinus = iphi; - if (extrabits == 0 && iphi != 0){ - negShift = -1; - ivmMinus--; - } + int nextrabits = 2; + int overlapbits = nvmbits_ + nextrabits; + + unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits, nextrabits); + + unsigned int ivmPlus = iphi; + + int plusShift = 0; + int negShift = 0; + + if (extrabits == ((1U << nextrabits) - 1) && iphi != ((1U << settings_.nbitsvmme(layerdisk_)) - 1)) { + plusShift = 1; + ivmPlus++; + } + unsigned int ivmMinus = iphi; + if (extrabits == 0 && iphi != 0) { + negShift = -1; + ivmMinus--; + } int projrinv = -1; if (barrel_) { - projrinv = (1<<(nrinv_-1)) + (proj->fpgarinv().value() >> (proj->fpgarinv().nbits() - nrinv_)); + projrinv = (1 << (nrinv_ - 1)) + (proj->fpgarinv().value() >> (proj->fpgarinv().nbits() - nrinv_)); } else { //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->diskProj(layerdisk_-N_LAYER+1).fpgarproj().value() >> (proj->diskProj(layerdisk_-N_LAYER+1).fpgarproj().nbits() - nrbits_)) & + int rindex = (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarproj().value() >> + (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiprojder().value() >> - (proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiprojder().nbits() - nphiderbits_)) & + int phiderindex = (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgaphiprojder().value() >> + (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); - - int signindex = proj->diskProj(layerdisk_-N_LAYER+1).fpgarprojder().value() < 0; + + int signindex = proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarprojder().value() < 0; int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex; - projrinv = globals_->projectionRouterBendTable()->bendLoookup(layerdisk_-N_LAYER, bendindex); + projrinv = globals_->projectionRouterBendTable()->bendLoookup(layerdisk_ - N_LAYER, bendindex); - proj->diskProj(layerdisk_-N_LAYER+1).setBendIndex(projrinv); + proj->diskProj(layerdisk_ - N_LAYER + 1).setBendIndex(projrinv); } assert(projrinv >= 0); - unsigned int slot = barrel_ ? proj->layerProj(layerdisk_+1).fpgazbin1projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin1projvm().value(); - bool second = (barrel_ ? proj->layerProj(layerdisk_+1).fpgazbin2projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin2projvm().value()); + unsigned int slot = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin1projvm().value() + : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarbin1projvm().value(); + bool second = (barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin2projvm().value() + : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarbin2projvm().value()); - int nfinephi=3; - unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + nfinephi))) & ((1<layerProj(layerdisk_+1).fpgafinezvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgafinervm().value(); + int nfinephi = 3; + unsigned int projfinephi = + (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + nfinephi))) & ((1 << nfinephi) - 1); + int projfinerz = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgafinezvm().value() + : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgafinervm().value(); bool isPSseed = proj->PSseed(); @@ -325,21 +325,25 @@ void MatchProcessor::execute() { bool usesecondMinus = (second && (stubmem->nStubsBin(ivmMinus * nbins + slot + 1) != 0)); if (usefirstPlus) { - ProjectionTemp tmpProj(proj, slot, projrinv, projfinerz, projfinephi, ivmPlus, plusShift, usesecondPlus, isPSseed); + ProjectionTemp tmpProj( + proj, slot, projrinv, projfinerz, projfinephi, ivmPlus, plusShift, usesecondPlus, isPSseed); inputProjBuffer_.store(tmpProj); } else if (usesecondPlus) { - ProjectionTemp tmpProj(proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmPlus, plusShift, false, isPSseed); + ProjectionTemp tmpProj( + proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmPlus, plusShift, false, isPSseed); inputProjBuffer_.store(tmpProj); } - if (ivmPlus!=ivmMinus) { - if (usefirstMinus) { - ProjectionTemp tmpProj(proj, slot, projrinv, projfinerz, projfinephi, ivmMinus, negShift, usesecondMinus, isPSseed); - inputProjBuffer_.store(tmpProj); - } else if (usesecondMinus) { - ProjectionTemp tmpProj(proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmMinus, negShift, false, isPSseed); - inputProjBuffer_.store(tmpProj); - } - } + if (ivmPlus != ivmMinus) { + if (usefirstMinus) { + ProjectionTemp tmpProj( + proj, slot, projrinv, projfinerz, projfinephi, ivmMinus, negShift, usesecondMinus, isPSseed); + inputProjBuffer_.store(tmpProj); + } else if (usesecondMinus) { + ProjectionTemp tmpProj( + proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmMinus, negShift, false, isPSseed); + inputProjBuffer_.store(tmpProj); + } + } iproj++; if (iproj == projMem->nTracklets()) { iproj = 0; @@ -358,37 +362,37 @@ void MatchProcessor::execute() { bool addedProjection = false; for (unsigned int iME = 0; iME < nMatchEngines_; iME++) { if (!matchengines_[iME].idle()) - countme++; + countme++; matchengines_[iME].step(); //if match engine empty and we have queued projections add to match engine if ((!addedProjection) && matchengines_[iME].idle() && (!inputProjBuffer_.empty())) { - ProjectionTemp tmpProj = inputProjBuffer_.read(); - VMStubsMEMemory* stubmem = vmstubs_[0]; - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " adding projection to match engine"; - } - - int nbins = 8; - if (layerdisk_ >= 6) - nbins = 16; - - matchengines_[iME].init(stubmem, - tmpProj.iphi() * nbins + tmpProj.slot(), - tmpProj.projrinv(), - tmpProj.projfinerz(), - tmpProj.projfinephi(), - tmpProj.shift(), - tmpProj.usesecond(), - tmpProj.isPSseed(), - tmpProj.proj()); - addedProjection = true; + ProjectionTemp tmpProj = inputProjBuffer_.read(); + VMStubsMEMemory* stubmem = vmstubs_[0]; + + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " adding projection to match engine"; + } + + int nbins = 8; + if (layerdisk_ >= 6) + nbins = 16; + + matchengines_[iME].init(stubmem, + tmpProj.iphi() * nbins + tmpProj.slot(), + tmpProj.projrinv(), + tmpProj.projfinerz(), + tmpProj.projfinephi(), + tmpProj.shift(), + tmpProj.usesecond(), + tmpProj.isPSseed(), + tmpProj.proj()); + addedProjection = true; } } //Step 3 //Check if we have candidate match to process - + unsigned int iMEbest = nMatchEngines_; int bestTCID = -1; bool bestInPipeline = false; @@ -396,25 +400,25 @@ void MatchProcessor::execute() { bool empty = matchengines_[iME].empty(); medone = medone && (empty && matchengines_[iME].idle()); if (empty && matchengines_[iME].idle()) - continue; + continue; int currentTCID = empty ? matchengines_[iME].currentProj()->TCID() : matchengines_[iME].peek().first->TCID(); if ((iMEbest == nMatchEngines_) || (currentTCID < bestTCID)) { - iMEbest = iME; - bestTCID = currentTCID; - bestInPipeline = empty; + iMEbest = iME; + bestTCID = currentTCID; + bestInPipeline = empty; } <<<<<<< HEAD } - + if (iMEbest != nMatchEngines_ && (!bestInPipeline)) { std::pair candmatch = matchengines_[iMEbest].read(); - + const Stub* fpgastub = candmatch.second; Tracklet* tracklet = candmatch.first; - + if (oldTracklet != nullptr) { - //allow equal here since we can have more than one cadidate match per tracklet projection - assert(oldTracklet->TCID() <= tracklet->TCID()); + //allow equal here since we can have more than one cadidate match per tracklet projection + assert(oldTracklet->TCID() <= tracklet->TCID()); ======= if (iMEbest != nMatchEngines_ && (!bestInPipeline)) { @@ -441,27 +445,27 @@ void MatchProcessor::execute() { >>>>>>> ca9f4d8d9ec... Various fixes to comment on pull request (#68) } oldTracklet = tracklet; - + bool match = matchCalculator(tracklet, fpgastub); - + if (settings_.debugTracklet() && match) { - edm::LogVerbatim("Tracklet") << getName() << " have match"; + edm::LogVerbatim("Tracklet") << getName() << " have match"; } - + countall++; if (match) - countsel++; + countsel++; } - + if ((projdone && medone) || (istep == settings_.maxStep("MP") - 1)) { if (settings_.writeMonitorData("MP")) { - globals_->ofstream("matchprocessor.txt") << getName() << " " << istep << " " << countall << " " << countsel << " " - << countme << " " << countinputproj << endl; + globals_->ofstream("matchprocessor.txt") << getName() << " " << istep << " " << countall << " " << countsel + << " " << countme << " " << countinputproj << endl; } break; } } - + if (settings_.writeMonitorData("MC")) { globals_->ofstream("matchcalculator.txt") << getName() << " " << countall << " " << countsel << endl; } @@ -471,7 +475,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { const L1TStub* stub = fpgastub->l1tstub(); if (layerdisk_ < N_LAYER) { - const LayerProjection& layerProj = tracklet->layerProj(layerdisk_+1); + const LayerProjection& layerProj = tracklet->layerProj(layerdisk_ + 1); int ir = fpgastub->r().value(); int iphi = layerProj.fpgaphiproj().value(); int icorr = (ir * layerProj.fpgaphiprojder().value()) >> icorrshift_; @@ -483,7 +487,6 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { int ideltaz = fpgastub->z().value() - iz; int ideltaphi = (fpgastub->phi().value() - iphi) << phishift_; - //Floating point calculations @@ -510,8 +513,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double dz = z - (layerProj.zproj() + dr * layerProj.zprojder()); - double dphiapprox = - reco::reduceRange(phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); double dzapprox = z - (layerProj.zprojapprox() + dr * layerProj.zprojderapprox()); @@ -524,11 +526,11 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { bool truthmatch = tracklet->stubtruthmatch(stub); HistBase* hists = globals_->histograms(); - hists->FillLayerResidual(layerdisk_+1, + hists->FillLayerResidual(layerdisk_ + 1, seedindex, dphiapprox * settings_.rmean(layerdisk_), ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_), - (ideltaz << dzshift_ ) * settings_.kz(), + (ideltaz << dzshift_) * settings_.kz(), dz, truthmatch); } @@ -537,30 +539,31 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); globals_->ofstream("layerresiduals.txt") - << layerdisk_+1 << " " << seedindex << " " << pt << " " + << layerdisk_ + 1 << " " << seedindex << " " << pt << " " << ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_) << " " << dphiapprox * settings_.rmean(layerdisk_) << " " << phimatchcut_[seedindex] * settings_.kphi1() * settings_.rmean(layerdisk_) << " " - << (ideltaz << dzshift_) * settings_.kz() << " " << dz << " " << zmatchcut_[seedindex] * settings_.kz() << endl; + << (ideltaz << dzshift_) * settings_.kz() << " " << dz << " " << zmatchcut_[seedindex] * settings_.kz() + << endl; } bool imatch = ((unsigned int)std::abs(ideltaphi) <= phimatchcut_[seedindex]) && - ((unsigned int)std::abs(ideltaz << dzshift_) <= zmatchcut_[seedindex]); + ((unsigned int)std::abs(ideltaz << dzshift_) <= zmatchcut_[seedindex]); if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " ideltaphi cut " << ideltaphi << " " - << phimatchcut_[seedindex] << " ideltaz< 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 (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 (imatch) { - tracklet->addMatch(layerdisk_+1, + tracklet->addMatch(layerdisk_ + 1, ideltaphi, ideltaz, dphi, @@ -590,7 +593,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { assert(stub->z() * tracklet->t() > 0.0); int sign = (tracklet->t() > 0.0) ? 1 : -1; - int disk = sign * (layerdisk_-N_LAYER+1); + int disk = sign * (layerdisk_ - N_LAYER + 1); assert(disk != 0); //Perform integer calculations here @@ -598,7 +601,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { int iz = fpgastub->z().value(); const DiskProjection& diskProj = tracklet->diskProj(disk); - + int iphi = diskProj.fpgaphiproj().value(); int iphicorr = (iz * diskProj.fpgaphiprojder().value()) >> icorrshift_; iphi += iphicorr; @@ -613,7 +616,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { int ialphafact = 0; if (!stub->isPSmodule()) { assert(irstub < (int)N_DSS_MOD * 2); - if (layerdisk_-N_LAYER <= 1) { + if (layerdisk_ - N_LAYER <= 1) { ialphafact = ialphafactinner_[irstub]; irstub = settings_.rDSSinner(irstub) / settings_.kr(); } else { @@ -665,8 +668,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double drapprox = stub->r() - (diskProj.rprojapprox() + dz * diskProj.rprojderapprox()); double dphi = reco::reduceRange(phi - phiproj); - double dphiapprox = - reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); double drphi = dphi * stub->r(); double drphiapprox = dphiapprox * stub->r(); @@ -697,9 +699,10 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv()); globals_->ofstream("diskresiduals.txt") - << layerdisk_-N_LAYER+1 << " " << stub->isPSmodule() << " " << tracklet->layer() << " " << abs(tracklet->disk()) << " " << pt - << " " << ideltaphi * settings_.kphi() * stub->r() << " " << drphiapprox << " " << drphicut << " " - << ideltar * settings_.krprojshiftdisk() << " " << deltar << " " << drcut << " " << endl; + << layerdisk_ - N_LAYER + 1 << " " << stub->isPSmodule() << " " << tracklet->layer() << " " + << abs(tracklet->disk()) << " " << pt << " " << ideltaphi * settings_.kphi() * stub->r() << " " << drphiapprox + << " " << drphicut << " " << ideltar * settings_.krprojshiftdisk() << " " << deltar << " " << drcut << " " + << endl; } bool match = (std::abs(drphi) < drphicut) && (std::abs(deltar) < drcut); diff --git a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc index 38cb88e9cfc55..8b00125715769 100644 --- a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc @@ -72,8 +72,6 @@ void MemoryBase::findAndReplaceAll(std::string& data, std::string toSearch, std: } void MemoryBase::openFile(bool first, std::string dirName, std::string filebase) { - - std::string fname = filebase + getName(); findAndReplaceAll(fname, "PHIa", "PHIaa"); @@ -92,8 +90,8 @@ void MemoryBase::openFile(bool first, std::string dirName, std::string filebase) fname += std::to_string(iSector_ + 1); fname += ".dat"; - openfile(out_, first, dirName, dirName+fname, __FILE__, __LINE__); - + openfile(out_, first, dirName, dirName + fname, __FILE__, __LINE__); + out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; bx_++; diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc index b2b36ed012754..e1935c351adf0 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc @@ -92,18 +92,16 @@ void ProjectionRouter::execute() { fpgaphi = tracklet->layerProj(layerdisk_ + 1).fpgaphiproj(); } else { int disk = layerdisk_ - (N_LAYER - 1); - DiskProjection& diskProj = tracklet->diskProj(disk); + DiskProjection& diskProj = tracklet->diskProj(disk); fpgaphi = diskProj.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 = (diskProj.fpgarproj().value() >> (diskProj.fpgarproj().nbits() - nrbits_)) & - ((1 << nrbits_) - 1); + int rindex = (diskProj.fpgarproj().value() >> (diskProj.fpgarproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (diskProj.fpgaphiprojder().value() >> - (diskProj.fpgaphiprojder().nbits() - nphiderbits_)) & + int phiderindex = (diskProj.fpgaphiprojder().value() >> (diskProj.fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); int signindex = (diskProj.fpgarprojder().value() < 0); diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc index 922b2535528a6..78de56f0076db 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouterBendTable.cc @@ -25,7 +25,7 @@ void ProjectionRouterBendTable::init(Settings const& settings, if (iphider > (1 << (nphiderbits - 1))) iphider -= (1 << nphiderbits); iphider = iphider << (settings.nbitsphiprojderL123() - nphiderbits); - + double rproj = ir * settings.krprojshiftdisk(); double phider = iphider * globals->ITC_L1L2()->der_phiD_final.K(); double t = settings.zmean(idisk) / rproj; diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc index 637985d12a796..999f4888ef88d 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc @@ -9,7 +9,7 @@ ProjectionTemp::ProjectionTemp(Tracklet* proj, int projfinerz, unsigned int projfinephi, unsigned int iphi, - int shift, + int shift, bool usesecond, bool isPSseed) { proj_ = proj; diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index b442182e93ca4..a220f039d1369 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -484,12 +484,12 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { stubphi = curStub->l1tstub()->phi(); // Get region that the stub is in (Layer 1->6, Disk 1->5) int Layer = curStub->layerdisk() + 1; - if (Layer>6) { - Layer=0; + if (Layer > 6) { + Layer = 0; } - int Disk = curStub->layerdisk()-5; - if (Disk<0) { - Disk=0; + int Disk = curStub->layerdisk() - 5; + if (Disk < 0) { + Disk = 0; } // Get phi projection of tracklet int seedindex = curTracklet->seedIndex(); diff --git a/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc b/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc index 3779ea1b7232d..4ea8f49d3f953 100644 --- a/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc +++ b/L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc @@ -11,19 +11,17 @@ void SLHCEvent::addL1SimTrack( } bool SLHCEvent::addStub(string DTClink, - int region, - int layerdisk, - string stubword, - int isPSmodule, - int isFlipped, - double x, - double y, - double z, - double bend, - double strip, - vector tps -) { - + int region, + int layerdisk, + string stubword, + int isPSmodule, + int isFlipped, + double x, + double y, + double z, + double bend, + double strip, + vector tps) { L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps); stubs_.push_back(stub); @@ -174,4 +172,3 @@ unsigned int SLHCEvent::layersHit(int tpid, int& nlayers, int& ndisks) { return l1 + 2 * l2 + 4 * l3 + 8 * l4 + 16 * l5 + 32 * l6 + 64 * d1 + 128 * d2 + 256 * d3 + 512 * d4 + 1024 * d5; } - diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 681cf22c46b98..982a87a8162b7 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -61,12 +61,11 @@ Sector::Sector(unsigned int i, Settings const& settings, Globals* globals) : set Sector::~Sector() = default; bool Sector::addStub(L1TStub stub, string dtc) { - - unsigned int layerdisk=stub.layerdisk(); + unsigned int layerdisk = stub.layerdisk(); double stubphi = stub.phi(); - if (stubphi-phimin_>M_PI){ - stubphi-=2*M_PI; + if (stubphi - phimin_ > M_PI) { + stubphi -= 2 * M_PI; } if (layerdisk < N_LAYER && globals_->phiCorr(layerdisk) == nullptr) { @@ -77,7 +76,7 @@ bool Sector::addStub(L1TStub stub, string dtc) { nbits = 4; globals_->phiCorr(layerdisk)->init(layerdisk + 1, nbits, 3); } - + Stub fpgastub(stub, settings_, *globals_); if (layerdisk < N_LAYER) { @@ -88,101 +87,97 @@ bool Sector::addStub(L1TStub stub, string dtc) { int iphicorr = phiCorrTable.getphiCorrValue(bendbin, rbin); fpgastub.setPhiCorr(iphicorr); } - - FPGAWord phi=fpgastub.phicorr(); - int ireg=phi.value()>>(phi.nbits()-settings_.nbitsallstubs(layerdisk)); - int nadd=0; + FPGAWord phi = fpgastub.phicorr(); + int ireg = phi.value() >> (phi.nbits() - settings_.nbitsallstubs(layerdisk)); + + int nadd = 0; for (unsigned int i = 0; i < IL_.size(); i++) { - const string& name=IL_[i]->getName(); - if (name.find("_" + dtc) == string::npos) continue; - if ( (name[3]=='L' && name[4]-'1'==(int)layerdisk) || (name[3]=='D' && name[4]-'1'==(int)layerdisk-6) ) { - if (name[8]-'A'==ireg){ - IL_[i]->addStub(stub, fpgastub); - nadd++; + const string& name = IL_[i]->getName(); + if (name.find("_" + dtc) == string::npos) + continue; + if ((name[3] == 'L' && name[4] - '1' == (int)layerdisk) || + (name[3] == 'D' && name[4] - '1' == (int)layerdisk - 6)) { + if (name[8] - 'A' == ireg) { + IL_[i]->addStub(stub, fpgastub); + nadd++; } } } - assert(nadd==1); + assert(nadd == 1); - if (settings_.writeMem() && isector_ == (int)settings_.writememsect() ) { + if (settings_.writeMem() && isector_ == (int)settings_.writememsect()) { writeLink(fpgastub); } - + return true; } void Sector::writeLinkNewEvent(int event) { - - if (DTCLink_ofstreams_.size()==0) { + if (DTCLink_ofstreams_.size() == 0) { //FIXME should be in settings - static string dtcbasenames[12]={"PS10G_1","PS10G_2","PS10G_3","PS10G_4","PS_1","PS_2","2S_1","2S_2","2S_3","2S_4","2S_5","2S_6"}; - for (const auto& dtcbasename: dtcbasenames) { - for (int neg=0;neg<2;neg++) { - string dtcnametmp=(neg==0?"":"neg")+dtcbasename; - for (int ab=0;ab<2;ab++) { - string dtcname=dtcnametmp+(ab==0?"_A":"_B"); - string fname = "../data/MemPrints/InputStubs/Link_"+dtcname+"_"+to_string(isector_+1)+".dat"; - ofstream* out = new ofstream; - out->open(fname.c_str()); - DTCLink_ofstreams_[dtcname] = out; - } + static string dtcbasenames[12] = { + "PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", "2S_4", "2S_5", "2S_6"}; + for (const auto& dtcbasename : dtcbasenames) { + for (int neg = 0; neg < 2; neg++) { + string dtcnametmp = (neg == 0 ? "" : "neg") + dtcbasename; + for (int ab = 0; ab < 2; ab++) { + string dtcname = dtcnametmp + (ab == 0 ? "_A" : "_B"); + string fname = "../data/MemPrints/InputStubs/Link_" + dtcname + "_" + to_string(isector_ + 1) + ".dat"; + ofstream* out = new ofstream; + out->open(fname.c_str()); + DTCLink_ofstreams_[dtcname] = out; + } } } } - for(auto& out:DTCLink_ofstreams_){ - FPGAWord bx(event%8,3,true); - (*out.second) << "BX "< > dtclayers{ - {"PS10G_1", {0,6,8,10}}, - {"PS10G_2", {0,7,9}}, - {"PS10G_3", {1,7}}, - {"PS10G_4", {6,8,10}}, - {"PS_1", {2,7}}, - {"PS_2", {2,9}}, - {"2S_1", {3,4}}, - {"2S_2", {4}}, - {"2S_3", {5}}, - {"2S_4", {5,8}}, - {"2S_5", {6,9}}, - {"2S_6", {7,10}} - }; - - string dtcname=fpgastub.l1tstub()->DTClink(); - int layerdisk=fpgastub.l1tstub()->layerdisk(); - - int start=dtcname.substr(0,3)=="neg"?3:0; - - string dtcbase=dtcname.substr(start,dtcname.size()-2-start); - - vector layers=dtclayers[dtcbase]; - - int lcode=-1; - for(unsigned int index=0;index > dtclayers{{"PS10G_1", {0, 6, 8, 10}}, + {"PS10G_2", {0, 7, 9}}, + {"PS10G_3", {1, 7}}, + {"PS10G_4", {6, 8, 10}}, + {"PS_1", {2, 7}}, + {"PS_2", {2, 9}}, + {"2S_1", {3, 4}}, + {"2S_2", {4}}, + {"2S_3", {5}}, + {"2S_4", {5, 8}}, + {"2S_5", {6, 9}}, + {"2S_6", {7, 10}}}; + + string dtcname = fpgastub.l1tstub()->DTClink(); + int layerdisk = fpgastub.l1tstub()->layerdisk(); + + int start = dtcname.substr(0, 3) == "neg" ? 3 : 0; + + string dtcbase = dtcname.substr(start, dtcname.size() - 2 - start); + + vector layers = dtclayers[dtcbase]; + + int lcode = -1; + for (unsigned int index = 0; index < layers.size(); index++) { + if (layerdisk == layers[index]) { + lcode = index; } } - assert(lcode!=-1); - + assert(lcode != -1); + assert(DTCLink_ofstreams_.find(dtcname) != DTCLink_ofstreams_.end()); - FPGAWord ldcode(lcode,2,true); + FPGAWord ldcode(lcode, 2, true); string dataword = "1|" + ldcode.str() + "|" + fpgastub.str(); (*DTCLink_ofstreams_.find(dtcname)->second) << dataword << " " << trklet::hexFormat(dataword) << endl; - - } void Sector::addMem(string memType, string memName) { diff --git a/L1Trigger/TrackFindingTracklet/src/Stub.cc b/L1Trigger/TrackFindingTracklet/src/Stub.cc index 4a2c53ae0ba53..3d116ae9867a2 100644 --- a/L1Trigger/TrackFindingTracklet/src/Stub.cc +++ b/L1Trigger/TrackFindingTracklet/src/Stub.cc @@ -15,71 +15,73 @@ using namespace trklet; Stub::Stub(Settings const& settings) : settings_(settings) {} Stub::Stub(L1TStub& stub, Settings const& settings, Globals& globals) : settings_(settings) { + const string& stubwordhex = stub.stubword(); - const string& stubwordhex=stub.stubword(); + const string stubwordbin = convertHexToBin(stubwordhex); - const string stubwordbin=convertHexToBin(stubwordhex); - - layerdisk_=stub.layerdisk(); + layerdisk_ = stub.layerdisk(); int nbendbits = 4; if (stub.isPSmodule()) nbendbits = 3; - int nalphabits=0; + int nalphabits = 0; - int nrbits=settings_.nrbitsstub(layerdisk_); - int nzbits=settings_.nzbitsstub(layerdisk_); - int nphibits=settings_.nphibitsstub(layerdisk_); + int nrbits = settings_.nrbitsstub(layerdisk_); + int nzbits = settings_.nzbitsstub(layerdisk_); + int nphibits = settings_.nphibitsstub(layerdisk_); - if (layerdisk_>=N_LAYER && !stub.isPSmodule()) { - nalphabits=settings.nbitsalpha(); - nrbits=7; + if (layerdisk_ >= N_LAYER && !stub.isPSmodule()) { + nalphabits = settings.nbitsalpha(); + nrbits = 7; } int layer = stub.layer() + 1; - assert(nbendbits+nalphabits+nrbits+nzbits+nphibits==36); - - bitset<32> rbits(stubwordbin.substr(0,nrbits)); - bitset<32> zbits(stubwordbin.substr(nrbits,nzbits)); - bitset<32> phibits(stubwordbin.substr(nrbits+nzbits,nphibits)); - bitset<32> alphabits(stubwordbin.substr(nphibits+nzbits+nrbits,nalphabits)); - bitset<32> bendbits(stubwordbin.substr(nphibits+nzbits+nrbits+nalphabits,nbendbits)); - - int newbend=bendbits.to_ulong(); - - int newr=rbits.to_ulong(); - if (layerdisk_=(1<<(nrbits-1))) newr=newr-(1< rbits(stubwordbin.substr(0, nrbits)); + bitset<32> zbits(stubwordbin.substr(nrbits, nzbits)); + bitset<32> phibits(stubwordbin.substr(nrbits + nzbits, nphibits)); + bitset<32> alphabits(stubwordbin.substr(nphibits + nzbits + nrbits, nalphabits)); + bitset<32> bendbits(stubwordbin.substr(nphibits + nzbits + nrbits + nalphabits, nbendbits)); + + int newbend = bendbits.to_ulong(); + + int newr = rbits.to_ulong(); + if (layerdisk_ < N_LAYER) { + if (newr >= (1 << (nrbits - 1))) + newr = newr - (1 << nrbits); } - int newz=zbits.to_ulong(); - if (newz>=(1<<(nzbits-1))) newz=newz-(1<= (1 << (nzbits - 1))) + newz = newz - (1 << nzbits); - - int newphi=phibits.to_ulong(); + int newphi = phibits.to_ulong(); - int newalpha=alphabits.to_ulong();//-(1<<(nalphabits-1)); - if (newalpha>=(1<<(nalphabits-1))) newalpha=newalpha-(1<= (1 << (nalphabits - 1))) + newalpha = newalpha - (1 << nalphabits); l1tstub_ = &stub; //int ibendnew = bendencode(newbend*bendfact, stub.isPSmodule()); - + bend_.set(newbend, nbendbits, true, __LINE__, __FILE__); - + phi_.set(newphi, nphibits, true, __LINE__, __FILE__); phicorr_.set(newphi, nphibits, true, __LINE__, __FILE__); - bool pos=false; - if (layerdisk_>5) { - pos=true; - int disk=layerdisk_-5; - if (stub.z()<0.0) disk=-disk; + bool pos = false; + if (layerdisk_ > 5) { + pos = true; + int disk = layerdisk_ - 5; + if (stub.z() < 0.0) + disk = -disk; disk_.set(disk, 4, false, __LINE__, __FILE__); if (!stub.isPSmodule()) { alpha_.set(newalpha, nalphabits, false, __LINE__, __FILE__); - nrbits=4; + nrbits = 4; } } else { disk_.set(0, 4, false, __LINE__, __FILE__); @@ -89,29 +91,25 @@ Stub::Stub(L1TStub& stub, Settings const& settings, Globals& globals) : settings z_.set(newz, nzbits, false, __LINE__, __FILE__); if (settings.writeMonitorData("StubBend")) { - - - unsigned int nsimtrks=globals.event()->nsimtracks(); + unsigned int nsimtrks = globals.event()->nsimtracks(); //cout << "Have L1 stub" << endl; - - for (unsigned int isimtrk=0;isimtrksimtrack(isimtrk); - if (stub.tpmatch2(simtrk.trackid())) { - double dr=0.18; - double rinv=simtrk.charge()*0.01*settings_.c()*settings_.bfield()/simtrk.pt(); - double pitch=settings_.stripPitch(stub.isPSmodule()); - double bend=stub.r()*dr*0.5*rinv/pitch; - - globals.ofstream("stubbend.dat") << layerdisk_ << " "<simtrack(isimtrk); + if (stub.tpmatch2(simtrk.trackid())) { + double dr = 0.18; + double rinv = simtrk.charge() * 0.01 * settings_.c() * settings_.bfield() / simtrk.pt(); + double pitch = settings_.stripPitch(stub.isPSmodule()); + double bend = stub.r() * dr * 0.5 * rinv / pitch; + + globals.ofstream("stubbend.dat") << layerdisk_ << " " << stub.isPSmodule() << " " + << simtrk.pt() * simtrk.charge() << " " << bend << " " << newbend << " " + << settings.benddecode(newbend, layerdisk_, stub.isPSmodule()) << " " + << settings.bendcut(newbend, layerdisk_, stub.isPSmodule()) << endl; } } } - } FPGAWord Stub::iphivmFineBins(int VMbits, int finebits) const { diff --git a/L1Trigger/TrackFindingTracklet/src/TETableBase.cc b/L1Trigger/TrackFindingTracklet/src/TETableBase.cc index aeca99c2fc326..6e701edf0ee15 100644 --- a/L1Trigger/TrackFindingTracklet/src/TETableBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TETableBase.cc @@ -9,7 +9,7 @@ TETableBase::TETableBase(Settings const& settings) : settings_(settings) {} void TETableBase::writeVMTable(const std::string& dir, const std::string& name, bool positive) { // Write LUT table. - ofstream out=openfile(dir, name, __FILE__, __LINE__); + ofstream out = openfile(dir, name, __FILE__, __LINE__); out << "{" << endl; for (unsigned int i = 0; i < table_.size(); i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc b/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc index b3791a5f74e49..3b39c761a80e7 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackDerTable.cc @@ -358,10 +358,9 @@ void TrackDerTable::fillTable() { } if (settings_.writeTable()) { - - ofstream outL=openfile(settings_.tablePath(), "FitDerTableNew_LayerMem.tab", __FILE__, __LINE__); - - int nbits=6; + ofstream outL = openfile(settings_.tablePath(), "FitDerTableNew_LayerMem.tab", __FILE__, __LINE__); + + int nbits = 6; for (unsigned int i = 0; i < LayerMem_.size(); i++) { FPGAWord tmp; int tmp1 = LayerMem_[i]; @@ -372,9 +371,9 @@ void TrackDerTable::fillTable() { } outL.close(); - ofstream outD=openfile(settings_.tablePath(), "FitDerTableNew_DiskMem.tab", __FILE__, __LINE__); + ofstream outD = openfile(settings_.tablePath(), "FitDerTableNew_DiskMem.tab", __FILE__, __LINE__); - nbits=7; + nbits = 7; for (int tmp1 : DiskMem_) { if (tmp1 < 0) tmp1 = (1 << nbits) - 1; @@ -384,9 +383,9 @@ void TrackDerTable::fillTable() { } outD.close(); - ofstream outLD=openfile(settings_.tablePath(), "FitDerTableNew_LayerDiskMem.tab", __FILE__, __LINE__); + ofstream outLD = openfile(settings_.tablePath(), "FitDerTableNew_LayerDiskMem.tab", __FILE__, __LINE__); - nbits=15; + nbits = 15; for (int tmp1 : LayerDiskMem_) { if (tmp1 < 0) tmp1 = (1 << nbits) - 1; @@ -615,79 +614,79 @@ void TrackDerTable::fillTable() { } // if (goodseed) FPGAWord tmprinvdphi[N_PROJ]; - int nbits=16; + int nbits = 16; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmprinvdphi[j] > (1 << nbits)) itmprinvdphi[j] = (1 << nbits) - 1; - tmprinvdphi[j].set(itmprinvdphi[j], nbits+1, false, __LINE__, __FILE__); + tmprinvdphi[j].set(itmprinvdphi[j], nbits + 1, false, __LINE__, __FILE__); } outrinvdphi[i] << tmprinvdphi[0].str() << tmprinvdphi[1].str() << tmprinvdphi[2].str() << tmprinvdphi[3].str() << endl; FPGAWord tmprinvdzordr[N_PROJ]; - nbits=15; + nbits = 15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmprinvdzordr[j] > (1 << nbits)) itmprinvdzordr[j] = (1 << nbits) - 1; - tmprinvdzordr[j].set(itmprinvdzordr[j], nbits+1, false, __LINE__, __FILE__); + tmprinvdzordr[j].set(itmprinvdzordr[j], nbits + 1, false, __LINE__, __FILE__); } outrinvdzordr[i] << tmprinvdzordr[0].str() << tmprinvdzordr[1].str() << tmprinvdzordr[2].str() << tmprinvdzordr[3].str() << endl; FPGAWord tmpphi0dphi[N_PROJ]; - nbits=13; + nbits = 13; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpphi0dphi[j] > (1 << nbits)) itmpphi0dphi[j] = (1 << nbits) - 1; - tmpphi0dphi[j].set(itmpphi0dphi[j], nbits+1, false, __LINE__, __FILE__); + tmpphi0dphi[j].set(itmpphi0dphi[j], nbits + 1, false, __LINE__, __FILE__); } outphi0dphi[i] << tmpphi0dphi[0].str() << tmpphi0dphi[1].str() << tmpphi0dphi[2].str() << tmpphi0dphi[3].str() << endl; FPGAWord tmpphi0dzordr[N_PROJ]; - nbits=15; + nbits = 15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpphi0dzordr[j] > (1 << nbits)) itmpphi0dzordr[j] = (1 << nbits) - 1; - tmpphi0dzordr[j].set(itmpphi0dzordr[j], nbits+1, false, __LINE__, __FILE__); + tmpphi0dzordr[j].set(itmpphi0dzordr[j], nbits + 1, false, __LINE__, __FILE__); } outphi0dzordr[i] << tmpphi0dzordr[0].str() << tmpphi0dzordr[1].str() << tmpphi0dzordr[2].str() << tmpphi0dzordr[3].str() << endl; FPGAWord tmptdphi[N_PROJ]; - nbits=14; + nbits = 14; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmptdphi[j] > (1 << nbits)) itmptdphi[j] = (1 << nbits) - 1; - tmptdphi[j].set(itmptdphi[j], nbits+1, false, __LINE__, __FILE__); + tmptdphi[j].set(itmptdphi[j], nbits + 1, false, __LINE__, __FILE__); } outtdphi[i] << tmptdphi[0].str() << tmptdphi[1].str() << tmptdphi[2].str() << tmptdphi[3].str() << endl; FPGAWord tmptdzordr[N_PROJ]; - nbits=15; + nbits = 15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmptdzordr[j] > (1 << nbits)) itmptdzordr[j] = (1 << nbits) - 1; - tmptdzordr[j].set(itmptdzordr[j], nbits+1, false, __LINE__, __FILE__); + tmptdzordr[j].set(itmptdzordr[j], nbits + 1, false, __LINE__, __FILE__); } outtdzordr[i] << tmptdzordr[0].str() << tmptdzordr[1].str() << tmptdzordr[2].str() << tmptdzordr[3].str() << endl; FPGAWord tmpz0dphi[N_PROJ]; - nbits=13; + nbits = 13; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpz0dphi[j] > (1 << nbits)) itmpz0dphi[j] = (1 << nbits) - 1; - tmpz0dphi[j].set(itmpz0dphi[j], nbits+1, false, __LINE__, __FILE__); + tmpz0dphi[j].set(itmpz0dphi[j], nbits + 1, false, __LINE__, __FILE__); } outz0dphi[i] << tmpz0dphi[0].str() << tmpz0dphi[1].str() << tmpz0dphi[2].str() << tmpz0dphi[3].str() << endl; FPGAWord tmpz0dzordr[N_PROJ]; - nbits=15; + nbits = 15; for (unsigned int j = 0; j < N_PROJ; ++j) { if (itmpz0dzordr[j] > (1 << nbits)) itmpz0dzordr[j] = (1 << nbits) - 1; - tmpz0dzordr[j].set(itmpz0dzordr[j], nbits+1, false, __LINE__, __FILE__); + tmpz0dzordr[j].set(itmpz0dzordr[j], nbits + 1, false, __LINE__, __FILE__); } outz0dzordr[i] << tmpz0dzordr[0].str() << tmpz0dzordr[1].str() << tmpz0dzordr[2].str() << tmpz0dzordr[3].str() << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index 11e2fcef97b63..382eaf0d5fd55 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -249,8 +249,9 @@ std::string Tracklet::vmstrlayer(int layer, unsigned int allstubindex) { FPGAWord tmp; tmp.set(irinvvm, 5, true, __LINE__, __FILE__); std::string oss = index.str() + "|" + layerproj_[layer - 1].fpgazbin1projvm().str() + "|" + - layerproj_[layer - 1].fpgazbin2projvm().str() + "|" + layerproj_[layer - 1].fpgafinezvm().str() - + "|" + layerproj_[layer-1].fpgafinephivm().str() + "|" + tmp.str() + "|" + std::to_string(PSseed()); + layerproj_[layer - 1].fpgazbin2projvm().str() + "|" + layerproj_[layer - 1].fpgafinezvm().str() + + "|" + layerproj_[layer - 1].fpgafinephivm().str() + "|" + tmp.str() + "|" + + std::to_string(PSseed()); return oss; } @@ -263,8 +264,8 @@ std::string Tracklet::vmstrdisk(int disk, unsigned int allstubindex) { index.set(allstubindex, 7, true, __LINE__, __FILE__); } std::string oss = index.str() + "|" + diskproj_[disk - 1].fpgarbin1projvm().str() + "|" + - diskproj_[disk - 1].fpgarbin2projvm().str() + "|" + diskproj_[disk - 1].fpgafinervm().str() - + "|" + diskproj_[disk-1].fpgafinephivm().str() + "|" + diskproj_[disk - 1].getBendIndex().str(); + diskproj_[disk - 1].fpgarbin2projvm().str() + "|" + diskproj_[disk - 1].fpgafinervm().str() + "|" + + diskproj_[disk - 1].fpgafinephivm().str() + "|" + diskproj_[disk - 1].getBendIndex().str(); return oss; } @@ -822,16 +823,17 @@ Track Tracklet::makeTrack(const vector& l1stubs) { } int Tracklet::layer() const { - int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk()layerdisk() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk()layerdisk() + 1 : 999, - l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk()layerdisk() + 1 : 999, l = min(min(l1, l2), l3); + int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerStub_->layerdisk() + 1 : 999, + l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleStub_->layerdisk() + 1 : 999, + l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerStub_->layerdisk() + 1 : 999, + l = min(min(l1, l2), l3); return (l < 999 ? l : 0); } int Tracklet::disk() const { - int d1 = (innerFPGAStub_ && (innerFPGAStub_->layerdisk()>=N_LAYER)) ? innerStub_->disk() : 999, - d2 = (middleFPGAStub_ && (middleFPGAStub_->layerdisk()>=N_LAYER)) ? middleStub_->disk() : 999, - d3 = (outerFPGAStub_ && (outerFPGAStub_->layerdisk()>=N_LAYER)) ? outerStub_->disk() : 999, d = 999; + int d1 = (innerFPGAStub_ && (innerFPGAStub_->layerdisk() >= N_LAYER)) ? innerStub_->disk() : 999, + d2 = (middleFPGAStub_ && (middleFPGAStub_->layerdisk() >= N_LAYER)) ? middleStub_->disk() : 999, + d3 = (outerFPGAStub_ && (outerFPGAStub_->layerdisk() >= N_LAYER)) ? outerStub_->disk() : 999, d = 999; if (abs(d1) < min(abs(d2), abs(d3))) d = d1; if (abs(d2) < min(abs(d1), abs(d3))) @@ -900,9 +902,9 @@ unsigned int Tracklet::calcSeedIndex() const { assert(innerFPGAStub_ != nullptr); assert(outerFPGAStub_ != nullptr); if (middleFPGAStub_ && seedlayer == 2 && abs(seeddisk) == 1) { - int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk()layerdisk() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk()layerdisk() + 1 : 999, - l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk()layerdisk() + 1 : 999; + int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerStub_->layerdisk() + 1 : 999, + l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleStub_->layerdisk() + 1 : 999, + l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerStub_->layerdisk() + 1 : 999; if (l1 + l2 + l3 < 1998) { // If two stubs are layer stubs seedindex = 10; // L2L3D1 } else { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc index 5800d9b7c8c08..ad765de628a16 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc @@ -43,7 +43,8 @@ TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Gl } // write the drinv and invt inverse tables - if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable() ) && iTC_ == 0 && iSector_ == 0) { + if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable()) && iTC_ == 0 && + iSector_ == 0) { void (*writeLUT)(const VarInv&, const string&) = nullptr; if (settings.writeInvTable()) { // Verilog version writeLUT = [](const VarInv& x, const string& basename) -> void { @@ -155,9 +156,9 @@ void TrackletCalculator::execute() { unsigned int countall = 0; unsigned int countsel = 0; - bool print=(iSector_==3)&&(getName()=="TC_L1L2G"); - print=false; - + 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(); @@ -175,8 +176,8 @@ void TrackletCalculator::execute() { edm::LogVerbatim("Tracklet") << "TrackletCalculator execute " << getName() << "[" << iSector_ << "]"; } - if (innerFPGAStub->layerdisk()layerdisk()>=N_LAYER) { + 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) @@ -184,20 +185,21 @@ void TrackletCalculator::execute() { } else { //barrel+barrel seeding bool accept = barrelSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); - if (print) { - cout << stubpair->getName()<<" i inner outer : "<allStubIndex().value()<<" " - <allStubIndex().value()<<" accept = "<getName() << " i inner outer : " << countall << " " + << innerFPGAStub->allStubIndex().value() << " " << outerFPGAStub->allStubIndex().value() + << " accept = " << accept << endl; + } if (accept) countsel++; } } else { - if (outerFPGAStub->layerdisk()>=N_LAYER) { + if (outerFPGAStub->layerdisk() >= N_LAYER) { //disk+disk seeding bool accept = diskSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); if (accept) countsel++; - } else if (innerFPGAStub->layerdisk()>=N_LAYER) { + } else if (innerFPGAStub->layerdisk() >= N_LAYER) { //layer+disk seeding bool accept = overlapSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); if (accept) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index 4a889b8506b27..d646178da25b1 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -338,7 +338,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, << " " << outerFPGAStub->layer().value(); } - assert(outerFPGAStub->layerdisk()layerdisk() < N_LAYER); assert(layerdisk1_ == (unsigned int)innerFPGAStub->layer().value()); assert(layerdisk1_ < N_LAYER && layerdisk2_ < N_LAYER); @@ -1118,9 +1118,9 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, const Stub* outerFPGAStub, const L1TStub* outerStub) { //Deal with overlap stubs here - assert(outerFPGAStub->layerdisk()layerdisk() < N_LAYER); - assert(innerFPGAStub->layerdisk()>=N_LAYER); + assert(innerFPGAStub->layerdisk() >= N_LAYER); int disk = innerFPGAStub->disk().value(); @@ -1398,7 +1398,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, diskprojs[i].init(settings_, i + 2, - settings_.zmean(i+1), + settings_.zmean(i + 1), iphiprojdisk[i], irprojdisk[i], ITC->der_phiD_final.ival(), diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index d51c3fe3b9b82..93b7ca48d1379 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -244,20 +244,24 @@ void TrackletCalculatorDisplaced::execute() { if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced execute " << getName() << "[" << iSector_ << "]"; - if (innerFPGAStub->layerdisk()layerdisk()layerdisk()layerdisk() < N_LAYER && middleFPGAStub->layerdisk() < N_LAYER && + outerFPGAStub->layerdisk() < N_LAYER) { //barrel+barrel seeding bool accept = LLLSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub); if (accept) countsel++; - } else if (innerFPGAStub->layerdisk()>=N_LAYER && middleFPGAStub->layerdisk()>=N_LAYER && outerFPGAStub->layerdisk()>=N_LAYER) { + } else if (innerFPGAStub->layerdisk() >= N_LAYER && middleFPGAStub->layerdisk() >= N_LAYER && + outerFPGAStub->layerdisk() >= N_LAYER) { throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Invalid seeding!"; } else { //layer+disk seeding - if (innerFPGAStub->layerdisk()layerdisk()>=N_LAYER && outerFPGAStub->layerdisk()>=N_LAYER) { //D1D2L2 + if (innerFPGAStub->layerdisk() < N_LAYER && middleFPGAStub->layerdisk() >= N_LAYER && + outerFPGAStub->layerdisk() >= N_LAYER) { //D1D2L2 bool accept = DDLSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub); if (accept) countsel++; - } else if (innerFPGAStub->layerdisk()>=N_LAYER && middleFPGAStub->layerdisk()layerdisk()layerdisk() >= N_LAYER && middleFPGAStub->layerdisk() < N_LAYER && + outerFPGAStub->layerdisk() < N_LAYER) { //L2L3D1 bool accept = LLDSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub); if (accept) countsel++; @@ -372,7 +376,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, << " trying stub triplet in layer (L L L): " << innerFPGAStub->layer().value() << " " << middleFPGAStub->layer().value() << " " << outerFPGAStub->layer().value(); - assert(outerFPGAStub->layerdisk()layerdisk() < N_LAYER); double r1 = innerStub->r(); double z1 = innerStub->z(); @@ -454,33 +458,32 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK]; //TODO: implement the actual integer calculation - if(settings_.useapprox()){ + if (settings_.useapprox()) { approxtracklet(r1, - z1, - phi1, - r2, - z2, - phi2, - r3, - z3, - phi3, - take3, - ndisks, - rinvapprox, - phi0approx, - d0approx, - tapprox, - z0approx, - phiprojapprox, - zprojapprox, - phiderapprox, - zderapprox, - phiprojdiskapprox, - rprojdiskapprox, - phiderdiskapprox, - rderdiskapprox); - } - else{ + z1, + phi1, + r2, + z2, + phi2, + r3, + z3, + phi3, + take3, + ndisks, + rinvapprox, + phi0approx, + d0approx, + tapprox, + z0approx, + phiprojapprox, + zprojapprox, + phiderapprox, + zderapprox, + phiprojdiskapprox, + rprojdiskapprox, + phiderdiskapprox, + rderdiskapprox); + } else { rinvapprox = rinv; phi0approx = phi0; d0approx = d0; @@ -871,33 +874,32 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK]; //TODO: implement the actual integer calculation - if(settings_.useapprox()){ + if (settings_.useapprox()) { approxtracklet(r1, - z1, - phi1, - r2, - z2, - phi2, - r3, - z3, - phi3, - take3, - ndisks, - rinvapprox, - phi0approx, - d0approx, - tapprox, - z0approx, - phiprojapprox, - zprojapprox, - phiderapprox, - zderapprox, - phiprojdiskapprox, - rprojdiskapprox, - phiderdiskapprox, - rderdiskapprox); - } - else{ + z1, + phi1, + r2, + z2, + phi2, + r3, + z3, + phi3, + take3, + ndisks, + rinvapprox, + phi0approx, + d0approx, + tapprox, + z0approx, + phiprojapprox, + zprojapprox, + phiderapprox, + zderapprox, + phiprojdiskapprox, + rprojdiskapprox, + phiderdiskapprox, + rderdiskapprox); + } else { rinvapprox = rinv; phi0approx = phi0; d0approx = d0; @@ -1272,33 +1274,32 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK]; //TODO: implement the actual integer calculation - if(settings_.useapprox()){ + if (settings_.useapprox()) { approxtracklet(r1, - z1, - phi1, - r2, - z2, - phi2, - r3, - z3, - phi3, - take3, - ndisks, - rinvapprox, - phi0approx, - d0approx, - tapprox, - z0approx, - phiprojapprox, - zprojapprox, - phiderapprox, - zderapprox, - phiprojdiskapprox, - rprojdiskapprox, - phiderdiskapprox, - rderdiskapprox); - } - else{ + z1, + phi1, + r2, + z2, + phi2, + r3, + z3, + phi3, + take3, + ndisks, + rinvapprox, + phi0approx, + d0approx, + tapprox, + z0approx, + phiprojapprox, + zprojapprox, + phiderapprox, + zderapprox, + phiprojdiskapprox, + rprojdiskapprox, + phiderdiskapprox, + rderdiskapprox); + } else { rinvapprox = rinv; phi0approx = phi0; d0approx = d0; @@ -1682,14 +1683,16 @@ void TrackletCalculatorDisplaced::exacttracklet(double r1, double y2 = r2 * sin(phi2); double y3 = r3 * sin(phi3); - double dy21=y2-y1; - double dy32=y3-y2; + double dy21 = y2 - y1; + double dy32 = y3 - y2; //Hack to protect against dividing by zero //code should be rewritten to avoid this - if (dy21==0.0) dy21=1e-9; - if (dy32==0.0) dy32=1e-9; - + if (dy21 == 0.0) + dy21 = 1e-9; + if (dy32 == 0.0) + dy32 = 1e-9; + double k1 = -(x2 - x1) / dy21; double k2 = -(x3 - x2) / dy32; double b1 = 0.5 * (y2 + y1) - 0.5 * (x1 + x2) * k1; @@ -1896,10 +1899,9 @@ void TrackletCalculatorDisplaced::approxtracklet(double r1, phi0 = -phi1c * r1 * (r2 + r3) * a + phi2c * r2 * (r1 + r3) * b - phi3c * r3 * (r1 + r2) * c; d0 = r1 * r2 * r3 * (-phi1c * a + phi2c * b - phi3c * c); - t = ((z - z1) / (r - r1)) * (1. + d0 * halfRinv - 0.5 * d0OverR1 * d0OverR - - sixth * (r1 * r1 + r2 * r2 + r1 * r2) * halfRinv_0 * halfRinv_0); - z0 = z1 - - t * r1 * (1.0 - d0_0 * halfRinv_0 - 0.5 * d0OverR1 * d0OverR1 + sixth * r1 * r1 * halfRinv_0 * halfRinv_0); + t = ((z - z1) / (r - r1)) * + (1. + d0 * halfRinv - 0.5 * d0OverR1 * d0OverR - sixth * (r1 * r1 + r2 * r2 + r1 * r2) * halfRinv_0 * halfRinv_0); + z0 = z1 - t * r1 * (1.0 - d0_0 * halfRinv_0 - 0.5 * d0OverR1 * d0OverR1 + sixth * r1 * r1 * halfRinv_0 * halfRinv_0); rinv = 2.0 * halfRinv; phi0 += -phimin_; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc index 2636ea1b1d6cb..a7698fcac8328 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc @@ -13,1140 +13,1013 @@ using namespace std; using namespace trklet; -TrackletConfigBuilder::TrackletConfigBuilder(const Settings& settings): - settings_(settings){ - - NSector_=N_SECTOR; - rcrit_=settings.rcrit(); - - combinedmodules_=settings.combined(); - - extended_=settings.extended(); - - rinvmax_=settings.rinvmax(); - - rmaxdisk_=settings.rmaxdisk(); - zlength_=settings.zlength(); - - for (int i=0;i(settings.nvmte(0,iseed),settings.nvmte(1,iseed)); - NTC_[iseed]=settings.NTC(iseed); + for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) { + NVMTE_[iseed] = std::pair(settings.nvmte(0, iseed), settings.nvmte(1, iseed)); + NTC_[iseed] = settings.NTC(iseed); } initGeom(); - + buildTE(); - + buildTC(); buildProjections(); - } -std::pair TrackletConfigBuilder::seedLayers(unsigned int iSeed) { - - return std::pair(settings_.seedlayers(0,iSeed),settings_.seedlayers(1,iSeed)); - +std::pair TrackletConfigBuilder::seedLayers(unsigned int iSeed) { + return std::pair(settings_.seedlayers(0, iSeed), settings_.seedlayers(1, iSeed)); } - -void TrackletConfigBuilder::initGeom(){ - - for(unsigned int ilayer=0;ilayer > emptyVec; +void TrackletConfigBuilder::initGeom() { + for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) { + double dphi = dphisectorHG_ / NRegions_[ilayer]; + for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) { + std::vector > emptyVec; projections_[ilayer].push_back(emptyVec); - double phimin=dphi*iReg; - double phimax=phimin+dphi; - std::pair tmp(phimin,phimax); + double phimin = dphi * iReg; + double phimax = phimin + dphi; + std::pair tmp(phimin, phimax); allStubs_[ilayer].push_back(tmp); - double dphiVM=dphi/NVMME_[ilayer]; - for(unsigned int iVM=0;iVM tmp(phivmmin,phivmmax); - VMStubsME_[ilayer].push_back(tmp); + double dphiVM = dphi / NVMME_[ilayer]; + for (unsigned int iVM = 0; iVM < NVMME_[ilayer]; iVM++) { + double phivmmin = phimin + iVM * dphiVM; + double phivmmax = phivmmin + dphiVM; + std::pair tmp(phivmmin, phivmmax); + VMStubsME_[ilayer].push_back(tmp); } } } - for(unsigned int iseed=0;iseed tmp(phivmmin,phivmmax); + for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) { + unsigned int l1 = seedLayers(iseed).first; + unsigned int l2 = seedLayers(iseed).second; + unsigned int nVM1 = NVMTE_[iseed].first; + unsigned int nVM2 = NVMTE_[iseed].second; + double dphiVM = dphisectorHG_ / (nVM1 * NRegions_[l1]); + for (unsigned int iVM = 0; iVM < nVM1 * NRegions_[l1]; iVM++) { + double phivmmin = iVM * dphiVM; + double phivmmax = phivmmin + dphiVM; + std::pair tmp(phivmmin, phivmmax); VMStubsTE_[iseed].first.push_back(tmp); } - dphiVM=dphisectorHG_/(nVM2*NRegions_[l2]); - for(unsigned int iVM=0;iVM tmp(phivmmin,phivmmax); + dphiVM = dphisectorHG_ / (nVM2 * NRegions_[l2]); + for (unsigned int iVM = 0; iVM < nVM2 * NRegions_[l2]; iVM++) { + double phivmmin = iVM * dphiVM; + double phivmmax = phivmmin + dphiVM; + std::pair tmp(phivmmin, phivmmax); VMStubsTE_[iseed].second.push_back(tmp); } - } + } } -std::pair TrackletConfigBuilder::seedRadii(unsigned int iseed) { - - std::pair seedlayers=seedLayers(iseed); - - unsigned int l1=seedlayers.first; - unsigned int l2=seedlayers.second; - - double r1,r2; - - if (iseed<4) { //barrel seeding - r1=rmean_[l1]; - r2=rmean_[l2]; - } else if (iseed<6) { //disk seeding - r1=rmean_[0]+40.0; //Somwwhat of a hack - but allows finding all the regions +std::pair TrackletConfigBuilder::seedRadii(unsigned int iseed) { + std::pair seedlayers = seedLayers(iseed); + + unsigned int l1 = seedlayers.first; + unsigned int l2 = seedlayers.second; + + double r1, r2; + + if (iseed < 4) { //barrel seeding + r1 = rmean_[l1]; + r2 = rmean_[l2]; + } else if (iseed < 6) { //disk seeding + r1 = rmean_[0] + 40.0; //Somwwhat of a hack - but allows finding all the regions //when projecting to L1 - r2=r1*zmean_[l2-6]/zmean_[l1-6]; - } else { //overlap seeding - r1=rmean_[l1]; - r2=r1*zmean_[l2-6]/zlength_; + r2 = r1 * zmean_[l2 - 6] / zmean_[l1 - 6]; + } else { //overlap seeding + r1 = rmean_[l1]; + r2 = r1 * zmean_[l2 - 6] / zlength_; } - - return std::pair(r1,r2); + + return std::pair(r1, r2); } +bool TrackletConfigBuilder::validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2) { + double rinvmin = 999.9; + double rinvmax = -999.9; -bool TrackletConfigBuilder::validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2){ - - double rinvmin=999.9; - double rinvmax=-999.9; - - double phi1[2]={VMStubsTE_[iseed].first[iTE1].first,VMStubsTE_[iseed].first[iTE1].second}; - double phi2[2]={VMStubsTE_[iseed].second[iTE2].first,VMStubsTE_[iseed].second[iTE2].second}; - - std::pair seedradii=seedRadii(iseed); - - for (unsigned int i1=0;i1<2;i1++) { - for (unsigned int i2=0;i2<2;i2++) { - double arinv=rinv(seedradii.first,phi1[i1],seedradii.second,phi2[i2]); - if (arinvrinvmax) rinvmax=arinv; + double phi1[2] = {VMStubsTE_[iseed].first[iTE1].first, VMStubsTE_[iseed].first[iTE1].second}; + double phi2[2] = {VMStubsTE_[iseed].second[iTE2].first, VMStubsTE_[iseed].second[iTE2].second}; + + std::pair seedradii = seedRadii(iseed); + + for (unsigned int i1 = 0; i1 < 2; i1++) { + for (unsigned int i2 = 0; i2 < 2; i2++) { + double arinv = rinv(seedradii.first, phi1[i1], seedradii.second, phi2[i2]); + if (arinv < rinvmin) + rinvmin = arinv; + if (arinv > rinvmax) + rinvmax = arinv; } } - - if (rinvmin>rinvmax_) return false; - if (rinvmax<-rinvmax_) return false; - + + if (rinvmin > rinvmax_) + return false; + if (rinvmax < -rinvmax_) + return false; + return true; - } - + void TrackletConfigBuilder::buildTE() { - - for(unsigned int iseed=0;iseed tmp(i1,i2); - TE_[iseed].push_back(tmp); - } + for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) { + for (unsigned int i1 = 0; i1 < VMStubsTE_[iseed].first.size(); i1++) { + for (unsigned int i2 = 0; i2 < VMStubsTE_[iseed].second.size(); i2++) { + if (validTEPair(iseed, i1, i2)) { + std::pair tmp(i1, i2); + TE_[iseed].push_back(tmp); + } } } - } + } } +void TrackletConfigBuilder::buildTC() { + for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) { + unsigned int nTC = NTC_[iSeed]; + std::vector >& TEs = TE_[iSeed]; + std::vector >& TCs = TC_[iSeed]; -void TrackletConfigBuilder::buildTC(){ - - for(unsigned int iSeed=0;iSeed >& TEs=TE_[iSeed]; - std::vector >& TCs=TC_[iSeed]; - //Very naive method to group TEs in TC - - double invnTC=nTC*(1.0/TEs.size()); - - for(unsigned int iTE=0;iTE=(int)TCs.size()) { - std::vector tmp; - tmp.push_back(iTE); - TCs.push_back(tmp); + + double invnTC = nTC * (1.0 / TEs.size()); + + for (unsigned int iTE = 0; iTE < TEs.size(); iTE++) { + int iTC = invnTC * iTE; + assert(iTC < (int)nTC); + if (iTC >= (int)TCs.size()) { + std::vector tmp; + tmp.push_back(iTE); + TCs.push_back(tmp); } else { - TCs[iTC].push_back(iTE); + TCs[iTC].push_back(iTE); } } } } -std::pair TrackletConfigBuilder::seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC){ - - std::vector >& TCs=TC_[iSeed]; - - std::pair seedradii=seedRadii(iSeed); - - double phimin=999.0; - double phimax=-999.0; - for (unsigned int iTE=0;iTEphimax) phimax=aphi; +std::pair TrackletConfigBuilder::seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC) { + std::vector >& TCs = TC_[iSeed]; + + std::pair seedradii = seedRadii(iSeed); + + double phimin = 999.0; + double phimax = -999.0; + for (unsigned int iTE = 0; iTE < TCs[iTC].size(); iTE++) { + unsigned int theTE = TCs[iTC][iTE]; + unsigned int l1TE = TE_[iSeed][theTE].first; + unsigned int l2TE = TE_[iSeed][theTE].second; + double phi1[2] = {VMStubsTE_[iSeed].first[l1TE].first, VMStubsTE_[iSeed].first[l1TE].second}; + double phi2[2] = {VMStubsTE_[iSeed].second[l2TE].first, VMStubsTE_[iSeed].second[l2TE].second}; + for (unsigned int i1 = 0; i1 < 2; i1++) { + for (unsigned int i2 = 0; i2 < 2; i2++) { + double aphi = phi(seedradii.first, phi1[i1], seedradii.second, phi2[i2], rproj); + if (aphi < phimin) + phimin = aphi; + if (aphi > phimax) + phimax = aphi; } } } - return std::pair(phimin,phimax); + return std::pair(phimin, phimax); } -void TrackletConfigBuilder::buildProjections(){ - - - for(unsigned int iseed=0;iseed >& TCs=TC_[iseed]; - - for (unsigned int ilayer=0;ilayer phiRange=seedPhiRange(rproj,iseed,iTC); - if (phiRange.firstallStubs_[ilayer][iReg].first) { - std::pair tmp(iseed,iTC); //seedindex and TC - projections_[ilayer][iReg].push_back(tmp); - } - } +void TrackletConfigBuilder::buildProjections() { + for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) { + std::vector >& TCs = TC_[iseed]; + + for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) { + if (matchport_[iseed][ilayer] == -1) + continue; + for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) { + for (unsigned int iTC = 0; iTC < TCs.size(); iTC++) { + double rproj = rmaxdisk_; + if (ilayer < 6) + rproj = rmean_[ilayer]; + std::pair phiRange = seedPhiRange(rproj, iseed, iTC); + if (phiRange.first < allStubs_[ilayer][iReg].second && phiRange.second > allStubs_[ilayer][iReg].first) { + std::pair tmp(iseed, iTC); //seedindex and TC + projections_[ilayer][iReg].push_back(tmp); + } + } } } - } + } } - -double TrackletConfigBuilder::phi(double r1, double phi1, double r2, double phi2,double r) { - - double rhoinv=rinv(r1,phi1,r2,phi2); - if (fabs(rhoinv)>rinvmax_) { - rhoinv=rinvmax_*rhoinv/fabs(rhoinv); +double TrackletConfigBuilder::phi(double r1, double phi1, double r2, double phi2, double r) { + double rhoinv = rinv(r1, phi1, r2, phi2); + if (fabs(rhoinv) > rinvmax_) { + rhoinv = rinvmax_ * rhoinv / fabs(rhoinv); } - return phi1+asin(0.5*r*rhoinv)-asin(0.5*r1*rhoinv); - + return phi1 + asin(0.5 * r * rhoinv) - asin(0.5 * r1 * rhoinv); } - - double TrackletConfigBuilder::rinv(double r1, double phi1, double r2, double phi2) { - - double deltaphi=phi1-phi2; - return 2*sin(deltaphi)/sqrt(r2*r2+r1*r1-2*r1*r2*cos(deltaphi)); - + double deltaphi = phi1 - phi2; + return 2 * sin(deltaphi) / sqrt(r2 * r2 + r1 * r1 - 2 * r1 * r2 * cos(deltaphi)); } std::string TrackletConfigBuilder::iSeedStr(unsigned int iSeed) { + static std::string name[8] = {"L1L2", "L2L3", "L3L4", "L5L6", "D1D2", "D3D4", "L1D1", "L2D1"}; - static std::string name[8]={"L1L2","L2L3","L3L4","L5L6","D1D2","D3D4","L1D1","L2D1"}; - - assert(iSeed<8); + assert(iSeed < 8); return name[iSeed]; - } - std::string TrackletConfigBuilder::numStr(unsigned int i) { - - static std::string num[32]={"1","2","3","4","5","6","7","8","9","10", - "11","12","13","14","15","16","17","18","19","20", - "21","22","23","24","25","26","27","28","29","30","31","32"}; - assert(i<32); + static std::string num[32] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", + "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", + "23", "24", "25", "26", "27", "28", "29", "30", "31", "32"}; + assert(i < 32); return num[i]; - } std::string TrackletConfigBuilder::iTCStr(unsigned int iTC) { - - static std::string name[12]={"A","B","C","D","E","F","G","H","I","J","K","L"}; - - assert(iTC<12); + static std::string name[12] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}; + + assert(iTC < 12); return name[iTC]; - } std::string TrackletConfigBuilder::iRegStr(unsigned int iReg, unsigned int iSeed) { - - static std::string name[8]={"A","B","C","D","E","F","G","H"}; - - static std::string nameOverlap[8]={"X","Y","Z","W","Q","R","S","T"}; - - static std::string nameL2L3[4]={"I","J","K","L"}; - - if (iSeed==1) { - assert(iReg<4); + static std::string name[8] = {"A", "B", "C", "D", "E", "F", "G", "H"}; + + static std::string nameOverlap[8] = {"X", "Y", "Z", "W", "Q", "R", "S", "T"}; + + static std::string nameL2L3[4] = {"I", "J", "K", "L"}; + + if (iSeed == 1) { + assert(iReg < 4); return nameL2L3[iReg]; } - if (iSeed==6||iSeed==7) { - assert(iReg<8); + if (iSeed == 6 || iSeed == 7) { + assert(iReg < 8); return nameOverlap[iReg]; } - assert(iReg<8); + assert(iReg < 8); return name[iReg]; - } - - -std::string TrackletConfigBuilder::TCName(unsigned int iSeed,unsigned int iTC){ +std::string TrackletConfigBuilder::TCName(unsigned int iSeed, unsigned int iTC) { if (combinedmodules_) { - return "TP_"+iSeedStr(iSeed)+iTCStr(iTC); + return "TP_" + iSeedStr(iSeed) + iTCStr(iTC); } else { - return "TC_"+iSeedStr(iSeed)+iTCStr(iTC); + return "TC_" + iSeedStr(iSeed) + iTCStr(iTC); } } std::string TrackletConfigBuilder::LayerName(unsigned int ilayer) { - return ilayer<6?("L"+numStr(ilayer)):("D"+numStr(ilayer-6)); + return ilayer < 6 ? ("L" + numStr(ilayer)) : ("D" + numStr(ilayer - 6)); } -std::string TrackletConfigBuilder::TPROJName(unsigned int iSeed, unsigned int iTC, - unsigned int ilayer, unsigned int ireg) { - return "TPROJ_"+iSeedStr(iSeed)+iTCStr(iTC)+"_"+LayerName(ilayer)+"PHI"+iTCStr(ireg); +std::string TrackletConfigBuilder::TPROJName(unsigned int iSeed, + unsigned int iTC, + unsigned int ilayer, + unsigned int ireg) { + return "TPROJ_" + iSeedStr(iSeed) + iTCStr(iTC) + "_" + LayerName(ilayer) + "PHI" + iTCStr(ireg); } std::string TrackletConfigBuilder::PRName(unsigned int ilayer, unsigned int ireg) { if (combinedmodules_) { - return "MP_"+LayerName(ilayer)+"PHI"+iTCStr(ireg); + return "MP_" + LayerName(ilayer) + "PHI" + iTCStr(ireg); } else { - return "PR_"+LayerName(ilayer)+"PHI"+iTCStr(ireg); + return "PR_" + LayerName(ilayer) + "PHI" + iTCStr(ireg); } } -void TrackletConfigBuilder::writeProjectionMemories(std::ostream& os, std::ostream& memories, std::ostream&){ - - for(unsigned int ilayer=0;ilayer "< "< " << TCName(iSeed, iTC) << ".projout" + << LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin" + << std::endl; + } + } + } } -std::string TrackletConfigBuilder::SPDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, - unsigned int l2, unsigned int ireg2, unsigned int ivm2, - unsigned int l3, unsigned int ireg3, unsigned int ivm3, - unsigned int iseed) { +std::string TrackletConfigBuilder::SPName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int iseed) { + return "SP_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" + + iRegStr(ireg2, iseed) + numStr(ivm2); +} - - return "SPD_"+LayerName(l1)+"PHI"+iRegStr(ireg1,iseed)+numStr(ivm1)+ - "_"+LayerName(l2)+"PHI"+iRegStr(ireg2,iseed)+numStr(ivm2)+ - "_"+LayerName(l3)+"PHI"+iRegStr(ireg3,iseed)+numStr(ivm3); - +std::string TrackletConfigBuilder::SPDName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int l3, + unsigned int ireg3, + unsigned int ivm3, + unsigned int iseed) { + return "SPD_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" + + iRegStr(ireg2, iseed) + numStr(ivm2) + "_" + LayerName(l3) + "PHI" + iRegStr(ireg3, iseed) + numStr(ivm3); } -std::string TrackletConfigBuilder::TEName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, - unsigned int l2, unsigned int ireg2, unsigned int ivm2, - unsigned int iseed) { - - return "TE_"+LayerName(l1)+"PHI"+iRegStr(ireg1,iseed)+numStr(ivm1)+ - "_"+LayerName(l2)+"PHI"+iRegStr(ireg2,iseed)+numStr(ivm2); - +std::string TrackletConfigBuilder::TEName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int iseed) { + return "TE_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" + + iRegStr(ireg2, iseed) + numStr(ivm2); } -std::string TrackletConfigBuilder::TEDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, - unsigned int l2, unsigned int ireg2, unsigned int ivm2, - unsigned int iseed) { - - return "TED_"+LayerName(l1)+"PHI"+iRegStr(ireg1,iseed)+numStr(ivm1)+ - "_"+LayerName(l2)+"PHI"+iRegStr(ireg2,iseed)+numStr(ivm2); - +std::string TrackletConfigBuilder::TEDName(unsigned int l1, + unsigned int ireg1, + unsigned int ivm1, + unsigned int l2, + unsigned int ireg2, + unsigned int ivm2, + unsigned int iseed) { + return "TED_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" + + iRegStr(ireg2, iseed) + numStr(ivm2); } -std::string TrackletConfigBuilder::TParName(unsigned int l1, - unsigned int l2, - unsigned int l3, - unsigned int itc) { - - return "TPAR_"+LayerName(l1)+LayerName(l2)+LayerName(l3)+iTCStr(itc); - +std::string TrackletConfigBuilder::TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) { + return "TPAR_" + LayerName(l1) + LayerName(l2) + LayerName(l3) + iTCStr(itc); } -std::string TrackletConfigBuilder::TCDName(unsigned int l1, - unsigned int l2, - unsigned int l3, - unsigned int itc) { - - return "TCD_"+LayerName(l1)+LayerName(l2)+LayerName(l3)+iTCStr(itc); - +std::string TrackletConfigBuilder::TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) { + return "TCD_" + LayerName(l1) + LayerName(l2) + LayerName(l3) + iTCStr(itc); } -std::string TrackletConfigBuilder::TPROJName(unsigned int l1, - unsigned int l2, - unsigned int l3, - unsigned int itc, - unsigned int projlayer, - unsigned int projreg) { - - return "TPROJ_"+LayerName(l1)+LayerName(l2)+LayerName(l3)+iTCStr(itc)+ - "_"+LayerName(projlayer)+"PHI"+iTCStr(projreg); - +std::string TrackletConfigBuilder::TPROJName( + unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc, unsigned int projlayer, unsigned int projreg) { + return "TPROJ_" + LayerName(l1) + LayerName(l2) + LayerName(l3) + iTCStr(itc) + "_" + LayerName(projlayer) + "PHI" + + iTCStr(projreg); } -std::string TrackletConfigBuilder::FTName(unsigned int l1, - unsigned int l2, - unsigned int l3) { - - return "FT_"+LayerName(l1)+LayerName(l2)+LayerName(l3); - +std::string TrackletConfigBuilder::FTName(unsigned int l1, unsigned int l2, unsigned int l3) { + return "FT_" + LayerName(l1) + LayerName(l2) + LayerName(l3); } -std::string TrackletConfigBuilder::TREName(unsigned int l1, unsigned int ireg1, - unsigned int l2, unsigned int ireg2, - unsigned int iseed, unsigned int count) { - - return "TRE_"+LayerName(l1)+iRegStr(ireg1,iseed)+ - LayerName(l2)+iRegStr(ireg2,iseed)+"_"+numStr(count); - +std::string TrackletConfigBuilder::TREName( + unsigned int l1, unsigned int ireg1, unsigned int l2, unsigned int ireg2, unsigned int iseed, unsigned int count) { + return "TRE_" + LayerName(l1) + iRegStr(ireg1, iseed) + LayerName(l2) + iRegStr(ireg2, iseed) + "_" + numStr(count); } -std::string TrackletConfigBuilder::STName(unsigned int l1, unsigned int ireg1, - unsigned int l2, unsigned int ireg2, - unsigned int l3, unsigned int ireg3, - unsigned int iseed, unsigned int count) { - - return "ST_"+LayerName(l1)+iRegStr(ireg1,iseed)+ - LayerName(l2)+iRegStr(ireg2,iseed)+"_"+LayerName(l3)+iRegStr(ireg3,iseed)+"_"+numStr(count); - +std::string TrackletConfigBuilder::STName(unsigned int l1, + unsigned int ireg1, + unsigned int l2, + unsigned int ireg2, + unsigned int l3, + unsigned int ireg3, + unsigned int iseed, + unsigned int count) { + return "ST_" + LayerName(l1) + iRegStr(ireg1, iseed) + LayerName(l2) + iRegStr(ireg2, iseed) + "_" + LayerName(l3) + + iRegStr(ireg3, iseed) + "_" + numStr(count); } -std::string TrackletConfigBuilder::TCNAme(unsigned int iseed, unsigned int iTC){ - return "TC_"+iSeedStr(iseed)+iTCStr(iTC); +std::string TrackletConfigBuilder::TCNAme(unsigned int iseed, unsigned int iTC) { + return "TC_" + iSeedStr(iseed) + iTCStr(iTC); } -void TrackletConfigBuilder::writeSPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules){ - - if (combinedmodules_) return; - - for(unsigned int iSeed=0;iSeed "< "< " + << TEName(l1, TE1 / NVMTE_[iSeed].first, TE1, l2, TE2 / NVMTE_[iSeed].second, TE2, iSeed) + << ".stubpairout output=> " << TCNAme(iSeed, iTC) << ".stubpairin" << std::endl; } } } } -void TrackletConfigBuilder::writeSPDMemories(std::ostream& wires, std::ostream& memories, std::ostream& modules){ - - if (!extended_) return; +void TrackletConfigBuilder::writeSPDMemories(std::ostream& wires, std::ostream& memories, std::ostream& modules) { + if (!extended_) + return; vector stubTriplets[N_SEED]; - - for(unsigned int iSeed=N_SEED_PROMPT;iSeed "< " - <0) { - unsigned int nallstub = settings_.nallstubs(ilay-1); - for (unsigned int ireg=0;ireg0) { - unsigned int nallstub = settings_.nallstubs(idisk+5); - for (unsigned int ireg=0;ireg "<< TCDName(layerdisk1,layerdisk2,layerdisk3,itc)<<".projout"< "<< "PR_"< " + << TEDName(layerdisk1, ireg1, ireg1 * nvm1 + ivm1, layerdisk2, ireg2, ireg2 * nvm2 + ivm2, iSeed) + << ".stubpairout output=> " << TREName(layerdisk1, ireg1, layerdisk2, ireg2, iSeed, count) + << ".stubpair" + << "1" + << "in" << std::endl; + } + } + } + } + } + } + unsigned int nTC = 10; + for (unsigned int itc = 0; itc < nTC; itc++) { + for (int iproj = 0; iproj < 4; iproj++) { + int ilay = settings_.projlayers(iSeed, iproj); + if (ilay > 0) { + unsigned int nallstub = settings_.nallstubs(ilay - 1); + for (unsigned int ireg = 0; ireg < nallstub; ireg++) { + memories << "TrackletProjections: " << TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, ilay - 1, ireg) + << " [54]" << std::endl; + } + } + + int idisk = settings_.projdisks(iSeed, iproj); + if (idisk > 0) { + unsigned int nallstub = settings_.nallstubs(idisk + 5); + for (unsigned int ireg = 0; ireg < nallstub; ireg++) { + memories << "TrackletProjections: " << TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, idisk + 5, ireg) + << " [54]" << std::endl; + + wires << TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, idisk + 5, ireg) << " input=> " + << TCDName(layerdisk1, layerdisk2, layerdisk3, itc) << ".projout" << LayerName(idisk + 1) << "PHI" + << iTCStr(ireg) << " output=> " + << "PR_" << LayerName(idisk + 1) << "PHI" << iTCStr(ireg) << ".projin" << std::endl; + } + } } - - memories << "TrackletParameters: " - << TParName(layerdisk1, - layerdisk2, - layerdisk3, - itc) - << " [56]"< " << trename << ".stubtripout output=> " - << TCDName(layerdisk1,layerdisk2,layerdisk3,iTC) << ".stubtriplet"<<((iST*nTC)%nST)<<"in"< PR_"< MC_"< PR_" << LayerName(ilayer) << "PHI" + << iTCStr(iReg) << ".allprojout output=> MC_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allprojin" + << std::endl; } } } -void TrackletConfigBuilder::writeCMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules){ - - if (combinedmodules_) return; - - for(unsigned int ilayer=0;ilayer ME_"< MC_"< ME_" + << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << ".matchout output=> MC_" + << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << ".matchin" << std::endl; } } - } +void TrackletConfigBuilder::writeVMPROJMemories(std::ostream& os, std::ostream& memories, std::ostream&) { + if (combinedmodules_) + return; -void TrackletConfigBuilder::writeVMPROJMemories(std::ostream& os, std::ostream& memories, std::ostream&){ - - if (combinedmodules_) return; - - for(unsigned int ilayer=0;ilayer PR_"< ME_" - << LayerName(ilayer)<<"PHI"< PR_" + << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << ".vmprojout" + << "PHI" << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << " output=> ME_" << LayerName(ilayer) << "PHI" + << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << ".vmprojin" << std::endl; } } - } - - -void TrackletConfigBuilder::writeFMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules){ +void TrackletConfigBuilder::writeFMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) { if (combinedmodules_) { - for(unsigned int ilayer=0;ilayer MP_"< FT_"< MP_" + << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed) + << ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl; + } } - } + } } else { - for(unsigned int ilayer=0;ilayer MC_"< FT_"< MC_" + << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed) + << ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl; + } } - } - } + } + } } -void TrackletConfigBuilder::writeASMemories(std::ostream& os, std::ostream& memories, std::ostream& modules){ - +void TrackletConfigBuilder::writeASMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) { if (combinedmodules_) { - //First write AS memories used by MatchProcessor - for(unsigned int ilayer=0;ilayer VMR_"< MP_"< VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MP_" + << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl; } } - - + //Next write AS memories used by TrackletProcessor - for(unsigned int ilayer=0;ilayermax) - continue; - - if (max-min>=2) { - ext="M"; - if (iReg==min) - ext="R"; - if (iReg==max) - ext="L"; - } - - if (max-min==1) { - if (nTCReg==2) { - assert(0); - if (jTCReg==0){ - if (iReg==min) - ext="R"; - if (iReg==max) - ext="B"; - } - if (jTCReg==1){ - if (iReg==min) - ext="A"; - if (iReg==max) - ext="L"; - } - } - if (nTCReg==3) { - if (jTCReg==0){ - if (iReg==min) - ext="A"; - if (iReg==max) - ext="F"; - } - if (jTCReg==1){ - if (iReg==min) - ext="E"; - if (iReg==max) - ext="D"; - } - if (jTCReg==2){ - if (iReg==min) - ext="C"; - if (iReg==max) - ext="B"; - } - } - } - //cout << "iseed ratio max min : "<5) { - ext="_O"+ext; - } else { - ext="_D"+ext; - } - - nmem++; - if (inner) { - memories << "AllInnerStubs: "; - } else { - memories << "AllStubs: "; - } - memories << "AS_"< VMR_"< TP_"< max) + continue; + + if (max - min >= 2) { + ext = "M"; + if (iReg == min) + ext = "R"; + if (iReg == max) + ext = "L"; + } + + if (max - min == 1) { + if (nTCReg == 2) { + assert(0); + if (jTCReg == 0) { + if (iReg == min) + ext = "R"; + if (iReg == max) + ext = "B"; + } + if (jTCReg == 1) { + if (iReg == min) + ext = "A"; + if (iReg == max) + ext = "L"; + } + } + if (nTCReg == 3) { + if (jTCReg == 0) { + if (iReg == min) + ext = "A"; + if (iReg == max) + ext = "F"; + } + if (jTCReg == 1) { + if (iReg == min) + ext = "E"; + if (iReg == max) + ext = "D"; + } + if (jTCReg == 2) { + if (iReg == min) + ext = "C"; + if (iReg == max) + ext = "B"; + } + } + } + //cout << "iseed ratio max min : "< 5) { + ext = "_O" + ext; + } else { + ext = "_D" + ext; + } + + nmem++; + if (inner) { + memories << "AllInnerStubs: "; + } else { + memories << "AllStubs: "; + } + memories << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ext << " [42]" << std::endl; + os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ext << " input=> VMR_" << LayerName(ilayer) + << "PHI" << iTCStr(iReg) << ".all" << (inner ? "inner" : "") << "stubout output=> TP_" << iSeedStr(iSeed) + << iTCStr(iTC); + if (inner) { + os << ".innerallstubin" << std::endl; + } else { + os << ".outerallstubin" << std::endl; + } + } + } } } } else { //First write AS memories used by MatchCalculator - for(unsigned int ilayer=0;ilayer VMR_"< MC_"< VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MC_" + << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl; } } - - + //Next write AS memories used by TrackletCalculator - for(unsigned int ilayer=0;ilayer VMR_"< TC_"< VMR_" + << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> TC_" << iSeedStr(iSeed) + << iTCStr(iTC); + if (ilayer == l1) { + os << ".innerallstubin" << std::endl; + } else { + os << ".outerallstubin" << std::endl; + } + } + } + } } } } } -void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& memories, std::ostream&){ - +void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& memories, std::ostream&) { if (combinedmodules_) { //First write VMS memories used by MatchProcessor - for(unsigned int ilayer=0;ilayer VMR_"< MP_"< VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg) + << " output=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstubin" << std::endl; } } - + //Next write VMS memories used by TrackletProcessor - for(unsigned int iSeed=0;iSeed VMR_"< TP_"< VMR_" + << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstubout_seed_" << iSeed << " output=> TP_" + << LayerName(l1) << LayerName(l2) << iTCStr(iReg * nTCReg + iTC) << ".outervmstubin" << std::endl; + } } } } else { //First write VMS memories used by MatchEngine - for(unsigned int ilayer=0;ilayer VMR_"< ME_"< VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg) + << iVMME + 1 << " output=> ME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << iVMME + 1 << ".vmstubin" + << std::endl; } } - + //Next write VMS memories used by MatchCalculator - for(unsigned int iSeed=0;iSeed VMR_"< TE_"< VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg) + << iVMTE + 1 << " output=> TE_" << LayerName(l1) << "PHI" << iRegStr(TE1 / NVMTE1, iSeed) << TE1 + 1 + << "_" << LayerName(l2) << "PHI" << iRegStr(TE2 / NVMTE2, iSeed) << TE2 + 1; + if (innerouterseed == 0) { + os << ".innervmstubin" << std::endl; + } else { + os << ".outervmstubin" << std::endl; + } + } + } } } } } -void TrackletConfigBuilder::writeTPARMemories(std::ostream& os, std::ostream& memories, std::ostream& modules){ - +void TrackletConfigBuilder::writeTPARMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) { if (combinedmodules_) { - for(unsigned int iSeed=0;iSeed TP_"< FT_"< TP_" << iSeedStr(iSeed) << iTCStr(iTP) + << ".trackpar output=> FT_" << iSeedStr(iSeed) << ".tparin" << std::endl; } } } else { - for(unsigned int iSeed=0;iSeed TC_"< FT_"< TC_" << iSeedStr(iSeed) << iTCStr(iTC) + << ".trackpar output=> FT_" << iSeedStr(iSeed) << ".tparin" << std::endl; } } } } -void TrackletConfigBuilder::writeTFMemories(std::ostream& os, std::ostream& memories, std::ostream& modules){ - - for(unsigned int iSeed=0;iSeed FT_"< PD.trackin"< FT_" << iSeedStr(iSeed) << ".trackout output=> PD.trackin" << std::endl; } - } -void TrackletConfigBuilder::writeCTMemories(std::ostream& os, std::ostream& memories, std::ostream& modules){ - - modules << "PurgeDuplicate: PD"< PD.trackout output=>"< PD.trackout output=>" << std::endl; + } +} +void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memories, std::ostream&) { //FIXME these should not be hardcoded - but for now wanted to avoid reading file string dtcname[52]; unsigned int layerdisk[52]; @@ -1154,111 +1027,255 @@ void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memo double phimax[52]; //FIXME layerdisk numbering should be 0 to 10 - - dtcname[0] ="PS10G_1"; layerdisk[0] =0; phimin[0] = 0.304273; phimax[0] = 0.742925; - dtcname[1] ="PS10G_1"; layerdisk[1] =6; phimin[1] = -0.185672; phimax[1] = 0.883803; - dtcname[2] ="PS10G_1"; layerdisk[2] =8; phimin[2] = -0.132414; phimax[2] = 0.830545; - dtcname[3] ="PS10G_1"; layerdisk[3] =10; phimin[3] = -0.132414; phimax[3] = 0.830545; - dtcname[4] ="PS10G_2"; layerdisk[4] =0; phimin[4] = -0.0133719; phimax[4] = 0.715599; - dtcname[5] ="PS10G_2"; layerdisk[5] =7; phimin[5] = -0.110089; phimax[5] = 0.808221; - dtcname[6] ="PS10G_2"; layerdisk[6] =9; phimin[6] = -0.132414; phimax[6] = 0.830545; - dtcname[7] ="PS10G_3"; layerdisk[7] = 1; phimin[7] = -0.11381; phimax[7] = 0.822812; - dtcname[8] ="PS10G_3"; layerdisk[8] = 7; phimin[8] = -0.185672; phimax[8] = 0.883803; - dtcname[9] ="PS10G_4"; layerdisk[9] = 6; phimin[9] = -0.0823971; phimax[9] = 0.780529; - dtcname[10]="PS10G_4"; layerdisk[10]= 8; phimin[10]= -0.0963091; phimax[10]= 0.794441; - dtcname[11]="PS10G_4"; layerdisk[11]= 10; phimin[11]= -0.0963091; phimax[11]= 0.794441; - dtcname[12]="PS_1"; layerdisk[12]= 2; phimin[12]= 0.0827748; phimax[12]= 0.615357; - dtcname[13]="PS_1"; layerdisk[13]= 7; phimin[13]= -0.0823971; phimax[13]= 0.780529; - dtcname[14]="PS_2"; layerdisk[14]= 2; phimin[14]= -0.0917521; phimax[14]= 0.614191; - dtcname[15]="PS_2"; layerdisk[15]= 9; phimin[15]= -0.0963091; phimax[15]= 0.794441; - dtcname[16]="2S_1"; layerdisk[16]= 3; phimin[16]= -0.0246209; phimax[16]= 0.763311; - dtcname[17]="2S_1"; layerdisk[17]= 4; phimin[17]= 0.261875; phimax[17]= 0.403311; - dtcname[18]="2S_2"; layerdisk[18]= 4; phimin[18]= -0.0542445; phimax[18]= 0.715509; - dtcname[19]="2S_3"; layerdisk[19]= 5; phimin[19]= 0.0410126; phimax[19]= 0.730605; - dtcname[20]="2S_4"; layerdisk[20]= 5; phimin[20]= -0.0428961; phimax[20]= 0.693862; - dtcname[21]="2S_4"; layerdisk[21]= 8; phimin[21]= -0.0676705; phimax[21]= 0.765802; - dtcname[22]="2S_5"; layerdisk[22]= 6; phimin[22]= -0.0648206; phimax[22]= 0.762952; - dtcname[23]="2S_5"; layerdisk[23]= 9; phimin[23]= -0.0676705; phimax[23]= 0.765802; - dtcname[24]="2S_6"; layerdisk[24]= 7; phimin[24]= -0.0648206; phimax[24]= 0.762952; - dtcname[25]="2S_6"; layerdisk[25]= 10; phimin[25]= -0.0676705; phimax[25]= 0.765802; - dtcname[26]="negPS10G_1"; layerdisk[26]= 0; phimin[26]= -0.023281; phimax[26]= 0.372347; - dtcname[27]="negPS10G_1"; layerdisk[27]= 6; phimin[27]= -0.185672; phimax[27]= 0.883803; - dtcname[28]="negPS10G_1"; layerdisk[28]= 8; phimin[28]= -0.132414; phimax[28]= 0.830545; - dtcname[29]="negPS10G_1"; layerdisk[29]= 10; phimin[29]= -0.132414; phimax[29]= 0.830545; - dtcname[30]="negPS10G_2"; layerdisk[30]= 0; phimin[30]= -0.0133719; phimax[30]= 0.715599; - dtcname[31]="negPS10G_2"; layerdisk[31]= 7; phimin[31]= -0.110089; phimax[31]= 0.808221; - dtcname[32]="negPS10G_2"; layerdisk[32]= 9; phimin[32]= -0.132414; phimax[32]= 0.830545; - dtcname[33]="negPS10G_3"; layerdisk[33]= 1; phimin[33]= -0.115834; phimax[33]= 0.813823; - dtcname[34]="negPS10G_3"; layerdisk[34]= 7; phimin[34]= -0.185672; phimax[34]= 0.883803; - dtcname[35]="negPS10G_4"; layerdisk[35]= 6; phimin[35]= -0.0823971; phimax[35]= 0.780529; - dtcname[36]="negPS10G_4"; layerdisk[36]= 8; phimin[36]= -0.0963091; phimax[36]= 0.794441; - dtcname[37]="negPS10G_4"; layerdisk[37]= 10; phimin[37]= -0.0963091; phimax[37]= 0.794441; - dtcname[38]="negPS_1"; layerdisk[38]= 2; phimin[38]= -0.0961318; phimax[38]= 0.445198; - dtcname[39]="negPS_1"; layerdisk[39]= 7; phimin[39]= -0.0823971; phimax[39]= 0.780529; - dtcname[40]="negPS_2"; layerdisk[40]= 2; phimin[40]= -0.0917521; phimax[40]= 0.614191; - dtcname[41]="negPS_2"; layerdisk[41]= 9; phimin[41]= -0.0963091; phimax[41]= 0.794441; - dtcname[42]="neg2S_1"; layerdisk[42]= 3; phimin[42]= -0.0246209; phimax[42]= 0.763311; - dtcname[43]="neg2S_1"; layerdisk[43]= 4; phimin[43]= 0.261875; phimax[43]= 0.403311; - dtcname[44]="neg2S_2"; layerdisk[44]= 4; phimin[44]= -0.0542445; phimax[44]= 0.715509; - dtcname[45]="neg2S_3"; layerdisk[45]= 5; phimin[45]= 0.0410126; phimax[45]= 0.730605; - dtcname[46]="neg2S_4"; layerdisk[46]= 5; phimin[46]= -0.0428961; phimax[46]= 0.693862; - dtcname[47]="neg2S_4"; layerdisk[47]= 8; phimin[47]= -0.06767; phimax[47]= 0.765802; - dtcname[48]="neg2S_5"; layerdisk[48]= 6; phimin[48]= -0.0648201; phimax[48]= 0.762952; - dtcname[49]="neg2S_5"; layerdisk[49]= 9; phimin[49]= -0.06767; phimax[49]= 0.765802; - dtcname[50]="neg2S_6"; layerdisk[50]= 7; phimin[50]= -0.0648201; phimax[50]= 0.762952; - dtcname[51]="neg2S_6"; layerdisk[51]= 10; phimin[51]= -0.06767; phimax[51]= 0.765802; - - - double dphi=0.5*dphisectorHG_-M_PI/NSector_; - - for(unsigned int i=0;i<52;i++) { - - double phimintmp=phimin[i]+dphi; - double phimaxtmp=phimax[i]+dphi; - - for(unsigned int iReg=0; iRegphimaxtmp && - allStubs_[layerdisk[i]][iReg].second output=> VMR_"< phimaxtmp && allStubs_[layerdisk[i]][iReg].second < phimintmp) + continue; + + if (allStubs_[layerdisk[i]][iReg].second < phimaxtmp) { + memories << "InputLink: IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_A" + << " [36]" << std::endl; + os << "IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_A" + << " input=> output=> VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; } - - if (allStubs_[layerdisk[i]][iReg].first>phimintmp) { - memories << "InputLink: IL_"< output=> VMR_"< phimintmp) { + memories << "InputLink: IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_B" + << " [36]" << std::endl; + os << "IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_B" + << " input=> output=> VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; } - } } - } -void TrackletConfigBuilder::writeAll(std::ostream& wires, std::ostream& memories, std::ostream& modules){ - - writeILMemories(wires,memories,modules); - writeASMemories(wires,memories,modules); - writeVMSMemories(wires,memories,modules); - writeSPMemories(wires,memories,modules); - writeSPDMemories(wires,memories,modules); - writeProjectionMemories(wires,memories,modules); - writeTPARMemories(wires,memories,modules); - writeVMPROJMemories(wires,memories,modules); - writeAPMemories(wires,memories,modules); - writeCMMemories(wires,memories,modules); - writeFMMemories(wires,memories,modules); - writeTFMemories(wires,memories,modules); - writeCTMemories(wires,memories,modules); - +void TrackletConfigBuilder::writeAll(std::ostream& wires, std::ostream& memories, std::ostream& modules) { + writeILMemories(wires, memories, modules); + writeASMemories(wires, memories, modules); + writeVMSMemories(wires, memories, modules); + writeSPMemories(wires, memories, modules); + writeSPDMemories(wires, memories, modules); + writeProjectionMemories(wires, memories, modules); + writeTPARMemories(wires, memories, modules); + writeVMPROJMemories(wires, memories, modules); + writeAPMemories(wires, memories, modules); + writeCMMemories(wires, memories, modules); + writeFMMemories(wires, memories, modules); + writeTFMemories(wires, memories, modules); + writeCTMemories(wires, memories, modules); } - - - diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc index fe5149f39e455..1f2146bfc5c3b 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc @@ -122,8 +122,11 @@ void TrackletEngine::execute() { if (!(pttableinner_[ptinnerindex] && pttableouter_[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()); + << settings_.benddecode( + innervmstub.bend().value(), layerdisk1_, innervmstub.isPSmodule()) + << " " + << settings_.benddecode( + outervmstub.bend().value(), layerdisk2_, outervmstub.isPSmodule()); } continue; } @@ -267,9 +270,8 @@ void TrackletEngine::setVMPhiBin() { } void TrackletEngine::writeTETable() { + ofstream outstubptinnercut = openfile(settings_.tablePath(), getName() + "_stubptinnercut.tab", __FILE__, __LINE__); - ofstream outstubptinnercut=openfile(settings_.tablePath(), getName() + "_stubptinnercut.tab", __FILE__, __LINE__); - outstubptinnercut << "{" << endl; for (unsigned int i = 0; i < pttableinner_.size(); i++) { if (i != 0) @@ -279,7 +281,7 @@ void TrackletEngine::writeTETable() { outstubptinnercut << endl << "};" << endl; outstubptinnercut.close(); - ofstream outstubptoutercut=openfile(settings_.tablePath(), getName() + "_stubptoutercut.tab", __FILE__, __LINE__); + ofstream outstubptoutercut = openfile(settings_.tablePath(), getName() + "_stubptoutercut.tab", __FILE__, __LINE__); outstubptoutercut << "{" << endl; for (unsigned int i = 0; i < pttableouter_.size(); i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc index 850244d4985c8..4b18c80a9aa36 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc @@ -174,21 +174,20 @@ void TrackletEngineDisplaced::execute() { 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()); + 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 + //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); @@ -258,9 +257,10 @@ void TrackletEngineDisplaced::execute() { 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()); + 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; } @@ -338,9 +338,10 @@ void TrackletEngineDisplaced::execute() { 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()); + 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; } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc index b1c2eae99af54..fa1583ec13cab 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc @@ -5,142 +5,147 @@ using namespace std; using namespace trklet; -TrackletEngineUnit::TrackletEngineUnit(const Settings* const settings, unsigned int nbitsfinephi, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int iSeed, unsigned int nbitsfinephidiff, unsigned int iAllStub, std::vector const& pttableinner, std::vector const& pttableouter, VMStubsTEMemory* outervmstubs) - : settings_(settings), candpairs_(3) { - idle_=true; - nbitsfinephi_=nbitsfinephi; - layerdisk2_=layerdisk2; - layerdisk1_=layerdisk1; - iSeed_=iSeed; - nbitsfinephidiff_=nbitsfinephidiff; - iAllStub_=iAllStub; - pttableinner_=pttableinner; - pttableouter_=pttableouter; - outervmstubs_=outervmstubs; +TrackletEngineUnit::TrackletEngineUnit(const Settings* const settings, + unsigned int nbitsfinephi, + unsigned int layerdisk1, + unsigned int layerdisk2, + unsigned int iSeed, + unsigned int nbitsfinephidiff, + unsigned int iAllStub, + std::vector const& pttableinner, + std::vector const& pttableouter, + VMStubsTEMemory* outervmstubs) + : settings_(settings), candpairs_(3) { + idle_ = true; + nbitsfinephi_ = nbitsfinephi; + layerdisk2_ = layerdisk2; + layerdisk1_ = layerdisk1; + iSeed_ = iSeed; + nbitsfinephidiff_ = nbitsfinephidiff; + iAllStub_ = iAllStub; + pttableinner_ = pttableinner; + pttableouter_ = pttableouter; + outervmstubs_ = outervmstubs; } - -void TrackletEngineUnit::init(const TEData& tedata){ - tedata_=tedata; - nreg_=0; - istub_=0; - idle_=false; - assert(tedata_.regions_.size()>0); - std::tie(next_,ireg_,nstub_) = tedata_.regions_[0]; +void TrackletEngineUnit::init(const TEData& tedata) { + tedata_ = tedata; + nreg_ = 0; + istub_ = 0; + idle_ = false; + assert(tedata_.regions_.size() > 0); + std::tie(next_, ireg_, nstub_) = tedata_.regions_[0]; } -void TrackletEngineUnit::reset(){ - idle_=true; - goodpair_=false; - goodpair__=false; +void TrackletEngineUnit::reset() { + idle_ = true; + goodpair_ = false; + goodpair__ = false; candpairs_.reset(); } -void TrackletEngineUnit::step(bool print, int istep,int iTE){ - - +void TrackletEngineUnit::step(bool print, int istep, int iTE) { //if (print) cout << "istep="<allStubIndex().value()<<" "<allStubIndex().value()<allStubIndex().value() << " " << candpair__.second->allStubIndex().value() << endl; candpairs_.store(candpair__); } - - goodpair__=goodpair_; - candpair__=candpair_; - goodpair_=false; + goodpair__ = goodpair_; + candpair__ = candpair_; + + goodpair_ = false; - if (idle_||nearfull_) { - if (print) cout << "istep="<nVMStubsBinned(ireg_*nbins+ibin)); - + int ibin = tedata_.start_ + next_; + + int nbins = (1 << NFINERZBITS); + + assert(istub_ < outervmstubs_->nVMStubsBinned(ireg_ * nbins + ibin)); + const VMStubTE& outervmstub = outervmstubs_->getVMStubTEBinned(ireg_ * nbins + ibin, istub_); - int rzbin = (outervmstub.vmbits().value() & (nbins-1)); + int rzbin = (outervmstub.vmbits().value() & (nbins - 1)); FPGAWord iphiouterbin = outervmstub.finephi(); assert(iphiouterbin == outervmstub.finephi()); - + //New code to calculate lut value int outerfinephi = iAllStub_ * (1 << (nbitsfinephi_ - settings_->nbitsallstubs(layerdisk2_))) + - ireg_ * (1 << settings_->nfinephi(1,iSeed_)) + iphiouterbin.value(); + ireg_ * (1 << settings_->nfinephi(1, iSeed_)) + iphiouterbin.value(); int idphi = outerfinephi - tedata_.innerfinephi_; - bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_- 1 ))); + bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_ - 1))); idphi = idphi & ((1 << nbitsfinephidiff_) - 1); - + if (iSeed_ >= 4) { //Also use r-position int ir = ((ibin & 3) << 1) + (rzbin >> 2); idphi = (idphi << 3) + ir; } - - if (next_!=0) - rzbin += 8; + if (next_ != 0) + rzbin += 8; - unsigned int firstDiskSeed=4; + unsigned int firstDiskSeed = 4; if (iSeed_ >= firstDiskSeed) { //Also use r-position - int ibinMask=3; //Get two least sign. bits - int ir = ((ibin & ibinMask) << 1) + (rzbin >> (NFINERZBITS-1)); - int nrbits=3; + int ibinMask = 3; //Get two least sign. bits + int ir = ((ibin & ibinMask) << 1) + (rzbin >> (NFINERZBITS - 1)); + int nrbits = 3; idphi = (idphi << nrbits) + ir; } if (next_ != 0) - rzbin += (1<>>>>>> ca9f4d8d9ec... Various fixes to comment on pull request (#68) if ((rzbin < tedata_.rzbinfirst_) || (rzbin - tedata_.rzbinfirst_ > tedata_.rzdiffmax_)) { if (settings_->debugTracklet()) { - edm::LogVerbatim("Tracklet") - << " layer-disk stub pair rejected because rbin cut : " << rzbin << " " << tedata_.rzbinfirst_ - << " " << tedata_.rzdiffmax_; + edm::LogVerbatim("Tracklet") << " layer-disk stub pair rejected because rbin cut : " << rzbin << " " + << tedata_.rzbinfirst_ << " " << tedata_.rzdiffmax_; } } else { - FPGAWord outerbend = outervmstub.bend(); - + int ptinnerindex = (idphi << tedata_.innerbend_.nbits()) + tedata_.innerbend_.value(); int ptouterindex = (idphi << outerbend.nbits()) + outerbend.value(); if (!(inrange && pttableinner_[ptinnerindex] && pttableouter_[ptouterindex])) { if (settings_->debugTracklet()) { - edm::LogVerbatim("Tracklet") <<" Stub pair rejected because of stub pt cut bends : " - << settings_->benddecode(tedata_.innerbend_.value(), layerdisk1_, tedata_.stub_->isPSmodule()) << " " - << settings_->benddecode(outerbend.value(), layerdisk2_, outervmstub.isPSmodule()); + edm::LogVerbatim("Tracklet") << " Stub pair rejected because of stub pt cut bends : " + << settings_->benddecode( + tedata_.innerbend_.value(), layerdisk1_, tedata_.stub_->isPSmodule()) + << " " + << settings_->benddecode(outerbend.value(), layerdisk2_, outervmstub.isPSmodule()); } } else { - candpair_=pair(tedata_.stub_, outervmstub.stub()); - goodpair_=true; + candpair_ = pair(tedata_.stub_, outervmstub.stub()); + goodpair_ = true; } } - if (print) cout << "istep="<allStubIndex().value()<<" "<allStubIndex().value() << " " << istub_ << " " << nstub_ + << " nreg regionsize" << nreg_ << " " << tedata_.regions_.size() << endl; istub_++; - assert(nstub_<=N_VMSTUBSMAX); - if (istub_>=nstub_) { - istub_=0; + assert(nstub_ <= N_VMSTUBSMAX); + if (istub_ >= nstub_) { + istub_ = 0; nreg_++; - if (nreg_>=tedata_.regions_.size()) { - nreg_=0; - idle_=true; + if (nreg_ >= tedata_.regions_.size()) { + nreg_ = 0; + idle_ = true; } else { - std::tie(next_,ireg_,nstub_) = tedata_.regions_[nreg_]; + std::tie(next_, ireg_, nstub_) = tedata_.regions_[nreg_]; } } - - } - diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index eeff1268a2af7..334c372a4021e 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -43,11 +43,11 @@ void TrackletEventProcessor::init(Settings const& theSettings) { } if (settings_->kphider() != globals_->ITC_L1L2()->der_phiL_final.K()) { - throw cms::Exception("Inconsistency") << "t conversion parameter inconsistency:" - <kphider()/globals_->ITC_L1L2()->der_phiL_final.K()<<"\n"; + throw cms::Exception("Inconsistency") + << "t conversion parameter inconsistency:" << settings_->kphider() / globals_->ITC_L1L2()->der_phiL_final.K() + << "\n"; } - if (settings_->debugTracklet()) { edm::LogVerbatim("Tracklet") << "========================================================= \n" << "Conversion factors for global coordinates: \n" @@ -86,7 +86,6 @@ void TrackletEventProcessor::init(Settings const& theSettings) { } if (settings_->extended()) { - ifstream inmem(settings_->memoryModulesFile().c_str()); assert(inmem.good()); @@ -95,35 +94,31 @@ void TrackletEventProcessor::init(Settings const& theSettings) { ifstream inwire(settings_->wiresFile().c_str()); assert(inwire.good()); - - configure(inwire,inmem,inproc); + + configure(inwire, inmem, inproc); } else { TrackletConfigBuilder config(*settings_); //Write configurations to file. - if (settings_->writeConfig()){ - std::ofstream wires=openfile(settings_->tablePath(), "wires.dat", __FILE__, __LINE__); - std::ofstream memories=openfile(settings_->tablePath(), "memories.dat", __FILE__, __LINE__); - std::ofstream modules=openfile(settings_->tablePath(), "modules.dat", __FILE__, __LINE__); - - config.writeAll(wires,memories,modules); + if (settings_->writeConfig()) { + std::ofstream wires = openfile(settings_->tablePath(), "wires.dat", __FILE__, __LINE__); + std::ofstream memories = openfile(settings_->tablePath(), "memories.dat", __FILE__, __LINE__); + std::ofstream modules = openfile(settings_->tablePath(), "modules.dat", __FILE__, __LINE__); + + config.writeAll(wires, memories, modules); } - + std::stringstream wires; std::stringstream memories; std::stringstream modules; - config.writeAll(wires,memories,modules); - configure(wires,memories,modules); - + config.writeAll(wires, memories, modules); + configure(wires, memories, modules); } - } - void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& inproc) { - // get the memory modules if (settings_->debugTracklet()) { edm::LogVerbatim("Tracklet") << "Will read memory modules"; @@ -147,7 +142,6 @@ void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& edm::LogVerbatim("Tracklet") << "Will read processing modules"; } - while (inproc.good()) { string procType, procName; inproc >> procType >> procName; @@ -166,7 +160,6 @@ void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& edm::LogVerbatim("Tracklet") << "Will read wiring information"; } - while (inwire.good()) { string line; getline(inwire, line); @@ -189,12 +182,9 @@ void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& sector->addWire(mem, procin, procout); } } - } - void TrackletEventProcessor::event(SLHCEvent& ev) { - globals_->event() = &ev; tracks_.clear(); @@ -208,37 +198,38 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { } cleanTimer_.stop(); - if (settings_->writeMem()) { + if (settings_->writeMem()) { sectors_[settings_->writememsect()]->writeLinkNewEvent(eventnum_); } addStubTimer_.start(); - vector layerstubs(N_LAYER+N_DISK,0); - vector layerstubssector(N_SECTOR*(N_LAYER+N_DISK),0); - + vector layerstubs(N_LAYER + N_DISK, 0); + vector layerstubssector(N_SECTOR * (N_LAYER + N_DISK), 0); + for (int j = 0; j < ev.nstubs(); j++) { L1TStub stub = ev.stub(j); - string dtc=stub.DTClink(); + string dtc = stub.DTClink(); unsigned int isector = stub.region(); layerstubs[stub.layerdisk()]++; - layerstubssector[isector*(N_LAYER+N_DISK)+stub.layerdisk()]++; - + layerstubssector[isector * (N_LAYER + N_DISK) + stub.layerdisk()]++; + sectors_[isector]->addStub(stub, dtc); } if (settings_->writeMonitorData("StubsLayerSector")) { - for (unsigned int index=0;indexofstream("stubslayersector.txt") << layerdisk << " " << sector << " " << layerstubssector[index] << endl; + for (unsigned int index = 0; index < layerstubssector.size(); index++) { + int layerdisk = index % (N_LAYER + N_DISK); + int sector = index / (N_LAYER + N_DISK); + globals_->ofstream("stubslayersector.txt") + << layerdisk << " " << sector << " " << layerstubssector[index] << endl; } } if (settings_->writeMonitorData("StubsLayer")) { - for (unsigned int layerdisk=0;layerdiskofstream("stubslayer.txt") << layerdisk << " " << layerstubs[layerdisk] << endl; } } @@ -424,7 +415,6 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { } } PDTimer_.stop(); - } void TrackletEventProcessor::printSummary() { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index 140f2e20f6aa8..9427f254f6d6e 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -16,12 +16,11 @@ using namespace std; using namespace trklet; - - TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Globals* globals, unsigned int iSector) - : TrackletCalculatorBase(name, settings, globals, iSector), tebuffer_(CircularBuffer(3),0,0,0,0), vmrtable_(settings) { - - iAllStub_=-1; + : TrackletCalculatorBase(name, settings, globals, iSector), + tebuffer_(CircularBuffer(3), 0, 0, 0, 0), + vmrtable_(settings) { + iAllStub_ = -1; for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) { vector tmp(settings_.nallstubs(ilayer), nullptr); @@ -33,8 +32,8 @@ TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Glob trackletprojdisks_.push_back(tmp); } - outervmstubs_=nullptr; - + outervmstubs_ = nullptr; + initLayerDisksandISeed(layerdisk1_, layerdisk2_, iSeed_); nbitszfinebintable_ = settings_.vmrlutzbits(layerdisk1_); @@ -45,18 +44,16 @@ TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Glob nbitsrzbin_ = NFINERZBITS; if (iSeed_ == 4 || iSeed_ == 5) nbitsrzbin_ = 2; - - + innerphibits_ = settings_.nfinephi(0, iSeed_); outerphibits_ = settings_.nfinephi(1, iSeed_); - + // set TC index - iTC_=name_[7] -'A'; - assert(iTC_ >=0 && iTC_<14); + iTC_ = name_[7] - 'A'; + assert(iTC_ >= 0 && iTC_ < 14); TCIndex_ = (iSeed_ << 4) + iTC_; assert(TCIndex_ >= 0 && TCIndex_ <= (int)settings_.ntrackletmax()); - } void TrackletProcessor::addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory) { @@ -115,45 +112,64 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { if (input == "outervmstubin") { auto* tmp = dynamic_cast(memory); assert(tmp != nullptr); - outervmstubs_=tmp; - iAllStub_=tmp->getName()[11]-'A'; - if (iSeed_==1) iAllStub_=tmp->getName()[11]-'I'; - if (iSeed_==6||iSeed_==7){ - if (tmp->getName()[11]=='X') - iAllStub_=0; - if (tmp->getName()[11]=='Y') - iAllStub_=1; - if (tmp->getName()[11]=='Z') - iAllStub_=2; - if (tmp->getName()[11]=='W') - iAllStub_=3; + outervmstubs_ = tmp; + iAllStub_ = tmp->getName()[11] - 'A'; + if (iSeed_ == 1) + iAllStub_ = tmp->getName()[11] - 'I'; + if (iSeed_ == 6 || iSeed_ == 7) { + if (tmp->getName()[11] == 'X') + iAllStub_ = 0; + if (tmp->getName()[11] == 'Y') + iAllStub_ = 1; + if (tmp->getName()[11] == 'Z') + iAllStub_ = 2; + if (tmp->getName()[11] == 'W') + iAllStub_ = 3; } - buildLUT(); //need iAllStub_ set before building the table //FIXME should be in initiall - - TrackletEngineUnit teunit(&settings_,nbitsfinephi_,layerdisk1_,layerdisk2_,iSeed_,nbitsfinephidiff_,iAllStub_,pttableinnernew_,pttableouternew_,outervmstubs_); - if (iSeed_==0) teunits_.resize(5,teunit); - if (iSeed_==1) teunits_.resize(2,teunit); - if (iSeed_==2) teunits_.resize(5,teunit); - if (iSeed_==3) teunits_.resize(3,teunit); - if (iSeed_==4) teunits_.resize(3,teunit); - if (iSeed_==5) teunits_.resize(2,teunit); - if (iSeed_==6) teunits_.resize(3,teunit); - if (iSeed_==7) teunits_.resize(2,teunit); - + buildLUT(); //need iAllStub_ set before building the table //FIXME should be in initiall + + TrackletEngineUnit teunit(&settings_, + nbitsfinephi_, + layerdisk1_, + layerdisk2_, + iSeed_, + nbitsfinephidiff_, + iAllStub_, + pttableinnernew_, + pttableouternew_, + outervmstubs_); + if (iSeed_ == 0) + teunits_.resize(5, teunit); + if (iSeed_ == 1) + teunits_.resize(2, teunit); + if (iSeed_ == 2) + teunits_.resize(5, teunit); + if (iSeed_ == 3) + teunits_.resize(3, teunit); + if (iSeed_ == 4) + teunits_.resize(3, teunit); + if (iSeed_ == 5) + teunits_.resize(2, teunit); + if (iSeed_ == 6) + teunits_.resize(3, teunit); + if (iSeed_ == 7) + teunits_.resize(2, teunit); + return; } if (input == "innerallstubin") { auto* tmp = dynamic_cast(memory); assert(tmp != nullptr); - if (innerallstubs_.size()==2) { //FIXME this should be done with better logic with reading the input stubs - innerallstubs_.insert(innerallstubs_.begin(),tmp); + if (innerallstubs_.size() == 2) { //FIXME this should be done with better logic with reading the input stubs + innerallstubs_.insert(innerallstubs_.begin(), tmp); } else { innerallstubs_.push_back(tmp); } //FIXME should be done once after all inputs are added - tebuffer_ = tuple, unsigned int , unsigned int, unsigned int, unsigned int>(CircularBuffer(3),0,0,0,innerallstubs_.size()); + tebuffer_ = tuple, unsigned int, unsigned int, unsigned int, unsigned int>( + CircularBuffer(3), 0, 0, 0, innerallstubs_.size()); return; } @@ -163,25 +179,23 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { outerallstubs_.push_back(tmp); return; } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ - << " Could not find input : " << input; + throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; } void TrackletProcessor::execute() { + bool print = (iSector_ == 3) && (getName() == "TP_L1L2D"); + print = false; - bool print=(iSector_==3)&&(getName()=="TP_L1L2D"); - print=false; - if (!settings_.useSeed(iSeed_)) return; //Not most elegant solution; but works - int donecount=0; + int donecount = 0; //Consistency checks - assert(iAllStub_>=0); - assert(iAllStub_<(int)settings_.nallstubs(layerdisk2_)); - assert(outervmstubs_!=nullptr); + assert(iAllStub_ >= 0); + assert(iAllStub_ < (int)settings_.nallstubs(layerdisk2_)); + assert(outervmstubs_ != nullptr); //used to collect performance data unsigned int countall = 0; @@ -191,18 +205,18 @@ void TrackletProcessor::execute() { unsigned int stubpairs = 0; unsigned int ntedata = 0; - + unsigned int ninnerstubs = 0; //Actual implemenation starts here - + //Reset the tebuffer std::get<0>(tebuffer_).reset(); std::get<1>(tebuffer_) = 0; std::get<2>(tebuffer_) = std::get<3>(tebuffer_); - + //Reset the teunits - for(auto& teunit:teunits_) { + for (auto& teunit : teunits_) { teunit.reset(); } @@ -212,257 +226,246 @@ void TrackletProcessor::execute() { bool goodtedata = false; bool goodtedata__ = false; bool goodtedata___ = false; - - + bool tebuffernearfull; - - for(unsigned int istep=0;istep& tedatabuffer=std::get<0>(tebuffer_); - unsigned int& istub=std::get<1>(tebuffer_); - unsigned int& imem=std::get<2>(tebuffer_); - cout << "istep="<& tedatabuffer = std::get<0>(tebuffer_); + unsigned int& istub = std::get<1>(tebuffer_); + unsigned int& imem = std::get<2>(tebuffer_); + cout << "istep=" << istep << " TEBuffer: " << istub << " " << imem << " " << tedatabuffer.rptr() << " " + << tedatabuffer.wptr(); + int k = -1; + for (auto& teunit : teunits_) { + k++; + cout << " [" << k << " " << teunit.rptr() << " " << teunit.wptr() << " " << teunit.idle() << "]"; } cout << endl; } - CircularBuffer& tedatabuffer=std::get<0>(tebuffer_); - tebuffernearfull=tedatabuffer.nearfull(); + CircularBuffer& tedatabuffer = std::get<0>(tebuffer_); + tebuffernearfull = tedatabuffer.nearfull(); // // First block here checks if there is a teunit with data that should should be used // to calculate the tracklet parameters // - TrackletEngineUnit* teunitptr=nullptr; + TrackletEngineUnit* teunitptr = nullptr; - int iTE=0; - int icount=-1; - for (auto& teunit:teunits_) { + int iTE = 0; + int icount = -1; + for (auto& teunit : teunits_) { teunit.setNearFull(); icount++; - if (!teunit.empty()){ - teunitptr=&teunit; - iTE=icount; + if (!teunit.empty()) { + teunitptr = &teunit; + iTE = icount; } } - - if (teunitptr!=nullptr) { - auto stubpair=teunitptr->read(); + + if (teunitptr != nullptr) { + auto stubpair = teunitptr->read(); stubpairs++; - + if (trackletpars_->nTracklets() >= settings_.ntrackletmax()) { - edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName(); - break; + edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName(); + break; } countall++; const Stub* innerFPGAStub = stubpair.first; const L1TStub* innerStub = innerFPGAStub->l1tstub(); - + const Stub* outerFPGAStub = stubpair.second; const L1TStub* outerStub = outerFPGAStub->l1tstub(); - + if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "TrackletProcessor execute " << getName() << "[" << iSector_ << "]"; + edm::LogVerbatim("Tracklet") << "TrackletProcessor execute " << getName() << "[" << iSector_ << "]"; } - - - bool accept = false; - if (iSeed_<4) { - if (print) cout << "istep="<(tebuffer_).read()); - if (print) std::cout << "istep="<allStubIndex().value()<(tebuffer_).read()); + if (print) + std::cout << "istep=" << istep << " TEUnit init iTE inner : " << ite << " " + << teunit.innerStub()->allStubIndex().value() << std::endl; + notemptytebuffer = false; //prevent initialzing another TE unit + } } - teunit.step(print,istep,ite); + teunit.step(print, istep, ite); } - // // The third block here checks if we have input stubs to process // // - if (goodtedata___) tedatabuffer.store(tedata___); + if (goodtedata___) + tedatabuffer.store(tedata___); - goodtedata=false; + goodtedata = false; - - unsigned int& istub=std::get<1>(tebuffer_); - unsigned int& imem=std::get<2>(tebuffer_); - unsigned int imemend=std::get<4>(tebuffer_); + unsigned int& istub = std::get<1>(tebuffer_); + unsigned int& imem = std::get<2>(tebuffer_); + unsigned int imemend = std::get<4>(tebuffer_); //if (print) cout << "istep="<getName(); + edm::LogVerbatim("Tracklet") << getName() << " Have stub in " << innerallstubs_[imem]->getName(); } - + bool negdisk = (stub->disk().value() < 0); //FIXME stub needs to contain bit for +/- z disk - FPGAWord phicorr=stub->phicorr(); - int innerfinephi=phicorr.bits(phicorr.nbits()-nbitsfinephi_,nbitsfinephi_); + FPGAWord phicorr = stub->phicorr(); + int innerfinephi = phicorr.bits(phicorr.nbits() - nbitsfinephi_, nbitsfinephi_); FPGAWord innerbend = stub->bend(); //Take the top nbitszfinebintable_ bits of the z coordinate - int indexz = (stub->z().value() >> (stub->z().nbits() - nbitszfinebintable_))&((1<z().value() >> (stub->z().nbits() - nbitszfinebintable_)) & ((1 << nbitszfinebintable_) - 1); int indexr = -1; if (layerdisk1_ > (N_LAYER - 1)) { - if (negdisk) { - indexz = ((1 << nbitszfinebintable_) - 1 ) - indexz; - } - indexr = stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_); - } else { //Take the top nbitsfinebintable_ bits of the z coordinate - indexr = (stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_))&((1<r().value() >> (stub->r().nbits() - nbitsrfinebintable_); + } else { //Take the top nbitsfinebintable_ bits of the z coordinate + indexr = (stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_)) & ((1 << nbitsrfinebintable_) - 1); } - - - int lutval=-1; - if (iSeed_ < 6 ) { //FIXME should only be one table... - lutval = vmrtable_.lookupinner(indexz, indexr); + + int lutval = -1; + if (iSeed_ < 6) { //FIXME should only be one table... + lutval = vmrtable_.lookupinner(indexz, indexr); } else { - lutval = vmrtable_.lookupinneroverlap(indexz, indexr); + lutval = vmrtable_.lookupinneroverlap(indexz, indexr); } if (lutval != -1) { - - unsigned int lutwidth = settings_.lutwidthtab(0, iSeed_); - FPGAWord lookupbits(lutval, lutwidth, true, __LINE__, __FILE__); - - int rzfinebinfirst = lookupbits.bits(0, 3); //finephi - int next = lookupbits.bits(3, 1); //next r/z bin - int start = lookupbits.bits(4, nbitsrzbin_); - int rzdiffmax = lookupbits.bits(4 + nbitsrzbin_, 3); - - if ((iSeed_ == 4 || iSeed_ == 5) && negdisk) { //TODO - need to store negative disk - start += 4; - } - int last = start + next; - - int nbins=8; - - unsigned int useregindex=(innerfinephi << innerbend.nbits()) + innerbend.value(); - if (iSeed_>=4) { - //FIXME If the lookupbits were rationally organized this would be much simpler - int ir = ((start & 3) << 1) + (rzfinebinfirst >> 2); - useregindex=(useregindex<<3)+ir; - } - - assert(useregindexnVMStubsBinned(ireg*nbins+ibin) << " stubs"; - } - assert(ireg*nbins+ibinnBin()); - int nstubs=outervmstubs_->nVMStubsBinned(ireg*nbins+ibin); - - if (print) cout << "Add to TEBuffer stub ibin ireg nstubs: "<allStubIndex().value() - <<" "<0) { - mask="1"+mask; - tedata.regions_.emplace_back(tuple(ibin-start,ireg,nstubs)); - countteall+=nstubs; - } else { - mask="0"+mask; - } - - } - } - - if (tedata.regions_.size()>0) { - //if (print) cout << "Add to TEBuffer stub : "<allStubIndex().value()<= 4) { + //FIXME If the lookupbits were rationally organized this would be much simpler + int ir = ((start & 3) << 1) + (rzfinebinfirst >> 2); + useregindex = (useregindex << 3) + ir; + } + + assert(useregindex < useregion_.size()); + unsigned int usereg = useregion_[useregindex]; + + tedata.regions_.clear(); + tedata.stub_ = stub; + tedata.rzbinfirst_ = rzfinebinfirst; + tedata.start_ = start; + tedata.innerfinephi_ = innerfinephi; + tedata.rzdiffmax_ = rzdiffmax; + tedata.innerbend_ = innerbend; + + std::string mask = ""; + + for (int ibin = start; ibin <= last; ibin++) { + for (unsigned int ireg = 0; ireg < settings_.nvmte(1, iSeed_); ireg++) { + assert(ireg < 8); + if (!(usereg & (1 << ireg))) { + mask = "0" + mask; + continue; + } + + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " looking for matching stub in bin " << ibin << " with " + << outervmstubs_->nVMStubsBinned(ireg * nbins + ibin) << " stubs"; + } + assert(ireg * nbins + ibin < outervmstubs_->nBin()); + int nstubs = outervmstubs_->nVMStubsBinned(ireg * nbins + ibin); + + if (print) + cout << "Add to TEBuffer stub ibin ireg nstubs: " << stub->allStubIndex().value() << " " << ibin << " " + << ireg << " " << nstubs << endl; + + if (nstubs > 0) { + mask = "1" + mask; + tedata.regions_.emplace_back(tuple(ibin - start, ireg, nstubs)); + countteall += nstubs; + } else { + mask = "0" + mask; + } + } + } + + if (tedata.regions_.size() > 0) { + //if (print) cout << "Add to TEBuffer stub : "<allStubIndex().value()<= innerallstubs_[imem]->nStubs()) { - istub=0; - imem++; + istub = 0; + imem++; } - } else if ((!tebuffernearfull) && imem < imemend && istub==0) { + } else if ((!tebuffernearfull) && imem < imemend && istub == 0) { imem++; } goodtedata___ = goodtedata__; goodtedata__ = goodtedata; - + tedata___ = tedata__; tedata__ = tedata; @@ -470,26 +473,25 @@ void TrackletProcessor::execute() { // stop looping over istep if done // - bool done=true; + bool done = true; - if (imem4) { + if (donecount > 4) { break; } - } <<<<<<< HEAD @@ -497,88 +499,85 @@ void TrackletProcessor::execute() { // // Done with processing - collect performance statistics // - + if (settings_.writeMonitorData("TP")) { - globals_->ofstream("trackletprocessor.txt") << getName() - << " " << ninnerstubs //# inner stubs - << " " << outervmstubs_->nVMStubs() //# outer stubs - << " " << countteall //# pairs tried in TE - << " " << stubpairs //# stubs pairs - << " " << countsel //# tracklets found - << endl; + globals_->ofstream("trackletprocessor.txt") << getName() << " " << ninnerstubs //# inner stubs + << " " << outervmstubs_->nVMStubs() //# outer stubs + << " " << countteall //# pairs tried in TE + << " " << stubpairs //# stubs pairs + << " " << countsel //# tracklets found + << endl; } ======= -void TrackletProcessor::writeTETable() { - ofstream outstubptinnercut; - outstubptinnercut.open(getName() + "_stubptinnercut.tab"); - outstubptinnercut << "{" << endl; - // the below is outcommented as the writing of these tables are currently not implemented, to be adressed - //for(unsigned int i=0;i>>>>>> fd1f230d81e... part one of PR review fixes for TrackFindingTracklet package } - - void TrackletProcessor::buildLUT() { - //number of fine phi bins in sector - int nfinephibins=settings_.nallstubs(layerdisk2_)*settings_.nvmte(1,iSeed_)*(1<5) { - if (iSeed_==6) { - rmax=settings_.rmaxdiskl1overlapvm(); - } - if (iSeed_==7) { - rmax=settings_.rmaxdiskvm(); -======= if (iSeed_ > 5) { if (iSeed_ == 6) { rmax = settings_.rmaxdiskl1overlapvm(); - } else if (iSeed_ == 7) { + } + if (iSeed_ == 7) { rmax = settings_.rmaxdiskvm(); +======= + if (iSeed_ > 5) { + if (iSeed_ == 6) { + rmax = settings_.rmaxdiskl1overlapvm(); + } else if (iSeed_ == 7) { + rmax = settings_.rmaxdiskvm(); >>>>>>> fd1f230d81e... part one of PR review fixes for TrackFindingTracklet package } - rmin=settings_.rmean(layerdisk1_); + rmin = settings_.rmean(layerdisk1_); } else { - rmax=settings_.rmaxdiskvm(); - rmin=rmax*settings_.zmean(layerdisk2_-6-1)/settings_.zmean(layerdisk2_-6); + rmax = settings_.rmaxdiskvm(); + rmin = rmax * settings_.zmean(layerdisk2_ - 6 - 1) / settings_.zmean(layerdisk2_ - 6); } } - double dphimax=asin(0.5*settings_.maxrinv()*rmax)-asin(0.5*settings_.maxrinv()*rmin); + double dphimax = asin(0.5 * settings_.maxrinv() * rmax) - asin(0.5 * settings_.maxrinv() * rmin); - int nbins=2.0*(dphimax/dfinephi+1.0); - - nbitsfinephidiff_=log(nbins)/log(2.0)+1; - - nbitsfinephi_=settings_.nbitsallstubs(layerdisk2_)+settings_.nbitsvmte(1,iSeed_)+settings_.nfinephi(1,iSeed_); + int nbins = 2.0 * (dphimax / dfinephi + 1.0); + + nbitsfinephidiff_ = log(nbins) / log(2.0) + 1; + + nbitsfinephi_ = settings_.nbitsallstubs(layerdisk2_) + settings_.nbitsvmte(1, iSeed_) + settings_.nfinephi(1, iSeed_); int outerrbits = 3; if (iSeed_ < 4) { @@ -586,10 +585,10 @@ void TrackletProcessor::buildLUT() { } int outerrbins = (1 << outerrbits); - + double dphi[2]; double router[2]; - + unsigned int nbendbitsinner = 3; unsigned int nbendbitsouter = 3; if (iSeed_ == 2) { @@ -598,157 +597,155 @@ void TrackletProcessor::buildLUT() { nbendbitsinner = 4; nbendbitsouter = 4; } - - int nbinsfinephidiff = (1<=nbinsfinephidiff/2) { - iphidiff=iphibin-nbinsfinephidiff; + int iphidiff = iphibin; + if (iphibin >= nbinsfinephidiff / 2) { + iphidiff = iphibin - nbinsfinephidiff; } //min and max dphi - dphi[0] = (iphidiff-1.5)*dfinephi; - dphi[1] = (iphidiff+1.5)*dfinephi; + dphi[0] = (iphidiff - 1.5) * dfinephi; + dphi[1] = (iphidiff + 1.5) * dfinephi; for (int irouterbin = 0; irouterbin < outerrbins; irouterbin++) { if (iSeed_ >= 4) { - router[0] = settings_.rmindiskvm() + - irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; - router[1] = settings_.rmindiskvm() + - (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; + router[0] = + settings_.rmindiskvm() + irouterbin * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; + router[1] = + settings_.rmindiskvm() + (irouterbin + 1) * (settings_.rmaxdiskvm() - settings_.rmindiskvm()) / outerrbins; } else { - router[0] = settings_.rmean(layerdisk2_); - router[1] = settings_.rmean(layerdisk2_); + router[0] = settings_.rmean(layerdisk2_); + router[1] = settings_.rmean(layerdisk2_); } - + double bendinnermin = 20.0; double bendinnermax = -20.0; double bendoutermin = 20.0; double bendoutermax = -20.0; double rinvmin = 1.0; for (int i2 = 0; i2 < 2; i2++) { - for (int i3 = 0; i3 < 2; i3++) { - double rinner = 0.0; - if (iSeed_ == 4 || iSeed_ == 5) { - rinner = router[i3] * settings_.zmean(layerdisk1_ - N_LAYER) / settings_.zmean(layerdisk2_ - N_LAYER); - } else { - rinner = settings_.rmean(layerdisk1_); - } - double rinv1 = rinv(0.0, -dphi[i2], rinner, router[i3]); - double pitchinner = - (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double pitchouter = - (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); - double abendinner = bendstrip(rinner, rinv1, pitchinner); - double abendouter = bendstrip(router[i3], rinv1, pitchouter); - if (abendinner < bendinnermin) - bendinnermin = abendinner; - if (abendinner > bendinnermax) - bendinnermax = abendinner; - if (abendouter < bendoutermin) - bendoutermin = abendouter; - if (abendouter > bendoutermax) - bendoutermax = abendouter; - if (std::abs(rinv1) < rinvmin) { - rinvmin = std::abs(rinv1); - } - } + for (int i3 = 0; i3 < 2; i3++) { + double rinner = 0.0; + if (iSeed_ == 4 || iSeed_ == 5) { + rinner = router[i3] * settings_.zmean(layerdisk1_ - N_LAYER) / settings_.zmean(layerdisk2_ - N_LAYER); + } else { + rinner = settings_.rmean(layerdisk1_); + } + double rinv1 = rinv(0.0, -dphi[i2], rinner, router[i3]); + double pitchinner = (rinner < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); + double pitchouter = + (router[i3] < settings_.rcrit()) ? settings_.stripPitch(true) : settings_.stripPitch(false); + double abendinner = bendstrip(rinner, rinv1, pitchinner); + double abendouter = bendstrip(router[i3], rinv1, pitchouter); + if (abendinner < bendinnermin) + bendinnermin = abendinner; + if (abendinner > bendinnermax) + bendinnermax = abendinner; + if (abendouter < bendoutermin) + bendoutermin = abendouter; + if (abendouter > bendoutermax) + bendoutermax = abendouter; + if (std::abs(rinv1) < rinvmin) { + rinvmin = std::abs(rinv1); + } + } } - + bool passptcut = rinvmin < settings_.rinvcutte(); - + for (int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) { - double bend = settings_.benddecode(ibend, layerdisk1_, nbendbitsinner == 3); - - bool passinner = bend <= bendinnermax + settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3) && - bend >= bendinnermin - settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3); - pttableinnernew_.push_back(passinner && passptcut); + double bend = settings_.benddecode(ibend, layerdisk1_, nbendbitsinner == 3); + + bool passinner = bend <= bendinnermax + settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3) && + bend >= bendinnermin - settings_.bendcutte(ibend, layerdisk1_, nbendbitsinner == 3); + pttableinnernew_.push_back(passinner && passptcut); } - + for (int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) { - double bend = settings_.benddecode(ibend, layerdisk2_, nbendbitsouter == 3); - - bool passouter = bend <= bendoutermax + settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3) && - bend >= bendoutermin - settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3); - pttableouternew_.push_back(passouter && passptcut); + double bend = settings_.benddecode(ibend, layerdisk2_, nbendbitsouter == 3); + + bool passouter = bend <= bendoutermax + settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3) && + bend >= bendoutermin - settings_.bendcutte(ibend, layerdisk2_, nbendbitsouter == 3); + pttableouternew_.push_back(passouter && passptcut); } } } - int nirbits=0; - if (iSeed_>=4) - nirbits=3; - - int nregmax=0; - - for(int innerfinephi=0;innerfinephi<(1<=-(1<<(nbitsfinephidiff_-1))); - if (idphi<0) idphi=idphi+(1<=4) - idphi1=(idphi<<3)+ir; - int ptinnerindexnew = (idphi1 << nbendbitsinner) + innerbend; - match=match||(inrange && pttableinnernew_[ptinnerindexnew]); - } - if (match&&ir<3) - nreg++; - if (match) { - usereg=usereg|(1<nregmax) - nregmax=nreg; + int nirbits = 0; + if (iSeed_ >= 4) + nirbits = 3; + + int nregmax = 0; + + for (int innerfinephi = 0; innerfinephi < (1 << nbitsfinephi_); innerfinephi++) { + for (int innerbend = 0; innerbend < (1 << nbendbitsinner); innerbend++) { + for (int ir = 0; ir < (1 << nirbits); ir++) { + int nreg = 0; + unsigned int usereg = 0; + for (unsigned int ireg = 0; ireg < settings_.nvmte(1, iSeed_); ireg++) { + bool match = false; + for (int ifinephiouter = 0; ifinephiouter < (1 << settings_.nfinephi(1, iSeed_)); ifinephiouter++) { + int outerfinephi = iAllStub_ * (1 << (nbitsfinephi_ - settings_.nbitsallstubs(layerdisk2_))) + + ireg * (1 << settings_.nfinephi(1, iSeed_)) + ifinephiouter; + int idphi = outerfinephi - innerfinephi; + bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_ - 1))); + if (idphi < 0) + idphi = idphi + (1 << nbitsfinephidiff_); + int idphi1 = idphi; + if (iSeed_ >= 4) + idphi1 = (idphi << 3) + ir; + int ptinnerindexnew = (idphi1 << nbendbitsinner) + innerbend; + match = match || (inrange && pttableinnernew_[ptinnerindexnew]); + } + if (match && ir < 3) + nreg++; + if (match) { + usereg = usereg | (1 << ireg); + } + } + + useregion_.push_back(usereg); + if (nreg > nregmax) + nregmax = nreg; } - } + } } if (settings_.writeTable()) { ofstream out; - out.open(settings_.tablePath()+getName() +"_usereg.tab"); + out.open(settings_.tablePath() + getName() + "_usereg.tab"); out << "{" << endl; for (unsigned int i = 0; i < useregion_.size(); i++) { if (i != 0) { - out << "," << endl; + out << "," << endl; } out << useregion_[i]; } out << endl << "};" << endl; out.close(); - ofstream outstubptinnercut; - outstubptinnercut.open(settings_.tablePath()+getName() + "_stubptinnercut.tab"); + outstubptinnercut.open(settings_.tablePath() + getName() + "_stubptinnercut.tab"); outstubptinnercut << "{" << endl; - for(unsigned int i=0;ibend().nbits(); - if (layerdisk_ >= N_LAYER) + 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); + 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); assert(vmstubsMEPHI_[ivmPlus] != nullptr); vmstubsMEPHI_[ivmPlus]->addStub(vmstub, vmbin); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc index 25ea37c2b4255..04dd5e40b86fd 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc @@ -28,8 +28,7 @@ VMRouterCM::VMRouterCM(string name, Settings const& settings, Globals* global, u nbitszfinebintable_ = settings_.vmrlutzbits(layerdisk_); nbitsrfinebintable_ = settings_.vmrlutrbits(layerdisk_); - nvmmebins_=settings_.NLONGVMBINS()*((layerdisk_>=6)?2:1); //number of long z/r bins in VM - + nvmmebins_ = settings_.NLONGVMBINS() * ((layerdisk_ >= 6) ? 2 : 1); //number of long z/r bins in VM } void VMRouterCM::addOutput(MemoryBase* memory, string output) { @@ -41,8 +40,8 @@ void VMRouterCM::addOutput(MemoryBase* memory, string output) { if (output == "allinnerstubout") { AllInnerStubsMemory* tmp = dynamic_cast(memory); assert(tmp != nullptr); - char memtype=memory->getName().back(); - allinnerstubs_.emplace_back(memtype,tmp); + char memtype = memory->getName().back(); + allinnerstubs_.emplace_back(memtype, tmp); return; } @@ -58,42 +57,42 @@ void VMRouterCM::addOutput(MemoryBase* memory, string output) { 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++; + vmbin = vmbin * 10 + memory->getName().substr(pos, 1)[0] - '0'; + pos++; } } if (memory->getName().substr(3, 2) == "TE") { VMStubsTEMemory* tmp = dynamic_cast(memory); - int iseed = output[output.size()-1]-'0'; - assert(iseed>=0); - assert(iseed<8); - + int iseed = output[output.size() - 1] - '0'; + assert(iseed >= 0); + assert(iseed < 8); + int seedindex = -1; for (unsigned int k = 0; k < vmstubsTEPHI_.size(); k++) { - if (vmstubsTEPHI_[k].seednumber == (unsigned int)iseed) { - seedindex = k; - } + if (vmstubsTEPHI_[k].seednumber == (unsigned int)iseed) { + seedindex = k; + } } if (seedindex == -1) { - seedindex = vmstubsTEPHI_.size(); - vector vectmp; - VMStubsTEPHICM atmp(iseed, vectmp); - vmstubsTEPHI_.push_back(atmp); + seedindex = vmstubsTEPHI_.size(); + vector vectmp; + VMStubsTEPHICM atmp(iseed, vectmp); + vmstubsTEPHI_.push_back(atmp); } - tmp->resize(settings_.NLONGVMBINS()*settings_.nvmte(1,iseed)); + tmp->resize(settings_.NLONGVMBINS() * settings_.nvmte(1, iseed)); vmstubsTEPHI_[seedindex].vmstubmem.push_back(tmp); - + } else if (memory->getName().substr(3, 2) == "ME") { VMStubsMEMemory* tmp = dynamic_cast(memory); assert(tmp != nullptr); - tmp->resize(nvmmebins_*settings_.nvmme(layerdisk_)); + tmp->resize(nvmmebins_ * settings_.nvmme(layerdisk_)); assert(vmstubsMEPHI_[0] == nullptr); - vmstubsMEPHI_[0] = tmp; + vmstubsMEPHI_[0] = tmp; } else { throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " memory: " << memory->getName() << " => should never get here!"; } - + return; } @@ -117,7 +116,6 @@ void VMRouterCM::addInput(MemoryBase* memory, string input) { } void VMRouterCM::execute() { - unsigned int allStubCounter = 0; //Loop over the input stubs @@ -147,70 +145,81 @@ void VMRouterCM::execute() { for (auto& allstub : allstubs_) { allstub->addStub(stub); - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " adding stub to " - << allstub->getName(); - } - + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << allstub->getName(); + } } - + FPGAWord iphi = stub->phicorr(); - unsigned int iphipos = iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + 3),3); + unsigned int iphipos = iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + 3), 3); - unsigned int phicutmax=4; - unsigned int phicutmin=4; + unsigned int phicutmax = 4; + unsigned int phicutmin = 4; - if (layerdisk_!=0) { - phicutmax=6; - phicutmin=2; + if (layerdisk_ != 0) { + phicutmax = 6; + phicutmin = 2; } - + //Fill inner allstubs memories - in HLS this is the same write to multiple memories for (auto& allstub : allinnerstubs_) { - char memtype=allstub.first; - if (memtype=='R' && iphipos=phicutmin) continue; - if (memtype=='A' && iphipos<4) continue; - if (memtype=='B' && iphipos>=4) continue; - if (memtype=='E' && iphipos>=4) continue; - if (memtype=='F' && iphipos<4) continue; - if (memtype=='C' && iphipos>=4) continue; - if (memtype=='D' && iphipos<4) continue; - - int absz = std::abs(stub->z().value()); - if (layerdisk_==1 && absz<50.0/settings_.kz(layerdisk_)) continue; - if ((layerdisk_==2 || layerdisk_==4) && absz>95.0/settings_.kz(layerdisk_)) continue; - if ((layerdisk_==6 || layerdisk_==8) && stub->r().value()>55.0/settings_.kr()) continue; - if ((layerdisk_==6 || layerdisk_==8) && stub->r().value()<2*int(N_DSS_MOD)) continue; - if (layerdisk_==0) { - if (memtype=='M'||memtype=='R'||memtype=='L') { - if (absz<70.0/settings_.kz(layerdisk_)) continue; - } else { - if (absz>95.0/settings_.kz(layerdisk_)) continue; - } - } - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " adding stub to " - << allstub.second->getName(); - } + char memtype = allstub.first; + if (memtype == 'R' && iphipos < phicutmax) + continue; + if (memtype == 'L' && iphipos >= phicutmin) + continue; + if (memtype == 'A' && iphipos < 4) + continue; + if (memtype == 'B' && iphipos >= 4) + continue; + if (memtype == 'E' && iphipos >= 4) + continue; + if (memtype == 'F' && iphipos < 4) + continue; + if (memtype == 'C' && iphipos >= 4) + continue; + if (memtype == 'D' && iphipos < 4) + continue; + + int absz = std::abs(stub->z().value()); + if (layerdisk_ == 1 && absz < 50.0 / settings_.kz(layerdisk_)) + continue; + if ((layerdisk_ == 2 || layerdisk_ == 4) && absz > 95.0 / settings_.kz(layerdisk_)) + continue; + if ((layerdisk_ == 6 || layerdisk_ == 8) && stub->r().value() > 55.0 / settings_.kr()) + continue; + if ((layerdisk_ == 6 || layerdisk_ == 8) && stub->r().value() < 2 * int(N_DSS_MOD)) + continue; + if (layerdisk_ == 0) { + if (memtype == 'M' || memtype == 'R' || memtype == 'L') { + if (absz < 70.0 / settings_.kz(layerdisk_)) + continue; + } else { + if (absz > 95.0 / settings_.kz(layerdisk_)) + continue; + } + } + + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << allstub.second->getName(); + } allstub.second->addStub(stub); } //Fill all the ME VM memories unsigned int ivm = - iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_)), - settings_.nbitsvmme(layerdisk_)); + iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_)), + settings_.nbitsvmme(layerdisk_)); //Calculate the z and r position for the vmstub //Take the top nbitszfinebintable_ bits of the z coordinate - int indexz = (stub->z().value() >> (stub->z().nbits() - nbitszfinebintable_))&((1<z().value() >> (stub->z().nbits() - nbitszfinebintable_)) & ((1 << nbitszfinebintable_) - 1); int indexr = -1; if (layerdisk_ > (N_LAYER - 1)) { if (negdisk) { - indexz = ((1 << nbitszfinebintable_) -1 ) - indexz; + indexz = ((1 << nbitszfinebintable_) - 1) - indexz; } indexr = stub->r().value(); if (stub->isPSmodule()) { @@ -218,7 +227,7 @@ void VMRouterCM::execute() { } } else { //Take the top nbitsfinebintable_ bits of the z coordinate. The & is to handle the negative z values. - indexr = (stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_))&((1<r().value() >> (stub->r().nbits() - nbitsrfinebintable_)) & ((1 << nbitsrfinebintable_) - 1); } assert(indexz >= 0); @@ -232,46 +241,45 @@ void VMRouterCM::execute() { int vmbin = melut >> NFINERZBITS; if (negdisk) - vmbin += (1<bend().nbits(); - if (layerdisk_ >= N_LAYER) + if (layerdisk_ >= N_LAYER) nbendbits = settings_.nbendbitsmedisk(); VMStubME vmstub( stub, - stub->iphivmFineBins(settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_),NFINERZBITS), + stub->iphivmFineBins(settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_), NFINERZBITS), FPGAWord(rzfine, NFINERZBITS, true, __LINE__, __FILE__), FPGAWord(stub->bend().value(), nbendbits, true, __LINE__, __FILE__), allStubIndex); - + assert(vmstubsMEPHI_[0] != nullptr); - vmstubsMEPHI_[0]->addStub(vmstub, ivm*nvmmebins_+vmbin); + vmstubsMEPHI_[0]->addStub(vmstub, ivm * nvmmebins_ + vmbin); //Fill the TE VM memories - if (layerdisk_>=6&&(!stub->isPSmodule())) - continue; - - for (auto& ivmstubTEPHI : vmstubsTEPHI_) { + if (layerdisk_ >= 6 && (!stub->isPSmodule())) + continue; + for (auto& ivmstubTEPHI : vmstubsTEPHI_) { unsigned int iseed = ivmstubTEPHI.seednumber; unsigned int lutwidth = settings_.lutwidthtab(1, iseed); int lutval = -999; - if (layerdisk_ < N_LAYER) { - lutval = melut; - } else { - lutval = vmrtable_.lookupdisk(indexz, indexr); - if (lutval == 0) { - continue; - } - } + if (layerdisk_ < N_LAYER) { + lutval = melut; + } else { + lutval = vmrtable_.lookupdisk(indexz, indexr); + if (lutval == 0) { + continue; + } + } - assert(lutval >= 0); + assert(lutval >= 0); FPGAWord binlookup(lutval, lutwidth, true, __LINE__, __FILE__); @@ -282,9 +290,9 @@ void VMRouterCM::execute() { iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmte(1, iseed)), settings_.nbitsvmte(1, iseed)); - int 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__); + int 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(1, iseed), settings_.nfinephi(1, iseed)); @@ -295,12 +303,12 @@ void VMRouterCM::execute() { for (unsigned int l = 0; l < nmem; l++) { if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " try adding stub to " - << ivmstubTEPHI.vmstubmem[l]->getName() - << " bin=" << bin << " ivmte " << ivmte << " finephi " << finephi.value() - << " regions bits " << settings_.nphireg(1, iseed)<<" finephibits "<addVMStub(tmpstub, ivmte*settings_.NLONGVMBINS()+bin); + edm::LogVerbatim("Tracklet") << getName() << " try adding stub to " << ivmstubTEPHI.vmstubmem[l]->getName() + << " bin=" << bin << " ivmte " << ivmte << " finephi " << finephi.value() + << " regions bits " << settings_.nphireg(1, iseed) << " finephibits " + << settings_.nfinephi(1, iseed); + } + ivmstubTEPHI.vmstubmem[l]->addVMStub(tmpstub, ivmte * settings_.NLONGVMBINS() + bin); } } } diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc index 11d11768aad3a..84cb75dac4e14 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterPhiCorrTable.cc @@ -38,9 +38,8 @@ void VMRouterPhiCorrTable::init(int layer, int bendbits, int rbits) { } int VMRouterPhiCorrTable::getphiCorrValue(int ibend, int irbin) const { - - assert(layer_>0.0&&layer_<=(int)N_LAYER); - double bend = - settings_.benddecode(ibend, layer_-1, layer_ <= (int)N_PSLAYER); + assert(layer_ > 0.0 && layer_ <= (int)N_LAYER); + double bend = -settings_.benddecode(ibend, layer_ - 1, layer_ <= (int)N_PSLAYER); //for the rbin - calculate the distance to the nominal layer radius double Delta = (irbin + 0.5) * dr_ - settings_.drmax(); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc index 8dfe4ef1e7d45..ff196500cf8c7 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc @@ -10,8 +10,9 @@ using namespace trklet; VMRouterTable::VMRouterTable(Settings const& settings) : settings_(settings) {} -VMRouterTable::VMRouterTable(Settings const& settings, unsigned int layerdisk, std::string const& name) : settings_(settings) { - init(layerdisk,name); +VMRouterTable::VMRouterTable(Settings const& settings, unsigned int layerdisk, std::string const& name) + : settings_(settings) { + init(layerdisk, name); } void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { @@ -44,22 +45,22 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { double z = zmin_ + (izbin + 0.5) * dz_; if (settings_.combined()) { - int iznew=izbin-(1<<(zbits_-1)); - if (iznew<0) - iznew+=(1<=0); - assert(iznew<(1<=0); - assert(irnew<(1<= 0); + assert(iznew < (1 << zbits_)); + z = zmin_ + (iznew + 0.5) * dz_; + if (layerdisk < N_LAYER) { + int irnew = irbin - (1 << (rbits_ - 1)); + if (irnew < 0) + irnew += (1 << rbits_); + assert(irnew >= 0); + assert(irnew < (1 << rbits_)); + r = rmin_ + (irnew + 0.5) * dr_; + } } - + if (layerdisk > (N_LAYER - 1) && irbin < 10) //special case for the tabulated radii in 2S disks r = (layerdisk <= 7) ? settings_.rDSSinner(irbin) : settings_.rDSSouter(irbin); @@ -80,7 +81,7 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { if (layerdisk >= N_LAYER) { double rproj = r * settings_.zmean(layerdisk - N_LAYER) / z; bin = 0.5 * NBINS * (rproj - settings_.rmindiskvm()) / (settings_.rmaxdiskvm() - settings_.rmindiskvm()); - //bin value of zero indicates that stub is out of range + //bin value of zero indicates that stub is out of range if (bin < 0) bin = 0; if (bin >= NBINS / 2) @@ -120,75 +121,71 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { } if (settings_.writeTable()) { - if (!settings_.combined()) { // write finebin tables writeVMTable(settings_.tablePath(), name + "_finebin.tab", vmrtable_); // write barrel seed teinner tables (L1L2, L2L3, L3L4, L5L6) if (layerdisk == 0 || layerdisk == 1 || layerdisk == 2 || layerdisk == 4) { - std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "L" + std::to_string(layerdisk + 2); - writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); + std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "L" + std::to_string(layerdisk + 2); + writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); } // write disk seed teinner tables (D1D2, D3D4) if (layerdisk == 6 || layerdisk == 8) { - std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1) + "D" + to_string(layerdisk - N_LAYER + 2); - writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); + std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1) + "D" + to_string(layerdisk - N_LAYER + 2); + writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinner_); } // write overlap seed teinner tables (L1D1, L2D1) if (layerdisk == 0 || layerdisk == 1) { - std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "D1"; - writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinneroverlap_); + std::string fnamesuffix = "L" + to_string(layerdisk + 1) + "D1"; + writeVMTable(settings_.tablePath(), "VMTableInner" + fnamesuffix + ".tab", vmrtableteinneroverlap_); } // write barrel teouter tables (L2, L3, L4, L6, same as finebin tables) if (layerdisk == 1 || layerdisk == 2 || layerdisk == 3 || layerdisk == 5) { - std::string fnamesuffix = "L" + to_string(layerdisk + 1); - writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtable_); - // write disk teouter tables (D1, D2, D4) - if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { - std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); - writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); - } + std::string fnamesuffix = "L" + to_string(layerdisk + 1); + writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtable_); + // write disk teouter tables (D1, D2, D4) + if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { + std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); + writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); + } } } else { - - std::string fname = "VMRME_"; - if (layerdisk<6) { - fname+="L" + std::to_string(layerdisk+1) +".tab"; + std::string fname = "VMRME_"; + if (layerdisk < 6) { + fname += "L" + std::to_string(layerdisk + 1) + ".tab"; } else { - fname+="D" + std::to_string(layerdisk-5) +".tab"; + fname += "D" + std::to_string(layerdisk - 5) + ".tab"; } - writeVMTable(settings_.tablePath(),fname,vmrtable_); + writeVMTable(settings_.tablePath(), fname, vmrtable_); if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { - std::string fname = "VMRTE_D" + to_string(layerdisk - N_LAYER + 1)+".tab"; - writeVMTable(settings_.tablePath(), fname, vmrtabletedisk_); + std::string fname = "VMRTE_D" + to_string(layerdisk - N_LAYER + 1) + ".tab"; + writeVMTable(settings_.tablePath(), fname, vmrtabletedisk_); } - - if (vmrtableteinner_.size()>0) { - ofstream out; - if (layerdisk<6) { - out.open(settings_.tablePath()+"TP_L" + std::to_string(layerdisk+1) +".tab"); - } else { - out.open(settings_.tablePath()+"TP_D" + std::to_string(layerdisk-5) +".tab"); - } - out << "{" << endl; - for (unsigned int i = 0; i < vmrtableteinner_.size(); i++) { - if (i != 0) { - out << "," << endl; - } - if (vmrtableteinner_[i]==-1) { - out << 1023; - } else { - out << vmrtableteinner_[i]; - } - } - out << endl << "};" << endl; - out.close(); + + if (vmrtableteinner_.size() > 0) { + ofstream out; + if (layerdisk < 6) { + out.open(settings_.tablePath() + "TP_L" + std::to_string(layerdisk + 1) + ".tab"); + } else { + out.open(settings_.tablePath() + "TP_D" + std::to_string(layerdisk - 5) + ".tab"); + } + out << "{" << endl; + for (unsigned int i = 0; i < vmrtableteinner_.size(); i++) { + if (i != 0) { + out << "," << endl; + } + if (vmrtableteinner_[i] == -1) { + out << 1023; + } else { + out << vmrtableteinner_[i]; + } + } + out << endl << "};" << endl; + out.close(); } } } - - } int VMRouterTable::getLookup(unsigned int layerdisk, double z, double r, int iseed) { @@ -379,8 +376,7 @@ int VMRouterTable::lookupinnerThird(int zbin, int rbin) { } void VMRouterTable::writeVMTable(std::string const& dir, std::string const& name, std::vector const& table) { - - ofstream out=openfile(dir,name,__FILE__,__LINE__); + ofstream out = openfile(dir, name, __FILE__, __LINE__); out << "{" << endl; for (unsigned int i = 0; i < table.size(); i++) { diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc index 156d0184b5407..425f23faca72d 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc @@ -11,7 +11,7 @@ VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings, unsigned //set the layer or disk that the memory is in initLayerDisk(6, layer_, disk_); - layerdisk_=initLayerDisk(6); + layerdisk_ = initLayerDisk(6); //Pointer to other VMStub memory for creating stub pairs other_ = nullptr; @@ -59,29 +59,27 @@ VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings, unsigned isinner_ = false; stubsbinnedvm_.resize(settings_.NLONGVMBINS()); - } bool VMStubsTEMemory::addVMStub(VMStubTE vmstub, int bin) { //If the pt of the stub is consistent with the allowed pt of tracklets //in that can be formed in this VM and the other VM used in the TE. - - if (settings_.combined()){ - if (disk_>0) { + if (settings_.combined()) { + if (disk_ > 0) { assert(vmstub.stub()->isPSmodule()); } bool negdisk = vmstub.stub()->disk().value() < 0.0; if (negdisk) - bin+=4; - assert(bin<(int)stubsbinnedvm_.size()); - if (stubsbinnedvm_[bin].size()layerdisk()layerdisk() < N_LAYER) { if (!isinner_) { if (stubsbinnedvm_[bin].size() >= settings_.maxStubsPerBin()) return false; @@ -168,7 +166,7 @@ bool VMStubsTEMemory::addVMStub(VMStubTE vmstub) { } } } else { - if (vmstub.stub()->layerdisk()layerdisk() < N_LAYER) { if (!isinner_) { stubsbinnedvm_[bin].push_back(vmstub); } @@ -284,9 +282,8 @@ void VMStubsTEMemory::setbendtable(std::vector vmbendtable) { } void VMStubsTEMemory::writeVMBendTable() { + ofstream outvmbendcut = openfile(settings_.tablePath(), getName() + "_vmbendcut.tab", __FILE__, __LINE__); - ofstream outvmbendcut=openfile(settings_.tablePath(), getName() + "_vmbendcut.tab", __FILE__, __LINE__); - outvmbendcut << "{" << endl; unsigned int vmbendtableSize = vmbendtable_.size(); assert(vmbendtableSize == 16 || vmbendtableSize == 8); diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index 76e74a68ab041..8ef1aff36ee46 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -116,7 +116,6 @@ int main(const int argc, const char **argv) { for (int eventnum = 0; eventnum < nevents && !in->eof(); eventnum++) { SLHCEvent ev(*in); - /* L1SimTrack simtrk; From b140ffe64e0d98c8b71dfbbcfa3c454d7903c5f1 Mon Sep 17 00:00:00 2001 From: Louise Skinnari Date: Tue, 2 Mar 2021 20:00:49 +0100 Subject: [PATCH 04/45] fix cherrypick mess up --- .../src/MatchProcessor.cc | 25 ------------- .../src/TrackletEngineUnit.cc | 1 - .../src/TrackletProcessor.cc | 36 ------------------- 3 files changed, 62 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 921c2c8886cd2..0a7c02abae761 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -407,7 +407,6 @@ void MatchProcessor::execute() { bestTCID = currentTCID; bestInPipeline = empty; } -<<<<<<< HEAD } if (iMEbest != nMatchEngines_ && (!bestInPipeline)) { @@ -419,30 +418,6 @@ void MatchProcessor::execute() { if (oldTracklet != nullptr) { //allow equal here since we can have more than one cadidate match per tracklet projection assert(oldTracklet->TCID() <= tracklet->TCID()); -======= - - if (iMEbest != nMatchEngines_ && (!bestInPipeline)) { - const std::pair& candmatch = matchengines_[iMEbest].read(); - - const Stub* fpgastub = candmatch.second; - Tracklet* tracklet = candmatch.first; - - if (oldTracklet != nullptr) { - //allow equal here since we can have more than one cadidate match per tracklet projection - assert(oldTracklet->TCID() <= tracklet->TCID()); - } - oldTracklet = tracklet; - - bool match = matchCalculator(tracklet, fpgastub); - - if (settings_.debugTracklet() && match) { - edm::LogVerbatim("Tracklet") << getName() << " have match"; - } - - countall++; - if (match) - countsel++; ->>>>>>> ca9f4d8d9ec... Various fixes to comment on pull request (#68) } oldTracklet = tracklet; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc index fa1583ec13cab..cc177337fbaad 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc @@ -106,7 +106,6 @@ void TrackletEngineUnit::step(bool print, int istep, int iTE) { if (next_ != 0) rzbin += (1 << NFINERZBITS); ->>>>>>> ca9f4d8d9ec... Various fixes to comment on pull request (#68) if ((rzbin < tedata_.rzbinfirst_) || (rzbin - tedata_.rzbinfirst_ > tedata_.rzdiffmax_)) { if (settings_->debugTracklet()) { edm::LogVerbatim("Tracklet") << " layer-disk stub pair rejected because rbin cut : " << rzbin << " " diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index 9427f254f6d6e..ce8bdabd06920 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -494,8 +494,6 @@ void TrackletProcessor::execute() { } } -<<<<<<< HEAD - // // Done with processing - collect performance statistics // @@ -508,32 +506,6 @@ void TrackletProcessor::execute() { << " " << countsel //# tracklets found << endl; } - - -======= - void TrackletProcessor::writeTETable() { - ofstream outstubptinnercut; - outstubptinnercut.open(getName() + "_stubptinnercut.tab"); - outstubptinnercut << "{" << endl; - // the below is outcommented as the writing of these tables are currently not implemented, to be adressed - //for(unsigned int i=0;i>>>>>> fd1f230d81e... part one of PR review fixes for TrackFindingTracklet package } void TrackletProcessor::buildLUT() { @@ -549,20 +521,12 @@ void TrackletProcessor::buildLUT() { rmin = settings_.rmean(layerdisk1_); rmax = settings_.rmean(layerdisk2_); } else { -<<<<<<< HEAD if (iSeed_ > 5) { if (iSeed_ == 6) { rmax = settings_.rmaxdiskl1overlapvm(); } if (iSeed_ == 7) { rmax = settings_.rmaxdiskvm(); -======= - if (iSeed_ > 5) { - if (iSeed_ == 6) { - rmax = settings_.rmaxdiskl1overlapvm(); - } else if (iSeed_ == 7) { - rmax = settings_.rmaxdiskvm(); ->>>>>>> fd1f230d81e... part one of PR review fixes for TrackFindingTracklet package } rmin = settings_.rmean(layerdisk1_); } else { From 04d9dfad3f913c10d9d1c305cc1b0a1aec7c969d Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Tue, 2 Mar 2021 15:30:02 -0500 Subject: [PATCH 05/45] Remove LayerProjection class --- .../interface/LayerProjection.h | 150 ------------------ .../TrackFindingTracklet/interface/Tracklet.h | 20 +-- .../src/LayerProjection.cc | 90 ----------- .../src/MatchCalculator.cc | 20 +-- .../TrackFindingTracklet/src/MatchEngine.cc | 18 +-- .../src/MatchProcessor.cc | 36 ++--- .../src/ProjectionRouter.cc | 2 +- .../src/PurgeDuplicate.cc | 2 +- .../TrackFindingTracklet/src/Tracklet.cc | 23 ++- .../src/TrackletCalculatorBase.cc | 116 +++++++------- .../src/TrackletCalculatorDisplaced.cc | 89 ++++++----- .../src/TrackletProjectionsMemory.cc | 8 +- 12 files changed, 164 insertions(+), 410 deletions(-) delete mode 100644 L1Trigger/TrackFindingTracklet/interface/LayerProjection.h delete mode 100644 L1Trigger/TrackFindingTracklet/src/LayerProjection.cc diff --git a/L1Trigger/TrackFindingTracklet/interface/LayerProjection.h b/L1Trigger/TrackFindingTracklet/interface/LayerProjection.h deleted file mode 100644 index 01a55076838d3..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/LayerProjection.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_LayerProjection_h -#define L1Trigger_TrackFindingTracklet_interface_LayerProjection_h - -#include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" - -namespace trklet { - - class Settings; - - class LayerProjection { - public: - LayerProjection() { valid_ = false; } - - ~LayerProjection() = default; - - void init(Settings const& settings, - int projlayer, - int iphiproj, - int izproj, - int iphider, - int izder, - double phiproj, - double zproj, - double phiprojder, - double zprojder, - double phiprojapprox, - double zprojapprox, - double phiprojderapprox, - double zprojderapprox, - bool isPSseed = false); - - bool valid() const { return valid_; } - - int projlayer() const { - assert(valid_); - return projlayer_; - }; - - const FPGAWord& fpgaphiproj() const { - assert(valid_); - return fpgaphiproj_; - }; - - const FPGAWord& fpgazproj() const { - assert(valid_); - return fpgazproj_; - }; - - const FPGAWord& fpgaphiprojder() const { - assert(valid_); - return fpgaphiprojder_; - }; - - const FPGAWord& fpgazprojder() const { - assert(valid_); - return fpgazprojder_; - }; - - const FPGAWord& fpgazbin1projvm() const { - assert(valid_); - return fpgazbin1projvm_; - }; - - const FPGAWord& fpgazbin2projvm() const { - assert(valid_); - return fpgazbin2projvm_; - }; - - const FPGAWord& fpgafinezvm() const { - assert(valid_); - return fpgafinezvm_; - }; - - const FPGAWord& fpgafinephivm() const { - assert(valid_); - return fpgafinephivm_; - }; - - double phiproj() const { - assert(valid_); - return phiproj_; - }; - - double zproj() const { - assert(valid_); - return zproj_; - }; - - double phiprojder() const { - assert(valid_); - return phiprojder_; - }; - - double zprojder() const { - assert(valid_); - return zprojder_; - }; - - double phiprojapprox() const { - assert(valid_); - return phiprojapprox_; - }; - - double zprojapprox() const { - assert(valid_); - return zprojapprox_; - }; - - double phiprojderapprox() const { - assert(valid_); - return phiprojderapprox_; - }; - - double zprojderapprox() const { - assert(valid_); - return zprojderapprox_; - }; - - protected: - bool valid_; - - int projlayer_; - - double rproj_; - - FPGAWord fpgaphiproj_; - FPGAWord fpgazproj_; - FPGAWord fpgaphiprojder_; - FPGAWord fpgazprojder_; - - FPGAWord fpgazbin1projvm_; - FPGAWord fpgazbin2projvm_; - FPGAWord fpgafinezvm_; - FPGAWord fpgafinephivm_; - - double phiproj_; - double zproj_; - double phiprojder_; - double zprojder_; - - double zbin1_; - double zbin2_; - - double phiprojapprox_; - double zprojapprox_; - double phiprojderapprox_; - double zprojderapprox_; - }; -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index fb1b8925fe30a..49b2fb082c661 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -14,7 +14,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" #include "L1Trigger/TrackFindingTracklet/interface/Track.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackPars.h" -#include "L1Trigger/TrackFindingTracklet/interface/LayerProjection.h" +#include "L1Trigger/TrackFindingTracklet/interface/Projection.h" #include "L1Trigger/TrackFindingTracklet/interface/DiskProjection.h" #include "L1Trigger/TrackFindingTracklet/interface/LayerResidual.h" #include "L1Trigger/TrackFindingTracklet/interface/DiskResidual.h" @@ -50,7 +50,7 @@ namespace trklet { int id0, int iz0, int it, - LayerProjection layerprojs[N_PROJ], + Projection projs[N_LAYER+N_DISK], DiskProjection diskprojs[N_PROJ], bool disk, bool overlap = false); @@ -87,15 +87,14 @@ namespace trklet { std::string trackletprojstrlayer(int layer) const { return trackletprojstr(layer); } std::string trackletprojstrdisk(int disk) const { return trackletprojstrD(disk); } - bool validProj(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - return layerproj_[layer - 1].valid(); + bool validProj(int layerdisk) const { + assert(layerdisk >= 0 && layerdisk < N_LAYER+N_DISK); + return proj_[layerdisk].valid(); } - const LayerProjection& layerProj(int layer) const { - assert(layer > 0 && layer <= N_LAYER); - assert(layerproj_[layer - 1].valid()); - return layerproj_[layer - 1]; + const Projection& proj(int layerdisk) const { + assert(validProj(layerdisk)); + return proj_[layerdisk]; } //Disks residuals @@ -321,7 +320,8 @@ namespace trklet { std::unique_ptr fpgatrack_; - LayerProjection layerproj_[N_LAYER]; + Projection proj_[N_LAYER+N_DISK]; + DiskProjection diskproj_[N_DISK]; LayerResidual layerresid_[N_LAYER]; diff --git a/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc b/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc deleted file mode 100644 index 5ffb4060ce2eb..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/LayerProjection.cc +++ /dev/null @@ -1,90 +0,0 @@ - -#include "L1Trigger/TrackFindingTracklet/interface/LayerProjection.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -using namespace std; -using namespace trklet; - -void LayerProjection::init(Settings const& settings, - int projlayer, - int iphiproj, - int izproj, - int iphider, - int izder, - double phiproj, - double zproj, - double phiprojder, - double zprojder, - double phiprojapprox, - double zprojapprox, - double phiprojderapprox, - double zprojderapprox, - bool isPSseed) { - assert(projlayer > 0); - assert(projlayer <= N_LAYER); - - valid_ = true; - - projlayer_ = projlayer; - unsigned int layerdisk = projlayer - 1; - - fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); - fpgazproj_.set(izproj, settings.nzbitsstub(layerdisk), false, __LINE__, __FILE__); - - if (layerdisk < N_PSLAYER) { - fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); - fpgazprojder_.set(izder, settings.nbitszprojderL123(), false, __LINE__, __FILE__); - } else { - fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL456(), false, __LINE__, __FILE__); - fpgazprojder_.set(izder, settings.nbitszprojderL456(), false, __LINE__, __FILE__); - } - - ////Separate the vm projections into zbins - ////This determines the central bin: - ////int zbin=4+(zproj.value()>>(zproj.nbits()-3)); - ////But we need some range (particularly for L5L6 seed projecting to L1-L3): - int offset = isPSseed ? 1 : 4; - - int ztemp = fpgazproj_.value() >> (fpgazproj_.nbits() - settings.MEBinsBits() - NFINERZBITS); - unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp - offset) >> NFINERZBITS); - unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp + offset) >> NFINERZBITS); - - if (zbin1 >= settings.MEBins()) { - zbin1 = 0; //note that zbin1 is unsigned - } - if (zbin2 >= settings.MEBins()) { - zbin2 = settings.MEBins() - 1; - } - - assert(zbin1 <= zbin2); - assert(zbin2 - zbin1 <= 1); - - fpgazbin1projvm_.set(zbin1, settings.MEBinsBits(), true, __LINE__, __FILE__); // first z bin - - int nextbin = zbin1 != zbin2; - fpgazbin2projvm_.set(nextbin, 1, true, __LINE__, __FILE__); // need to check adjacent z bin? - - //fine vm z bits. Use 4 bits for fine position. starting at zbin 1 - int finez = ((1 << (settings.MEBinsBits() + NFINERZBITS - 1)) + ztemp) - (zbin1 << NFINERZBITS); - - fpgafinezvm_.set(finez, NFINERZBITS + 1, true, __LINE__, __FILE__); // fine z postions starting at zbin1 - - //fine phi bits - int projfinephi = - (fpgaphiproj_.value() >> - (fpgaphiproj_.nbits() - (settings.nbitsallstubs(projlayer_) + settings.nbitsvmme(projlayer_) + NFINEPHIBITS))) & - ((1 << NFINEPHIBITS) - 1); - fpgafinephivm_.set(projfinephi, NFINEPHIBITS, true, __LINE__, __FILE__); // fine phi postions - - phiproj_ = phiproj; - zproj_ = zproj; - phiprojder_ = phiprojder; - zprojder_ = zprojder; - - phiprojapprox_ = phiprojapprox; - zprojapprox_ = zprojapprox; - phiprojderapprox_ = phiprojderapprox; - zprojderapprox_ = zprojderapprox; -} diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index b30894aad7a88..aa71a494f98ff 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -215,15 +215,15 @@ void MatchCalculator::execute() { if (layerdisk_ < N_LAYER) { //Integer calculation - const LayerProjection& layerProj = tracklet->layerProj(layerdisk_ + 1); + const Projection& proj = tracklet->proj(layerdisk_); int ir = fpgastub->r().value(); - int iphi = layerProj.fpgaphiproj().value(); - int icorr = (ir * layerProj.fpgaphiprojder().value()) >> icorrshift_; + int iphi = proj.fpgaphiproj().value(); + int icorr = (ir * proj.fpgaphiprojder().value()) >> icorrshift_; iphi += icorr; - int iz = layerProj.fpgazproj().value(); - int izcor = (ir * layerProj.fpgazprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_; + int iz = proj.fpgarzproj().value(); + int izcor = (ir * proj.fpgarzprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_; iz += izcor; int ideltaz = fpgastub->z().value() - iz; @@ -249,13 +249,15 @@ void MatchCalculator::execute() { double dr = r - settings_.rmean(layerdisk_); assert(std::abs(dr) < settings_.drmax()); - double dphi = reco::reduceRange(phi - (layerProj.phiproj() + dr * layerProj.phiprojder())); + double dphi = + reco::reduceRange(phi - (proj.phiproj() + dr * proj.phiprojder())); - double dz = z - (layerProj.zproj() + dr * layerProj.zprojder()); + double dz = z - (proj.rzproj() + dr * proj.rzprojder()); - double dphiapprox = reco::reduceRange(phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); + double dphiapprox = reco::reduceRange( + phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox())); - double dzapprox = z - (layerProj.zprojapprox() + dr * layerProj.zprojderapprox()); + double dzapprox = z - (proj.rzprojapprox() + dr * proj.rzprojderapprox()); int seedindex = tracklet->getISeed(); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index bd7f3c933d640..2582224190908 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -179,11 +179,10 @@ void MatchEngine::execute() { iproj++; moreproj = iproj < nproj; - unsigned int rzfirst = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin1projvm().value() - : proj->diskProj(layerdisk_ - 5).fpgarbin1projvm().value(); + unsigned int rzfirst = barrel_ ? proj->proj(layerdisk_).fpgarzbin1projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin1projvm().value(); unsigned int rzlast = rzfirst; - bool second = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin2projvm().value() - : proj->diskProj(layerdisk_ - 5).fpgarbin2projvm().value(); + bool second = barrel_ ? proj->proj(layerdisk_).fpgarzbin2projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin2projvm().value(); + if (second) rzlast += 1; @@ -237,21 +236,18 @@ void MatchEngine::execute() { Tracklet* proj = vmprojs_->getTracklet(projindex); - FPGAWord fpgafinephi = - barrel_ ? proj->layerProj(layerdisk_ + 1).fpgafinephivm() : proj->diskProj(layerdisk_ - 5).fpgafinephivm(); + FPGAWord fpgafinephi = barrel_ ? proj->proj(layerdisk_).fpgafinephivm() : proj->diskProj(layerdisk_-5).fpgafinephivm(); projfinephi = fpgafinephi.value(); nstubs = vmstubs_->nStubsBin(rzbin); - projfinerz = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgafinezvm().value() - : proj->diskProj(layerdisk_ - 5).fpgafinervm().value(); + projfinerz = barrel_ ? proj->proj(layerdisk_).fpgafinerzvm().value() : proj->diskProj(layerdisk_-5).fpgafinervm().value(); projrinv = barrel_ - ? ((1 << (nrinv_ - 1)) + ((-2 * proj->layerProj(layerdisk_ + 1).fpgaphiprojder().value()) >> - (proj->layerProj(layerdisk_ + 1).fpgaphiprojder().nbits() - (nrinv_ - 1)))) - : proj->diskProj(layerdisk_ - 5).getBendIndex().value(); + ? ((1<<(nrinv_-1)) + ((-2*proj->proj(layerdisk_).fpgaphiprojder().value()) >> (proj->proj(layerdisk_).fpgaphiprojder().nbits() - (nrinv_-1)))) + : proj->diskProj(layerdisk_-5).getBendIndex().value(); assert(projrinv >= 0); if (settings_.extended() && projrinv == (1 << nrinv_)) { if (settings_.debugTracklet()) { diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 0a7c02abae761..c5a8241d0ba60 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -250,8 +250,8 @@ void MatchProcessor::execute() { } Tracklet* proj = projMem->getTracklet(iproj); - FPGAWord fpgaphi = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgaphiproj() - : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgaphiproj(); + + FPGAWord fpgaphi = barrel_ ? proj->proj(layerdisk_).fpgaphiproj() : proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiproj(); unsigned int iphi = (fpgaphi.value() >> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); @@ -301,16 +301,11 @@ void MatchProcessor::execute() { } assert(projrinv >= 0); - unsigned int slot = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin1projvm().value() - : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarbin1projvm().value(); - bool second = (barrel_ ? proj->layerProj(layerdisk_ + 1).fpgazbin2projvm().value() - : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarbin2projvm().value()); + unsigned int slot = barrel_ ? proj->proj(layerdisk_).fpgarzbin1projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin1projvm().value(); + bool second = (barrel_ ? proj->proj(layerdisk_).fpgarzbin2projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin2projvm().value()); - int nfinephi = 3; - unsigned int projfinephi = - (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + nfinephi))) & ((1 << nfinephi) - 1); - int projfinerz = barrel_ ? proj->layerProj(layerdisk_ + 1).fpgafinezvm().value() - : proj->diskProj(layerdisk_ - N_LAYER + 1).fpgafinervm().value(); + unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + 3))) & 7; + int projfinerz = barrel_ ? proj->proj(layerdisk_).fpgafinerzvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgafinervm().value(); bool isPSseed = proj->PSseed(); @@ -450,14 +445,14 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { const L1TStub* stub = fpgastub->l1tstub(); if (layerdisk_ < N_LAYER) { - const LayerProjection& layerProj = tracklet->layerProj(layerdisk_ + 1); + const Projection& proj = tracklet->proj(layerdisk_); int ir = fpgastub->r().value(); - int iphi = layerProj.fpgaphiproj().value(); - int icorr = (ir * layerProj.fpgaphiprojder().value()) >> icorrshift_; + int iphi = proj.fpgaphiproj().value(); + int icorr = (ir * proj.fpgaphiprojder().value()) >> icorrshift_; iphi += icorr; - int iz = layerProj.fpgazproj().value(); - int izcor = (ir * layerProj.fpgazprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_; + int iz = proj.fpgarzproj().value(); + int izcor = (ir * proj.fpgarzprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_; iz += izcor; int ideltaz = fpgastub->z().value() - iz; @@ -484,13 +479,14 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double dr = r - settings_.rmean(layerdisk_); assert(std::abs(dr) < settings_.drmax()); - double dphi = reco::reduceRange(phi - (layerProj.phiproj() + dr * layerProj.phiprojder())); + double dphi = reco::reduceRange(phi - (proj.phiproj() + dr * proj.phiprojder())); - double dz = z - (layerProj.zproj() + dr * layerProj.zprojder()); + double dz = z - (proj.rzproj() + dr * proj.rzprojder()); - double dphiapprox = reco::reduceRange(phi - (layerProj.phiprojapprox() + dr * layerProj.phiprojderapprox())); + double dphiapprox = + reco::reduceRange(phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox())); - double dzapprox = z - (layerProj.zprojapprox() + dr * layerProj.zprojderapprox()); + double dzapprox = z - (proj.rzprojapprox() + dr * proj.rzprojderapprox()); int seedindex = tracklet->getISeed(); diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc index e1935c351adf0..419dead08e2f8 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc @@ -89,7 +89,7 @@ void ProjectionRouter::execute() { FPGAWord fpgaphi; if (layerdisk_ < N_LAYER) { - fpgaphi = tracklet->layerProj(layerdisk_ + 1).fpgaphiproj(); + fpgaphi = tracklet->proj(layerdisk_).fpgaphiproj(); } else { int disk = layerdisk_ - (N_LAYER - 1); DiskProjection& diskProj = tracklet->diskProj(disk); diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index a220f039d1369..9525ab696f49d 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -506,7 +506,7 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { phiproj = stubphi; // Otherwise, get projection of tracklet } else if (Layer != 0) { - phiproj = curTracklet->layerProj(Layer).phiproj(); + phiproj = curTracklet->proj(Layer-1).phiproj(); } else if (Disk != 0) { phiproj = curTracklet->diskProj(Disk).phiproj(); } else { diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index 382eaf0d5fd55..07cb6b4758627 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -35,7 +35,7 @@ Tracklet::Tracklet(Settings const& settings, int id0, int iz0, int it, - LayerProjection layerprojs[N_PROJ], + Projection projs[N_LAYER+N_DISK], DiskProjection diskprojs[N_PROJ], bool disk, bool overlap) @@ -98,10 +98,10 @@ Tracklet::Tracklet(Settings const& settings, for (unsigned int i = 0; i < N_LAYER - 2; i++) { if (projlayer_[i] == 0) continue; - if (!layerprojs[i].valid()) + if (!projs[projlayer_[i]-1].valid()) continue; - layerproj_[projlayer_[i] - 1] = layerprojs[i]; + proj_[projlayer_[i] - 1] = projs[projlayer_[i] - 1]; } //Now handle projections to the disks for (unsigned int i = 0; i < N_DISK; i++) { @@ -232,8 +232,8 @@ std::string Tracklet::vmstrlayer(int layer, unsigned int allstubindex) { //int irinvvm=16+(fpgarinv().value()>>(fpgarinv().nbits()-5)); // rinv is not directly available in the TrackletProjection. // can be inferred from phi derivative: rinv = - phider * 2 - int tmp_irinv = layerproj_[layer - 1].fpgaphiprojder().value() * (-2); - int nbits_irinv = layerproj_[layer - 1].fpgaphiprojder().nbits() + 1; + int tmp_irinv = proj_[layer - 1].fpgaphiprojder().value() * (-2); + int nbits_irinv = proj_[layer - 1].fpgaphiprojder().nbits() + 1; // irinv in VMProjection: // top 5 bits of rinv and shifted to be positive @@ -248,10 +248,9 @@ std::string Tracklet::vmstrlayer(int layer, unsigned int allstubindex) { assert(irinvvm < 32); FPGAWord tmp; tmp.set(irinvvm, 5, true, __LINE__, __FILE__); - std::string oss = index.str() + "|" + layerproj_[layer - 1].fpgazbin1projvm().str() + "|" + - layerproj_[layer - 1].fpgazbin2projvm().str() + "|" + layerproj_[layer - 1].fpgafinezvm().str() + - "|" + layerproj_[layer - 1].fpgafinephivm().str() + "|" + tmp.str() + "|" + - std::to_string(PSseed()); + std::string oss = index.str() + "|" + proj_[layer - 1].fpgarzbin1projvm().str() + "|" + + proj_[layer - 1].fpgarzbin2projvm().str() + "|" + proj_[layer - 1].fpgafinerzvm().str() + + "|" + proj_[layer-1].fpgafinephivm().str() + "|" + tmp.str() + "|" + std::to_string(PSseed()); return oss; } @@ -279,9 +278,9 @@ std::string Tracklet::trackletprojstr(int layer) const { FPGAWord tcid; tcid.set(TCIndex_, settings_.nbitstcindex(), true, __LINE__, __FILE__); - std::string oss = tcid.str() + "|" + tmp.str() + "|" + layerproj_[layer - 1].fpgaphiproj().str() + "|" + - layerproj_[layer - 1].fpgazproj().str() + "|" + layerproj_[layer - 1].fpgaphiprojder().str() + "|" + - layerproj_[layer - 1].fpgazprojder().str(); + std::string oss = tcid.str() + "|" + tmp.str() + "|" + proj_[layer - 1].fpgaphiproj().str() + "|" + + proj_[layer - 1].fpgarzproj().str() + "|" + proj_[layer - 1].fpgaphiprojder().str() + "|" + + proj_[layer - 1].fpgarzprojder().str(); return oss; } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index d646178da25b1..20629e5f095bc 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -230,8 +230,8 @@ void TrackletCalculatorBase::addDiskProj(Tracklet* tracklet, int disk) { bool TrackletCalculatorBase::addLayerProj(Tracklet* tracklet, int layer) { assert(layer > 0); - FPGAWord fpgaz = tracklet->layerProj(layer).fpgazproj(); - FPGAWord fpgaphi = tracklet->layerProj(layer).fpgaphiproj(); + FPGAWord fpgaz = tracklet->proj(layer-1).fpgarzproj(); + FPGAWord fpgaphi = tracklet->proj(layer-1).fpgaphiproj(); if (fpgaphi.atExtreme()) edm::LogProblem("Tracklet") << "at extreme! " << fpgaphi.value(); @@ -483,7 +483,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, //now binary int irinv, iphi0, it, iz0; - LayerProjection layerprojs[N_LAYER - 2]; + Projection projs[N_LAYER+N_DISK]; DiskProjection diskprojs[N_DISK]; int iphiproj[N_LAYER - 2], izproj[N_LAYER - 2]; @@ -594,21 +594,21 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, izproj[i] >>= (settings_.nzbitsstub(0) - settings_.nzbitsstub(5)); } - layerprojs[i].init(settings_, - settings_.projlayers(iSeed_, i), - iphiproj[i], - izproj[i], - ITC->der_phiL_final.ival(), - ITC->der_zL_final.ival(), - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - ITC->der_phiL_final.fval(), - ITC->der_zL_final.fval(), - !(iSeed_ == 2 || iSeed_ == 3)); + projs[settings_.projlayers(iSeed_, i)-1].init(settings_, + settings_.projlayers(iSeed_, i)-1, + iphiproj[i], + izproj[i], + ITC->der_phiL_final.ival(), + ITC->der_zL_final.ival(), + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + ITC->der_phiL_final.fval(), + ITC->der_zL_final.fval(), + !(iSeed_ == 2 || iSeed_ == 3)); } iphiprojdisk[0] = ITC->phiD_0_final.ival(); @@ -681,7 +681,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, 0, iz0, it, - layerprojs, + projs, diskprojs, false); @@ -725,7 +725,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, for (unsigned int j = 0; j < N_LAYER - 2; j++) { int lproj = settings_.projlayers(iSeed_, j); bool added = false; - if (tracklet->validProj(lproj)) { + if (tracklet->validProj(lproj-1)) { added = addLayerProj(tracklet, lproj); if (added && lproj == 3) addL3 = true; @@ -976,7 +976,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, if (!inSector(iphi0, irinv, phi0approx, rinvapprox)) return false; - LayerProjection layerprojs[N_LAYER - 2]; + Projection projs[N_LAYER+N_DISK]; DiskProjection diskprojs[N_DISK - 2]; for (unsigned int i = 0; i < N_DISK - 2; ++i) { @@ -995,22 +995,22 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, //shift bits - allways in PS modules for disk seeding iphiproj[i] >>= (settings_.nphibitsstub(5) - settings_.nphibitsstub(0)); - layerprojs[i].init(settings_, - i + 1, - iphiproj[i], - izproj[i], - ITC->der_phiL_final.ival(), - ITC->der_zL_final.ival(), - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - ITC->der_phiL_final.fval(), - ITC->der_zL_final.fval(), - true); - } + projs[i].init(settings_, + i, + iphiproj[i], + izproj[i], + ITC->der_phiL_final.ival(), + ITC->der_zL_final.ival(), + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + ITC->der_phiL_final.fval(), + ITC->der_zL_final.fval(), + true); +} iphiprojdisk[0] = ITC->phiD_0_final.ival(); iphiprojdisk[1] = ITC->phiD_1_final.ival(); @@ -1078,7 +1078,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, 0, iz0, it, - layerprojs, + projs, diskprojs, true); @@ -1096,11 +1096,11 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, } trackletpars_->addTracklet(tracklet); - if (tracklet->validProj(1)) { + if (tracklet->validProj(0)) { addLayerProj(tracklet, 1); } - if (tracklet->validProj(2)) { + if (tracklet->validProj(1)) { addLayerProj(tracklet, 2); } @@ -1349,7 +1349,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, if (!inSector(iphi0, irinv, phi0approx, rinvapprox)) return false; - LayerProjection layerprojs[N_LAYER - 2]; + Projection projs[N_LAYER+N_DISK]; DiskProjection diskprojs[N_DISK]; for (unsigned int i = 0; i < N_DISK - 2; ++i) { @@ -1368,21 +1368,21 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, //adjust bits for PS modules (no 2S modules in overlap seeds) iphiproj[i] >>= (settings_.nphibitsstub(5) - settings_.nphibitsstub(0)); - layerprojs[i].init(settings_, - i + 1, - iphiproj[i], - izproj[i], - ITC->der_phiL_final.ival(), - ITC->der_zL_final.ival(), - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - ITC->der_phiL_final.fval(), - ITC->der_zL_final.fval(), - true); + projs[i].init(settings_, + i, + iphiproj[i], + izproj[i], + ITC->der_phiL_final.ival(), + ITC->der_zL_final.ival(), + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + ITC->der_phiL_final.fval(), + ITC->der_zL_final.fval(), + true); } for (int i = 0; i < 4; ++i) { @@ -1442,7 +1442,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, 0, iz0, it, - layerprojs, + projs, diskprojs, false, true); @@ -1464,7 +1464,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, int layer = outerFPGAStub->layer().value() + 1; if (layer == 2) { - if (tracklet->validProj(1)) { + if (tracklet->validProj(0)) { addLayerProj(tracklet, 1); } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 93b7ca48d1379..50c9b95030234 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -314,8 +314,8 @@ void TrackletCalculatorDisplaced::addDiskProj(Tracklet* tracklet, int disk) { bool TrackletCalculatorDisplaced::addLayerProj(Tracklet* tracklet, int layer) { assert(layer > 0); - FPGAWord fpgaz = tracklet->layerProj(layer).fpgazproj(); - FPGAWord fpgaphi = tracklet->layerProj(layer).fpgaphiproj(); + FPGAWord fpgaz = tracklet->proj(layer-1).fpgarzproj(); + FPGAWord fpgaphi = tracklet->proj(layer-1).fpgaphiproj(); if (fpgaz.atExtreme()) return false; @@ -397,7 +397,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, double rinv, phi0, d0, t, z0; - LayerProjection layerprojs[N_LAYER - 2]; + Projection projs[N_LAYER+N_DISK]; DiskProjection diskprojs[N_DISK]; double phiproj[N_LAYER - 2], zproj[N_LAYER - 2], phider[N_LAYER - 2], zder[N_LAYER - 2]; @@ -653,21 +653,21 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, } } - layerprojs[i].init(settings_, - lproj_[i], - rproj_[i], - iphiproj[i], - izproj[i], - iphider[i], - izder[i], - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - phiderapprox[i], - zderapprox[i]); + projs[lproj_[i]-1].init(settings_, + lproj_[i]-1, + rproj_[i], + iphiproj[i], + izproj[i], + iphider[i], + izder[i], + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + phiderapprox[i], + zderapprox[i]); } if (std::abs(it * kt) > 1.0) { @@ -734,7 +734,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, id0, iz0, it, - layerprojs, + projs, diskprojs, false); @@ -758,7 +758,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, bool added = false; if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j]; - if (tracklet->validProj(lproj_[j])) { + if (tracklet->validProj(lproj_[j]-1)) { added = addLayerProj(tracklet, lproj_[j]); if (added && lproj_[j] == 5) addL5 = true; @@ -1024,7 +1024,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, return false; } - LayerProjection layerprojs[N_LAYER - 2]; + Projection projs[N_LAYER+N_DISK]; DiskProjection diskprojs[N_DISK]; for (unsigned int i = 0; i < toR_.size(); ++i) { @@ -1064,21 +1064,22 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1; } - layerprojs[i].init(settings_, - lproj_[i], - rproj_[i], - iphiproj[i], - izproj[i], - iphider[i], - izder[i], - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - phiderapprox[i], - zderapprox[i]); + projs[lproj_[i]-1].init(settings_, + lproj_[i]-1, + rproj_[i], + iphiproj[i], + izproj[i], + iphider[i], + izder[i], + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + phiderapprox[i], + zderapprox[i]); + } if (std::abs(it * kt) > 1.0) { @@ -1143,7 +1144,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, id0, iz0, it, - layerprojs, + projs, diskprojs, true); @@ -1164,8 +1165,8 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, for (unsigned int j = 0; j < toR_.size(); j++) { if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j] << " " - << tracklet->validProj(lproj_[j]); - if (tracklet->validProj(lproj_[j])) { + << tracklet->validProj(lproj_[j]-1); + if (tracklet->validProj(lproj_[j]-1)) { addLayerProj(tracklet, lproj_[j]); } } @@ -1424,7 +1425,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, return false; } - LayerProjection layerprojs[N_LAYER - 2]; + Projection projs[N_LAYER+N_DISK]; DiskProjection diskprojs[N_DISK]; for (unsigned int i = 0; i < toR_.size(); ++i) { @@ -1463,8 +1464,8 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1; } - layerprojs[i].init(settings_, - lproj_[i], + projs[lproj_[i]-1].init(settings_, + lproj_[i]-1, rproj_[i], iphiproj[i], izproj[i], @@ -1544,7 +1545,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, id0, iz0, it, - layerprojs, + projs, diskprojs, false); @@ -1565,7 +1566,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, for (unsigned int j = 0; j < toR_.size(); j++) { if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j]; - if (tracklet->validProj(lproj_[j])) { + if (tracklet->validProj(lproj_[j]-1)) { addLayerProj(tracklet, lproj_[j]); } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc index 1ea7db8f2994f..173326b4d25b1 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc @@ -16,11 +16,11 @@ TrackletProjectionsMemory::TrackletProjectionsMemory(string name, Settings const void TrackletProjectionsMemory::addProj(Tracklet* tracklet) { if (layer_ != 0 && disk_ == 0) - assert(tracklet->validProj(layer_)); + assert(tracklet->validProj(layer_-1)); if (layer_ == 0 && disk_ != 0) assert(tracklet->validProjDisk(disk_)); if (layer_ != 0 && disk_ != 0) - assert(tracklet->validProj(layer_) || tracklet->validProjDisk(disk_)); + assert(tracklet->validProj(layer_-1) || tracklet->validProjDisk(disk_)); for (auto& itracklet : tracklets_) { if (itracklet == tracklet) { @@ -47,8 +47,8 @@ void TrackletProjectionsMemory::writeTPROJ(bool first) { out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; for (unsigned int j = 0; j < tracklets_.size(); j++) { - string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_)) ? tracklets_[j]->trackletprojstrlayer(layer_) - : tracklets_[j]->trackletprojstrdisk(disk_); + string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_-1)) ? tracklets_[j]->trackletprojstrlayer(layer_) + : tracklets_[j]->trackletprojstrdisk(disk_); out_ << "0x"; out_ << std::setfill('0') << std::setw(2); out_ << hex << j << dec; From 549ac300766c8778799d1a635f37d76b92ffb9d1 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Wed, 3 Mar 2021 17:01:04 -0500 Subject: [PATCH 06/45] Further cleanup of tracklet projections interface --- .../{DiskProjection.h => Projection.h} | 112 +++++++------- .../TrackFindingTracklet/interface/Settings.h | 2 +- .../TrackFindingTracklet/interface/Tracklet.h | 20 +-- .../src/DiskProjection.cc | 101 ------------- .../src/MatchCalculator.cc | 19 +-- .../TrackFindingTracklet/src/MatchEngine.cc | 11 +- .../src/MatchProcessor.cc | 44 +++--- .../TrackFindingTracklet/src/Projection.cc | 138 ++++++++++++++++++ .../src/ProjectionRouter.cc | 16 +- .../src/PurgeDuplicate.cc | 7 +- .../TrackFindingTracklet/src/Tracklet.cc | 23 +-- .../src/TrackletCalculatorBase.cc | 115 ++++++++------- .../src/TrackletCalculatorDisplaced.cc | 114 +++++++-------- .../src/TrackletProjectionsMemory.cc | 4 +- 14 files changed, 370 insertions(+), 356 deletions(-) rename L1Trigger/TrackFindingTracklet/interface/{DiskProjection.h => Projection.h} (55%) delete mode 100644 L1Trigger/TrackFindingTracklet/src/DiskProjection.cc create mode 100644 L1Trigger/TrackFindingTracklet/src/Projection.cc diff --git a/L1Trigger/TrackFindingTracklet/interface/DiskProjection.h b/L1Trigger/TrackFindingTracklet/interface/Projection.h similarity index 55% rename from L1Trigger/TrackFindingTracklet/interface/DiskProjection.h rename to L1Trigger/TrackFindingTracklet/interface/Projection.h index 16b44c487e562..234b17820d964 100644 --- a/L1Trigger/TrackFindingTracklet/interface/DiskProjection.h +++ b/L1Trigger/TrackFindingTracklet/interface/Projection.h @@ -1,46 +1,39 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_DiskProjection_h -#define L1Trigger_TrackFindingTracklet_interface_DiskProjection_h +#ifndef L1Trigger_TrackFindingTracklet_interface_Projection_h +#define L1Trigger_TrackFindingTracklet_interface_Projection_h #include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" -#include - namespace trklet { class Settings; - class DiskProjection { + class Projection { public: - DiskProjection() { valid_ = false; } + Projection() { valid_ = false; } - ~DiskProjection() = default; + ~Projection() = default; void init(Settings const& settings, - int projdisk, - double zproj, + unsigned int layerdisk, int iphiproj, - int irproj, + int irzproj, int iphider, - int irder, + int irzder, double phiproj, - double rproj, + double rzproj, double phiprojder, - double rprojder, + double rzprojder, double phiprojapprox, - double rprojapprox, + double rzprojapprox, double phiprojderapprox, - double rprojderapprox); + double rzprojderapprox, + bool isPSseed); bool valid() const { return valid_; } - int projdisk() const { + unsigned int layerdisk() const { assert(valid_); - return projdisk_; - }; - - double zproj() const { - assert(valid_); - return zproj_; + return layerdisk_; }; const FPGAWord& fpgaphiproj() const { @@ -48,9 +41,9 @@ namespace trklet { return fpgaphiproj_; }; - const FPGAWord& fpgarproj() const { + const FPGAWord& fpgarzproj() const { assert(valid_); - return fpgarproj_; + return fpgarzproj_; }; const FPGAWord& fpgaphiprojder() const { @@ -58,39 +51,39 @@ namespace trklet { return fpgaphiprojder_; }; - const FPGAWord& fpgarprojder() const { + const FPGAWord& fpgarzprojder() const { assert(valid_); - return fpgarprojder_; + return fpgarzprojder_; }; - double phiproj() const { + const FPGAWord& fpgarzbin1projvm() const { assert(valid_); - return phiproj_; + return fpgarzbin1projvm_; }; - const FPGAWord& fpgarbin1projvm() const { + const FPGAWord& fpgarzbin2projvm() const { assert(valid_); - return fpgarbin1projvm_; + return fpgarzbin2projvm_; }; - const FPGAWord& fpgarbin2projvm() const { + const FPGAWord& fpgafinerzvm() const { assert(valid_); - return fpgarbin2projvm_; + return fpgafinerzvm_; }; - const FPGAWord& fpgafinervm() const { + const FPGAWord& fpgafinephivm() const { assert(valid_); - return fpgafinervm_; + return fpgafinephivm_; }; - const FPGAWord& fpgafinephivm() const { + double phiproj() const { assert(valid_); - return fpgafinephivm_; + return phiproj_; }; - double rproj() const { + double rzproj() const { assert(valid_); - return rproj_; + return rzproj_; }; double phiprojder() const { @@ -98,9 +91,9 @@ namespace trklet { return phiprojder_; }; - double rprojder() const { + double rzprojder() const { assert(valid_); - return rprojder_; + return rzprojder_; }; double phiprojapprox() const { @@ -108,9 +101,9 @@ namespace trklet { return phiprojapprox_; }; - double rprojapprox() const { + double rzprojapprox() const { assert(valid_); - return rprojapprox_; + return rzprojapprox_; }; double phiprojderapprox() const { @@ -118,44 +111,43 @@ namespace trklet { return phiprojderapprox_; }; - double rprojderapprox() const { + double rzprojderapprox() const { assert(valid_); - return rprojderapprox_; + return rzprojderapprox_; }; void setBendIndex(int bendindex) { fpgabendindex_.set(bendindex, 5, true, __LINE__, __FILE__); } - + const FPGAWord& getBendIndex() const { return fpgabendindex_; } protected: bool valid_; - int projdisk_; - - double zproj_; + unsigned int layerdisk_; FPGAWord fpgaphiproj_; - FPGAWord fpgarproj_; + FPGAWord fpgarzproj_; FPGAWord fpgaphiprojder_; - FPGAWord fpgarprojder_; + FPGAWord fpgarzprojder_; - FPGAWord fpgarbin1projvm_; - FPGAWord fpgarbin2projvm_; - FPGAWord fpgafinervm_; + FPGAWord fpgarzbin1projvm_; + FPGAWord fpgarzbin2projvm_; + FPGAWord fpgafinerzvm_; FPGAWord fpgafinephivm_; - FPGAWord fpgabendindex_; - double phiproj_; - double rproj_; + double rzproj_; double phiprojder_; - double rprojder_; + double rzprojder_; double phiprojapprox_; - double rprojapprox_; + double rzprojapprox_; double phiprojderapprox_; - double rprojderapprox_; - }; + double rzprojderapprox_; + //used by projections to disks + FPGAWord fpgabendindex_; + + }; }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index f1ed3fdc2d3b2..8560150ab32e9 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -842,7 +842,7 @@ namespace trklet { unsigned int nHelixPar_{4}; // 4 or 5 param helix fit bool extended_{false}; // turn on displaced tracking - bool combined_{false}; // use combined TP (TE+TC) and MP (PR+ME+MC) configuration + bool combined_{true}; // use combined TP (TE+TC) and MP (PR+ME+MC) configuration std::string skimfile_{""}; //if not empty events will be written out in ascii format to this file diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 49b2fb082c661..d9e3ce555db68 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -15,7 +15,6 @@ #include "L1Trigger/TrackFindingTracklet/interface/Track.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackPars.h" #include "L1Trigger/TrackFindingTracklet/interface/Projection.h" -#include "L1Trigger/TrackFindingTracklet/interface/DiskProjection.h" #include "L1Trigger/TrackFindingTracklet/interface/LayerResidual.h" #include "L1Trigger/TrackFindingTracklet/interface/DiskResidual.h" #include "L1Trigger/TrackFindingTracklet/interface/Util.h" @@ -51,7 +50,6 @@ namespace trklet { int iz0, int it, Projection projs[N_LAYER+N_DISK], - DiskProjection diskprojs[N_PROJ], bool disk, bool overlap = false); @@ -92,25 +90,11 @@ namespace trklet { return proj_[layerdisk].valid(); } - const Projection& proj(int layerdisk) const { + Projection& proj(int layerdisk) { assert(validProj(layerdisk)); return proj_[layerdisk]; } - //Disks residuals - - bool validProjDisk(int disk) const { - assert(abs(disk) <= N_DISK); - return diskproj_[abs(disk) - 1].valid(); - } - - //Should be const; but setBendIndex method needs to be migrated out of the disk projection - DiskProjection& diskProj(int disk) { - assert(abs(disk) <= N_DISK); - assert(diskproj_[abs(disk) - 1].valid()); - return diskproj_[abs(disk) - 1]; - } - bool matchdisk(int disk) const { assert(abs(disk) <= N_DISK); return diskresid_[abs(disk) - 1].valid(); @@ -322,8 +306,6 @@ namespace trklet { Projection proj_[N_LAYER+N_DISK]; - DiskProjection diskproj_[N_DISK]; - LayerResidual layerresid_[N_LAYER]; DiskResidual diskresid_[N_DISK]; diff --git a/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc b/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc deleted file mode 100644 index 3fe5e7af15861..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/DiskProjection.cc +++ /dev/null @@ -1,101 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/DiskProjection.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include -#include - -using namespace std; -using namespace trklet; - -void DiskProjection::init(Settings const& settings, - int projdisk, - double zproj, - int iphiproj, - int irproj, - int iphider, - int irder, - double phiproj, - double rproj, - double phiprojder, - double rprojder, - double phiprojapprox, - double rprojapprox, - double phiprojderapprox, - double rprojderapprox) { - assert(abs(projdisk) > 0); - assert(abs(projdisk) <= N_DISK); - - valid_ = true; - - zproj_ = zproj; - - projdisk_ = projdisk; - - unsigned int layerdisk = projdisk + N_LAYER - 1; - - assert(iphiproj >= 0); - - fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); - - fpgarproj_.set(irproj, settings.nrbitsstub(layerdisk), false, __LINE__, __FILE__); - - fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); - fpgarprojder_.set(irder, settings.nrbitsprojderdisk(), false, __LINE__, __FILE__); - - //TODO the -3 and +3 should be evaluated and efficiency for matching hits checked. - //This code should be migrated in the ProjectionRouter - double roffset = 3.0; - int rbin1 = 8.0 * (irproj * settings.krprojshiftdisk() - roffset - settings.rmindiskvm()) / - (settings.rmaxdisk() - settings.rmindiskvm()); - int rbin2 = 8.0 * (irproj * settings.krprojshiftdisk() + roffset - settings.rmindiskvm()) / - (settings.rmaxdisk() - settings.rmindiskvm()); - - if (irproj * settings.krprojshiftdisk() < 20.0) { - edm::LogPrint("Tracklet") << " WARNING : irproj = " << irproj << " " << irproj * settings.krprojshiftdisk() << " " - << projdisk_; - } - - if (rbin1 < 0) { - rbin1 = 0; - } - rbin2 = clamp(rbin2, 0, 7); - - assert(rbin1 <= rbin2); - assert(rbin2 - rbin1 <= 1); - - int finer = 64 * - ((irproj * settings.krprojshiftdisk() - settings.rmindiskvm()) - - rbin1 * (settings.rmaxdisk() - settings.rmindiskvm()) / 8.0) / - (settings.rmaxdisk() - settings.rmindiskvm()); - - finer = clamp(finer, 0, 15); - - int diff = rbin1 != rbin2; - if (irder < 0) - rbin1 += 8; - - fpgarbin1projvm_.set(rbin1, 4, true, __LINE__, __FILE__); // first r bin - fpgarbin2projvm_.set(diff, 1, true, __LINE__, __FILE__); // need to check adjacent r bin - - fpgafinervm_.set(finer, 4, true, __LINE__, __FILE__); // fine r postions starting at rbin1 - - //fine phi bits - int projfinephi = - (fpgaphiproj_.value() >> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(N_LAYER + projdisk_ - 1) + - settings.nbitsvmme(N_LAYER + projdisk_ - 1) + NFINEPHIBITS))) & - ((1 << NFINEPHIBITS) - 1); - - fpgafinephivm_.set(projfinephi, NFINEPHIBITS, true, __LINE__, __FILE__); // fine phi postions - - phiproj_ = phiproj; - rproj_ = rproj; - phiprojder_ = phiprojder; - rprojder_ = rprojder; - - phiprojapprox_ = phiprojapprox; - rprojapprox_ = rprojapprox; - phiprojderapprox_ = phiprojderapprox; - rprojderapprox_ = rprojderapprox; -} diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index aa71a494f98ff..f505a899543c8 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -348,22 +348,22 @@ void MatchCalculator::execute() { //Perform integer calculations here - const DiskProjection& diskProj = tracklet->diskProj(disk); + const Projection& proj = tracklet->proj(layerdisk_); int iz = fpgastub->z().value(); - int iphi = diskProj.fpgaphiproj().value(); + int iphi = proj.fpgaphiproj().value(); //TODO - need to express interms of constants int shifttmp = 6; - int iphicorr = (iz * diskProj.fpgaphiprojder().value()) >> shifttmp; + int iphicorr = (iz * proj.fpgaphiprojder().value()) >> shifttmp; iphi += iphicorr; - int ir = diskProj.fpgarproj().value(); + int ir = proj.fpgarzproj().value(); //TODO - need to express interms of constants int shifttmp2 = 7; - int ircorr = (iz * diskProj.fpgarprojder().value()) >> shifttmp2; + int ircorr = (iz * proj.fpgarzprojder().value()) >> shifttmp2; ir += ircorr; @@ -416,9 +416,9 @@ void MatchCalculator::execute() { << "\n stub " << stub->z() << " disk " << disk << " " << dz; } - double phiproj = diskProj.phiproj() + dz * diskProj.phiprojder(); + double phiproj = proj.phiproj() + dz * proj.phiprojder(); - double rproj = diskProj.rproj() + dz * diskProj.rprojder(); + double rproj = proj.rzproj() + dz * proj.rzprojder(); double deltar = r - rproj; @@ -426,9 +426,10 @@ void MatchCalculator::execute() { double dphi = reco::reduceRange(phi - phiproj); - double dphiapprox = reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); + double dphiapprox = + reco::reduceRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox())); - double drapprox = stub->r() - (diskProj.rprojapprox() + dz * diskProj.rprojderapprox()); + double drapprox = stub->r() - (proj.rzprojapprox() + dz * proj.rzprojderapprox()); double drphi = dphi * stub->r(); double drphiapprox = dphiapprox * stub->r(); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index 2582224190908..234def63884a6 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -179,9 +179,10 @@ void MatchEngine::execute() { iproj++; moreproj = iproj < nproj; - unsigned int rzfirst = barrel_ ? proj->proj(layerdisk_).fpgarzbin1projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin1projvm().value(); + unsigned int rzfirst = proj->proj(layerdisk_).fpgarzbin1projvm().value(); unsigned int rzlast = rzfirst; - bool second = barrel_ ? proj->proj(layerdisk_).fpgarzbin2projvm().value() : proj->diskProj(layerdisk_-5).fpgarbin2projvm().value(); + + bool second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); if (second) rzlast += 1; @@ -236,18 +237,18 @@ void MatchEngine::execute() { Tracklet* proj = vmprojs_->getTracklet(projindex); - FPGAWord fpgafinephi = barrel_ ? proj->proj(layerdisk_).fpgafinephivm() : proj->diskProj(layerdisk_-5).fpgafinephivm(); + FPGAWord fpgafinephi = proj->proj(layerdisk_).fpgafinephivm(); projfinephi = fpgafinephi.value(); nstubs = vmstubs_->nStubsBin(rzbin); - projfinerz = barrel_ ? proj->proj(layerdisk_).fpgafinerzvm().value() : proj->diskProj(layerdisk_-5).fpgafinervm().value(); + 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->diskProj(layerdisk_-5).getBendIndex().value(); + : proj->proj(layerdisk_).getBendIndex().value(); assert(projrinv >= 0); if (settings_.extended() && projrinv == (1 << nrinv_)) { if (settings_.debugTracklet()) { diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index c5a8241d0ba60..b63e863971c8f 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -251,7 +251,7 @@ void MatchProcessor::execute() { Tracklet* proj = projMem->getTracklet(iproj); - FPGAWord fpgaphi = barrel_ ? proj->proj(layerdisk_).fpgaphiproj() : proj->diskProj(layerdisk_-N_LAYER+1).fpgaphiproj(); + FPGAWord fpgaphi = proj->proj(layerdisk_).fpgaphiproj(); unsigned int iphi = (fpgaphi.value() >> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); @@ -283,29 +283,30 @@ void MatchProcessor::execute() { // 1 - r projections // 2 - phi derivative // 3 - the sign - i.e. if track is forward or backward - int rindex = (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarproj().value() >> - (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarproj().nbits() - nrbits_)) & + + int rindex = (proj->proj(layerdisk_).fpgarzproj().value() >> (proj->proj(layerdisk_).fpgarzproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgaphiprojder().value() >> - (proj->diskProj(layerdisk_ - N_LAYER + 1).fpgaphiprojder().nbits() - nphiderbits_)) & + int phiderindex = (proj->proj(layerdisk_).fpgaphiprojder().value() >> + (proj->proj(layerdisk_).fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); - - int signindex = proj->diskProj(layerdisk_ - N_LAYER + 1).fpgarprojder().value() < 0; + + int signindex = proj->proj(layerdisk_).fpgarzprojder().value() < 0; int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex; projrinv = globals_->projectionRouterBendTable()->bendLoookup(layerdisk_ - N_LAYER, bendindex); - proj->diskProj(layerdisk_ - N_LAYER + 1).setBendIndex(projrinv); + proj->proj(layerdisk_).setBendIndex(projrinv); + } assert(projrinv >= 0); - unsigned int slot = barrel_ ? proj->proj(layerdisk_).fpgarzbin1projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin1projvm().value(); - bool second = (barrel_ ? proj->proj(layerdisk_).fpgarzbin2projvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgarbin2projvm().value()); + unsigned int slot = proj->proj(layerdisk_).fpgarzbin1projvm().value(); + bool second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + 3))) & 7; - int projfinerz = barrel_ ? proj->proj(layerdisk_).fpgafinerzvm().value() : proj->diskProj(layerdisk_-N_LAYER+1).fpgafinervm().value(); + int projfinerz = proj->proj(layerdisk_).fpgafinerzvm().value(); bool isPSseed = proj->PSseed(); @@ -571,14 +572,15 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { int iz = fpgastub->z().value(); - const DiskProjection& diskProj = tracklet->diskProj(disk); + const Projection& proj = tracklet->proj(layerdisk_); + + int iphi = proj.fpgaphiproj().value(); + int iphicorr = (iz * proj.fpgaphiprojder().value()) >> icorrshift_; - int iphi = diskProj.fpgaphiproj().value(); - int iphicorr = (iz * diskProj.fpgaphiprojder().value()) >> icorrshift_; iphi += iphicorr; - int ir = diskProj.fpgarproj().value(); - int ircorr = (iz * diskProj.fpgarprojder().value()) >> icorzshift_; + int ir = proj.fpgarzproj().value(); + int ircorr = (iz * proj.fpgarzprojder().value()) >> icorzshift_; ir += ircorr; int ideltaphi = fpgastub->phi().value() - iphi; @@ -631,15 +633,17 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { assert(std::abs(dz) < settings_.dzmax()); } - double phiproj = diskProj.phiproj() + dz * diskProj.phiprojder(); - double rproj = diskProj.rproj() + dz * diskProj.rprojder(); + double phiproj = proj.phiproj() + dz * proj.phiprojder(); + double rproj = proj.rzproj() + dz * proj.rzprojder(); double deltar = r - rproj; double dr = stub->r() - rproj; - double drapprox = stub->r() - (diskProj.rprojapprox() + dz * diskProj.rprojderapprox()); + double drapprox = stub->r() - (proj.rzprojapprox() + dz * proj.rzprojderapprox()); double dphi = reco::reduceRange(phi - phiproj); - double dphiapprox = reco::reduceRange(phi - (diskProj.phiprojapprox() + dz * diskProj.phiprojderapprox())); + + double dphiapprox = + reco::reduceRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox())); double drphi = dphi * stub->r(); double drphiapprox = dphiapprox * stub->r(); diff --git a/L1Trigger/TrackFindingTracklet/src/Projection.cc b/L1Trigger/TrackFindingTracklet/src/Projection.cc new file mode 100644 index 0000000000000..f91cedd2e4a4f --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/src/Projection.cc @@ -0,0 +1,138 @@ + +#include "L1Trigger/TrackFindingTracklet/interface/Projection.h" +#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +using namespace std; +using namespace trklet; + +void Projection::init(Settings const& settings, + unsigned int layerdisk, + int iphiproj, + int irzproj, + int iphider, + int irzder, + double phiproj, + double rzproj, + double phiprojder, + double rzprojder, + double phiprojapprox, + double rzprojapprox, + double phiprojderapprox, + double rzprojderapprox, + bool isPSseed) { + assert(layerdisk < N_LAYER+N_DISK); + + valid_ = true; + + fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); + + if (layerdisk < N_LAYER) { + fpgarzproj_.set(irzproj, settings.nzbitsstub(layerdisk), false, __LINE__, __FILE__); + } else { + fpgarzproj_.set(irzproj, settings.nrbitsstub(layerdisk), false, __LINE__, __FILE__); + } + + + if (layerdisk < N_LAYER) { + if (layerdisk < N_PSLAYER) { + fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); + fpgarzprojder_.set(irzder, settings.nbitszprojderL123(), false, __LINE__, __FILE__); + } else { + fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL456(), false, __LINE__, __FILE__); + fpgarzprojder_.set(irzder, settings.nbitszprojderL456(), false, __LINE__, __FILE__); + } + } else { + fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); + fpgarzprojder_.set(irzder, settings.nrbitsprojderdisk(), false, __LINE__, __FILE__); + } + + if (layerdisk < N_LAYER) { + + ////Separate the vm projections into zbins + ////This determines the central bin: + ////int zbin=4+(zproj.value()>>(zproj.nbits()-3)); + ////But we need some range (particularly for L5L6 seed projecting to L1-L3): + int offset = isPSseed?1:4; + + int ztemp = fpgarzproj_.value() >> (fpgarzproj_.nbits() - settings.MEBinsBits() - NFINERZBITS); + unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp - offset) >> NFINERZBITS); + unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp + offset) >> NFINERZBITS); + + if (zbin1 >= settings.MEBins()) { + zbin1 = 0; //note that zbin1 is unsigned + } + if (zbin2 >= settings.MEBins()) { + zbin2 = settings.MEBins() - 1; + } + + assert(zbin1 <= zbin2); + assert(zbin2 - zbin1 <= 1); + + fpgarzbin1projvm_.set(zbin1, settings.MEBinsBits(), true, __LINE__, __FILE__); // first z bin + + int nextbin = zbin1 != zbin2; + fpgarzbin2projvm_.set(nextbin, 1, true, __LINE__, __FILE__); // need to check adjacent z bin? + + //fine vm z bits. Use 4 bits for fine position. starting at zbin 1 + int finez = ((1 << (settings.MEBinsBits() + NFINERZBITS - 1)) + ztemp) - (zbin1 << NFINERZBITS); + + fpgafinerzvm_.set(finez, NFINERZBITS+1, true, __LINE__, __FILE__); // fine z postions starting at zbin1 + + } else { + + //TODO the -3 and +3 should be evaluated and efficiency for matching hits checked. + //This code should be migrated in the ProjectionRouter + double roffset = 3.0; + int rbin1 = 8.0 * (irzproj * settings.krprojshiftdisk() - roffset - settings.rmindiskvm()) / + (settings.rmaxdisk() - settings.rmindiskvm()); + int rbin2 = 8.0 * (irzproj * settings.krprojshiftdisk() + roffset - settings.rmindiskvm()) / + (settings.rmaxdisk() - settings.rmindiskvm()); + + if (irzproj * settings.krprojshiftdisk() < 20.0) { + edm::LogPrint("Tracklet") << " WARNING : irproj = " << irzproj << " " << irzproj * settings.krprojshiftdisk() << " " + << layerdisk; + } + + if (rbin1 < 0) { + rbin1 = 0; + } + rbin2 = clamp(rbin2, 0, 7); + + assert(rbin1 <= rbin2); + assert(rbin2 - rbin1 <= 1); + + int finer = 64 * + ((irzproj * settings.krprojshiftdisk() - settings.rmindiskvm()) - + rbin1 * (settings.rmaxdisk() - settings.rmindiskvm()) / 8.0) / + (settings.rmaxdisk() - settings.rmindiskvm()); + + finer = clamp(finer, 0, 15); + + int diff = rbin1 != rbin2; + if (irzder < 0) + rbin1 += 8; + + fpgarzbin1projvm_.set(rbin1, 4, true, __LINE__, __FILE__); // first r bin + fpgarzbin2projvm_.set(diff, 1, true, __LINE__, __FILE__); // need to check adjacent r bin + + fpgafinerzvm_.set(finer, 4, true, __LINE__, __FILE__); // fine r postions starting at rbin1 + + } + + //fine phi bits + int projfinephi = (fpgaphiproj_.value() >> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(layerdisk) + settings.nbitsvmme(layerdisk) + NFINEPHIBITS ))) & ((1<proj(layerdisk_).fpgaphiproj(); } else { int disk = layerdisk_ - (N_LAYER - 1); - DiskProjection& diskProj = tracklet->diskProj(disk); - fpgaphi = diskProj.fpgaphiproj(); + + 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 = (diskProj.fpgarproj().value() >> (diskProj.fpgarproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (diskProj.fpgaphiprojder().value() >> (diskProj.fpgaphiprojder().nbits() - nphiderbits_)) & + 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 = (diskProj.fpgarprojder().value() < 0); + int signindex = (proj.fpgarzprojder().value() < 0); int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex; int ibendproj = globals_->projectionRouterBendTable()->bendLoookup(disk - 1, bendindex); - diskProj.setBendIndex(ibendproj); + proj.setBendIndex(ibendproj); } unsigned int iphivm = diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 9525ab696f49d..3ad253478c4e5 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -505,13 +505,8 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { (seedindex == 11 && (Layer == 2 || abs(Disk) == 1 || abs(Disk) == 2))) { phiproj = stubphi; // Otherwise, get projection of tracklet - } else if (Layer != 0) { - phiproj = curTracklet->proj(Layer-1).phiproj(); - } else if (Disk != 0) { - phiproj = curTracklet->diskProj(Disk).phiproj(); } else { - throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Layer: " << Layer << " -- Disk: " << Disk - << " Stub is not layer or disk in getPhiRes"; + phiproj = curTracklet->proj(curStub->layerdisk()).phiproj(); } // Calculate residual phires = std::abs(stubphi - phiproj); diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index 07cb6b4758627..a473242e90c15 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -36,7 +36,6 @@ Tracklet::Tracklet(Settings const& settings, int iz0, int it, Projection projs[N_LAYER+N_DISK], - DiskProjection diskprojs[N_PROJ], bool disk, bool overlap) : settings_(settings) { @@ -107,10 +106,10 @@ Tracklet::Tracklet(Settings const& settings, for (unsigned int i = 0; i < N_DISK; i++) { if (projdisk_[i] == 0) continue; - if (!diskprojs[i].valid()) + if (!projs[N_LAYER + projdisk_[i] -1].valid()) continue; - diskproj_[projdisk_[i] - 1] = diskprojs[i]; + proj_[N_LAYER + projdisk_[i] - 1] = projs[N_LAYER + projdisk_[i] -1]; } ichisqrphifit_.set(-1, 8, false); @@ -262,9 +261,9 @@ std::string Tracklet::vmstrdisk(int disk, unsigned int allstubindex) { } else { index.set(allstubindex, 7, true, __LINE__, __FILE__); } - std::string oss = index.str() + "|" + diskproj_[disk - 1].fpgarbin1projvm().str() + "|" + - diskproj_[disk - 1].fpgarbin2projvm().str() + "|" + diskproj_[disk - 1].fpgafinervm().str() + "|" + - diskproj_[disk - 1].fpgafinephivm().str() + "|" + diskproj_[disk - 1].getBendIndex().str(); + std::string oss = index.str() + "|" + proj_[N_LAYER + disk - 1].fpgarzbin1projvm().str() + "|" + + proj_[N_LAYER + disk - 1].fpgarzbin2projvm().str() + "|" + proj_[N_LAYER + disk - 1].fpgafinerzvm().str() + + "|" + proj_[N_LAYER + disk - 1].fpgafinephivm().str() + "|" + proj_[N_LAYER + disk - 1].getBendIndex().str(); return oss; } @@ -292,10 +291,14 @@ std::string Tracklet::trackletprojstrD(int disk) const { } tmp.set(trackletIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__); FPGAWord tcid; - tcid.set(TCIndex_, settings_.nbitstcindex(), true, __LINE__, __FILE__); - std::string oss = tcid.str() + "|" + tmp.str() + "|" + diskproj_[abs(disk) - 1].fpgaphiproj().str() + "|" + - diskproj_[abs(disk) - 1].fpgarproj().str() + "|" + diskproj_[abs(disk) - 1].fpgaphiprojder().str() + - "|" + diskproj_[abs(disk) - 1].fpgarprojder().str(); + if (settings_.extended()) { + tcid.set(TCIndex_, 8, true, __LINE__, __FILE__); + } else { + tcid.set(TCIndex_, 7, true, __LINE__, __FILE__); + } + std::string oss = tcid.str() + "|" + tmp.str() + "|" + proj_[N_LAYER + abs(disk) - 1].fpgaphiproj().str() + "|" + + proj_[N_LAYER + abs(disk) - 1].fpgarzproj().str() + "|" + proj_[N_LAYER + abs(disk) - 1].fpgaphiprojder().str() + + "|" + proj_[N_LAYER + abs(disk) - 1].fpgarzprojder().str(); return oss; } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index 20629e5f095bc..c26c5cbe7edf5 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -211,20 +211,23 @@ void TrackletCalculatorBase::exactprojdisk(double zproj, } void TrackletCalculatorBase::addDiskProj(Tracklet* tracklet, int disk) { - FPGAWord fpgar = tracklet->diskProj(disk).fpgarproj(); + + disk=std::abs(disk); + + FPGAWord fpgar = tracklet->proj(N_LAYER+disk-1).fpgarzproj(); if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm()) return; if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk()) return; - FPGAWord fpgaphi = tracklet->diskProj(disk).fpgaphiproj(); + FPGAWord fpgaphi = tracklet->proj(N_LAYER+disk-1).fpgaphiproj(); int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5); - int iphi = iphivmRaw / (32 / settings_.nallstubs(abs(disk) + N_DISK)); + int iphi = iphivmRaw / (32 / settings_.nallstubs(disk + N_LAYER - 1)); - addProjectionDisk(disk, iphi, trackletprojdisks_[abs(disk) - 1][iphi], tracklet); + addProjectionDisk(disk, iphi, trackletprojdisks_[disk - 1][iphi], tracklet); } bool TrackletCalculatorBase::addLayerProj(Tracklet* tracklet, int layer) { @@ -484,7 +487,6 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, int irinv, iphi0, it, iz0; Projection projs[N_LAYER+N_DISK]; - DiskProjection diskprojs[N_DISK]; int iphiproj[N_LAYER - 2], izproj[N_LAYER - 2]; int iphiprojdisk[N_DISK], irprojdisk[N_DISK]; @@ -633,22 +635,24 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] < settings_.rmindisk() / ITC->rD_0_final.K() || irprojdisk[i] > settings_.rmaxdisk() / ITC->rD_0_final.K()) continue; + + projs[i+N_LAYER].init(settings_, + i+N_LAYER, + iphiprojdisk[i], + irprojdisk[i], + ITC->der_phiD_final.ival(), + ITC->der_rD_final.ival(), + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + ITC->der_phiD_final.fval(), + ITC->der_rD_final.fval(), + !(iSeed_ == 2 || iSeed_ == 3)); + - diskprojs[i].init(settings_, - i + 1, - settings_.zmean(i), - iphiprojdisk[i], - irprojdisk[i], - ITC->der_phiD_final.ival(), - ITC->der_rD_final.ival(), - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - ITC->der_phiD_final.fval(), - ITC->der_rD_final.fval()); } } @@ -682,7 +686,6 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, iz0, it, projs, - diskprojs, false); if (settings_.debugTracklet()) { @@ -750,7 +753,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, continue; if (it < 0) disk = -disk; - if (tracklet->validProjDisk(abs(disk))) { + if (tracklet->validProj(N_LAYER + abs(disk) -1 )) { addDiskProj(tracklet, disk); } } @@ -977,7 +980,6 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, return false; Projection projs[N_LAYER+N_DISK]; - DiskProjection diskprojs[N_DISK - 2]; for (unsigned int i = 0; i < N_DISK - 2; ++i) { //Check is outside z range @@ -1031,21 +1033,21 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] <= 0 || irprojdisk[i] > settings_.rmaxdisk() / ITC->rD_0_final.K()) continue; - diskprojs[i].init(settings_, - settings_.projdisks(iSeed_, i), - settings_.zmean(settings_.projdisks(iSeed_, i) - 1), - iphiprojdisk[i], - irprojdisk[i], - ITC->der_phiD_final.ival(), - ITC->der_rD_final.ival(), - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - ITC->der_phiD_final.fval(), - ITC->der_rD_final.fval()); + projs[settings_.projdisks(iSeed_, i)+N_LAYER-1].init(settings_, + settings_.projdisks(iSeed_, i)+N_LAYER-1, + iphiprojdisk[i], + irprojdisk[i], + ITC->der_phiD_final.ival(), + ITC->der_rD_final.ival(), + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + ITC->der_phiD_final.fval(), + ITC->der_rD_final.fval(), + true); } if (settings_.writeMonitorData("TPars")) { @@ -1079,7 +1081,6 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, iz0, it, projs, - diskprojs, true); if (settings_.debugTracklet()) { @@ -1105,7 +1106,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, } for (unsigned int j = 0; j < N_DISK - 2; j++) { - if (tracklet->validProjDisk(sign * settings_.projdisks(iSeed_, j))) { + if (tracklet->validProj(N_LAYER + settings_.projdisks(iSeed_, j) - 1)) { addDiskProj(tracklet, sign * settings_.projdisks(iSeed_, j)); } } @@ -1350,7 +1351,6 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, return false; Projection projs[N_LAYER+N_DISK]; - DiskProjection diskprojs[N_DISK]; for (unsigned int i = 0; i < N_DISK - 2; ++i) { //check that zproj is in range @@ -1396,21 +1396,21 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] <= 0 || irprojdisk[i] > settings_.rmaxdisk() / ITC->rD_0_final.K()) continue; - diskprojs[i].init(settings_, - i + 2, - settings_.zmean(i + 1), - iphiprojdisk[i], - irprojdisk[i], - ITC->der_phiD_final.ival(), - ITC->der_rD_final.ival(), - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - ITC->der_phiD_final.fval(), - ITC->der_rD_final.fval()); + projs[N_LAYER+i+1].init(settings_, + N_LAYER+i+1, + iphiprojdisk[i], + irprojdisk[i], + ITC->der_phiD_final.ival(), + ITC->der_rD_final.ival(), + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + ITC->der_phiD_final.fval(), + ITC->der_rD_final.fval(), + true); } if (settings_.writeMonitorData("TPars")) { @@ -1443,7 +1443,6 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, iz0, it, projs, - diskprojs, false, true); @@ -1472,7 +1471,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, for (unsigned int disk = 2; disk < 6; disk++) { if (layer == 2 && disk == 5) continue; - if (tracklet->validProjDisk(disk)) { + if (tracklet->validProj(N_LAYER + disk - 1)) { addDiskProj(tracklet, disk); } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 50c9b95030234..449641bb528a3 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -296,19 +296,21 @@ void TrackletCalculatorDisplaced::execute() { } void TrackletCalculatorDisplaced::addDiskProj(Tracklet* tracklet, int disk) { - FPGAWord fpgar = tracklet->diskProj(disk).fpgarproj(); + + disk = std::abs(disk); + FPGAWord fpgar = tracklet->proj(disk).fpgarzproj(); if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm()) return; if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk()) return; - FPGAWord fpgaphi = tracklet->diskProj(disk).fpgaphiproj(); + FPGAWord fpgaphi = tracklet->proj(disk).fpgaphiproj(); int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5); - int iphi = iphivmRaw / (32 / settings_.nallstubs(abs(disk) + N_DISK)); + int iphi = iphivmRaw / (32 / settings_.nallstubs(disk + N_LAYER -1)); - addProjectionDisk(disk, iphi, trackletprojdisks_[abs(disk) - 1][iphi], tracklet); + addProjectionDisk(disk, iphi, trackletprojdisks_[disk - 1][iphi], tracklet); } bool TrackletCalculatorDisplaced::addLayerProj(Tracklet* tracklet, int layer) { @@ -398,7 +400,6 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, double rinv, phi0, d0, t, z0; Projection projs[N_LAYER+N_DISK]; - DiskProjection diskprojs[N_DISK]; double phiproj[N_LAYER - 2], zproj[N_LAYER - 2], phider[N_LAYER - 2], zder[N_LAYER - 2]; double phiprojdisk[N_DISK], rprojdisk[N_DISK], phiderdisk[N_DISK], rderdisk[N_DISK]; @@ -688,21 +689,21 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, if (rprojdiskapprox[i] < settings_.rmindisk() || rprojdiskapprox[i] > settings_.rmaxdisk()) continue; - diskprojs[i].init(settings_, - i + 1, - rproj_[i], - iphiprojdisk[i], - irprojdisk[i], - iphiderdisk[i], - irderdisk[i], - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - phiderdisk[i], - rderdisk[i]); + projs[N_LAYER + i].init(settings_, + N_LAYER + i, + iphiprojdisk[i], + irprojdisk[i], + iphiderdisk[i], + irderdisk[i], + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + phiderdisk[i], + rderdisk[i], + false); } } @@ -735,7 +736,6 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, iz0, it, projs, - diskprojs, false); if (settings_.debugTracklet()) @@ -779,7 +779,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, disk = -disk; if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk; - if (tracklet->validProjDisk(abs(disk))) { + if (tracklet->validProj(N_LAYER + abs(disk) -1)) { addDiskProj(tracklet, disk); } } @@ -1025,7 +1025,6 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, } Projection projs[N_LAYER+N_DISK]; - DiskProjection diskprojs[N_DISK]; for (unsigned int i = 0; i < toR_.size(); ++i) { iphiproj[i] = phiprojapprox[i] / kphiproj; @@ -1098,21 +1097,21 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] < settings_.rmindisk() / krprojdisk || irprojdisk[i] > settings_.rmaxdisk() / krprojdisk) continue; - diskprojs[i].init(settings_, - i + 1, - rproj_[i], - iphiprojdisk[i], - irprojdisk[i], - iphiderdisk[i], - irderdisk[i], - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - phiderdisk[i], - rderdisk[i]); + projs[N_LAYER + i].init(settings_, + N_LAYER + i, + iphiprojdisk[i], + irprojdisk[i], + iphiderdisk[i], + irderdisk[i], + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + phiderdisk[i], + rderdisk[i], + false); } } @@ -1145,7 +1144,6 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, iz0, it, projs, - diskprojs, true); if (settings_.debugTracklet()) @@ -1179,8 +1177,8 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, disk = -disk; if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk << " " - << tracklet->validProjDisk(abs(disk)); - if (tracklet->validProjDisk(abs(disk))) { + << tracklet->validProj(N_LAYER + abs(disk) + 1); + if (tracklet->validProj(N_LAYER+abs(disk)-1)) { addDiskProj(tracklet, disk); } } @@ -1426,7 +1424,6 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, } Projection projs[N_LAYER+N_DISK]; - DiskProjection diskprojs[N_DISK]; for (unsigned int i = 0; i < toR_.size(); ++i) { iphiproj[i] = phiprojapprox[i] / kphiproj; @@ -1499,21 +1496,21 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] < settings_.rmindisk() / krprojdisk || irprojdisk[i] > settings_.rmaxdisk() / krprojdisk) continue; - diskprojs[i].init(settings_, - i + 1, - rproj_[i], - iphiprojdisk[i], - irprojdisk[i], - iphiderdisk[i], - irderdisk[i], - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - phiderdisk[i], - rderdisk[i]); + projs[N_LAYER+i].init(settings_, + i, + iphiprojdisk[i], + irprojdisk[i], + iphiderdisk[i], + irderdisk[i], + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + phiderdisk[i], + rderdisk[i], + false); } } @@ -1546,7 +1543,6 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, iz0, it, projs, - diskprojs, false); if (settings_.debugTracklet()) @@ -1579,7 +1575,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, disk = -disk; if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk; - if (tracklet->validProjDisk(abs(disk))) { + if (tracklet->validProj(N_LAYER + abs(disk) - 1)) { addDiskProj(tracklet, disk); } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc index 173326b4d25b1..ae621073605ec 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc @@ -18,9 +18,9 @@ void TrackletProjectionsMemory::addProj(Tracklet* tracklet) { if (layer_ != 0 && disk_ == 0) assert(tracklet->validProj(layer_-1)); if (layer_ == 0 && disk_ != 0) - assert(tracklet->validProjDisk(disk_)); + assert(tracklet->validProj(N_LAYER + abs(disk_) -1 )); if (layer_ != 0 && disk_ != 0) - assert(tracklet->validProj(layer_-1) || tracklet->validProjDisk(disk_)); + assert(tracklet->validProj(layer_-1) || tracklet->validProj(N_LAYER+abs(disk_)-1)); for (auto& itracklet : tracklets_) { if (itracklet == tracklet) { From e6474571b3bd4af33406aab08ec019e6ea50be30 Mon Sep 17 00:00:00 2001 From: Anders Date: Sat, 6 Mar 2021 17:51:39 +0100 Subject: [PATCH 07/45] Correct number of processing steps by changing < to <= --- L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc | 2 +- L1Trigger/TrackFindingTracklet/src/VMRouter.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc index 3bf5560879d43..6c991a8fc23be 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc @@ -81,7 +81,7 @@ void ProjectionRouter::execute() { for (auto& iproj : inputproj_) { for (unsigned int i = 0; i < iproj->nTracklets(); i++) { - if (allprojcount > settings_.maxStep("PR")) + if (allprojcount >= settings_.maxStep("PR")) continue; Tracklet* tracklet = iproj->getTracklet(i); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc index a517b03358a63..55817f28f5924 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc @@ -149,7 +149,7 @@ void VMRouter::execute() { //Loop over the input stubs for (auto& stubinput : stubinputs_) { for (unsigned int i = 0; i < stubinput->nStubs(); i++) { - if (allStubCounter > settings_.maxStep("VMR")) + if (allStubCounter >= settings_.maxStep("VMR")) continue; if (allStubCounter > 127) continue; From b51b039e96b35a974694fa26e9650559bb422535 Mon Sep 17 00:00:00 2001 From: Anders Date: Sun, 7 Mar 2021 21:58:53 +0100 Subject: [PATCH 08/45] Add missing include of algorithm --- L1Trigger/TrackFindingTracklet/src/Projection.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/L1Trigger/TrackFindingTracklet/src/Projection.cc b/L1Trigger/TrackFindingTracklet/src/Projection.cc index f91cedd2e4a4f..a6b68dec55551 100644 --- a/L1Trigger/TrackFindingTracklet/src/Projection.cc +++ b/L1Trigger/TrackFindingTracklet/src/Projection.cc @@ -3,6 +3,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include using namespace std; using namespace trklet; From cf5498de2bd2026e45ff0677c223f486417b67e3 Mon Sep 17 00:00:00 2001 From: Anders Date: Mon, 8 Mar 2021 16:17:59 +0100 Subject: [PATCH 09/45] Remove extra const --- L1Trigger/TrackFindingTracklet/interface/Tracklet.h | 6 +++--- L1Trigger/TrackFindingTracklet/src/Tracklet.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index d9e3ce555db68..3578c017ec322 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -244,11 +244,11 @@ namespace trklet { int TCID() const { return TCIndex_ * (1 << settings_.nbitstrackletindex()) + trackletIndex_; } - const int getISeed() const; - const int getITC() const; + int getISeed() const; + int getITC() const; void setTrackIndex(int index); - const int trackIndex() const; + int trackIndex() const; unsigned int PSseed() const { return ((layer() == 1) || (layer() == 2) || (disk() != 0)) ? 1 : 0; } diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index a473242e90c15..da59f270df2f7 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -857,13 +857,13 @@ void Tracklet::setTrackletIndex(unsigned int index) { assert(index <= settings_.ntrackletmax()); } -const int Tracklet::getISeed() const { +int Tracklet::getISeed() const { const int iSeed = TCIndex_ >> settings_.nbitsitc(); assert(iSeed >= 0 && iSeed <= (int)N_SEED); return iSeed; } -const int Tracklet::getITC() const { +int Tracklet::getITC() const { const int iSeed = getISeed(), iTC = TCIndex_ - (iSeed << settings_.nbitsitc()); assert(iTC >= 0 && iTC <= 14); return iTC; @@ -874,7 +874,7 @@ void Tracklet::setTrackIndex(int index) { assert(index <= (int)settings_.ntrackletmax()); } -const int Tracklet::trackIndex() const { return trackIndex_; } +int Tracklet::trackIndex() const { return trackIndex_; } unsigned int Tracklet::calcSeedIndex() const { int seedindex = -1; From 1bf7df1c82397c395cb71875c22003d513ba79bd Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Mon, 8 Mar 2021 10:33:42 -0500 Subject: [PATCH 10/45] Remove some commented out code --- L1Trigger/TrackFindingTracklet/test/fpga.cc | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index 8ef1aff36ee46..287f157e5a2a7 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -116,27 +116,6 @@ int main(const int argc, const char **argv) { for (int eventnum = 0; eventnum < nevents && !in->eof(); eventnum++) { SLHCEvent ev(*in); - /* - - L1SimTrack simtrk; - - if (ev.nsimtracks()==0) { - continue; - } - - simtrk=ev.simtrack(0); - - double eta=simtrk.eta(); - - if (std::abs(std::abs(eta)-1.45)>0.15) { - continue; - } - if (simtrk.pt()<5.0) continue; - if (simtrk.pt()<2.0) continue; - - cout << "x,y,z : "< Date: Mon, 8 Mar 2021 16:45:28 -0500 Subject: [PATCH 11/45] Remove duplicate code --- L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc index cc177337fbaad..0558cd23ad5ba 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc @@ -88,14 +88,6 @@ void TrackletEngineUnit::step(bool print, int istep, int iTE) { idphi = idphi & ((1 << nbitsfinephidiff_) - 1); - if (iSeed_ >= 4) { //Also use r-position - int ir = ((ibin & 3) << 1) + (rzbin >> 2); - idphi = (idphi << 3) + ir; - } - - if (next_ != 0) - rzbin += 8; - unsigned int firstDiskSeed = 4; if (iSeed_ >= firstDiskSeed) { //Also use r-position int ibinMask = 3; //Get two least sign. bits @@ -106,6 +98,7 @@ void TrackletEngineUnit::step(bool print, int istep, int iTE) { if (next_ != 0) rzbin += (1 << NFINERZBITS); + if ((rzbin < tedata_.rzbinfirst_) || (rzbin - tedata_.rzbinfirst_ > tedata_.rzdiffmax_)) { if (settings_->debugTracklet()) { edm::LogVerbatim("Tracklet") << " layer-disk stub pair rejected because rbin cut : " << rzbin << " " From 314eb77b38af7bb6d3520ace8886a040b382850a Mon Sep 17 00:00:00 2001 From: Anders Date: Tue, 9 Mar 2021 23:40:14 +0100 Subject: [PATCH 12/45] Fix message logger and DTC Stub for consistency with hybrid configuration --- .../TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py | 5 ++--- L1Trigger/TrackerDTC/src/Stub.cc | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index ade9bd3bb2e4d..ab4700cc12ce0 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -28,9 +28,8 @@ process.load('Configuration.StandardSequences.MagneticField_cff') process.load('FWCore.MessageService.MessageLogger_cfi') -process.MessageLogger.categories.append('Tracklet') -process.MessageLogger.categories.append('L1track') -process.MessageLogger.Tracklet = cms.untracked.PSet(limit = cms.untracked.int32(-1)) +process.MessageLogger.L1track = dict(limit = -1) +process.MessageLogger.Tracklet = dict(limit = -1) if GEOMETRY == "D49": print "using geometry " + GEOMETRY + " (tilted)" diff --git a/L1Trigger/TrackerDTC/src/Stub.cc b/L1Trigger/TrackerDTC/src/Stub.cc index 73b23f4a7be38..4f50ff9189dae 100644 --- a/L1Trigger/TrackerDTC/src/Stub.cc +++ b/L1Trigger/TrackerDTC/src/Stub.cc @@ -131,9 +131,9 @@ namespace trackerDTC { // encode bend const vector& encodingBend = setup.encodingBend(sm->windowSize(), sm->psModule()); - const auto pos = find(encodingBend.begin(), encodingBend.end(), abs(bend_)); + const auto pos = find(encodingBend.begin(), encodingBend.end(), abs(ttStubRef->bendBE())); const int uBend = distance(encodingBend.begin(), pos); - bend_ = pow(-1, signbit(bend_)) * (uBend - (int)encodingBend.size() / 2); + bend_ = pow(-1, signbit(bend_)) * uBend; } // returns bit accurate representation of Stub @@ -149,7 +149,8 @@ namespace trackerDTC { TTDTC::BV Stub::formatHybrid(int region) const { const SensorModule::Type type = sm_->type(); // stub phi w.r.t. processing region centre in rad - const double phi = phi_ - (region - .5) * setup_->baseRegion(); + const double phi = phi_ - (region - .5) * setup_->baseRegion() + 0.5 * setup_->hybridBasePhi(type) * (1<hybridWidthPhi(type)); + // convert stub variables into bit vectors const TTBV hwR(r_, setup_->hybridBaseR(type), setup_->hybridWidthR(type), true); const TTBV hwPhi(phi, setup_->hybridBasePhi(type), setup_->hybridWidthPhi(type), true); @@ -235,4 +236,4 @@ namespace trackerDTC { hwLayer.str()); } -} // namespace trackerDTC \ No newline at end of file +} // namespace trackerDTC From 03717725c6b23abb00277b51919bf0976d9e400e Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Tue, 9 Mar 2021 17:56:02 -0500 Subject: [PATCH 13/45] Fix problem with writing of input link memories --- L1Trigger/TrackFindingTracklet/src/Sector.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 982a87a8162b7..6999d57150d96 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -124,9 +124,10 @@ void Sector::writeLinkNewEvent(int event) { string dtcnametmp = (neg == 0 ? "" : "neg") + dtcbasename; for (int ab = 0; ab < 2; ab++) { string dtcname = dtcnametmp + (ab == 0 ? "_A" : "_B"); - string fname = "../data/MemPrints/InputStubs/Link_" + dtcname + "_" + to_string(isector_ + 1) + ".dat"; + string dirName = settings_.memPath() + "InputStubs/"; + string fname = dirName + "Link_" + dtcname + "_" + to_string(isector_ + 1) + ".dat"; ofstream* out = new ofstream; - out->open(fname.c_str()); + openfile(*out, true, dirName,fname, __FILE__, __LINE__); DTCLink_ofstreams_[dtcname] = out; } } From c9c646a682c7a25145a8a602c2ecec56771c268c Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Tue, 9 Mar 2021 20:45:54 -0500 Subject: [PATCH 14/45] Create Residual class that will replace LayerResidual and DiskResidual --- .../interface/{LayerResidual.h => Residual.h} | 45 +++++++-------- .../TrackFindingTracklet/interface/Settings.h | 2 +- .../TrackFindingTracklet/interface/Tracklet.h | 13 ++--- .../TrackFindingTracklet/src/FitTrack.cc | 48 ++++++++-------- .../src/MatchCalculator.cc | 1 - .../src/MatchProcessor.cc | 1 - .../src/{LayerResidual.cc => Residual.cc} | 30 +++++----- .../TrackFindingTracklet/src/Tracklet.cc | 57 +++++++++---------- 8 files changed, 94 insertions(+), 103 deletions(-) rename L1Trigger/TrackFindingTracklet/interface/{LayerResidual.h => Residual.h} (61%) rename L1Trigger/TrackFindingTracklet/src/{LayerResidual.cc => Residual.cc} (54%) diff --git a/L1Trigger/TrackFindingTracklet/interface/LayerResidual.h b/L1Trigger/TrackFindingTracklet/interface/Residual.h similarity index 61% rename from L1Trigger/TrackFindingTracklet/interface/LayerResidual.h rename to L1Trigger/TrackFindingTracklet/interface/Residual.h index 1c2cf303ae479..8eb934bee4d92 100644 --- a/L1Trigger/TrackFindingTracklet/interface/LayerResidual.h +++ b/L1Trigger/TrackFindingTracklet/interface/Residual.h @@ -1,5 +1,5 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_LayerResidual_h -#define L1Trigger_TrackFindingTracklet_interface_LayerResidual_h +#ifndef L1Trigger_TrackFindingTracklet_interface_Residual_h +#define L1Trigger_TrackFindingTracklet_interface_Residual_h #include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" @@ -10,22 +10,21 @@ namespace trklet { class Settings; class Stub; - class LayerResidual { + class Residual { public: - LayerResidual() { valid_ = false; } + Residual() { valid_ = false; } - ~LayerResidual() = default; + ~Residual() = default; void init(Settings const& settings, - int layer, + unsigned int layerdisk, int iphiresid, - int izresid, + int irzresid, int istubid, double phiresid, - double zresid, + double rzresid, double phiresidapprox, - double zresidapprox, - double rstub, + double rzresidapprox, const Stub* stubptr); bool valid() const { return valid_; } @@ -35,9 +34,9 @@ namespace trklet { return fpgaphiresid_; }; - const FPGAWord& fpgazresid() const { + const FPGAWord& fpgarzresid() const { assert(valid_); - return fpgazresid_; + return fpgarzresid_; }; const FPGAWord& fpgastubid() const { @@ -50,9 +49,9 @@ namespace trklet { return phiresid_; }; - double zresid() const { + double rzresid() const { assert(valid_); - return zresid_; + return rzresid_; }; double phiresidapprox() const { @@ -60,16 +59,11 @@ namespace trklet { return phiresidapprox_; }; - double zresidapprox() const { + double rzresidapprox() const { assert(valid_); - return zresidapprox_; + return rzresidapprox_; }; - double rstub() const { - assert(valid_); - return rstub_; - } - const Stub* stubptr() const { assert(valid_); return stubptr_; @@ -78,19 +72,18 @@ namespace trklet { protected: bool valid_; - int layer_; + unsigned int layerdisk_; FPGAWord fpgaphiresid_; - FPGAWord fpgazresid_; + FPGAWord fpgarzresid_; FPGAWord fpgastubid_; double phiresid_; - double zresid_; + double rzresid_; double phiresidapprox_; - double zresidapprox_; + double rzresidapprox_; - double rstub_; const Stub* stubptr_; }; diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 8560150ab32e9..bb463794c6f87 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -746,7 +746,7 @@ namespace trklet { {"TPars", false}, {"TPD", false}, {"TrackletPars", false}, {"TED", false}, {"TP", false}, {"TRE", false}, {"VMR", false}, {"StubsLayer", false}, {"StubsLayerSector", false}, - {"HitEff", false}, {"MatchEff", false}, {"Cabling", false}, + {"HitEff", false}, {"MatchEff", true}, {"Cabling", false}, {"IFit", false}, {"AS", false}}; std::array rDSSinner_mod_{{68.9391, 78.7750, 85.4550, 96.3150, 102.3160}}; diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 3578c017ec322..041ac52246c06 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -15,7 +15,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/Track.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackPars.h" #include "L1Trigger/TrackFindingTracklet/interface/Projection.h" -#include "L1Trigger/TrackFindingTracklet/interface/LayerResidual.h" +#include "L1Trigger/TrackFindingTracklet/interface/Residual.h" #include "L1Trigger/TrackFindingTracklet/interface/DiskResidual.h" #include "L1Trigger/TrackFindingTracklet/interface/Util.h" @@ -113,7 +113,6 @@ namespace trklet { double dphiapprox, double dzapprox, int stubid, - double rstub, const trklet::Stub* stubptr); void addMatchDisk(int disk, @@ -136,13 +135,13 @@ namespace trklet { bool match(int layer) { assert(layer > 0 && layer <= N_LAYER); - return layerresid_[layer - 1].valid(); + return resid_[layer - 1].valid(); } - const LayerResidual& layerResid(int layer) { + const Residual& resid(int layer) { assert(layer > 0 && layer <= N_LAYER); - assert(layerresid_[layer - 1].valid()); - return layerresid_[layer - 1]; + assert(resid_[layer - 1].valid()); + return resid_[layer - 1]; } std::vector getL1Stubs(); @@ -306,7 +305,7 @@ namespace trklet { Projection proj_[N_LAYER+N_DISK]; - LayerResidual layerresid_[N_LAYER]; + Residual resid_[N_LAYER]; DiskResidual diskresid_[N_DISK]; Settings const& settings_; diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 7d0fa0468e355..50ba0c4e64604 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -201,15 +201,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: continue; } if (tracklet->match(l)) { - const LayerResidual& layerResid = tracklet->layerResid(l); + const Residual& resid = tracklet->resid(l); lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - phiresid[nlayers] = layerResid.phiresidapprox(); - zresid[nlayers] = layerResid.zresidapprox(); - phiresidexact[nlayers] = layerResid.phiresid(); - zresidexact[nlayers] = layerResid.zresid(); - iphiresid[nlayers] = layerResid.fpgaphiresid().value(); - izresid[nlayers] = layerResid.fpgazresid().value(); + phiresid[nlayers] = resid.phiresidapprox(); + zresid[nlayers] = resid.rzresidapprox(); + phiresidexact[nlayers] = resid.phiresid(); + zresidexact[nlayers] = resid.rzresid(); + iphiresid[nlayers] = resid.fpgaphiresid().value(); + izresid[nlayers] = resid.fpgarzresid().value(); layers[nlayers++] = l; } @@ -267,13 +267,13 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const LayerResidual& layerResid = tracklet->layerResid(l); - phiresid[nlayers] = layerResid.phiresidapprox(); - zresid[nlayers] = layerResid.zresidapprox(); - phiresidexact[nlayers] = layerResid.phiresid(); - zresidexact[nlayers] = layerResid.zresid(); - iphiresid[nlayers] = layerResid.fpgaphiresid().value(); - izresid[nlayers] = layerResid.fpgazresid().value(); + const Residual& resid = tracklet->resid(l); + phiresid[nlayers] = resid.phiresidapprox(); + zresid[nlayers] = resid.rzresidapprox(); + phiresidexact[nlayers] = resid.phiresid(); + zresidexact[nlayers] = resid.rzresid(); + iphiresid[nlayers] = resid.fpgaphiresid().value(); + izresid[nlayers] = resid.fpgarzresid().value(); layers[nlayers++] = l; } @@ -342,15 +342,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (tracklet->match(l)) { lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const LayerResidual& layerResid = tracklet->layerResid(l); - assert(std::abs(layerResid.phiresidapprox()) < 0.2); - phiresid[nlayers] = layerResid.phiresidapprox(); - zresid[nlayers] = layerResid.zresidapprox(); - assert(std::abs(layerResid.phiresid()) < 0.2); - phiresidexact[nlayers] = layerResid.phiresid(); - zresidexact[nlayers] = layerResid.zresid(); - iphiresid[nlayers] = layerResid.fpgaphiresid().value(); - izresid[nlayers] = layerResid.fpgazresid().value(); + const Residual& resid = tracklet->resid(l); + assert(std::abs(resid.phiresidapprox()) < 0.2); + phiresid[nlayers] = resid.phiresidapprox(); + zresid[nlayers] = resid.rzresidapprox(); + assert(std::abs(resid.phiresid()) < 0.2); + phiresidexact[nlayers] = resid.phiresid(); + zresidexact[nlayers] = resid.rzresid(); + iphiresid[nlayers] = resid.fpgaphiresid().value(); + izresid[nlayers] = resid.fpgarzresid().value(); layers[nlayers++] = l; } @@ -462,7 +462,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: realrstub[i] = tracklet->outerStub()->r(); } if (tracklet->match(layers[i]) && layers[i] < 4) { - const Stub* stubptr = tracklet->layerResid(layers[i]).stubptr(); + const Stub* stubptr = tracklet->resid(layers[i]).stubptr(); realrstub[i] = stubptr->l1tstub()->r(); assert(std::abs(realrstub[i] - r[i]) < 5.0); } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index f505a899543c8..44e756cc28be5 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -327,7 +327,6 @@ void MatchCalculator::execute() { dphiapprox, dzapprox, (phiregion_ << 7) + fpgastub->stubindex().value(), - stub->r(), mergedMatches[j].second); if (settings_.debugTracklet()) { diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index b63e863971c8f..6ff9869ad0672 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -543,7 +543,6 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { dphiapprox, dzapprox, (phiregion_ << 7) + fpgastub->stubindex().value(), - stub->r(), fpgastub); if (settings_.debugTracklet()) { diff --git a/L1Trigger/TrackFindingTracklet/src/LayerResidual.cc b/L1Trigger/TrackFindingTracklet/src/Residual.cc similarity index 54% rename from L1Trigger/TrackFindingTracklet/src/LayerResidual.cc rename to L1Trigger/TrackFindingTracklet/src/Residual.cc index b9483e5135881..224d836185b19 100644 --- a/L1Trigger/TrackFindingTracklet/src/LayerResidual.cc +++ b/L1Trigger/TrackFindingTracklet/src/Residual.cc @@ -1,42 +1,44 @@ -#include "L1Trigger/TrackFindingTracklet/interface/LayerResidual.h" +#include "L1Trigger/TrackFindingTracklet/interface/Residual.h" #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" using namespace std; using namespace trklet; -void LayerResidual::init(Settings const& settings, - int layer, +void Residual::init(Settings const& settings, + unsigned int layerdisk, int iphiresid, - int izresid, + int irzresid, int istubid, double phiresid, - double zresid, + double rzresid, double phiresidapprox, - double zresidapprox, - double rstub, + double rzresidapprox, const Stub* stubptr) { - assert(layer > 0); - assert(layer <= N_LAYER); + assert(layerdisk < N_LAYER + N_DISK); if (valid_ && (std::abs(iphiresid) > std::abs(fpgaphiresid_.value()))) return; valid_ = true; - layer_ = layer; + layerdisk_ = layerdisk; fpgaphiresid_.set(iphiresid, settings.phiresidbits(), false, __LINE__, __FILE__); - fpgazresid_.set(izresid, settings.zresidbits(), false, __LINE__, __FILE__); + if (layerdisk < N_LAYER) { + fpgarzresid_.set(irzresid, settings.zresidbits(), false, __LINE__, __FILE__); + } else { + fpgarzresid_.set(irzresid, settings.rresidbits(), false, __LINE__, __FILE__); + } + int nbitsid = 10; fpgastubid_.set(istubid, nbitsid, true, __LINE__, __FILE__); assert(!fpgaphiresid_.atExtreme()); phiresid_ = phiresid; - zresid_ = zresid; + rzresid_ = rzresid; phiresidapprox_ = phiresidapprox; - zresidapprox_ = zresidapprox; + rzresidapprox_ = rzresidapprox; - rstub_ = rstub; stubptr_ = stubptr; } diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index da59f270df2f7..217b55745e53b 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -310,11 +310,10 @@ void Tracklet::addMatch(int layer, double dphiapprox, double dzapprox, int stubid, - double rstub, const trklet::Stub* stubptr) { assert(layer > 0 && layer <= N_LAYER); - layerresid_[layer - 1].init( - settings_, layer, ideltaphi, ideltaz, stubid, dphi, dz, dphiapprox, dzapprox, rstub, stubptr); + resid_[layer - 1].init( + settings_, layer, ideltaphi, ideltaz, stubid, dphi, dz, dphiapprox, dzapprox, stubptr); } void Tracklet::addMatchDisk(int disk, @@ -347,8 +346,8 @@ void Tracklet::addMatchDisk(int disk, int Tracklet::nMatches() { int nmatches = 0; - for (const auto& ilayerresid : layerresid_) { - if (ilayerresid.valid()) { + for (const auto& iresid : resid_) { + if (iresid.valid()) { nmatches++; } } @@ -377,9 +376,9 @@ std::string Tracklet::fullmatchstr(int layer) { tmp.set(trackletIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__); FPGAWord tcid; tcid.set(TCIndex_, settings_.nbitstcindex(), true, __LINE__, __FILE__); - std::string oss = tcid.str() + "|" + tmp.str() + "|" + layerresid_[layer - 1].fpgastubid().str() + "|" + - layerresid_[layer - 1].stubptr()->r().str() + "|" + layerresid_[layer - 1].fpgaphiresid().str() + - "|" + layerresid_[layer - 1].fpgazresid().str(); + std::string oss = tcid.str() + "|" + tmp.str() + "|" + resid_[layer - 1].fpgastubid().str() + "|" + + resid_[layer - 1].stubptr()->r().str() + "|" + resid_[layer - 1].fpgaphiresid().str() + + "|" + resid_[layer - 1].fpgarzresid().str(); return oss; } @@ -411,9 +410,9 @@ std::vector Tracklet::getL1Stubs() { if (outerStub_) tmp.push_back(outerStub_); - for (const auto& ilayerresid : layerresid_) { - if (ilayerresid.valid()) - tmp.push_back(ilayerresid.stubptr()->l1tstub()); + for (const auto& iresid : resid_) { + if (iresid.valid()) + tmp.push_back(iresid.stubptr()->l1tstub()); } for (const auto& idiskresid : diskresid_) { @@ -441,19 +440,19 @@ std::map Tracklet::getStubIDs() { if (barrel_) { for (int i = 0; i < N_LAYER; i++) { //check barrel - if (layerresid_[i].valid()) { + if (resid_[i].valid()) { // two extra bits to indicate if the matched stub is local or from neighbor int location = 1; // local - location <<= layerresid_[i].fpgastubid().nbits(); + location <<= resid_[i].fpgastubid().nbits(); - stubIDs[1 + i] = layerresid_[i].fpgastubid().value() + location; + stubIDs[1 + i] = resid_[i].fpgastubid().value() + location; } //check disk if (i >= N_DISK) continue; //i=[0..4] for disks if (diskresid_[i].valid()) { - if (i == 3 && layerresid_[0].valid() && innerFPGAStub_->layer().value() == 1) + if (i == 3 && resid_[0].valid() && innerFPGAStub_->layer().value() == 1) continue; // Don't add D4 if track has L1 stub // two extra bits to indicate if the matched stub is local or from neighbor int location = 1; // local @@ -478,16 +477,16 @@ std::map Tracklet::getStubIDs() { } else if (disk_) { for (int i = 0; i < N_DISK; i++) { //check barrel - if (layerresid_[i].valid()) { + if (resid_[i].valid()) { // two extra bits to indicate if the matched stub is local or from neighbor int location = 1; // local - location <<= layerresid_[i].fpgastubid().nbits(); + location <<= resid_[i].fpgastubid().nbits(); - stubIDs[1 + i] = layerresid_[i].fpgastubid().value() + location; + stubIDs[1 + i] = resid_[i].fpgastubid().value() + location; } //check disks - if (i == 4 && layerresid_[1].valid()) + if (i == 4 && resid_[1].valid()) continue; // Don't add D5 if track has L2 stub if (diskresid_[i].valid()) { // two extra bits to indicate if the matched stub is local or from neighbor @@ -522,12 +521,12 @@ std::map Tracklet::getStubIDs() { } else if (overlap_) { for (int i = 0; i < N_DISK; i++) { //check barrel - if (layerresid_[i].valid()) { + if (resid_[i].valid()) { // two extra bits to indicate if the matched stub is local or from neighbor int location = 1; // local - location <<= layerresid_[i].fpgastubid().nbits(); + location <<= resid_[i].fpgastubid().nbits(); - stubIDs[1 + i] = layerresid_[i].fpgastubid().value() + location; + stubIDs[1 + i] = resid_[i].fpgastubid().value() + location; } //check disks @@ -537,12 +536,12 @@ std::map Tracklet::getStubIDs() { location <<= diskresid_[i].fpgastubid().nbits(); if (innerStub_->disk() < 0) { // if negative overlap - if (innerFPGAStub_->layer().value() != 2 || !layerresid_[0].valid() || + if (innerFPGAStub_->layer().value() != 2 || !resid_[0].valid() || i != 3) { // Don't add D4 if this is an L3L2 track with an L1 stub stubIDs[-11 - i] = diskresid_[i].fpgastubid().value() + location; } } else { - if (innerFPGAStub_->layer().value() != 2 || !layerresid_[0].valid() || i != 3) { + if (innerFPGAStub_->layer().value() != 2 || !resid_[0].valid() || i != 3) { stubIDs[11 + i] = diskresid_[i].fpgastubid().value() + location; } } @@ -639,7 +638,7 @@ const std::string Tracklet::layerstubstr(const unsigned layer) const { assert(layer < N_LAYER); std::stringstream oss(""); - if (!layerresid_[layer].valid()) + if (!resid_[layer].valid()) oss << "0|0000000|0000000000|0000000|000000000000|000000000"; else { if (trackIndex_ < 0 || trackIndex_ > (int)settings_.ntrackletmax()) { @@ -649,10 +648,10 @@ const std::string Tracklet::layerstubstr(const unsigned layer) const { const FPGAWord tmp(trackIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__); oss << "1|"; // valid bit oss << tmp.str() << "|"; - oss << layerresid_[layer].fpgastubid().str() << "|"; - oss << layerresid_[layer].stubptr()->r().str() << "|"; - oss << layerresid_[layer].fpgaphiresid().str() << "|"; - oss << layerresid_[layer].fpgazresid().str(); + oss << resid_[layer].fpgastubid().str() << "|"; + oss << resid_[layer].stubptr()->r().str() << "|"; + oss << resid_[layer].fpgaphiresid().str() << "|"; + oss << resid_[layer].fpgarzresid().str(); } return oss.str(); From da789391bb2402fbe9f8c0091e76657b53ff9c2c Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Tue, 9 Mar 2021 23:11:27 -0500 Subject: [PATCH 15/45] Remove the use of the class DiskResiduals --- .../interface/DiskResidual.h | 112 ------------------ .../TrackFindingTracklet/interface/Tracklet.h | 23 ++-- .../TrackFindingTracklet/src/DiskResidual.cc | 47 -------- .../TrackFindingTracklet/src/FitTrack.cc | 85 ++++++------- .../src/MatchCalculator.cc | 2 - .../src/MatchProcessor.cc | 2 - .../TrackFindingTracklet/src/Tracklet.cc | 87 +++++++------- 7 files changed, 92 insertions(+), 266 deletions(-) delete mode 100644 L1Trigger/TrackFindingTracklet/interface/DiskResidual.h delete mode 100644 L1Trigger/TrackFindingTracklet/src/DiskResidual.cc diff --git a/L1Trigger/TrackFindingTracklet/interface/DiskResidual.h b/L1Trigger/TrackFindingTracklet/interface/DiskResidual.h deleted file mode 100644 index 546410e5a78b7..0000000000000 --- a/L1Trigger/TrackFindingTracklet/interface/DiskResidual.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef L1Trigger_TrackFindingTracklet_interface_DiskResidual_h -#define L1Trigger_TrackFindingTracklet_interface_DiskResidual_h - -#include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" - -#include - -namespace trklet { - - class Settings; - class Stub; - - class DiskResidual { - public: - DiskResidual() { valid_ = false; } - - ~DiskResidual() = default; - - void init(Settings const& settings, - int disk, - int iphiresid, - int irresid, - int istubid, - double phiresid, - double rresid, - double phiresidapprox, - double rresidapprox, - double zstub, - double alpha, - FPGAWord ialpha, - const Stub* stubptr); - - bool valid() const { return valid_; } - - const FPGAWord& fpgaphiresid() const { - assert(valid_); - return fpgaphiresid_; - }; - - const FPGAWord& fpgarresid() const { - assert(valid_); - return fpgarresid_; - }; - - const FPGAWord& fpgastubid() const { - assert(valid_); - return fpgastubid_; - }; - - double phiresid() const { - assert(valid_); - return phiresid_; - }; - - double rresid() const { - assert(valid_); - return rresid_; - }; - - double phiresidapprox() const { - assert(valid_); - return phiresidapprox_; - }; - - double rresidapprox() const { - assert(valid_); - return rresidapprox_; - }; - - double zstub() const { - assert(valid_); - return zstub_; - }; - - double alpha() const { - assert(valid_); - return alpha_; - }; - - const FPGAWord& ialpha() const { - assert(valid_); - return ialpha_; - }; - - const Stub* stubptr() const { - assert(valid_); - return stubptr_; - }; - - protected: - bool valid_; - - int disk_; - - FPGAWord fpgaphiresid_; - FPGAWord fpgarresid_; - FPGAWord fpgastubid_; - - double phiresid_; - double rresid_; - - double phiresidapprox_; - double rresidapprox_; - - double zstub_; - double alpha_; - FPGAWord ialpha_; - const Stub* stubptr_; - }; - -}; // namespace trklet -#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 041ac52246c06..1439377da0c93 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -16,7 +16,6 @@ #include "L1Trigger/TrackFindingTracklet/interface/TrackPars.h" #include "L1Trigger/TrackFindingTracklet/interface/Projection.h" #include "L1Trigger/TrackFindingTracklet/interface/Residual.h" -#include "L1Trigger/TrackFindingTracklet/interface/DiskResidual.h" #include "L1Trigger/TrackFindingTracklet/interface/Util.h" namespace trklet { @@ -97,12 +96,7 @@ namespace trklet { bool matchdisk(int disk) const { assert(abs(disk) <= N_DISK); - return diskresid_[abs(disk) - 1].valid(); - } - - const DiskResidual& diskResid(int disk) const { - assert(matchdisk(disk)); - return diskresid_[abs(disk) - 1]; + return resid_[N_LAYER + abs(disk) - 1].valid(); } void addMatch(int layer, @@ -122,9 +116,7 @@ namespace trklet { double dr, double dphiapprox, double drapprox, - double alpha, int stubid, - double zstub, const trklet::Stub* stubptr); int nMatches(); @@ -138,10 +130,10 @@ namespace trklet { return resid_[layer - 1].valid(); } - const Residual& resid(int layer) { - assert(layer > 0 && layer <= N_LAYER); - assert(resid_[layer - 1].valid()); - return resid_[layer - 1]; + const Residual& resid(unsigned int layerdisk) { + assert(layerdisk < N_LAYER + N_DISK); + assert(resid_[layerdisk].valid()); + return resid_[layerdisk]; } std::vector getL1Stubs(); @@ -303,10 +295,9 @@ namespace trklet { std::unique_ptr fpgatrack_; - Projection proj_[N_LAYER+N_DISK]; + Projection proj_[N_LAYER + N_DISK]; - Residual resid_[N_LAYER]; - DiskResidual diskresid_[N_DISK]; + Residual resid_[N_LAYER + N_DISK]; Settings const& settings_; }; diff --git a/L1Trigger/TrackFindingTracklet/src/DiskResidual.cc b/L1Trigger/TrackFindingTracklet/src/DiskResidual.cc deleted file mode 100644 index 99213f18b9848..0000000000000 --- a/L1Trigger/TrackFindingTracklet/src/DiskResidual.cc +++ /dev/null @@ -1,47 +0,0 @@ -#include "L1Trigger/TrackFindingTracklet/interface/DiskResidual.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" - -using namespace std; -using namespace trklet; - -void DiskResidual::init(Settings const& settings, - int disk, - int iphiresid, - int irresid, - int istubid, - double phiresid, - double rresid, - double phiresidapprox, - double rresidapprox, - double zstub, - double alpha, - FPGAWord ialpha, - const Stub* stubptr) { - assert(abs(disk) > 0); - assert(abs(disk) <= N_DISK); - - if (valid_ && (std::abs(iphiresid) > std::abs(fpgaphiresid_.value()))) - return; - - valid_ = true; - - disk_ = disk; - - fpgaphiresid_.set(iphiresid, settings.phiresidbits(), false, __LINE__, __FILE__); - fpgarresid_.set(irresid, settings.rresidbits(), false, __LINE__, __FILE__); - assert(istubid >= 0); - unsigned int nbitsstubid = 10; - fpgastubid_.set(istubid, nbitsstubid, true, __LINE__, __FILE__); - assert(!fpgaphiresid_.atExtreme()); - - phiresid_ = phiresid; - rresid_ = rresid; - - phiresidapprox_ = phiresidapprox; - rresidapprox_ = rresidapprox; - - zstub_ = zstub; - alpha_ = alpha; - ialpha_ = ialpha; - stubptr_ = stubptr; -} diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 50ba0c4e64604..5f44e1a45b5fd 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -201,7 +201,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: continue; } if (tracklet->match(l)) { - const Residual& resid = tracklet->resid(l); + const Residual& resid = tracklet->resid(l-1); lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); phiresid[nlayers] = resid.phiresidapprox(); @@ -225,13 +225,14 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - const DiskResidual& diskResid = tracklet->diskResid(d); - if (std::abs(diskResid.alpha()) < 1e-20) { + const Residual& resid = tracklet->resid(N_LAYER + d -1); + double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); + if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * d - 1); diskmask |= (1 << (2 * (N_DISK - d) + 1)); } else { - int ialpha = diskResid.ialpha().value(); - int nalpha = diskResid.ialpha().nbits(); + int ialpha = resid.stubptr()->alphanew().value(); + int nalpha = resid.stubptr()->alphanew().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -241,13 +242,13 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: diskmask |= (1 << (2 * (N_DISK - d))); mult = mult << settings_.alphaBitsTable(); } - alpha[ndisks] = diskResid.alpha(); - phiresid[nlayers + ndisks] = diskResid.phiresidapprox(); - zresid[nlayers + ndisks] = diskResid.rresidapprox(); - phiresidexact[nlayers + ndisks] = diskResid.phiresid(); - zresidexact[nlayers + ndisks] = diskResid.rresid(); - iphiresid[nlayers + ndisks] = diskResid.fpgaphiresid().value(); - izresid[nlayers + ndisks] = diskResid.fpgarresid().value(); + alpha[ndisks] = resid.stubptr()->l1tstub()->alpha(pitch); + phiresid[nlayers + ndisks] = resid.phiresidapprox(); + zresid[nlayers + ndisks] = resid.rzresidapprox(); + phiresidexact[nlayers + ndisks] = resid.phiresid(); + zresidexact[nlayers + ndisks] = resid.rzresid(); + iphiresid[nlayers + ndisks] = resid.fpgaphiresid().value(); + izresid[nlayers + ndisks] = resid.fpgarzresid().value(); disks[ndisks++] = d; } @@ -267,7 +268,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const Residual& resid = tracklet->resid(l); + const Residual& resid = tracklet->resid(l-1); phiresid[nlayers] = resid.phiresidapprox(); zresid[nlayers] = resid.rzresidapprox(); phiresidexact[nlayers] = resid.phiresid(); @@ -299,13 +300,14 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - const DiskResidual& diskResid = tracklet->diskResid(d); - if (std::abs(diskResid.alpha()) < 1e-20) { + const Residual& resid = tracklet->resid(N_LAYER + abs(d) - 1); + double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); + if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * d1 - 1); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); } else { - int ialpha = diskResid.ialpha().value(); - int nalpha = diskResid.ialpha().nbits(); + int ialpha = resid.stubptr()->alphanew().value(); + int nalpha = resid.stubptr()->alphanew().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -316,15 +318,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: mult = mult << settings_.alphaBitsTable(); } - alpha[ndisks] = diskResid.alpha(); - assert(std::abs(diskResid.phiresidapprox()) < 0.2); - phiresid[nlayers + ndisks] = diskResid.phiresidapprox(); - zresid[nlayers + ndisks] = diskResid.rresidapprox(); - assert(std::abs(diskResid.phiresid()) < 0.2); - phiresidexact[nlayers + ndisks] = diskResid.phiresid(); - zresidexact[nlayers + ndisks] = diskResid.rresid(); - iphiresid[nlayers + ndisks] = diskResid.fpgaphiresid().value(); - izresid[nlayers + ndisks] = diskResid.fpgarresid().value(); + alpha[ndisks] = resid.stubptr()->l1tstub()->alpha(pitch); + assert(std::abs(resid.phiresidapprox()) < 0.2); + phiresid[nlayers + ndisks] = resid.phiresidapprox(); + zresid[nlayers + ndisks] = resid.rzresidapprox(); + assert(std::abs(resid.phiresid()) < 0.2); + phiresidexact[nlayers + ndisks] = resid.phiresid(); + zresidexact[nlayers + ndisks] = resid.rzresid(); + iphiresid[nlayers + ndisks] = resid.fpgaphiresid().value(); + izresid[nlayers + ndisks] = resid.fpgarzresid().value(); disks[ndisks++] = d; } @@ -342,7 +344,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (tracklet->match(l)) { lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const Residual& resid = tracklet->resid(l); + const Residual& resid = tracklet->resid(l-1); assert(std::abs(resid.phiresidapprox()) < 0.2); phiresid[nlayers] = resid.phiresidapprox(); zresid[nlayers] = resid.rzresidapprox(); @@ -373,15 +375,16 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; if (tracklet->matchdisk(d)) { - const DiskResidual& diskResid = tracklet->diskResid(d); - if (std::abs(diskResid.alpha()) < 1e-20) { + const Residual& resid = tracklet->resid(N_LAYER + abs(d) -1); + double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); + if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * (N_DISK - d1)); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); FPGAWord tmp; tmp.set(diskmask, 10); } else { - int ialpha = diskResid.ialpha().value(); - int nalpha = diskResid.ialpha().nbits(); + int ialpha = resid.stubptr()->alphanew().value(); + int nalpha = resid.stubptr()->alphanew().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -394,15 +397,15 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: mult = mult << settings_.alphaBitsTable(); } - alpha[ndisks] = diskResid.alpha(); - assert(std::abs(diskResid.phiresidapprox()) < 0.2); - phiresid[nlayers + ndisks] = diskResid.phiresidapprox(); - zresid[nlayers + ndisks] = diskResid.rresidapprox(); - assert(std::abs(diskResid.phiresid()) < 0.2); - phiresidexact[nlayers + ndisks] = diskResid.phiresid(); - zresidexact[nlayers + ndisks] = diskResid.rresid(); - iphiresid[nlayers + ndisks] = diskResid.fpgaphiresid().value(); - izresid[nlayers + ndisks] = diskResid.fpgarresid().value(); + alpha[ndisks] = resid.stubptr()->l1tstub()->alpha(pitch); + assert(std::abs(resid.phiresidapprox()) < 0.2); + phiresid[nlayers + ndisks] = resid.phiresidapprox(); + zresid[nlayers + ndisks] = resid.rzresidapprox(); + assert(std::abs(resid.phiresid()) < 0.2); + phiresidexact[nlayers + ndisks] = resid.phiresid(); + zresidexact[nlayers + ndisks] = resid.rzresid(); + iphiresid[nlayers + ndisks] = resid.fpgaphiresid().value(); + izresid[nlayers + ndisks] = resid.fpgarzresid().value(); disks[ndisks++] = d; } @@ -462,7 +465,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: realrstub[i] = tracklet->outerStub()->r(); } if (tracklet->match(layers[i]) && layers[i] < 4) { - const Stub* stubptr = tracklet->resid(layers[i]).stubptr(); + const Stub* stubptr = tracklet->resid(layers[i]-1).stubptr(); realrstub[i] = stubptr->l1tstub()->r(); assert(std::abs(realrstub[i] - r[i]) < 5.0); } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 44e756cc28be5..e6b6a45a48087 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -494,9 +494,7 @@ void MatchCalculator::execute() { dr, drphiapprox / stub->r(), drapprox, - stub->alpha(settings_.stripPitch(stub->isPSmodule())), (phiregion_ << 7) + fpgastub->stubindex().value(), - stub->z(), fpgastub); if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet << " " diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 6ff9869ad0672..5c1eb268419e7 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -706,9 +706,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { dr, drphiapprox / stub->r(), drapprox, - stub->alpha(settings_.stripPitch(stub->isPSmodule())), (phiregion_ << 7) + fpgastub->stubindex().value(), - stub->z(), fpgastub); if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet << " " diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index 217b55745e53b..256fc9f9ee07e 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -313,7 +313,7 @@ void Tracklet::addMatch(int layer, const trklet::Stub* stubptr) { assert(layer > 0 && layer <= N_LAYER); resid_[layer - 1].init( - settings_, layer, ideltaphi, ideltaz, stubid, dphi, dz, dphiapprox, dzapprox, stubptr); + settings_, layer-1, ideltaphi, ideltaz, stubid, dphi, dz, dphiapprox, dzapprox, stubptr); } void Tracklet::addMatchDisk(int disk, @@ -323,31 +323,29 @@ void Tracklet::addMatchDisk(int disk, double dr, double dphiapprox, double drapprox, - double alpha, int stubid, - double zstub, const trklet::Stub* stubptr) { assert(abs(disk) <= N_DISK); - diskresid_[abs(disk) - 1].init(settings_, - disk, - ideltaphi, - ideltar, - stubid, - dphi, - dr, - dphiapprox, - drapprox, - zstub, - alpha, - stubptr->alphanew(), - stubptr); + + resid_[N_LAYER + abs(disk) - 1].init(settings_, + N_LAYER + abs(disk) -1, + ideltaphi, + ideltar, + stubid, + dphi, + dr, + dphiapprox, + drapprox, + stubptr); } int Tracklet::nMatches() { int nmatches = 0; + int ilay=0; for (const auto& iresid : resid_) { - if (iresid.valid()) { + ilay++; + if (iresid.valid()&&ilay<=N_LAYER) { nmatches++; } } @@ -358,8 +356,10 @@ int Tracklet::nMatches() { int Tracklet::nMatchesDisk() { int nmatches = 0; - for (const auto& idiskresid : diskresid_) { - if (idiskresid.valid()) { + int ilay=0; + for (const auto& idiskresid : resid_) { + ilay++; + if (idiskresid.valid()&&ilay>N_LAYER) { nmatches++; } } @@ -392,11 +392,11 @@ std::string Tracklet::fullmatchdiskstr(int disk) { tmp.set(trackletIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__); FPGAWord tcid; tcid.set(TCIndex_, settings_.nbitstcindex(), true, __LINE__, __FILE__); - const FPGAWord& stubr = diskresid_[disk - 1].stubptr()->r(); - const bool isPS = diskresid_[disk - 1].stubptr()->isPSmodule(); - std::string oss = tcid.str() + "|" + tmp.str() + "|" + diskresid_[disk - 1].fpgastubid().str() + "|" + + const FPGAWord& stubr = resid_[N_LAYER + disk - 1].stubptr()->r(); + const bool isPS = resid_[N_LAYER + disk - 1].stubptr()->isPSmodule(); + std::string oss = tcid.str() + "|" + tmp.str() + "|" + resid_[N_LAYER + disk - 1].fpgastubid().str() + "|" + (isPS ? stubr.str() : ("00000000" + stubr.str())) + "|" + - diskresid_[disk - 1].fpgaphiresid().str() + "|" + diskresid_[disk - 1].fpgarresid().str(); + resid_[N_LAYER + disk - 1].fpgaphiresid().str() + "|" + resid_[N_LAYER + disk - 1].fpgarzresid().str(); return oss; } @@ -415,11 +415,6 @@ std::vector Tracklet::getL1Stubs() { tmp.push_back(iresid.stubptr()->l1tstub()); } - for (const auto& idiskresid : diskresid_) { - if (idiskresid.valid()) - tmp.push_back(idiskresid.stubptr()->l1tstub()); - } - return tmp; } @@ -451,17 +446,17 @@ std::map Tracklet::getStubIDs() { //check disk if (i >= N_DISK) continue; //i=[0..4] for disks - if (diskresid_[i].valid()) { + if (resid_[N_LAYER + i].valid()) { if (i == 3 && resid_[0].valid() && innerFPGAStub_->layer().value() == 1) continue; // Don't add D4 if track has L1 stub // two extra bits to indicate if the matched stub is local or from neighbor int location = 1; // local - location <<= diskresid_[i].fpgastubid().nbits(); + location <<= resid_[N_LAYER + i].fpgastubid().nbits(); if (itfit().value() < 0) { - stubIDs[-11 - i] = diskresid_[i].fpgastubid().value() + location; + stubIDs[-11 - i] = resid_[N_LAYER + i].fpgastubid().value() + location; } else { - stubIDs[11 + i] = diskresid_[i].fpgastubid().value() + location; + stubIDs[11 + i] = resid_[N_LAYER + i].fpgastubid().value() + location; } } } @@ -488,15 +483,15 @@ std::map Tracklet::getStubIDs() { //check disks if (i == 4 && resid_[1].valid()) continue; // Don't add D5 if track has L2 stub - if (diskresid_[i].valid()) { + if (resid_[N_LAYER + i].valid()) { // two extra bits to indicate if the matched stub is local or from neighbor int location = 1; // local - location <<= diskresid_[i].fpgastubid().nbits(); + location <<= resid_[N_LAYER + i].fpgastubid().nbits(); if (innerStub_->disk() < 0) { - stubIDs[-11 - i] = diskresid_[i].fpgastubid().value() + location; + stubIDs[-11 - i] = resid_[N_LAYER + i].fpgastubid().value() + location; } else { - stubIDs[11 + i] = diskresid_[i].fpgastubid().value() + location; + stubIDs[11 + i] = resid_[N_LAYER + i].fpgastubid().value() + location; } } } @@ -530,19 +525,19 @@ std::map Tracklet::getStubIDs() { } //check disks - if (diskresid_[i].valid()) { + if (resid_[N_LAYER + i].valid()) { // two extra bits to indicate if the matched stub is local or from neighbor int location = 1; // local - location <<= diskresid_[i].fpgastubid().nbits(); + location <<= resid_[N_LAYER + i].fpgastubid().nbits(); if (innerStub_->disk() < 0) { // if negative overlap if (innerFPGAStub_->layer().value() != 2 || !resid_[0].valid() || i != 3) { // Don't add D4 if this is an L3L2 track with an L1 stub - stubIDs[-11 - i] = diskresid_[i].fpgastubid().value() + location; + stubIDs[-11 - i] = resid_[N_LAYER + i].fpgastubid().value() + location; } } else { if (innerFPGAStub_->layer().value() != 2 || !resid_[0].valid() || i != 3) { - stubIDs[11 + i] = diskresid_[i].fpgastubid().value() + location; + stubIDs[11 + i] = resid_[N_LAYER + i].fpgastubid().value() + location; } } } @@ -661,7 +656,7 @@ const std::string Tracklet::diskstubstr(const unsigned disk) const { assert(disk < N_DISK); std::stringstream oss(""); - if (!diskresid_[disk].valid()) + if (!resid_[N_LAYER + disk].valid()) oss << "0|0000000|0000000000|000000000000|000000000000|0000000"; else { if (trackIndex_ < 0 || trackIndex_ > (int)settings_.ntrackletmax()) { @@ -669,14 +664,14 @@ const std::string Tracklet::diskstubstr(const unsigned disk) const { assert(0); } const FPGAWord tmp(trackIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__); - const FPGAWord& stubr = diskresid_[disk].stubptr()->r(); - const bool isPS = diskresid_[disk].stubptr()->isPSmodule(); + const FPGAWord& stubr = resid_[N_LAYER + disk].stubptr()->r(); + const bool isPS = resid_[N_LAYER + disk].stubptr()->isPSmodule(); oss << "1|"; // valid bit oss << tmp.str() << "|"; - oss << diskresid_[disk].fpgastubid().str() << "|"; + oss << resid_[N_LAYER + disk].fpgastubid().str() << "|"; oss << (isPS ? stubr.str() : ("00000000" + stubr.str())) << "|"; - oss << diskresid_[disk].fpgaphiresid().str() << "|"; - oss << diskresid_[disk].fpgarresid().str(); + oss << resid_[N_LAYER + disk].fpgaphiresid().str() << "|"; + oss << resid_[N_LAYER + disk].fpgarzresid().str(); } return oss.str(); From 5f76609b1dab5071980b1f93979a70a84ec215a6 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Tue, 9 Mar 2021 23:29:40 -0500 Subject: [PATCH 16/45] Remove unused nMatch and nMatchDisk method of Tracklet --- .../TrackFindingTracklet/interface/Settings.h | 4 +-- .../TrackFindingTracklet/interface/Tracklet.h | 15 +++++------ .../interface/TrackletParametersMemory.h | 2 -- L1Trigger/TrackFindingTracklet/src/Sector.cc | 10 ------- .../TrackFindingTracklet/src/Tracklet.cc | 27 ------------------- .../src/TrackletParametersMemory.cc | 16 ----------- 6 files changed, 9 insertions(+), 65 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index bb463794c6f87..86a4a66d1d119 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -741,12 +741,12 @@ namespace trklet { {"HitPattern", false}, {"ChiSq", false}, {"Seeds", false}, {"FT", false}, {"Residuals", false}, {"StubBend", false}, {"MC", false}, {"MP", false}, {"ME", false}, - {"AP", false}, {"VMP", false}, {"NMatches", false}, + {"AP", false}, {"VMP", false}, {"TrackProjOcc", false}, {"TC", false}, {"Pars", false}, {"TPars", false}, {"TPD", false}, {"TrackletPars", false}, {"TED", false}, {"TP", false}, {"TRE", false}, {"VMR", false}, {"StubsLayer", false}, {"StubsLayerSector", false}, - {"HitEff", false}, {"MatchEff", true}, {"Cabling", false}, + {"HitEff", false}, {"MatchEff", false}, {"Cabling", false}, {"IFit", false}, {"AS", false}}; std::array rDSSinner_mod_{{68.9391, 78.7750, 85.4550, 96.3150, 102.3160}}; diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 1439377da0c93..6143d7ac24b91 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -94,10 +94,6 @@ namespace trklet { return proj_[layerdisk]; } - bool matchdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return resid_[N_LAYER + abs(disk) - 1].valid(); - } void addMatch(int layer, int ideltaphi, @@ -118,10 +114,7 @@ namespace trklet { double drapprox, int stubid, const trklet::Stub* stubptr); - - int nMatches(); - int nMatchesDisk(); - + std::string fullmatchstr(int layer); std::string fullmatchdiskstr(int disk); @@ -130,6 +123,12 @@ namespace trklet { return resid_[layer - 1].valid(); } + bool matchdisk(int disk) const { + assert(abs(disk) <= N_DISK); + return resid_[N_LAYER + abs(disk) - 1].valid(); + } + + const Residual& resid(unsigned int layerdisk) { assert(layerdisk < N_LAYER + N_DISK); assert(resid_[layerdisk].valid()); diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h b/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h index 088f937dcbc4c..38c1b98b1c16c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h @@ -28,8 +28,6 @@ namespace trklet { void clean() override; - void writeMatches(Globals *globals, int &matchesL1, int &matchesL3, int &matchesL5); - void writeTPAR(bool first); private: diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 6999d57150d96..907aa64887626 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -389,16 +389,6 @@ void Sector::writeCT(bool first) { } void Sector::clean() { - if (settings_.writeMonitorData("NMatches")) { - int matchesL1 = 0; - int matchesL3 = 0; - int matchesL5 = 0; - for (auto& i : TPAR_) { - i->writeMatches(globals_, matchesL1, matchesL3, matchesL5); - } - globals_->ofstream("nmatchessector.txt") << matchesL1 << " " << matchesL3 << " " << matchesL5 << endl; - } - for (auto& mem : MemoriesV_) { mem->clean(); } diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index 256fc9f9ee07e..f70ca5f884785 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -339,33 +339,6 @@ void Tracklet::addMatchDisk(int disk, stubptr); } -int Tracklet::nMatches() { - int nmatches = 0; - - int ilay=0; - for (const auto& iresid : resid_) { - ilay++; - if (iresid.valid()&&ilay<=N_LAYER) { - nmatches++; - } - } - - return nmatches; -} - -int Tracklet::nMatchesDisk() { - int nmatches = 0; - - int ilay=0; - for (const auto& idiskresid : resid_) { - ilay++; - if (idiskresid.valid()&&ilay>N_LAYER) { - nmatches++; - } - } - return nmatches; -} - std::string Tracklet::fullmatchstr(int layer) { assert(layer > 0 && layer <= N_LAYER); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc index 77392b49e62f9..1180abc707285 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc @@ -18,22 +18,6 @@ void TrackletParametersMemory::clean() { tracklets_.clear(); } -void TrackletParametersMemory::writeMatches(Globals* globals, int& matchesL1, int& matchesL3, int& matchesL5) { - ofstream& out = globals->ofstream("nmatches.txt"); - for (auto& tracklet : tracklets_) { - if ((tracklet->nMatches() + tracklet->nMatchesDisk()) > 0) { - if (tracklet->layer() == 1) - matchesL1++; - if (tracklet->layer() == 3) - matchesL3++; - if (tracklet->layer() == 5) - matchesL5++; - } - out << tracklet->layer() << " " << tracklet->disk() << " " << tracklet->nMatches() << " " - << tracklet->nMatchesDisk() << endl; - } -} - void TrackletParametersMemory::writeTPAR(bool first) { const string dirTP = settings_.memPath() + "TrackletParameters/"; From a181be97f07d92b40751599e430c7eef15e2f075 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Wed, 10 Mar 2021 19:09:02 -0500 Subject: [PATCH 17/45] (Re-)Implement the correction to writing the DTC data link file after moving functionality to Sector. --- L1Trigger/TrackFindingTracklet/src/Sector.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 907aa64887626..6d347b85250f1 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -176,7 +176,7 @@ void Sector::writeLink(const Stub& fpgastub) { FPGAWord ldcode(lcode, 2, true); - string dataword = "1|" + ldcode.str() + "|" + fpgastub.str(); + string dataword = fpgastub.str() + "|" + ldcode.str() + "|1" ; (*DTCLink_ofstreams_.find(dtcname)->second) << dataword << " " << trklet::hexFormat(dataword) << endl; } From 946b12048931f15cfad96ad5ef63d85568af7545 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Wed, 10 Mar 2021 21:28:59 -0500 Subject: [PATCH 18/45] Combine addMatch method for disk and layers into on method --- .../TrackFindingTracklet/interface/Tracklet.h | 23 ++--------- .../src/MatchCalculator.cc | 23 ++++------- .../src/MatchProcessor.cc | 29 +++++-------- .../TrackFindingTracklet/src/Tracklet.cc | 41 +++---------------- 4 files changed, 26 insertions(+), 90 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 6143d7ac24b91..13b03d1c0533f 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -94,27 +94,10 @@ namespace trklet { return proj_[layerdisk]; } + void addMatch(unsigned int layerdisk, int ideltaphi, int ideltarz, + double dphi, double drz, double dphiapprox, double drzapprox, + int stubid, const trklet::Stub* stubptr); - void addMatch(int layer, - int ideltaphi, - int ideltaz, - double dphi, - double dz, - double dphiapprox, - double dzapprox, - int stubid, - const trklet::Stub* stubptr); - - void addMatchDisk(int disk, - int ideltaphi, - int ideltar, - double dphi, - double dr, - double dphiapprox, - double drapprox, - int stubid, - const trklet::Stub* stubptr); - std::string fullmatchstr(int layer); std::string fullmatchdiskstr(int disk); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index e6b6a45a48087..f1a6a0d5ca300 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -319,13 +319,8 @@ void MatchCalculator::execute() { if (imatch) { countsel++; - tracklet->addMatch(layerdisk_ + 1, - ideltaphi, - ideltaz, - dphi, - dz, - dphiapprox, - dzapprox, + tracklet->addMatch(layerdisk_, ideltaphi, ideltaz, + dphi, dz, dphiapprox, dzapprox, (phiregion_ << 7) + fpgastub->stubindex().value(), mergedMatches[j].second); @@ -487,15 +482,11 @@ void MatchCalculator::execute() { edm::LogVerbatim("Tracklet") << "MatchCalculator found match in disk " << getName(); } - tracklet->addMatchDisk(disk, - ideltaphi, - ideltar, - drphi / stub->r(), - dr, - drphiapprox / stub->r(), - drapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), - fpgastub); + 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 << " " << iSector_; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 5c1eb268419e7..18bd694984946 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -535,16 +535,11 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { } if (imatch) { - tracklet->addMatch(layerdisk_ + 1, - ideltaphi, - ideltaz, - dphi, - dz, - dphiapprox, - dzapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), - fpgastub); - + tracklet->addMatch(layerdisk_, ideltaphi, ideltaz, + dphi, dz, dphiapprox, dzapprox, + (phiregion_ << 7) + fpgastub->stubindex().value(), + fpgastub); + if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet << " " << iSector_; @@ -699,15 +694,11 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { assert(std::abs(dphi) < 0.25); assert(std::abs(dphiapprox) < 0.25); - tracklet->addMatchDisk(disk, - ideltaphi, - ideltar, - drphi / stub->r(), - dr, - drphiapprox / stub->r(), - drapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), - fpgastub); + 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 << " " << iSector_; diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index f70ca5f884785..e6f83bc9c6607 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -302,41 +302,12 @@ std::string Tracklet::trackletprojstrD(int disk) const { return oss; } -void Tracklet::addMatch(int layer, - int ideltaphi, - int ideltaz, - double dphi, - double dz, - double dphiapprox, - double dzapprox, - int stubid, - const trklet::Stub* stubptr) { - assert(layer > 0 && layer <= N_LAYER); - resid_[layer - 1].init( - settings_, layer-1, ideltaphi, ideltaz, stubid, dphi, dz, dphiapprox, dzapprox, stubptr); -} - -void Tracklet::addMatchDisk(int disk, - int ideltaphi, - int ideltar, - double dphi, - double dr, - double dphiapprox, - double drapprox, - int stubid, - const trklet::Stub* stubptr) { - assert(abs(disk) <= N_DISK); - - resid_[N_LAYER + abs(disk) - 1].init(settings_, - N_LAYER + abs(disk) -1, - ideltaphi, - ideltar, - stubid, - dphi, - dr, - dphiapprox, - drapprox, - stubptr); +void Tracklet::addMatch(unsigned int layerdisk, int ideltaphi, int ideltarz, + double dphi, double drz, double dphiapprox, double drzapprox, + int stubid, const trklet::Stub* stubptr) { + assert(layerdisk < N_LAYER + N_DISK); + resid_[layerdisk].init(settings_, layerdisk, ideltaphi, ideltarz, + stubid, dphi, drz, dphiapprox, drzapprox, stubptr); } std::string Tracklet::fullmatchstr(int layer) { From 4c6a7744de481d390894fcb8a72c488d533082bf Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Wed, 10 Mar 2021 22:21:32 -0500 Subject: [PATCH 19/45] combine the disk and layer match into one method --- .../TrackFindingTracklet/interface/Tracklet.h | 12 +++------- .../TrackFindingTracklet/src/FitTrack.cc | 24 +++++++++---------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 13b03d1c0533f..da5743ee69b3b 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -101,17 +101,11 @@ namespace trklet { std::string fullmatchstr(int layer); std::string fullmatchdiskstr(int disk); - bool match(int layer) { - assert(layer > 0 && layer <= N_LAYER); - return resid_[layer - 1].valid(); - } - - bool matchdisk(int disk) const { - assert(abs(disk) <= N_DISK); - return resid_[N_LAYER + abs(disk) - 1].valid(); + bool match(unsigned int layerdisk) { + assert(layerdisk < N_LAYER + N_DISK); + return resid_[layerdisk].valid(); } - const Residual& resid(unsigned int layerdisk) { assert(layerdisk < N_LAYER + N_DISK); assert(resid_[layerdisk].valid()); diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 5f44e1a45b5fd..c7bdfe03dd6f9 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -200,7 +200,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: layers[nlayers++] = l; continue; } - if (tracklet->match(l)) { + if (tracklet->match(l-1)) { const Residual& resid = tracklet->resid(l-1); lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); @@ -224,8 +224,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; - if (tracklet->matchdisk(d)) { - const Residual& resid = tracklet->resid(N_LAYER + d -1); + if (tracklet->match(N_LAYER + d - 1)) { + const Residual& resid = tracklet->resid(N_LAYER + d - 1); double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * d - 1); @@ -264,11 +264,11 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (tracklet->isDisk()) { for (unsigned int l = 1; l <= 2; l++) { - if (tracklet->match(l)) { + if (tracklet->match(l - 1)) { lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const Residual& resid = tracklet->resid(l-1); + const Residual& resid = tracklet->resid(l - 1); phiresid[nlayers] = resid.phiresidapprox(); zresid[nlayers] = resid.rzresidapprox(); phiresidexact[nlayers] = resid.phiresid(); @@ -299,7 +299,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; - if (tracklet->matchdisk(d)) { + if (tracklet->match(N_LAYER + abs(d) - 1)) { const Residual& resid = tracklet->resid(N_LAYER + abs(d) - 1); double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { @@ -341,10 +341,10 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: layers[nlayers++] = l; continue; } - if (tracklet->match(l)) { + if (tracklet->match(l - 1)) { lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); - const Residual& resid = tracklet->resid(l-1); + const Residual& resid = tracklet->resid(l - 1); assert(std::abs(resid.phiresidapprox()) < 0.2); phiresid[nlayers] = resid.phiresidapprox(); zresid[nlayers] = resid.rzresidapprox(); @@ -374,8 +374,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (ndisks + nlayers >= N_FITSTUB) continue; - if (tracklet->matchdisk(d)) { - const Residual& resid = tracklet->resid(N_LAYER + abs(d) -1); + if (tracklet->match(N_LAYER + abs(d) - 1)) { + const Residual& resid = tracklet->resid(N_LAYER + abs(d) - 1); double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * (N_DISK - d1)); @@ -464,8 +464,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: if (layers[i] == tracklet->layer() + 1) { realrstub[i] = tracklet->outerStub()->r(); } - if (tracklet->match(layers[i]) && layers[i] < 4) { - const Stub* stubptr = tracklet->resid(layers[i]-1).stubptr(); + if (tracklet->match(layers[i] - 1) && layers[i] < 4) { + const Stub* stubptr = tracklet->resid(layers[i] - 1).stubptr(); realrstub[i] = stubptr->l1tstub()->r(); assert(std::abs(realrstub[i] - r[i]) < 5.0); } From 625582983f3e18f1d66cd422a987c87c932533ec Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Wed, 10 Mar 2021 22:50:39 -0500 Subject: [PATCH 20/45] Remove some redundant poiters to l1tstubs --- .../TrackFindingTracklet/interface/Tracklet.h | 8 +-- .../TrackFindingTracklet/src/FitTrack.cc | 6 +- .../TrackFindingTracklet/src/Tracklet.cc | 65 ++++++++----------- .../src/TrackletCalculatorBase.cc | 9 --- .../src/TrackletCalculatorDisplaced.cc | 9 --- 5 files changed, 31 insertions(+), 66 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index da5743ee69b3b..bc7385d063685 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -27,9 +27,6 @@ namespace trklet { class Tracklet { public: Tracklet(Settings const& settings, - const L1TStub* innerStub, - const L1TStub* middleStub, - const L1TStub* outerStub, const Stub* innerFPGAStub, const Stub* middleFPGAStub, const Stub* outerFPGAStub, @@ -60,13 +57,10 @@ namespace trklet { bool stubtruthmatch(const L1TStub* stub); - const L1TStub* innerStub() { return innerStub_; } const Stub* innerFPGAStub() { return innerFPGAStub_; } - const L1TStub* middleStub() { return middleStub_; } const Stub* middleFPGAStub() { return middleFPGAStub_; } - const L1TStub* outerStub() { return outerStub_; } const Stub* outerFPGAStub() { return outerFPGAStub_; } std::string addressstr(); @@ -236,9 +230,11 @@ namespace trklet { const Stub* middleFPGAStub_; const Stub* outerFPGAStub_; + /* const L1TStub* innerStub_; const L1TStub* middleStub_; const L1TStub* outerStub_; + */ int trackletIndex_; int TCIndex_; diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index c7bdfe03dd6f9..d013361a23877 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -456,13 +456,13 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: r[i] = settings_.rmean(layers[i] - 1); if (layers[i] == tracklet->layer()) { if (tracklet->isOverlap()) { - realrstub[i] = tracklet->outerStub()->r(); + realrstub[i] = tracklet->outerFPGAStub()->l1tstub()->r(); } else { - realrstub[i] = tracklet->innerStub()->r(); + realrstub[i] = tracklet->innerFPGAStub()->l1tstub()->r(); } } if (layers[i] == tracklet->layer() + 1) { - realrstub[i] = tracklet->outerStub()->r(); + realrstub[i] = tracklet->outerFPGAStub()->l1tstub()->r(); } if (tracklet->match(layers[i] - 1) && layers[i] < 4) { const Stub* stubptr = tracklet->resid(layers[i] - 1).stubptr(); diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index e6f83bc9c6607..98650e170b742 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -14,9 +14,6 @@ using namespace std; using namespace trklet; Tracklet::Tracklet(Settings const& settings, - const L1TStub* innerStub, - const L1TStub* middleStub, - const L1TStub* outerStub, const Stub* innerFPGAStub, const Stub* middleFPGAStub, const Stub* outerFPGAStub, @@ -50,12 +47,9 @@ Tracklet::Tracklet(Settings const& settings, assert(disk_ || barrel_ || overlap_); - if (barrel_ && middleStub == nullptr) - assert(innerStub->layer() < N_LAYER); + if (barrel_ && middleFPGAStub == nullptr) + assert(innerFPGAStub->l1tstub()->layer() < N_LAYER); - innerStub_ = innerStub; - middleStub_ = middleStub; - outerStub_ = outerStub; innerFPGAStub_ = innerFPGAStub; middleFPGAStub_ = middleFPGAStub; outerFPGAStub_ = outerFPGAStub; @@ -72,13 +66,6 @@ Tracklet::Tracklet(Settings const& settings, fpgatrack_ = nullptr; - if (innerStub_) - assert(innerStub_->layer() < N_LAYER || innerStub_->disk() < N_DISK); - if (middleStub_) - assert(middleStub_->layer() < N_LAYER || middleStub_->disk() < N_DISK); - if (outerStub_) - assert(outerStub_->layer() < N_LAYER || outerStub_->disk() < N_DISK); - seedIndex_ = calcSeedIndex(); triplet_ = (seedIndex_ >= 8); @@ -122,7 +109,7 @@ int Tracklet::tpseed() { set tpsetstubinner; set tpsetstubouter; - vector tps = innerStub_->tps(); + vector tps = innerFPGAStub_->l1tstub()->tps(); for (auto tp : tps) { if (tp != 0) { tpsetstubinner.insert(tp); @@ -130,7 +117,7 @@ int Tracklet::tpseed() { } } - tps = outerStub_->tps(); + tps = outerFPGAStub_->l1tstub()->tps(); for (auto tp : tps) { if (tp != 0) { tpsetstubouter.insert(tp); @@ -160,14 +147,14 @@ bool Tracklet::stubtruthmatch(const L1TStub* stub) { tpset.insert(abs(tp)); } } - tps = innerStub_->tps(); + tps = innerFPGAStub_->l1tstub()->tps(); for (auto tp : tps) { if (tp != 0) { tpsetstubinner.insert(tp); tpset.insert(abs(tp)); } } - tps = outerStub_->tps(); + tps = outerFPGAStub_->l1tstub()->tps(); for (auto tp : tps) { if (tp != 0) { tpsetstubouter.insert(tp); @@ -347,12 +334,12 @@ std::string Tracklet::fullmatchdiskstr(int disk) { std::vector Tracklet::getL1Stubs() { std::vector tmp; - if (innerStub_) - tmp.push_back(innerStub_); - if (middleStub_) - tmp.push_back(middleStub_); - if (outerStub_) - tmp.push_back(outerStub_); + if (innerFPGAStub_) + tmp.push_back(innerFPGAStub_->l1tstub()); + if (middleFPGAStub_) + tmp.push_back(middleFPGAStub_->l1tstub()); + if (outerFPGAStub_) + tmp.push_back(outerFPGAStub_->l1tstub()); for (const auto& iresid : resid_) { if (iresid.valid()) @@ -432,7 +419,7 @@ std::map Tracklet::getStubIDs() { int location = 1; // local location <<= resid_[N_LAYER + i].fpgastubid().nbits(); - if (innerStub_->disk() < 0) { + if (innerFPGAStub_->l1tstub()->disk() < 0) { stubIDs[-11 - i] = resid_[N_LAYER + i].fpgastubid().value() + location; } else { stubIDs[11 + i] = resid_[N_LAYER + i].fpgastubid().value() + location; @@ -474,7 +461,7 @@ std::map Tracklet::getStubIDs() { int location = 1; // local location <<= resid_[N_LAYER + i].fpgastubid().nbits(); - if (innerStub_->disk() < 0) { // if negative overlap + if (innerFPGAStub_->l1tstub()->disk() < 0) { // if negative overlap if (innerFPGAStub_->layer().value() != 2 || !resid_[0].valid() || i != 3) { // Don't add D4 if this is an L3L2 track with an L1 stub stubIDs[-11 - i] = resid_[N_LAYER + i].fpgastubid().value() + location; @@ -763,17 +750,17 @@ Track Tracklet::makeTrack(const vector& l1stubs) { } int Tracklet::layer() const { - int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerStub_->layerdisk() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleStub_->layerdisk() + 1 : 999, - l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerStub_->layerdisk() + 1 : 999, + int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerFPGAStub_->l1tstub()->layerdisk() + 1 : 999, + l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleFPGAStub_->l1tstub()->layerdisk() + 1 : 999, + l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerFPGAStub_->l1tstub()->layerdisk() + 1 : 999, l = min(min(l1, l2), l3); return (l < 999 ? l : 0); } int Tracklet::disk() const { - int d1 = (innerFPGAStub_ && (innerFPGAStub_->layerdisk() >= N_LAYER)) ? innerStub_->disk() : 999, - d2 = (middleFPGAStub_ && (middleFPGAStub_->layerdisk() >= N_LAYER)) ? middleStub_->disk() : 999, - d3 = (outerFPGAStub_ && (outerFPGAStub_->layerdisk() >= N_LAYER)) ? outerStub_->disk() : 999, d = 999; + int d1 = (innerFPGAStub_ && (innerFPGAStub_->layerdisk() >= N_LAYER)) ? innerFPGAStub_->l1tstub()->disk() : 999, + d2 = (middleFPGAStub_ && (middleFPGAStub_->layerdisk() >= N_LAYER)) ? middleFPGAStub_->l1tstub()->disk() : 999, + d3 = (outerFPGAStub_ && (outerFPGAStub_->layerdisk() >= N_LAYER)) ? outerFPGAStub_->l1tstub()->disk() : 999, d = 999; if (abs(d1) < min(abs(d2), abs(d3))) d = d1; if (abs(d2) < min(abs(d1), abs(d3))) @@ -784,10 +771,10 @@ int Tracklet::disk() const { } int Tracklet::disk2() const { - if (innerStub_->disk() > 0) { - return innerStub_->disk() + 1; + if (innerFPGAStub_->l1tstub()->disk() > 0) { + return innerFPGAStub_->l1tstub()->disk() + 1; } - return innerStub_->disk() - 1; + return innerFPGAStub_->l1tstub()->disk() - 1; } void Tracklet::setTrackletIndex(unsigned int index) { @@ -842,9 +829,9 @@ unsigned int Tracklet::calcSeedIndex() const { assert(innerFPGAStub_ != nullptr); assert(outerFPGAStub_ != nullptr); if (middleFPGAStub_ && seedlayer == 2 && abs(seeddisk) == 1) { - int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerStub_->layerdisk() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleStub_->layerdisk() + 1 : 999, - l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerStub_->layerdisk() + 1 : 999; + int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerFPGAStub_->l1tstub()->layerdisk() + 1 : 999, + l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleFPGAStub_->l1tstub()->layerdisk() + 1 : 999, + l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerFPGAStub_->l1tstub()->layerdisk() + 1 : 999; if (l1 + l2 + l3 < 1998) { // If two stubs are layer stubs seedindex = 10; // L2L3D1 } else { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index c26c5cbe7edf5..662a517c72455 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -664,9 +664,6 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - innerStub, - nullptr, - outerStub, innerFPGAStub, nullptr, outerFPGAStub, @@ -1059,9 +1056,6 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - innerStub, - nullptr, - outerStub, innerFPGAStub, nullptr, outerFPGAStub, @@ -1421,9 +1415,6 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - innerStub, - nullptr, - outerStub, innerFPGAStub, nullptr, outerFPGAStub, diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 449641bb528a3..8430c436e9173 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -714,9 +714,6 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - innerStub, - middleStub, - outerStub, innerFPGAStub, middleFPGAStub, outerFPGAStub, @@ -1122,9 +1119,6 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - innerStub, - middleStub, - outerStub, innerFPGAStub, middleFPGAStub, outerFPGAStub, @@ -1521,9 +1515,6 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - innerStub, - middleStub, - outerStub, innerFPGAStub, middleFPGAStub, outerFPGAStub, From c19d68d2b72c1410d6c88197d5df9034a83c3f3a Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Wed, 10 Mar 2021 23:14:53 -0500 Subject: [PATCH 21/45] Pass iSeed to Tracklet --- .../TrackFindingTracklet/interface/Tracklet.h | 10 +--- .../interface/TrackletCalculatorDisplaced.h | 1 + .../TrackFindingTracklet/src/Tracklet.cc | 58 ++----------------- .../src/TrackletCalculatorBase.cc | 3 + .../src/TrackletCalculatorDisplaced.cc | 23 ++++---- 5 files changed, 22 insertions(+), 73 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index bc7385d063685..7b42b1b7e7f01 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -27,6 +27,7 @@ namespace trklet { class Tracklet { public: Tracklet(Settings const& settings, + unsigned int iSeed, const Stub* innerFPGAStub, const Stub* middleFPGAStub, const Stub* outerFPGAStub, @@ -189,7 +190,6 @@ namespace trklet { int layer() const; int disk() const; - int disk2() const; bool isBarrel() const { return barrel_; } bool isOverlap() const { return overlap_; } @@ -215,8 +215,6 @@ namespace trklet { unsigned int seedIndex() const { return seedIndex_; } - unsigned int calcSeedIndex() const; - private: unsigned int seedIndex_; @@ -230,12 +228,6 @@ namespace trklet { const Stub* middleFPGAStub_; const Stub* outerFPGAStub_; - /* - const L1TStub* innerStub_; - const L1TStub* middleStub_; - const L1TStub* outerStub_; - */ - int trackletIndex_; int TCIndex_; int trackIndex_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h index 541d7043dfc60..8e85d6a55a94e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h @@ -159,6 +159,7 @@ namespace trklet { int TCIndex_; int layer_; int disk_; + unsigned int iSeed_; double rproj_[N_LAYER - 2]; int lproj_[N_LAYER - 2]; double zproj_[N_DISK - 2]; diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index 98650e170b742..bb2532a5c691c 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -14,6 +14,7 @@ using namespace std; using namespace trklet; Tracklet::Tracklet(Settings const& settings, + unsigned int iSeed, const Stub* innerFPGAStub, const Stub* middleFPGAStub, const Stub* outerFPGAStub, @@ -36,6 +37,9 @@ Tracklet::Tracklet(Settings const& settings, bool disk, bool overlap) : settings_(settings) { + + seedIndex_ = iSeed; + overlap_ = overlap; disk_ = disk; assert(!(disk && overlap)); @@ -66,8 +70,6 @@ Tracklet::Tracklet(Settings const& settings, fpgatrack_ = nullptr; - seedIndex_ = calcSeedIndex(); - triplet_ = (seedIndex_ >= 8); //fill projection layers @@ -770,13 +772,6 @@ int Tracklet::disk() const { return (d < 999 ? d : 0); } -int Tracklet::disk2() const { - if (innerFPGAStub_->l1tstub()->disk() > 0) { - return innerFPGAStub_->l1tstub()->disk() + 1; - } - return innerFPGAStub_->l1tstub()->disk() - 1; -} - void Tracklet::setTrackletIndex(unsigned int index) { trackletIndex_ = index; assert(index <= settings_.ntrackletmax()); @@ -801,48 +796,3 @@ void Tracklet::setTrackIndex(int index) { int Tracklet::trackIndex() const { return trackIndex_; } -unsigned int Tracklet::calcSeedIndex() const { - int seedindex = -1; - int seedlayer = layer(); - int seeddisk = disk(); - - if (seedlayer == 1 && seeddisk == 0) - seedindex = 0; //L1L2 - if (seedlayer == 3 && seeddisk == 0) - seedindex = 2; //L3L4 - if (seedlayer == 5 && seeddisk == 0) - seedindex = 3; //L5L6 - if (seedlayer == 0 && abs(seeddisk) == 1) - seedindex = 4; //D1D2 - if (seedlayer == 0 && abs(seeddisk) == 3) - seedindex = 5; //D3D4 - if (seedlayer == 1 && abs(seeddisk) == 1) - seedindex = 6; //L1D1 - if (seedlayer == 2 && abs(seeddisk) == 1) - seedindex = 7; //L2D1 - if (seedlayer == 2 && abs(seeddisk) == 0) - seedindex = 1; //L2L3 - if (middleFPGAStub_ && seedlayer == 2 && seeddisk == 0) - seedindex = 8; // L3L4L2 - if (middleFPGAStub_ && seedlayer == 4 && seeddisk == 0) - seedindex = 9; // L5L6L4 - assert(innerFPGAStub_ != nullptr); - assert(outerFPGAStub_ != nullptr); - if (middleFPGAStub_ && seedlayer == 2 && abs(seeddisk) == 1) { - int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerFPGAStub_->l1tstub()->layerdisk() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleFPGAStub_->l1tstub()->layerdisk() + 1 : 999, - l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerFPGAStub_->l1tstub()->layerdisk() + 1 : 999; - if (l1 + l2 + l3 < 1998) { // If two stubs are layer stubs - seedindex = 10; // L2L3D1 - } else { - seedindex = 11; // D1D2L2 - } - } - - if (seedindex < 0) { - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " seedlayer abs(seeddisk) : " << seedlayer - << " " << abs(seeddisk); - } - - return seedindex; -} diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index 662a517c72455..f8f1a40de2d92 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -664,6 +664,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, + iSeed_, innerFPGAStub, nullptr, outerFPGAStub, @@ -1056,6 +1057,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, + iSeed_, innerFPGAStub, nullptr, outerFPGAStub, @@ -1415,6 +1417,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, + iSeed_, innerFPGAStub, nullptr, outerFPGAStub, diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 8430c436e9173..e7ec811c810eb 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -38,22 +38,22 @@ TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, disk_ = name1[4] - '0'; // set TC index - int iSeed = -1; + int iSeed_ = 0; int iTC = name1[9] - 'A'; if (name1.substr(3, 6) == "L3L4L2") - iSeed = 8; + iSeed_ = 8; else if (name1.substr(3, 6) == "L5L6L4") - iSeed = 9; + iSeed_ = 9; else if (name1.substr(3, 6) == "L2L3D1") - iSeed = 10; + iSeed_ = 10; else if (name1.substr(3, 6) == "D1D2L2") - iSeed = 11; + iSeed_ = 11; - assert(iSeed != -1); - - TCIndex_ = (iSeed << 4) + iTC; + assert(iSeed_ != 0); + + TCIndex_ = (iSeed_ << 4) + iTC; assert(TCIndex_ >= 128 && TCIndex_ < 191); assert((layer_ != 0) || (disk_ != 0)); @@ -61,7 +61,7 @@ TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, toR_.clear(); toZ_.clear(); - if (iSeed == 8 || iSeed == 9) { + if (iSeed_ == 8 || iSeed_ == 9) { if (layer_ == 3) { rzmeanInv_[0] = 1.0 / settings_.rmean(2 - 1); rzmeanInv_[1] = 1.0 / settings_.rmean(3 - 1); @@ -100,7 +100,7 @@ TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, toR_.push_back(rproj_[i]); } - if (iSeed == 10 || iSeed == 11) { + if (iSeed_ == 10 || iSeed_ == 11) { if (layer_ == 2) { rzmeanInv_[0] = 1.0 / settings_.rmean(2 - 1); rzmeanInv_[1] = 1.0 / settings_.rmean(3 - 1); @@ -714,6 +714,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, + iSeed_, innerFPGAStub, middleFPGAStub, outerFPGAStub, @@ -1119,6 +1120,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, + iSeed_, innerFPGAStub, middleFPGAStub, outerFPGAStub, @@ -1515,6 +1517,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, + iSeed_, innerFPGAStub, middleFPGAStub, outerFPGAStub, From 52d12b81efbaede855fc4624feee97671c2fdc46 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Fri, 12 Mar 2021 16:39:33 -0500 Subject: [PATCH 22/45] Introduce an InputRouter module. Does not change functionality, but simplifies/unifies the code and makes it similar to the HLS --- .../interface/DTCLinkMemory.h | 38 +++++++++ .../interface/InputLinkMemory.h | 4 +- .../interface/InputRouter.h | 41 +++++++++ .../TrackFindingTracklet/interface/Sector.h | 8 +- .../TrackFindingTracklet/interface/Settings.h | 4 +- .../interface/TrackletEventProcessor.h | 1 + .../TrackFindingTracklet/src/DTCLinkMemory.cc | 51 +++++++++++ .../src/InputLinkMemory.cc | 39 +-------- .../TrackFindingTracklet/src/InputRouter.cc | 84 +++++++++++++++++++ L1Trigger/TrackFindingTracklet/src/Sector.cc | 45 +++++----- .../src/TrackletConfigBuilder.cc | 24 ++++-- .../src/TrackletEventProcessor.cc | 17 +++- 12 files changed, 287 insertions(+), 69 deletions(-) create mode 100644 L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h create mode 100644 L1Trigger/TrackFindingTracklet/interface/InputRouter.h create mode 100644 L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc create mode 100644 L1Trigger/TrackFindingTracklet/src/InputRouter.cc diff --git a/L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h b/L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h new file mode 100644 index 0000000000000..6179367a891be --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h @@ -0,0 +1,38 @@ +// This class holds a list of stubs for an DTC link. +// This modules 'owns' the pointers to the stubs. All subsequent modules that handles stubs uses a pointer to the original stored here. +#ifndef L1Trigger_TrackFindingTracklet_interface_DTCLinkMemory_h +#define L1Trigger_TrackFindingTracklet_interface_DTCLinkMemory_h + +#include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h" + +#include + +namespace trklet { + + class Settings; + class Globals; + class Stub; + class L1TStub; + + class DTCLinkMemory : public MemoryBase { + public: + DTCLinkMemory(std::string name, Settings const& settings, unsigned int iSector, double, double); + + ~DTCLinkMemory() override = default; + + void addStub(const L1TStub& al1stub, const Stub& stub); + + unsigned int nStubs() const { return stubs_.size(); } + + Stub* getStub(unsigned int i) { return stubs_[i]; } + + void writeStubs(bool first); + + void clean() override; + + private: + std::vector stubs_; + }; + +}; // namespace trklet +#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h index 9f1c3839630a2..547bc6f4e00db 100644 --- a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h @@ -21,7 +21,7 @@ namespace trklet { ~InputLinkMemory() override = default; - void addStub(const L1TStub& al1stub, const Stub& stub); + void addStub(Stub *stub); unsigned int nStubs() const { return stubs_.size(); } @@ -33,8 +33,6 @@ namespace trklet { private: std::vector stubs_; - int phiregion_; - unsigned int layerdisk_; }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/InputRouter.h b/L1Trigger/TrackFindingTracklet/interface/InputRouter.h new file mode 100644 index 0000000000000..32b1ff45112d3 --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/interface/InputRouter.h @@ -0,0 +1,41 @@ +// InputRouter: sorts input stubs into layer/disk and phi region +#ifndef L1Trigger_TrackFindingTracklet_interface_InputRouter_h +#define L1Trigger_TrackFindingTracklet_interface_InputRouter_h + +#include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h" +#include "L1Trigger/TrackFindingTracklet/interface/FPGAWord.h" + +#include +#include +#include + +namespace trklet { + + class Settings; + class Globals; + class MemoryBase; + class DTCLinkMemory; + class InputLinkMemory; + + class InputRouter : public ProcessBase { + public: + InputRouter(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + + ~InputRouter() override = default; + + void addOutput(MemoryBase* memory, std::string output) override; + void addInput(MemoryBase* memory, std::string input) override; + + void execute(); + + private: + + //The input stub memories + DTCLinkMemory* dtcstubs_; + + //The all stub memories - the ints are layerdisk and phiregion + std::vector, InputLinkMemory*> > irstubs_; + + }; +}; // namespace trklet +#endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Sector.h b/L1Trigger/TrackFindingTracklet/interface/Sector.h index ddb0dc539dc03..25c56e6784b04 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Sector.h +++ b/L1Trigger/TrackFindingTracklet/interface/Sector.h @@ -24,6 +24,7 @@ namespace trklet { class Stub; //Memory modules + class DTCLinkMemory; class InputLinkMemory; class AllStubsMemory; class AllInnerStubsMemory; @@ -41,6 +42,7 @@ namespace trklet { class CleanTrackMemory; //Processing modules + class InputRouter; class VMRouter; class VMRouterCM; class TrackletEngine; @@ -77,7 +79,8 @@ namespace trklet { ProcessBase* getProc(std::string procName); MemoryBase* getMem(std::string memName); - void writeInputStubs(bool first); + void writeDTCStubs(bool first); + void writeIRStubs(bool first); void writeVMSTE(bool first); void writeVMSME(bool first); void writeAS(bool first); @@ -96,6 +99,7 @@ namespace trklet { void clean(); // execute the different tracklet processing modules + void executeIR(); void executeVMR(); void executeTE(); void executeTED(); @@ -143,6 +147,7 @@ namespace trklet { std::map Memories_; std::vector MemoriesV_; + std::vector > DL_; std::vector > IL_; std::vector > AS_; std::vector > AIS_; @@ -160,6 +165,7 @@ namespace trklet { std::vector > CT_; std::map Processes_; + std::vector > IR_; std::vector > VMR_; std::vector > VMRCM_; std::vector > TE_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 86a4a66d1d119..275618906545d 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -724,7 +724,7 @@ namespace trklet { unsigned int maxstepoffset_{0}; //Number of processing steps for one event (108=18TM*240MHz/40MHz) - std::unordered_map maxstep_{{"Link", 108}, + std::unordered_map maxstep_{{"IR", 168}, {"VMR", 108}, {"TE", 108}, {"TC", 108}, @@ -746,7 +746,7 @@ namespace trklet { {"TPars", false}, {"TPD", false}, {"TrackletPars", false}, {"TED", false}, {"TP", false}, {"TRE", false}, {"VMR", false}, {"StubsLayer", false}, {"StubsLayerSector", false}, - {"HitEff", false}, {"MatchEff", false}, {"Cabling", false}, + {"HitEff", false}, {"MatchEff", false}, {"Cabling", false}, {"IFit", false}, {"AS", false}}; std::array rDSSinner_mod_{{68.9391, 78.7750, 85.4550, 96.3150, 102.3160}}; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h index e30273bac4a01..5e9a87d656325 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h @@ -47,6 +47,7 @@ namespace trklet { Timer cleanTimer_; Timer addStubTimer_; + Timer InputRouterTimer_; Timer VMRouterTimer_; Timer TETimer_; Timer TEDTimer_; diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc new file mode 100644 index 0000000000000..257562a4a547f --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc @@ -0,0 +1,51 @@ +#include "L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h" +#include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h" +#include "L1Trigger/TrackFindingTracklet/interface/Stub.h" + +#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" + +#include +#include +#include +#include + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +using namespace trklet; +using namespace std; + +DTCLinkMemory::DTCLinkMemory(string name, Settings const& settings, unsigned int iSector, double, double) + : MemoryBase(name, settings, iSector) { +} + +void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { + + //Make new objects owned by the dtclink memory and save in list of stubs + if (stubs_.size() < settings_.maxStep("IR")) { + Stub* stubptr = new Stub(stub); + stubptr->setl1tstub(new L1TStub(al1stub)); + + stubs_.emplace_back(stubptr); + } +} + +void DTCLinkMemory::writeStubs(bool first) { + const string dirIS = settings_.memPath() + "InputStubs/"; + openFile(first, dirIS, "Link_"); + + for (unsigned int j = 0; j < stubs_.size(); j++) { + string stub = stubs_[j]->str(); + out_ << std::setfill('0') << std::setw(2); + out_ << hex << j << dec; + out_ << " " << stub << " " << trklet::hexFormat(stub) << endl; + } + out_.close(); +} + +void DTCLinkMemory::clean() { + for (auto& stub : stubs_) { + delete stub->l1tstub(); + delete stub; + } + stubs_.clear(); +} diff --git a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc index 6d08588d0068f..7b5c49e6244b7 100644 --- a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc @@ -15,39 +15,10 @@ using namespace trklet; using namespace std; InputLinkMemory::InputLinkMemory(string name, Settings const& settings, unsigned int iSector, double, double) - : MemoryBase(name, settings, iSector) { - string subname = name.substr(5, 7); - phiregion_ = subname[3] - 'A'; - assert(phiregion_ >= 0 && phiregion_ < 8); + : MemoryBase(name, settings, iSector) {} - layerdisk_ = initLayerDisk(3); -} - -void InputLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { - //Various consistency checks - unsigned int stublayerdisk = stub.layerdisk(); - assert(stublayerdisk == layerdisk_); - - FPGAWord iphi = stub.phicorr(); - unsigned int nallbits = settings_.nbitsallstubs(layerdisk_); - int phibin = iphi.bits(iphi.nbits() - nallbits, nallbits); - int iphivmRaw = iphi.bits(iphi.nbits() - 5, 5); - - assert(phibin == phiregion_); - - if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Will add stub in " << getName() << " " - << "iphiwmRaw = " << iphivmRaw << " phi=" << al1stub.phi() << " z=" << al1stub.z() - << " r=" << al1stub.r(); - } - - //Make new objects owned by the inputlink memory and save in list of stubs - if (stubs_.size() < settings_.maxStep("Link")) { - Stub* stubptr = new Stub(stub); - stubptr->setl1tstub(new L1TStub(al1stub)); - - stubs_.emplace_back(stubptr); - } +void InputLinkMemory::addStub(Stub* stub) { + stubs_.push_back(stub); } void InputLinkMemory::writeStubs(bool first) { @@ -64,9 +35,5 @@ void InputLinkMemory::writeStubs(bool first) { } void InputLinkMemory::clean() { - for (auto& stub : stubs_) { - delete stub->l1tstub(); - delete stub; - } stubs_.clear(); } diff --git a/L1Trigger/TrackFindingTracklet/src/InputRouter.cc b/L1Trigger/TrackFindingTracklet/src/InputRouter.cc new file mode 100644 index 0000000000000..cdd10c76c1ad9 --- /dev/null +++ b/L1Trigger/TrackFindingTracklet/src/InputRouter.cc @@ -0,0 +1,84 @@ +#include "L1Trigger/TrackFindingTracklet/interface/InputRouter.h" +#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" +#include "L1Trigger/TrackFindingTracklet/interface/Globals.h" +#include "L1Trigger/TrackFindingTracklet/interface/Stub.h" +#include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h" +#include "L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h" +#include "L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +using namespace std; +using namespace trklet; + +InputRouter::InputRouter(string name, Settings const& settings, Globals* global, unsigned int iSector) + : ProcessBase(name, settings, global, iSector) { +} + +void InputRouter::addOutput(MemoryBase* memory, string output) { + if (settings_.writetrace()) { + edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " + << output; + } + + if (output == "stubout") { + InputLinkMemory* tmp = dynamic_cast(memory); + assert(tmp != nullptr); + unsigned int layerdisk=tmp->getName()[4]-'1'; + if (tmp->getName()[3]=='D') { + layerdisk+=N_LAYER; + } + assert(layerdisk < N_LAYER + N_DISK); + unsigned int phireg = tmp->getName()[8]-'A'; + std::pair layerphireg(layerdisk,phireg); + irstubs_.emplace_back(layerphireg, tmp); + return; + } + + + throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output; +} + +void InputRouter::addInput(MemoryBase* memory, string input) { + if (settings_.writetrace()) { + edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " + << input; + } + if (input == "stubin") { + dtcstubs_ = dynamic_cast(memory); + assert(dtcstubs_ != nullptr); + return; + } + throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; +} + +void InputRouter::execute() { + + for (unsigned int i = 0; i < settings_.maxStep("IR"); i++) { + + if (i>=dtcstubs_->nStubs()) { + break; + } + + Stub* stub = dtcstubs_->getStub(i); + + unsigned int layerdisk = stub->l1tstub()->layerdisk(); + + FPGAWord iphi = stub->phicorr(); + unsigned int iphipos = iphi.value()>>(iphi.nbits() - settings_.nbitsallstubs(layerdisk)); + + std::pair layerphireg(layerdisk,iphipos); + + //Fill inner allstubs memories - in HLS this is the same write to multiple memories + int iadd=0; + for (auto& irstubmem : irstubs_) { + if (layerphireg==irstubmem.first) { + irstubmem.second->addStub(stub); + iadd++; + } + } + assert(iadd==1); + } + +} diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 6d347b85250f1..a00f5eb6a4a04 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -3,6 +3,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" #include "L1Trigger/TrackFindingTracklet/interface/Globals.h" +#include "L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h" #include "L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h" @@ -19,6 +20,7 @@ #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" @@ -63,11 +65,6 @@ Sector::~Sector() = default; bool Sector::addStub(L1TStub stub, string dtc) { unsigned int layerdisk = stub.layerdisk(); - double stubphi = stub.phi(); - if (stubphi - phimin_ > M_PI) { - stubphi -= 2 * M_PI; - } - if (layerdisk < N_LAYER && globals_->phiCorr(layerdisk) == nullptr) { globals_->phiCorr(layerdisk) = new VMRouterPhiCorrTable(settings_); @@ -88,21 +85,13 @@ bool Sector::addStub(L1TStub stub, string dtc) { fpgastub.setPhiCorr(iphicorr); } - FPGAWord phi = fpgastub.phicorr(); - int ireg = phi.value() >> (phi.nbits() - settings_.nbitsallstubs(layerdisk)); - int nadd = 0; - for (unsigned int i = 0; i < IL_.size(); i++) { - const string& name = IL_[i]->getName(); + for (unsigned int i = 0; i < DL_.size(); i++) { + const string& name = DL_[i]->getName(); if (name.find("_" + dtc) == string::npos) continue; - if ((name[3] == 'L' && name[4] - '1' == (int)layerdisk) || - (name[3] == 'D' && name[4] - '1' == (int)layerdisk - 6)) { - if (name[8] - 'A' == ireg) { - IL_[i]->addStub(stub, fpgastub); - nadd++; - } - } + DL_[i]->addStub(stub, fpgastub); + nadd++; } assert(nadd == 1); @@ -182,7 +171,9 @@ void Sector::writeLink(const Stub& fpgastub) { } void Sector::addMem(string memType, string memName) { - if (memType == "InputLink:") { + if (memType == "DTCLink:") { + addMemToVec(DL_, memName, settings_, isector_, phimin_, phimax_); + } else if (memType == "InputLink:") { addMemToVec(IL_, memName, settings_, isector_, phimin_, phimax_); } else if (memType == "AllStubs:") { addMemToVec(AS_, memName, settings_, isector_); @@ -219,7 +210,9 @@ void Sector::addMem(string memType, string memName) { } void Sector::addProc(string procType, string procName) { - if (procType == "VMRouter:") { + if (procType == "InputRouter:") { + addProcToVec(IR_, procName, settings_, globals_, isector_); + } else if (procType == "VMRouter:") { addProcToVec(VMR_, procName, settings_, globals_, isector_); } else if (procType == "VMRouterCM:") { addProcToVec(VMRCM_, procName, settings_, globals_, isector_); @@ -298,7 +291,13 @@ MemoryBase* Sector::getMem(string memName) { return nullptr; } -void Sector::writeInputStubs(bool first) { +void Sector::writeDTCStubs(bool first) { + for (auto& i : DL_) { + i->writeStubs(first); + } +} + +void Sector::writeIRStubs(bool first) { for (auto& i : IL_) { i->writeStubs(first); } @@ -394,6 +393,12 @@ void Sector::clean() { } } +void Sector::executeIR() { + for (auto& i : IR_) { + i->execute(); + } +} + void Sector::executeVMR() { if (settings_.writeMonitorData("IL")) { ofstream& out = globals_->ofstream("inputlink.txt"); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc index a7698fcac8328..080eba116c0cd 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc @@ -1019,15 +1019,13 @@ void TrackletConfigBuilder::writeCTMemories(std::ostream& os, std::ostream& memo } } -void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memories, std::ostream&) { +void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) { //FIXME these should not be hardcoded - but for now wanted to avoid reading file string dtcname[52]; unsigned int layerdisk[52]; double phimin[52]; double phimax[52]; - //FIXME layerdisk numbering should be 0 to 10 - dtcname[0] = "PS10G_1"; layerdisk[0] = 0; phimin[0] = 0.304273; @@ -1239,6 +1237,22 @@ void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memo double dphi = 0.5 * dphisectorHG_ - M_PI / NSector_; + string olddtc=""; + for (unsigned int i = 0; i < 52; i++) { + if (olddtc!=dtcname[i]) { + modules << "InputRouter: IR_"< output=> IR_" << dtcname[i] << "_A.stubin" << std::endl; + os << "DL_" << dtcname[i] << "_B" + << " input=> output=> IR_" << dtcname[i] << "_B.stubin" << std::endl; + } + olddtc=dtcname[i]; + } + + for (unsigned int i = 0; i < 52; i++) { double phimintmp = phimin[i] + dphi; double phimaxtmp = phimax[i] + dphi; @@ -1251,14 +1265,14 @@ void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memo memories << "InputLink: IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_A" << " [36]" << std::endl; os << "IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_A" - << " input=> output=> VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; + << " input=> IR_"< VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; } if (allStubs_[layerdisk[i]][iReg].first > phimintmp) { memories << "InputLink: IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_B" << " [36]" << std::endl; os << "IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_B" - << " input=> output=> VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; + << " input=> IR_"< VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; } } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index 334c372a4021e..7bfd9015fd609 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -240,11 +240,21 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { // Now start the tracklet processing // VM router + InputRouterTimer_.start(); + for (unsigned int k = 0; k < N_SECTOR; k++) { + sectors_[k]->executeIR(); + if (settings_->writeMem() && k == settings_->writememsect()) { + sectors_[k]->writeDTCStubs(first); + sectors_[k]->writeIRStubs(first); + } + } + InputRouterTimer_.stop(); + + VMRouterTimer_.start(); for (unsigned int k = 0; k < N_SECTOR; k++) { sectors_[k]->executeVMR(); if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeInputStubs(first); sectors_[k]->writeVMSTE(first); sectors_[k]->writeVMSME(first); sectors_[k]->writeAS(first); @@ -436,7 +446,10 @@ void TrackletEventProcessor::printSummary() { << addStubTimer_.tottime() << "\n" << "VMRouter " << setw(10) << VMRouterTimer_.ntimes() << setw(20) << setprecision(3) << VMRouterTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << VMRouterTimer_.tottime(); + << VMRouterTimer_.tottime() << "\n" + << "InputRouter " << setw(10) << InputRouterTimer_.ntimes() << setw(20) + << setprecision(3) << InputRouterTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) + << InputRouterTimer_.tottime(); if (settings_->combined()) { edm::LogVerbatim("Tracklet") << "TrackletProcessor " << setw(10) << TPTimer_.ntimes() << setw(20) << setprecision(3) << TPTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) From 023c4391957336edd5f5a3670b548044e4b9d03f Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sun, 14 Mar 2021 13:03:32 -0400 Subject: [PATCH 23/45] Cleanup of writing the DTC link files --- .../TrackFindingTracklet/interface/Sector.h | 4 -- .../TrackFindingTracklet/src/DTCLinkMemory.cc | 37 +++++++++- L1Trigger/TrackFindingTracklet/src/Sector.cc | 70 ------------------- .../src/TrackletEventProcessor.cc | 4 -- 4 files changed, 36 insertions(+), 79 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Sector.h b/L1Trigger/TrackFindingTracklet/interface/Sector.h index 25c56e6784b04..e4b84aa81cf02 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Sector.h +++ b/L1Trigger/TrackFindingTracklet/interface/Sector.h @@ -135,9 +135,6 @@ namespace trklet { Processes_[procName] = procvec.back().get(); } - void writeLinkNewEvent(int event); - void writeLink(const Stub& fpgastub); - private: int isector_; Settings const& settings_; @@ -181,7 +178,6 @@ namespace trklet { std::vector > FT_; std::vector > PD_; - std::unordered_map DTCLink_ofstreams_; }; }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc index 257562a4a547f..63d6fe2a70373 100644 --- a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc @@ -30,11 +30,46 @@ void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { } void DTCLinkMemory::writeStubs(bool first) { + + //FIXME should be in settings + static map > dtclayers{{"PS10G_1", {0, 6, 8, 10}}, + {"PS10G_2", {0, 7, 9}}, + {"PS10G_3", {1, 7}}, + {"PS10G_4", {6, 8, 10}}, + {"PS_1", {2, 7}}, + {"PS_2", {2, 9}}, + {"2S_1", {3, 4}}, + {"2S_2", {4}}, + {"2S_3", {5}}, + {"2S_4", {5, 8}}, + {"2S_5", {6, 9}}, + {"2S_6", {7, 10}}}; + + const string dirIS = settings_.memPath() + "InputStubs/"; openFile(first, dirIS, "Link_"); for (unsigned int j = 0; j < stubs_.size(); j++) { - string stub = stubs_[j]->str(); + string dtcname = stubs_[j]->l1tstub()->DTClink(); + int layerdisk = stubs_[j]->l1tstub()->layerdisk(); + + int start = dtcname.substr(0, 3) == "neg" ? 3 : 0; + + string dtcbase = dtcname.substr(start, dtcname.size() - 2 - start); + + vector layers = dtclayers[dtcbase]; + + int lcode = -1; + for (unsigned int index = 0; index < layers.size(); index++) { + if (layerdisk == layers[index]) { + lcode = index; + } + } + assert(lcode != -1); + + FPGAWord ldcode(lcode, 2, true); + + string stub = stubs_[j]->str()+"|"+ldcode.str()+"|1"; out_ << std::setfill('0') << std::setw(2); out_ << hex << j << dec; out_ << " " << stub << " " << trklet::hexFormat(stub) << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index a00f5eb6a4a04..5d8e424c456b9 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -96,79 +96,9 @@ bool Sector::addStub(L1TStub stub, string dtc) { assert(nadd == 1); - if (settings_.writeMem() && isector_ == (int)settings_.writememsect()) { - writeLink(fpgastub); - } - return true; } -void Sector::writeLinkNewEvent(int event) { - if (DTCLink_ofstreams_.size() == 0) { - //FIXME should be in settings - static string dtcbasenames[12] = { - "PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", "2S_4", "2S_5", "2S_6"}; - for (const auto& dtcbasename : dtcbasenames) { - for (int neg = 0; neg < 2; neg++) { - string dtcnametmp = (neg == 0 ? "" : "neg") + dtcbasename; - for (int ab = 0; ab < 2; ab++) { - string dtcname = dtcnametmp + (ab == 0 ? "_A" : "_B"); - string dirName = settings_.memPath() + "InputStubs/"; - string fname = dirName + "Link_" + dtcname + "_" + to_string(isector_ + 1) + ".dat"; - ofstream* out = new ofstream; - openfile(*out, true, dirName,fname, __FILE__, __LINE__); - DTCLink_ofstreams_[dtcname] = out; - } - } - } - } - - for (auto& out : DTCLink_ofstreams_) { - FPGAWord bx(event % 8, 3, true); - (*out.second) << "BX " << bx.str() << " Event : " << event << endl; - } -} - -void Sector::writeLink(const Stub& fpgastub) { - //FIXME should be in settings - static map > dtclayers{{"PS10G_1", {0, 6, 8, 10}}, - {"PS10G_2", {0, 7, 9}}, - {"PS10G_3", {1, 7}}, - {"PS10G_4", {6, 8, 10}}, - {"PS_1", {2, 7}}, - {"PS_2", {2, 9}}, - {"2S_1", {3, 4}}, - {"2S_2", {4}}, - {"2S_3", {5}}, - {"2S_4", {5, 8}}, - {"2S_5", {6, 9}}, - {"2S_6", {7, 10}}}; - - string dtcname = fpgastub.l1tstub()->DTClink(); - int layerdisk = fpgastub.l1tstub()->layerdisk(); - - int start = dtcname.substr(0, 3) == "neg" ? 3 : 0; - - string dtcbase = dtcname.substr(start, dtcname.size() - 2 - start); - - vector layers = dtclayers[dtcbase]; - - int lcode = -1; - for (unsigned int index = 0; index < layers.size(); index++) { - if (layerdisk == layers[index]) { - lcode = index; - } - } - assert(lcode != -1); - - assert(DTCLink_ofstreams_.find(dtcname) != DTCLink_ofstreams_.end()); - - FPGAWord ldcode(lcode, 2, true); - - string dataword = fpgastub.str() + "|" + ldcode.str() + "|1" ; - - (*DTCLink_ofstreams_.find(dtcname)->second) << dataword << " " << trklet::hexFormat(dataword) << endl; -} void Sector::addMem(string memType, string memName) { if (memType == "DTCLink:") { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index 7bfd9015fd609..f930268c2540b 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -198,10 +198,6 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { } cleanTimer_.stop(); - if (settings_->writeMem()) { - sectors_[settings_->writememsect()]->writeLinkNewEvent(eventnum_); - } - addStubTimer_.start(); vector layerstubs(N_LAYER + N_DISK, 0); From 00a8a23c74a4dbcf66aa6762016053dc82219d3f Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sun, 14 Mar 2021 23:38:47 -0400 Subject: [PATCH 24/45] Change processing order such that all steps in one sector are done and then move to the next sector. This saves memory --- .../interface/MatchCalculator.h | 3 +- .../interface/MatchProcessor.h | 4 +- .../interface/ProcessBase.h | 4 - .../interface/PurgeDuplicate.h | 2 +- .../TrackFindingTracklet/interface/Sector.h | 7 +- .../TrackFindingTracklet/interface/Track.h | 8 +- .../interface/TrackletCalculator.h | 2 +- .../interface/TrackletCalculatorBase.h | 3 + .../interface/TrackletCalculatorDisplaced.h | 5 +- .../interface/TrackletEventProcessor.h | 7 +- .../interface/TrackletProcessor.h | 2 +- .../TrackFindingTracklet/src/FitTrack.cc | 4 +- .../src/MatchCalculator.cc | 21 +- .../TrackFindingTracklet/src/MatchEngine.cc | 4 +- .../src/MatchProcessor.cc | 22 +- .../TrackFindingTracklet/src/ProcessBase.cc | 14 +- .../src/PurgeDuplicate.cc | 16 +- L1Trigger/TrackFindingTracklet/src/Sector.cc | 26 +- L1Trigger/TrackFindingTracklet/src/Track.cc | 2 +- .../TrackFindingTracklet/src/Tracklet.cc | 11 +- .../src/TrackletCalculator.cc | 15 +- .../src/TrackletCalculatorDisplaced.cc | 6 +- .../src/TrackletEngine.cc | 2 +- .../src/TrackletEngineDisplaced.cc | 8 +- .../src/TrackletEventProcessor.cc | 364 ++++++++---------- .../src/TrackletProcessor.cc | 21 +- .../TrackFindingTracklet/src/TripletEngine.cc | 10 +- L1Trigger/TrackFindingTracklet/test/fpga.cc | 30 +- 28 files changed, 297 insertions(+), 326 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h b/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h index 16d95f9d85f33..455aa9ca42d2c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h @@ -27,7 +27,7 @@ namespace trklet { void addOutput(MemoryBase* memory, std::string output) override; void addInput(MemoryBase* memory, std::string input) override; - void execute(); + void execute(double phioffset); std::vector, const Stub*> > mergeMatches( std::vector& candmatch); @@ -40,7 +40,6 @@ namespace trklet { int icorrshift_; int icorzshift_; int phi0shift_; - double phioffset_; unsigned int phimatchcut_[N_SEED]; unsigned int zmatchcut_[N_SEED]; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index 691c470d67b0e..e0c4317fd53c5 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -30,7 +30,7 @@ namespace trklet { void addOutput(MemoryBase* memory, std::string output) override; void addInput(MemoryBase* memory, std::string input) override; - void execute(); + void execute(double phimin); bool matchCalculator(Tracklet* tracklet, const Stub* fpgastub); @@ -74,6 +74,8 @@ namespace trklet { //used for bend consistency with rinv std::vector table_; + double phimin_; + unsigned int nMatchEngines_; std::vector matchengines_; diff --git a/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h b/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h index 4033b6ca025cf..2391887581903 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h @@ -36,10 +36,6 @@ namespace trklet { protected: std::string name_; - unsigned int iSector_; - - double phimin_; - double phimax_; Settings const& settings_; Globals* globals_; diff --git a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h index 833c41e30a7b4..a643097262b8d 100644 --- a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h +++ b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h @@ -26,7 +26,7 @@ namespace trklet { void addOutput(MemoryBase* memory, std::string output) override; void addInput(MemoryBase* memory, std::string input) override; - void execute(std::vector& outputtracks_); + void execute(std::vector& outputtracks_, unsigned int iSector); private: double getPhiRes(Tracklet* curTracklet, const Stub* curStub); diff --git a/L1Trigger/TrackFindingTracklet/interface/Sector.h b/L1Trigger/TrackFindingTracklet/interface/Sector.h index e4b84aa81cf02..8b336d56afb3c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Sector.h +++ b/L1Trigger/TrackFindingTracklet/interface/Sector.h @@ -60,10 +60,13 @@ namespace trklet { class Sector { public: - Sector(unsigned int i, Settings const& settings, Globals* globals); + Sector(Settings const& settings, Globals* globals); ~Sector(); + //Set the sector + void setSector(unsigned int isector); + bool addStub(L1TStub stub, std::string dtc); //TODO - should be pointer or string // Creates all required memory modules based on wiring map (args: module type, module instance) @@ -112,7 +115,7 @@ namespace trklet { void executeMC(); void executeMP(); void executeFT(); - void executePD(std::vector& tracks); + void executePD(std::vector& tracks); std::vector getAllTracklets() const; std::vector getStubs() const; diff --git a/L1Trigger/TrackFindingTracklet/interface/Track.h b/L1Trigger/TrackFindingTracklet/interface/Track.h index cbf27a81c3f63..bd95a2a6cc43c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Track.h +++ b/L1Trigger/TrackFindingTracklet/interface/Track.h @@ -24,7 +24,7 @@ namespace trklet { double chisqrz, int hitpattern, std::map stubID, - const std::vector& l1stub, + const std::vector& l1stub, int seed); ~Track() = default; @@ -39,7 +39,7 @@ namespace trklet { int ichisq() const { return ichisqrphi_ + ichisqrz_; } const std::map& stubID() const { return stubID_; } - const std::vector& stubs() const { return l1stub_; } + const std::vector& stubs() const { return l1stub_; } //These are not used? Should be removed? const std::vector>& stubIDpremerge() const { return stubIDpremerge_; } @@ -69,7 +69,7 @@ namespace trklet { int nPSstubs() const { int npsstubs = 0; for (auto istub : l1stub_) { - if (istub->layer() < N_PSLAYER) + if (istub.layer() < N_PSLAYER) npsstubs++; } return npsstubs; @@ -88,7 +88,7 @@ namespace trklet { std::vector> stubIDpremerge_; std::vector> stubIDprefit_; std::map stubID_; - std::vector l1stub_; + std::vector l1stub_; unsigned int nstubs_; int seed_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h index 16d65ae9518b8..327d5ad8cd2b5 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h @@ -27,7 +27,7 @@ namespace trklet { void addOutput(MemoryBase* memory, std::string output) override; void addInput(MemoryBase* memory, std::string input) override; - void execute(); + void execute(unsigned int iSector, double phimin, double phimax); private: int iTC_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h index e58c5eb340adb..b05c3e435c003 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h @@ -131,6 +131,9 @@ namespace trklet { int TCIndex_; + unsigned int iSector_; + double phimin_, phimax_; + TrackletParametersMemory* trackletpars_; //First index is layer/disk second is phi region diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h index 8e85d6a55a94e..bf33ee9e428d2 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h @@ -28,7 +28,7 @@ namespace trklet { void addOutput(MemoryBase* memory, std::string output) override; void addInput(MemoryBase* memory, std::string input) override; - void execute(); + void execute(unsigned int iSector, double phimin, double phimax); void addDiskProj(Tracklet* tracklet, int disk); bool addLayerProj(Tracklet* tracklet, int layer); @@ -166,6 +166,9 @@ namespace trklet { int dproj_[N_DISK - 2]; double rzmeanInv_[N_DISK - 2]; + unsigned int iSector_; + double phimin_, phimax_; + std::vector toR_; std::vector toZ_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h index 5e9a87d656325..8e3fe01adc5ed 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h @@ -30,7 +30,7 @@ namespace trklet { void printSummary(); - std::vector& tracks() { return tracks_; } + const std::vector& tracks() const { return tracks_; } private: void configure(std::istream& inwire, std::istream& inmem, std::istream& inproc); @@ -39,7 +39,7 @@ namespace trklet { std::unique_ptr globals_; - std::vector > sectors_; + std::unique_ptr sector_; HistBase* histbase_{}; @@ -62,9 +62,8 @@ namespace trklet { Timer FTTimer_; Timer PDTimer_; - std::vector tracks_; + std::vector tracks_; - //std::map > dtclayerdisk_; }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h index 80c3d7dcb6f45..645174f151ae2 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h @@ -33,7 +33,7 @@ namespace trklet { void addInput(MemoryBase* memory, std::string input) override; - void execute(); + void execute(unsigned int iSector, double phimin, double phimax); void writeTETable(); diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index d013361a23877..71ba31bd39ba9 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -878,7 +878,7 @@ void FitTrack::execute() { for (auto& imatch : fullmatch1_) { edm::LogVerbatim("Tracklet") << imatch->getName() << " " << imatch->nMatches(); } - edm::LogVerbatim("Tracklet") << getName() << "[" << iSector_ << "] matches : " << matches1.size() << " " + edm::LogVerbatim("Tracklet") << getName() << " matches : " << matches1.size() << " " << matches2.size() << " " << matches3.size() << " " << matches4.size(); } @@ -1010,7 +1010,7 @@ void FitTrack::execute() { assert(trackfit_ != nullptr); if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << bestTracklet->getISeed() + fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << " " << bestTracklet->getISeed() << endl; fout.close(); } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index f1a6a0d5ca300..b61b64ea8a358 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -20,8 +20,7 @@ using namespace trklet; MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* global, unsigned int iSector) : ProcessBase(name, settings, global, iSector) { - phioffset_ = phimin_; - + phiregion_ = name[8] - 'A'; layerdisk_ = initLayerDisk(3); @@ -58,7 +57,7 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* } } - if (iSector_ == 0 && layerdisk_ < N_LAYER && settings_.writeTable()) { + if (layerdisk_ < N_LAYER && settings_.writeTable()) { ofstream outphicut = openfile(settings_.tablePath(), getName() + "_phicut.tab", __FILE__, __LINE__); outphicut << "{" << endl; @@ -85,7 +84,7 @@ MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* outzcut.close(); } - if (iSector_ == 0 && layerdisk_ >= N_LAYER && settings_.writeTable()) { + if (layerdisk_ >= N_LAYER && settings_.writeTable()) { ofstream outPSphicut = openfile(settings_.tablePath(), getName() + "_PSphicut.tab", __FILE__, __LINE__); outPSphicut << "{" << endl; @@ -186,7 +185,7 @@ void MatchCalculator::addInput(MemoryBase* memory, string input) { throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input " << input; } -void MatchCalculator::execute() { +void MatchCalculator::execute(double phioffset) { unsigned int countall = 0; unsigned int countsel = 0; @@ -231,7 +230,7 @@ void MatchCalculator::execute() { //Floating point calculations - double phi = stub->phi() - phioffset_; + double phi = stub->phi() - phioffset; double r = stub->r(); double z = stub->z(); @@ -325,8 +324,7 @@ void MatchCalculator::execute() { mergedMatches[j].second); if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet << " " - << iSector_; + edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet; } fullMatches_[seedindex]->addMatch(tracklet, mergedMatches[j].second); @@ -387,7 +385,7 @@ void MatchCalculator::execute() { //Perform floating point calculations here - double phi = stub->phi() - phioffset_; + double phi = stub->phi() - phioffset; double z = stub->z(); double r = stub->r(); @@ -406,7 +404,7 @@ void MatchCalculator::execute() { if (std::abs(dz) > settings_.dzmax()) { throw cms::Exception("LogicError") - << __FILE__ << " " << __LINE__ << " " << name_ << "_" << iSector_ << " " << tracklet->getISeed() + << __FILE__ << " " << __LINE__ << " " << name_ << " " << tracklet->getISeed() << "\n stub " << stub->z() << " disk " << disk << " " << dz; } @@ -488,8 +486,7 @@ void MatchCalculator::execute() { fpgastub); if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet << " " - << iSector_; + edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet; } fullMatches_[seedindex]->addMatch(tracklet, mergedMatches[j].second); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index 234def63884a6..881ed4d3da6f0 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -122,7 +122,7 @@ void MatchEngine::execute() { unsigned int countall = 0; unsigned int countpass = 0; - bool print = (iSector_ == 3) && (getName() == "ME_L3PHIC20"); + bool print = (getName() == "ME_L3PHIC20"); print = false; constexpr unsigned int kNBitsBuffer = 3; @@ -338,7 +338,7 @@ void MatchEngine::execute() { std::pair tmp(proj, vmprojs_->getAllProjIndex(projindex)); if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << proj->getISeed() << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << proj->getISeed() << endl; fout.close(); } candmatches_->addMatch(tmp, vmstub.stub()); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 18bd694984946..7c74418143733 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -51,7 +51,7 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g } } - if (iSector_ == 0 && barrel_ && settings_.writeTable()) { + if (barrel_ && settings_.writeTable()) { ofstream outphicut = openfile(settings_.tablePath(), getName() + "_phicut.tab", __FILE__, __LINE__); outphicut << "{" << endl; @@ -192,7 +192,7 @@ void MatchProcessor::addInput(MemoryBase* memory, string input) { throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input: " << input; } -void MatchProcessor::execute() { +void MatchProcessor::execute(double phimin) { assert(vmstubs_.size() == 1); /* @@ -211,6 +211,8 @@ void MatchProcessor::execute() { //bool print = getName()=="MP_L3PHIC" && iSector_==3; + phimin_ = phimin; + Tracklet* oldTracklet = nullptr; unsigned int countme = 0; @@ -466,9 +468,9 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double z = stub->z(); if (settings_.useapprox()) { - double dphi = reco::reduceRange(phi - fpgastub->phiapprox(phimin_, phimax_)); + double dphi = reco::reduceRange(phi - fpgastub->phiapprox(phimin_, 0.0)); assert(std::abs(dphi) < 0.001); - phi = fpgastub->phiapprox(phimin_, phimax_); + phi = fpgastub->phiapprox(phimin_, 0.0); z = fpgastub->zapprox(); r = fpgastub->rapprox(); } @@ -541,8 +543,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { fpgastub); if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet << " " - << iSector_; + edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet; } int iSeed = tracklet->getISeed(); @@ -607,9 +608,9 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double r = stub->r(); if (settings_.useapprox()) { - double dphi = reco::reduceRange(phi - fpgastub->phiapprox(phimin_, phimax_)); + double dphi = reco::reduceRange(phi - fpgastub->phiapprox(phimin_, 0.0)); assert(std::abs(dphi) < 0.001); - phi = fpgastub->phiapprox(phimin_, phimax_); + phi = fpgastub->phiapprox(phimin_, 0.0); z = fpgastub->zapprox(); r = fpgastub->rapprox(); } @@ -621,7 +622,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { double dz = z - sign * settings_.zmean(layerdisk_ - N_LAYER); if (std::abs(dz) > settings_.dzmax()) { - edm::LogProblem("Tracklet") << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " + edm::LogProblem("Tracklet") << __FILE__ << ":" << __LINE__ << " " << name_ << " " << tracklet->getISeed(); edm::LogProblem("Tracklet") << "stub " << stub->z() << " disk " << disk << " " << dz; assert(std::abs(dz) < settings_.dzmax()); @@ -700,8 +701,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { fpgastub); if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet << " " - << iSector_; + edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet; } int iSeed = tracklet->getISeed(); diff --git a/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc b/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc index b0a478f962424..1cfada1140ac7 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc @@ -12,19 +12,7 @@ using namespace trklet; using namespace std; ProcessBase::ProcessBase(string name, Settings const& settings, Globals* global, unsigned int iSector) - : name_(name), settings_(settings), globals_(global) { - iSector_ = iSector; - double dphi = 2 * M_PI / N_SECTOR; - double dphiHG = 0.5 * settings_.dphisectorHG() - M_PI / N_SECTOR; - phimin_ = iSector_ * dphi - dphiHG; - phimax_ = phimin_ + dphi + 2 * dphiHG; - phimin_ -= M_PI / N_SECTOR; - phimax_ -= M_PI / N_SECTOR; - if (phimin_ > M_PI) { - phimin_ -= 2 * M_PI; - phimax_ -= 2 * M_PI; - } -} + : name_(name), settings_(settings), globals_(global) {} unsigned int ProcessBase::nbits(unsigned int power) { if (power == 2) diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 3ad253478c4e5..bc41d0ee10ac3 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -78,7 +78,7 @@ void PurgeDuplicate::addInput(MemoryBase* memory, std::string input) { throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input: " << input; } -void PurgeDuplicate::execute(std::vector& outputtracks_) { +void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSector) { inputtracklets_.clear(); inputtracks_.clear(); @@ -92,7 +92,7 @@ void PurgeDuplicate::execute(std::vector& outputtracks_) { continue; for (unsigned int j = 0; j < inputtrackfit->nTracks(); j++) { Track* aTrack = inputtrackfit->getTrack(j)->getTrack(); - aTrack->setSector(iSector_); + aTrack->setSector(iSector); inputtracks_.push_back(aTrack); } } @@ -326,14 +326,14 @@ void PurgeDuplicate::execute(std::vector& outputtracks_) { Tracklet* tracklet = inputtracklets_[itrk]; std::vector trackstublist = inputstublists_[itrk]; - HybridFit hybridFitter(iSector_, settings_, globals_); + HybridFit hybridFitter(iSector, settings_, globals_); hybridFitter.Fit(tracklet, trackstublist); // If the track was accepted (and thus fit), add to output if (tracklet->fit()) { // Add track to output if it wasn't merged into another Track* outtrack = tracklet->getTrack(); - outtrack->setSector(iSector_); + outtrack->setSector(iSector); if (trackInfo[itrk].second == true) outtrack->setDuplicate(true); else @@ -362,7 +362,7 @@ void PurgeDuplicate::execute(std::vector& outputtracks_) { if (inputtracks_[itrk]->duplicate()) edm::LogPrint("Tracklet") << "WARNING: Track already tagged as duplicate!!"; - double phiBin = (inputtracks_[itrk]->phi0(settings_) - 2 * M_PI / 27 * iSector_) / (2 * M_PI / 9 / 50) + 9; + double phiBin = (inputtracks_[itrk]->phi0(settings_) - 2 * M_PI / 27 * iSector) / (2 * M_PI / 9 / 50) + 9; phiBin = std::max(phiBin, 0.); phiBin = std::min(phiBin, 34.); @@ -374,7 +374,7 @@ void PurgeDuplicate::execute(std::vector& outputtracks_) { inputtracks_[itrk]->setDuplicate(true); grid[(int)phiBin][(int)ptBin] = true; - double phiTest = inputtracks_[itrk]->phi0(settings_) - 2 * M_PI / 27 * iSector_; + double phiTest = inputtracks_[itrk]->phi0(settings_) - 2 * M_PI / 27 * iSector; if (phiTest < -2 * M_PI / 27) edm::LogVerbatim("Tracklet") << "track phi too small!"; if (phiTest > 2 * 2 * M_PI / 27) @@ -463,14 +463,14 @@ void PurgeDuplicate::execute(std::vector& outputtracks_) { if (inputtrackfits_[i]->getTrack(j)->getTrack()->duplicate() == 0) { if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " + fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector << " " << inputtrackfits_[i]->getTrack(j)->getISeed() << endl; fout.close(); } outputtracklets_[i]->addTrack(inputtrackfits_[i]->getTrack(j)); } //For root file: - outputtracks_.push_back(inputtrackfits_[i]->getTrack(j)->getTrack()); + outputtracks_.push_back(*inputtrackfits_[i]->getTrack(j)->getTrack()); } } } diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 5d8e424c456b9..9bd12412c3518 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -45,8 +45,13 @@ using namespace std; using namespace trklet; -Sector::Sector(unsigned int i, Settings const& settings, Globals* globals) : settings_(settings), globals_(globals) { - isector_ = i; +Sector::Sector(Settings const& settings, Globals* globals) : isector_(-1), settings_(settings), globals_(globals) {} + +Sector::~Sector() = default; + +void Sector::setSector(unsigned int isector){ + assert(isector phimax_) { phimin_ -= 2 * M_PI; } + } -Sector::~Sector() = default; + bool Sector::addStub(L1TStub stub, string dtc) { unsigned int layerdisk = stub.layerdisk(); @@ -364,13 +370,13 @@ void Sector::executeTRE() { void Sector::executeTP() { for (auto& i : TP_) { - i->execute(); + i->execute(isector_, phimin_, phimax_); } } void Sector::executeTC() { for (auto& i : TC_) { - i->execute(); + i->execute(isector_, phimin_, phimax_); } if (settings_.writeMonitorData("TrackProjOcc")) { @@ -383,7 +389,7 @@ void Sector::executeTC() { void Sector::executeTCD() { for (auto& i : TCD_) { - i->execute(); + i->execute(isector_, phimin_, phimax_); } } @@ -401,13 +407,13 @@ void Sector::executeME() { void Sector::executeMC() { for (auto& i : MC_) { - i->execute(); + i->execute(phimin_); } } void Sector::executeMP() { for (auto& i : MP_) { - i->execute(); + i->execute(phimin_); } } @@ -417,9 +423,9 @@ void Sector::executeFT() { } } -void Sector::executePD(std::vector& tracks) { +void Sector::executePD(std::vector& tracks) { for (auto& i : PD_) { - i->execute(tracks); + i->execute(tracks, isector_); } } diff --git a/L1Trigger/TrackFindingTracklet/src/Track.cc b/L1Trigger/TrackFindingTracklet/src/Track.cc index 58e1469936aae..61cb8d1521704 100644 --- a/L1Trigger/TrackFindingTracklet/src/Track.cc +++ b/L1Trigger/TrackFindingTracklet/src/Track.cc @@ -14,7 +14,7 @@ Track::Track(TrackPars ipars, double chisqrz, int hitpattern, std::map stubID, - const std::vector& l1stub, + const std::vector& l1stub, int seed) { ipars_ = ipars; ichisqrphi_ = ichisqrphi; diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index bb2532a5c691c..ac3a8de2484cf 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -736,7 +736,16 @@ Track Tracklet::makeTrack(const vector& l1stubs) { fpgafitpars_.d0().value(), fpgafitpars_.t().value(), fpgafitpars_.z0().value()); + + // If fitter produced no stub list, take it from original tracklet. + vector tmp= l1stubs.empty() ? getL1Stubs() : l1stubs; + + vector tmp2; + for(auto stub : tmp) { + tmp2.push_back(*stub); + } + Track tmpTrack( ipars, ichisqrphifit_.value(), @@ -745,7 +754,7 @@ Track Tracklet::makeTrack(const vector& l1stubs) { chisqrzfit_, hitpattern_, getStubIDs(), - (l1stubs.empty()) ? getL1Stubs() : l1stubs, // If fitter produced no stub list, take it from original tracklet. + tmp2, getISeed()); return tmpTrack; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc index ad765de628a16..026dca77596cb 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc @@ -43,8 +43,7 @@ TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Gl } // write the drinv and invt inverse tables - if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable()) && iTC_ == 0 && - iSector_ == 0) { + if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable()) && iTC_ == 0 ) { void (*writeLUT)(const VarInv&, const string&) = nullptr; if (settings.writeInvTable()) { // Verilog version writeLUT = [](const VarInv& x, const string& basename) -> void { @@ -62,7 +61,7 @@ TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Gl // write the firmware design for the calculation of the tracklet parameters // and projections - if ((settings_.writeVerilog() || settings_.writeHLS()) && iTC_ == 0 && iSector_ == 0) { + if ((settings_.writeVerilog() || settings_.writeHLS()) && iTC_ == 0) { void (*writeDesign)(const vector&, const string&) = nullptr; if (settings.writeVerilog()) { // Verilog version writeDesign = [](const vector& v, const string& basename) -> void { @@ -152,11 +151,15 @@ void TrackletCalculator::addInput(MemoryBase* memory, string input) { throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find intput : " << input; } -void TrackletCalculator::execute() { +void TrackletCalculator::execute(unsigned int iSector, double phimin, double phimax) { unsigned int countall = 0; unsigned int countsel = 0; - bool print = (iSector_ == 3) && (getName() == "TC_L1L2G"); + phimin_ = phimin; + phimax_ = phimax; + iSector_ = iSector; + + bool print = (iSector == 3) && (getName() == "TC_L1L2G"); print = false; for (auto& stubpair : stubpairs_) { @@ -173,7 +176,7 @@ void TrackletCalculator::execute() { const L1TStub* outerStub = outerFPGAStub->l1tstub(); if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "TrackletCalculator execute " << getName() << "[" << iSector_ << "]"; + edm::LogVerbatim("Tracklet") << "TrackletCalculator execute " << getName() << "[" << iSector << "]"; } if (innerFPGAStub->layerdisk() < N_LAYER && (getName() != "TC_D1L2A" && getName() != "TC_D1L2B")) { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index e7ec811c810eb..07f2c451e431f 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -220,10 +220,14 @@ void TrackletCalculatorDisplaced::addInput(MemoryBase* memory, string input) { throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; } -void TrackletCalculatorDisplaced::execute() { +void TrackletCalculatorDisplaced::execute(unsigned int iSector, double phimin, double phimax) { unsigned int countall = 0; unsigned int countsel = 0; + phimin_ = phimin; + phimax_ = phimax; + iSector_ = iSector; + for (auto& stubtriplet : stubtriplets_) { if (trackletpars_->nTracklets() >= settings_.ntrackletmax()) { edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc index 1f2146bfc5c3b..38ae2fcea9117 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc @@ -265,7 +265,7 @@ void TrackletEngine::setVMPhiBin() { innervmstubs_->setbendtable(vmbendinner); outervmstubs_->setbendtable(vmbendouter); - if (iSector_ == 0 && settings_.writeTable()) + if (settings_.writeTable()) writeTETable(); } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc index 4b18c80a9aa36..de421f0aa3dcc 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc @@ -191,7 +191,7 @@ void TrackletEngineDisplaced::execute() { if (!settings_.enableTripletTables() || settings_.writeTripletTables() || table_.at(index).count(isp)) { if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; fout.close(); } stubpairs_.at(isp)->addStubPair(firstvmstub, secondvmstub, index, getName()); @@ -272,7 +272,7 @@ void TrackletEngineDisplaced::execute() { (index < table_.size() && table_.at(index).count(isp))) { if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; fout.close(); } stubpairs_.at(isp)->addStubPair(firstvmstub, secondvmstub, index, getName()); @@ -285,7 +285,7 @@ void TrackletEngineDisplaced::execute() { } else if (disk1_ == 1 && disk2_ == 2) { if (settings_.debugTracklet()) - edm::LogVerbatim("Tracklet") << getName() << "[" << iSector_ << "] Disk-disk pair"; + edm::LogVerbatim("Tracklet") << getName() << " Disk-disk pair"; int lookupbits = firstvmstub.vmbits().value() & 511; bool negdisk = firstvmstub.stub()->disk().value() < 0; @@ -354,7 +354,7 @@ void TrackletEngineDisplaced::execute() { (index < table_.size() && table_.at(index).count(isp))) { if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; fout.close(); } stubpairs_.at(isp)->addStubPair(firstvmstub, secondvmstub, index, getName()); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index f930268c2540b..6de594a36b981 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -78,12 +78,7 @@ void TrackletEventProcessor::init(Settings const& theSettings) { globals_->histograms() = histbase_; } - // create the sector processors (1 sector processor = 1 board) - sectors_.resize(N_SECTOR); - - for (unsigned int i = 0; i < N_SECTOR; i++) { - sectors_[i] = make_unique(i, *settings_, globals_.get()); - } + sector_ = make_unique(*settings_, globals_.get()); if (settings_->extended()) { ifstream inmem(settings_->memoryModulesFile().c_str()); @@ -132,9 +127,7 @@ void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& if (settings_->writetrace()) { edm::LogVerbatim("Tracklet") << "Read memory: " << memType << " " << memName; } - for (auto& sector : sectors_) { - sector->addMem(memType, memName); - } + sector_->addMem(memType, memName); } // get the processing modules @@ -150,9 +143,7 @@ void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& if (settings_->writetrace()) { edm::LogVerbatim("Tracklet") << "Read process: " << procType << " " << procName; } - for (auto& sector : sectors_) { - sector->addProc(procType, procName); - } + sector_->addProc(procType, procName); } // get the wiring information @@ -178,9 +169,7 @@ void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream& ss >> tmp2 >> procout; } - for (auto& sector : sectors_) { - sector->addWire(mem, procin, procout); - } + sector_->addWire(mem, procin, procout); } } @@ -192,241 +181,208 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { eventnum_++; bool first = (eventnum_ == 1); - cleanTimer_.start(); for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->clean(); - } - cleanTimer_.stop(); - - addStubTimer_.start(); - - vector layerstubs(N_LAYER + N_DISK, 0); - vector layerstubssector(N_SECTOR * (N_LAYER + N_DISK), 0); - - for (int j = 0; j < ev.nstubs(); j++) { - L1TStub stub = ev.stub(j); - - string dtc = stub.DTClink(); - unsigned int isector = stub.region(); - - layerstubs[stub.layerdisk()]++; - layerstubssector[isector * (N_LAYER + N_DISK) + stub.layerdisk()]++; - - sectors_[isector]->addStub(stub, dtc); - } - - if (settings_->writeMonitorData("StubsLayerSector")) { - for (unsigned int index = 0; index < layerstubssector.size(); index++) { - int layerdisk = index % (N_LAYER + N_DISK); - int sector = index / (N_LAYER + N_DISK); - globals_->ofstream("stubslayersector.txt") + + sector_->setSector(k); + + cleanTimer_.start(); + sector_->clean(); + cleanTimer_.stop(); + + addStubTimer_.start(); + + vector layerstubs(N_LAYER + N_DISK, 0); + vector layerstubssector(N_SECTOR * (N_LAYER + N_DISK), 0); + + for (int j = 0; j < ev.nstubs(); j++) { + L1TStub stub = ev.stub(j); + unsigned int isector = stub.region(); + if (isector!=k) { + continue; + } + + string dtc = stub.DTClink(); + + layerstubs[stub.layerdisk()]++; + layerstubssector[isector * (N_LAYER + N_DISK) + stub.layerdisk()]++; + + sector_->addStub(stub, dtc); + } + + if (settings_->writeMonitorData("StubsLayerSector")) { + for (unsigned int index = 0; index < layerstubssector.size(); index++) { + int layerdisk = index % (N_LAYER + N_DISK); + int sector = index / (N_LAYER + N_DISK); + globals_->ofstream("stubslayersector.txt") << layerdisk << " " << sector << " " << layerstubssector[index] << endl; + } } - } - if (settings_->writeMonitorData("StubsLayer")) { - for (unsigned int layerdisk = 0; layerdisk < layerstubs.size(); layerdisk++) { - globals_->ofstream("stubslayer.txt") << layerdisk << " " << layerstubs[layerdisk] << endl; + if (settings_->writeMonitorData("StubsLayer")) { + for (unsigned int layerdisk = 0; layerdisk < layerstubs.size(); layerdisk++) { + globals_->ofstream("stubslayer.txt") << layerdisk << " " << layerstubs[layerdisk] << endl; + } } - } - addStubTimer_.stop(); + addStubTimer_.stop(); - // ---------------------------------------------------------------------------------------- - // Now start the tracklet processing + // ---------------------------------------------------------------------------------------- + // Now start the tracklet processing - // VM router - InputRouterTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeIR(); + // VM router + InputRouterTimer_.start(); + sector_->executeIR(); if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeDTCStubs(first); - sectors_[k]->writeIRStubs(first); + sector_->writeDTCStubs(first); + sector_->writeIRStubs(first); } - } - InputRouterTimer_.stop(); + InputRouterTimer_.stop(); - VMRouterTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeVMR(); + VMRouterTimer_.start(); + sector_->executeVMR(); if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeVMSTE(first); - sectors_[k]->writeVMSME(first); - sectors_[k]->writeAS(first); - sectors_[k]->writeAIS(first); + sector_->writeVMSTE(first); + sector_->writeVMSME(first); + sector_->writeAS(first); + sector_->writeAIS(first); } - } - VMRouterTimer_.stop(); - - // tracklet engine - TETimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeTE(); - } - TETimer_.stop(); - - // tracklet engine displaced - TEDTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeTED(); - } - TEDTimer_.stop(); - - // triplet engine - TRETimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeTRE(); + 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()) { - sectors_[k]->writeST(first); + sector_->writeST(first); } - } - TRETimer_.stop(); + TRETimer_.stop(); - // tracklet processor (alternative implementation to TE+TC) - TPTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeTP(); - } - TPTimer_.stop(); + // tracklet processor (alternative implementation to TE+TC) + TPTimer_.start(); + sector_->executeTP(); + TPTimer_.stop(); - for (unsigned int k = 0; k < N_SECTOR; k++) { if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeSP(first); + sector_->writeSP(first); } - } - - // tracklet calculator - TCTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeTC(); - } - TCTimer_.stop(); - - int nTP = globals_->event()->nsimtracks(); - for (int iTP = 0; iTP < nTP; iTP++) { - L1SimTrack simtrk = globals_->event()->simtrack(iTP); - if (simtrk.pt() < 2.0) - continue; - if (std::abs(simtrk.vz()) > 15.0) - continue; - if (hypot(simtrk.vx(), simtrk.vy()) > 0.1) - continue; - bool electron = (abs(simtrk.type()) == 11); - bool muon = (abs(simtrk.type()) == 13); - bool pion = (abs(simtrk.type()) == 211); - bool kaon = (abs(simtrk.type()) == 321); - bool proton = (abs(simtrk.type()) == 2212); - if (!(electron || muon || pion || kaon || proton)) - continue; - int nlayers = 0; - int ndisks = 0; - int simtrackid = simtrk.trackid(); - unsigned int hitmask = ev.layersHit(simtrackid, nlayers, ndisks); - if (nlayers + ndisks < 4) - continue; - - if (settings_->writeMonitorData("HitEff")) { - static ofstream outhit("hiteff.txt"); - outhit << simtrk.eta() << " " << (hitmask & 1) << " " << (hitmask & 2) << " " << (hitmask & 4) << " " - << (hitmask & 8) << " " << (hitmask & 16) << " " << (hitmask & 32) << " " << (hitmask & 64) << " " - << (hitmask & 128) << " " << (hitmask & 256) << " " << (hitmask & 512) << " " << (hitmask & 1024) << endl; - } - - std::unordered_set matchseed; - for (unsigned int k = 0; k < N_SECTOR; k++) { - std::unordered_set matchseedtmp = sectors_[k]->seedMatch(iTP); + + // tracklet calculator + TCTimer_.start(); + sector_->executeTC(); + TCTimer_.stop(); + + int nTP = globals_->event()->nsimtracks(); + for (int iTP = 0; iTP < nTP; iTP++) { + L1SimTrack simtrk = globals_->event()->simtrack(iTP); + if (simtrk.pt() < 2.0) + continue; + if (std::abs(simtrk.vz()) > 15.0) + continue; + if (hypot(simtrk.vx(), simtrk.vy()) > 0.1) + continue; + bool electron = (abs(simtrk.type()) == 11); + bool muon = (abs(simtrk.type()) == 13); + bool pion = (abs(simtrk.type()) == 211); + bool kaon = (abs(simtrk.type()) == 321); + bool proton = (abs(simtrk.type()) == 2212); + if (!(electron || muon || pion || kaon || proton)) + continue; + int nlayers = 0; + int ndisks = 0; + int simtrackid = simtrk.trackid(); + unsigned int hitmask = ev.layersHit(simtrackid, nlayers, ndisks); + if (nlayers + ndisks < 4) + continue; + + if (settings_->writeMonitorData("HitEff")) { + static ofstream outhit("hiteff.txt"); + outhit << simtrk.eta() << " " << (hitmask & 1) << " " << (hitmask & 2) << " " << (hitmask & 4) << " " + << (hitmask & 8) << " " << (hitmask & 16) << " " << (hitmask & 32) << " " << (hitmask & 64) << " " + << (hitmask & 128) << " " << (hitmask & 256) << " " << (hitmask & 512) << " " << (hitmask & 1024) << endl; + } + + std::unordered_set matchseed; + std::unordered_set matchseedtmp = sector_->seedMatch(iTP); matchseed.insert(matchseedtmp.begin(), matchseedtmp.end()); - } - if (settings_->bookHistos()) { - for (int iseed = 0; iseed < 8; iseed++) { - bool eff = matchseed.find(iseed) != matchseed.end(); - globals_->histograms()->fillSeedEff(iseed, simtrk.eta(), eff); + if (settings_->bookHistos()) { + for (int iseed = 0; iseed < 8; iseed++) { + bool eff = matchseed.find(iseed) != matchseed.end(); + globals_->histograms()->fillSeedEff(iseed, simtrk.eta(), eff); + } } } - } - // tracklet calculator displaced - TCDTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeTCD(); - } - TCDTimer_.stop(); + // tracklet calculator displaced + TCDTimer_.start(); + sector_->executeTCD(); + TCDTimer_.stop(); - for (unsigned int k = 0; k < N_SECTOR; k++) { if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeTPAR(first); - sectors_[k]->writeTPROJ(first); + sector_->writeTPAR(first); + sector_->writeTPROJ(first); } - } - // projection router - PRTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executePR(); + // projection router + PRTimer_.start(); + sector_->executePR(); if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeVMPROJ(first); - sectors_[k]->writeAP(first); + sector_->writeVMPROJ(first); + sector_->writeAP(first); } - } - PRTimer_.stop(); + PRTimer_.stop(); - // match engine - METimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeME(); + // match engine + METimer_.start(); + sector_->executeME(); if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeCM(first); + sector_->writeCM(first); } - } - METimer_.stop(); - - // match calculator - MCTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeMC(); - } - MCTimer_.stop(); + METimer_.stop(); + + // match calculator + MCTimer_.start(); + sector_->executeMC(); + MCTimer_.stop(); + + // match processor (alternative to ME+MC) + MPTimer_.start(); + sector_->executeMP(); + MPTimer_.stop(); - // match processor (alternative to ME+MC) - MPTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeMP(); - } - MPTimer_.stop(); - - for (unsigned int k = 0; k < N_SECTOR; k++) { if (settings_->writeMem() && k == settings_->writememsect()) { - sectors_[k]->writeMC(first); + sector_->writeMC(first); } - } - // fit track - FTTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executeFT(); + // fit track + FTTimer_.start(); + sector_->executeFT(); if ((settings_->writeMem() || settings_->writeMonitorData("IFit")) && k == settings_->writememsect()) { - sectors_[k]->writeTF(first); + sector_->writeTF(first); } - } - FTTimer_.stop(); + FTTimer_.stop(); - // purge duplicate - PDTimer_.start(); - for (unsigned int k = 0; k < N_SECTOR; k++) { - sectors_[k]->executePD(tracks_); + // purge duplicate + PDTimer_.start(); + sector_->executePD(tracks_); if (((settings_->writeMem() || settings_->writeMonitorData("IFit")) && k == settings_->writememsect()) || - settings_->writeMonitorData("CT")) { - sectors_[k]->writeCT(first); + settings_->writeMonitorData("CT")) { + sector_->writeCT(first); } + PDTimer_.stop(); } - PDTimer_.stop(); } void TrackletEventProcessor::printSummary() { - //if (settings_->writeMonitorData("Cabling")) { - // cabling_->writephirange(); - //} if (settings_->bookHistos()) { globals_->histograms()->close(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index ce8bdabd06920..bcafc0cfdad7c 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -182,10 +182,14 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input; } -void TrackletProcessor::execute() { - bool print = (iSector_ == 3) && (getName() == "TP_L1L2D"); +void TrackletProcessor::execute(unsigned int iSector, double phimin, double phimax) { + bool print = (iSector == 3) && (getName() == "TP_L1L2D"); print = false; + phimin_ = phimin; + phimax_ = phimax; + iSector_ = iSector; + if (!settings_.useSeed(iSeed_)) return; @@ -228,7 +232,7 @@ void TrackletProcessor::execute() { bool goodtedata___ = false; bool tebuffernearfull; - + for (unsigned int istep = 0; istep < settings_.maxStep("TP"); istep++) { if (print) { CircularBuffer& tedatabuffer = std::get<0>(tebuffer_); @@ -309,7 +313,7 @@ void TrackletProcessor::execute() { edm::LogVerbatim("Tracklet") << "TrackletProcessor execute done"; } } - + // // The second block fills the teunit if data in buffer and process TEUnit step // @@ -336,7 +340,7 @@ void TrackletProcessor::execute() { // The third block here checks if we have input stubs to process // // - + if (goodtedata___) tedatabuffer.store(tedata___); @@ -346,8 +350,6 @@ void TrackletProcessor::execute() { unsigned int& imem = std::get<2>(tebuffer_); unsigned int imemend = std::get<4>(tebuffer_); - //if (print) cout << "istep="<allStubIndex().value()<ofstream("trackletprocessor.txt") << getName() << " " << ninnerstubs //# inner stubs << " " << outervmstubs_->nVMStubs() //# outer stubs diff --git a/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc index a897a45d34287..e7298c9377abd 100644 --- a/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc @@ -233,7 +233,7 @@ void TripletEngine::execute() { edm::LogVerbatim("Tracklet") << "Adding layer-layer pair in " << getName(); if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; fout.close(); } stubtriplets_->addStubs(thirdvmstub.stub(), @@ -316,7 +316,7 @@ void TripletEngine::execute() { edm::LogVerbatim("Tracklet") << "Adding layer-disk pair in " << getName(); if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; fout.close(); } stubtriplets_->addStubs(thirdvmstub.stub(), @@ -400,7 +400,7 @@ void TripletEngine::execute() { edm::LogVerbatim("Tracklet") << "Adding layer-disk pair in " << getName(); if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << " " << iSeed_ << endl; fout.close(); } stubtriplets_->addStubs(thirdvmstub.stub(), @@ -463,7 +463,7 @@ void TripletEngine::writeTables() { ofstream fout; stringstream tableName; - tableName << "table/table_" << name_ << "_" << iSector_ << ".txt"; + tableName << "table/table_" << name_ << ".txt"; fout.open(tableName.str(), ofstream::out); for (const auto &entry : table_) @@ -472,7 +472,7 @@ void TripletEngine::writeTables() { for (const auto &tedName : spTable_) { tableName.str(""); - tableName << "table/table_" << tedName.first << "_" << name_ << "_" << iSector_ << ".txt"; + tableName << "table/table_" << tedName.first << "_" << name_ << ".txt"; fout.open(tableName.str(), ofstream::out); for (const auto &entry : tedName.second) { diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index 287f157e5a2a7..604e4fcc62691 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -214,7 +214,7 @@ int main(const int argc, const char **argv) { eventProcessor.event(ev); - std::vector &tracks = eventProcessor.tracks(); + const std::vector& tracks = eventProcessor.tracks(); // --------------------------------------------------------- // Block for producing ROOT-Tree @@ -256,18 +256,18 @@ int main(const int argc, const char **argv) { bool effloose = false; int itrackmatch = -1; for (unsigned int itrack = 0; itrack < tracks.size(); itrack++) { - const std::vector &stubs = tracks[itrack]->stubs(); + const std::vector &stubs = tracks[itrack].stubs(); if (seed == -1) { - if (tracks[itrack]->duplicate()) + if (tracks[itrack].duplicate()) continue; } else { - if (seed != tracks[itrack]->seed()) + if (seed != tracks[itrack].seed()) continue; } unsigned int nmatch = 0; for (auto stub : stubs) { - if (stub->tpmatch(simtrackid)) { + if (stub.tpmatch(simtrackid)) { nmatch++; } } @@ -293,14 +293,14 @@ int main(const int argc, const char **argv) { } if (itrackmatch >= 0) { - dpt = tracks[itrackmatch]->pt(settings) - q * simtrack.pt(); - dphi = tracks[itrackmatch]->phi0(settings) - simtrack.phi(); + dpt = tracks[itrackmatch].pt(settings) - q * simtrack.pt(); + dphi = tracks[itrackmatch].phi0(settings) - simtrack.phi(); if (dphi > M_PI) dphi -= 2 * M_PI; if (dphi < -M_PI) dphi += 2 * M_PI; - deta = tracks[itrackmatch]->eta(settings) - simtrack.eta(); - dz0 = tracks[itrackmatch]->z0(settings) - simtrack.vz(); + deta = tracks[itrackmatch].eta(settings) - simtrack.eta(); + dz0 = tracks[itrackmatch].z0(settings) - simtrack.vz(); } out << eventnum << " " << simeventid << " " << seed << " " << simtrackid << " " << simtrack.type() << " " @@ -312,18 +312,20 @@ int main(const int argc, const char **argv) { } int ntrack = 0; + int i = 0; for (auto &track : tracks) { + i++; if (settings.writeMonitorData("Pars")) { - outpars << track->duplicate() << " " << track->eta(settings) << " " << track->phi0(settings) << " " - << track->z0(settings) << " " << angle0to2pi::make0To2pi(track->phi0(settings)) / (2 * M_PI / N_SECTOR) - << " " << track->rinv(settings); + outpars << track.duplicate() << " " << track.eta(settings) << " " << track.phi0(settings) << " " + << track.z0(settings) << " " << angle0to2pi::make0To2pi(track.phi0(settings)) / (2 * M_PI / N_SECTOR) + << " " << track.rinv(settings); } - if (!track->duplicate()) { + if (!track.duplicate()) { ntrack++; } } - edm::LogVerbatim("Tracklet") << "Number of found tracks : " << tracks.size() << " unique " << ntrack; + edm::LogVerbatim("Tracklet") << "Number of found tracks : " << tracks.size() << " unique " << ntrack << " "; } eventProcessor.printSummary(); From f4109cc6e5cf41b431b1031769eddc2bd6634b52 Mon Sep 17 00:00:00 2001 From: Anders Date: Mon, 15 Mar 2021 17:21:37 +0100 Subject: [PATCH 25/45] Interface updates for CMSSW following change to module processing order --- .../TrackFindingTracklet/interface/FitTrack.h | 4 ++- .../plugins/L1FPGATrackProducer.cc | 28 +++++++++---------- .../TrackFindingTracklet/src/FitTrack.cc | 4 ++- .../src/PurgeDuplicate.cc | 2 +- L1Trigger/TrackFindingTracklet/src/Sector.cc | 2 +- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h index fb897ec1660bd..c9e71fa787893 100644 --- a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h +++ b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h @@ -38,7 +38,7 @@ namespace trklet { std::vector orderedMatches(std::vector& fullmatch); - void execute(); + void execute(unsigned int iSector); private: std::vector seedtracklet_; @@ -47,6 +47,8 @@ namespace trklet { std::vector fullmatch3_; std::vector fullmatch4_; + unsigned int iSector_; + TrackFitMemory* trackfit_; }; diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 1161be2d4fad6..de8c50a9dc106 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -569,7 +569,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe ev.write(asciiEventOut_); } - std::vector& tracks = eventProcessor.tracks(); + const std::vector& tracks = eventProcessor.tracks(); // this performs the actual tracklet event processing eventProcessor.event(ev); @@ -577,20 +577,20 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe int ntracks = 0; for (auto track : tracks) { - if (track->duplicate()) + if (track.duplicate()) continue; ntracks++; // this is where we create the TTTrack object - double tmp_rinv = track->rinv(settings); - double tmp_phi = track->phi0(settings); - double tmp_tanL = track->tanL(settings); - double tmp_z0 = track->z0(settings); - double tmp_d0 = track->d0(settings); - double tmp_chi2rphi = track->chisqrphi(); - double tmp_chi2rz = track->chisqrz(); - unsigned int tmp_hit = track->hitpattern(); + double tmp_rinv = track.rinv(settings); + double tmp_phi = track.phi0(settings); + double tmp_tanL = track.tanL(settings); + double tmp_z0 = track.z0(settings); + double tmp_d0 = track.d0(settings); + double tmp_chi2rphi = track.chisqrphi(); + double tmp_chi2rz = track.chisqrz(); + unsigned int tmp_hit = track.hitpattern(); TTTrack aTrack(tmp_rinv, tmp_phi, @@ -606,18 +606,18 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe settings.nHelixPar(), settings.bfield()); - unsigned int trksector = track->sector(); - unsigned int trkseed = (unsigned int)abs(track->seed()); + unsigned int trksector = track.sector(); + unsigned int trkseed = (unsigned int)abs(track.seed()); aTrack.setPhiSector(trksector); aTrack.setTrackSeedType(trkseed); - const vector& stubptrs = track->stubs(); + const vector& stubptrs = track.stubs(); vector stubs; stubs.reserve(stubptrs.size()); for (auto stubptr : stubptrs) { - stubs.push_back(*stubptr); + stubs.push_back(stubptr); } stubMapType::const_iterator it; diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 71ba31bd39ba9..80949fb18a9f4 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -867,13 +867,15 @@ std::vector FitTrack::orderedMatches(vector& fullma return tmp; } -void FitTrack::execute() { +void FitTrack::execute(unsigned int iSector) { // merge const std::vector& matches1 = orderedMatches(fullmatch1_); const std::vector& matches2 = orderedMatches(fullmatch2_); const std::vector& matches3 = orderedMatches(fullmatch3_); const std::vector& matches4 = orderedMatches(fullmatch4_); + iSector_ = iSector; + if (settings_.debugTracklet() && (matches1.size() + matches2.size() + matches3.size() + matches4.size()) > 0) { for (auto& imatch : fullmatch1_) { edm::LogVerbatim("Tracklet") << imatch->getName() << " " << imatch->nMatches(); diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index bc41d0ee10ac3..1c6750c665890 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -342,7 +342,7 @@ void PurgeDuplicate::execute(std::vector& outputtracks_, unsigned int iSe // Add all tracks to standalone root file output outtrack->setStubIDpremerge(inputstubidslists_[itrk]); outtrack->setStubIDprefit(mergedstubidslists_[itrk]); - outputtracks_.push_back(outtrack); + outputtracks_.push_back(*outtrack); } } } diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 9bd12412c3518..74ae87cc6c83e 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -419,7 +419,7 @@ void Sector::executeMP() { void Sector::executeFT() { for (auto& i : FT_) { - i->execute(); + i->execute(isector_); } } From bd26658f9b5024b14d74beb0523cabeefb70682e Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Mon, 15 Mar 2021 12:59:11 -0400 Subject: [PATCH 26/45] Change in VMRouter to processing PS links before 2S in disks --- L1Trigger/TrackFindingTracklet/interface/VMRouter.h | 4 ++-- L1Trigger/TrackFindingTracklet/src/VMRouter.cc | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/VMRouter.h b/L1Trigger/TrackFindingTracklet/interface/VMRouter.h index 5e93482182cfe..b540a3b6e3383 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMRouter.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMRouter.h @@ -57,8 +57,8 @@ namespace trklet { VMRouterTable vmrtable_; - //The input stub memories - std::vector stubinputs_; + //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_; diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc index 55817f28f5924..c37c013f78f26 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc @@ -136,7 +136,17 @@ void VMRouter::addInput(MemoryBase* memory, string input) { InputLinkMemory* tmp1 = dynamic_cast(memory); assert(tmp1 != nullptr); if (tmp1 != nullptr) { - stubinputs_.push_back(tmp1); + 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; } From d4d39b75c771de9a633acddbcd40e496dc5ee7f5 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Mon, 15 Mar 2021 17:25:49 -0400 Subject: [PATCH 27/45] Cleanup of unused iSector variable in processs and memory modules --- .../interface/AllInnerStubsMemory.h | 4 +- .../interface/AllProjectionsMemory.h | 4 +- .../interface/AllStubsMemory.h | 4 +- .../interface/CandidateMatchMemory.h | 4 +- .../interface/CleanTrackMemory.h | 4 +- .../interface/DTCLinkMemory.h | 4 +- .../TrackFindingTracklet/interface/FitTrack.h | 2 +- .../interface/FullMatchMemory.h | 4 +- .../interface/InputLinkMemory.h | 4 +- .../interface/InputRouter.h | 2 +- .../interface/MatchCalculator.h | 2 +- .../interface/MatchEngine.h | 2 +- .../interface/MatchProcessor.h | 2 +- .../interface/MemoryBase.h | 2 +- .../interface/ProcessBase.h | 2 +- .../interface/ProjectionRouter.h | 2 +- .../interface/PurgeDuplicate.h | 2 +- .../interface/StubPairsMemory.h | 4 +- .../interface/StubTripletsMemory.h | 4 +- .../interface/TrackFitMemory.h | 4 +- .../interface/TrackletCalculator.h | 2 +- .../interface/TrackletCalculatorBase.h | 2 +- .../interface/TrackletCalculatorDisplaced.h | 2 +- .../interface/TrackletEngine.h | 2 +- .../interface/TrackletEngineDisplaced.h | 2 +- .../interface/TrackletParametersMemory.h | 4 +- .../interface/TrackletProcessor.h | 2 +- .../interface/TrackletProjectionsMemory.h | 4 +- .../interface/TripletEngine.h | 2 +- .../interface/VMProjectionsMemory.h | 4 +- .../TrackFindingTracklet/interface/VMRouter.h | 2 +- .../interface/VMRouterCM.h | 2 +- .../interface/VMStubsMEMemory.h | 4 +- .../interface/VMStubsTEMemory.h | 4 +- .../src/AllInnerStubsMemory.cc | 8 +- .../src/AllProjectionsMemory.cc | 8 +- .../src/AllStubsMemory.cc | 7 +- .../src/CandidateMatchMemory.cc | 8 +- .../src/CleanTrackMemory.cc | 8 +- .../TrackFindingTracklet/src/DTCLinkMemory.cc | 7 +- .../TrackFindingTracklet/src/FitTrack.cc | 4 +- .../src/FullMatchMemory.cc | 8 +- .../src/InputLinkMemory.cc | 8 +- .../TrackFindingTracklet/src/InputRouter.cc | 4 +- .../src/MatchCalculator.cc | 4 +- .../TrackFindingTracklet/src/MatchEngine.cc | 4 +- .../src/MatchProcessor.cc | 4 +- .../TrackFindingTracklet/src/MemoryBase.cc | 4 +- .../TrackFindingTracklet/src/ProcessBase.cc | 2 +- .../src/ProjectionRouter.cc | 4 +- .../src/PurgeDuplicate.cc | 4 +- L1Trigger/TrackFindingTracklet/src/Sector.cc | 94 +++++++++---------- .../src/StubPairsMemory.cc | 8 +- .../src/StubTripletsMemory.cc | 8 +- .../src/TrackFitMemory.cc | 8 +- .../src/TrackletCalculator.cc | 4 +- .../src/TrackletCalculatorBase.cc | 5 +- .../src/TrackletCalculatorDisplaced.cc | 5 +- .../src/TrackletEngine.cc | 4 +- .../src/TrackletEngineDisplaced.cc | 5 +- .../src/TrackletEventProcessor.cc | 44 +++++---- .../src/TrackletParametersMemory.cc | 8 +- .../src/TrackletProcessor.cc | 4 +- .../src/TrackletProjectionsMemory.cc | 8 +- .../TrackFindingTracklet/src/TripletEngine.cc | 4 +- .../src/VMProjectionsMemory.cc | 8 +- .../TrackFindingTracklet/src/VMRouter.cc | 4 +- .../TrackFindingTracklet/src/VMRouterCM.cc | 4 +- .../src/VMStubsMEMemory.cc | 8 +- .../src/VMStubsTEMemory.cc | 10 +- 70 files changed, 235 insertions(+), 204 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h b/L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h index 376baf12cd4f8..50048e22a96ee 100644 --- a/L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/AllInnerStubsMemory.h @@ -15,7 +15,7 @@ namespace trklet { class AllInnerStubsMemory : public MemoryBase { public: - AllInnerStubsMemory(std::string name, Settings const& settings, unsigned int iSector); + AllInnerStubsMemory(std::string name, Settings const& settings); ~AllInnerStubsMemory() override = default; @@ -27,7 +27,7 @@ namespace trklet { void clean() override { stubs_.clear(); } - void writeStubs(bool first); + void writeStubs(bool first, unsigned int iSector); private: std::vector stubs_; diff --git a/L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h b/L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h index f6367108d9ca4..7f84afe390301 100644 --- a/L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/AllProjectionsMemory.h @@ -13,7 +13,7 @@ namespace trklet { class AllProjectionsMemory : public MemoryBase { public: - AllProjectionsMemory(std::string name, Settings const& settings, unsigned int iSector); + AllProjectionsMemory(std::string name, Settings const& settings); ~AllProjectionsMemory() override = default; @@ -25,7 +25,7 @@ namespace trklet { void clean() override { tracklets_.clear(); } - void writeAP(bool first); + void writeAP(bool first, unsigned int iSector); private: std::vector tracklets_; diff --git a/L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h b/L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h index c34601997b069..71254d512e3ac 100644 --- a/L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/AllStubsMemory.h @@ -15,7 +15,7 @@ namespace trklet { class AllStubsMemory : public MemoryBase { public: - AllStubsMemory(std::string name, Settings const& settings, unsigned int iSector); + AllStubsMemory(std::string name, Settings const& settings); ~AllStubsMemory() override = default; @@ -27,7 +27,7 @@ namespace trklet { void clean() override { stubs_.clear(); } - void writeStubs(bool first); + void writeStubs(bool first, unsigned int iSector); private: std::vector stubs_; diff --git a/L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h b/L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h index 96358051401c6..8a20813e378d4 100644 --- a/L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h @@ -16,7 +16,7 @@ namespace trklet { class CandidateMatchMemory : public MemoryBase { public: - CandidateMatchMemory(std::string name, Settings const& settings, unsigned int iSector); + CandidateMatchMemory(std::string name, Settings const& settings); ~CandidateMatchMemory() override = default; @@ -28,7 +28,7 @@ namespace trklet { void clean() override { matches_.clear(); } - void writeCM(bool first); + void writeCM(bool first, unsigned int iSector); private: std::vector, const Stub*> > matches_; diff --git a/L1Trigger/TrackFindingTracklet/interface/CleanTrackMemory.h b/L1Trigger/TrackFindingTracklet/interface/CleanTrackMemory.h index 41e64bd302f12..d17754d944f4b 100644 --- a/L1Trigger/TrackFindingTracklet/interface/CleanTrackMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/CleanTrackMemory.h @@ -12,7 +12,7 @@ namespace trklet { class CleanTrackMemory : public MemoryBase { public: - CleanTrackMemory(std::string name, Settings const& settings, unsigned int iSector, double phimin, double phimax); + CleanTrackMemory(std::string name, Settings const& settings, double phimin, double phimax); ~CleanTrackMemory() override = default; @@ -22,7 +22,7 @@ namespace trklet { void clean() override { tracks_.clear(); } - void writeCT(bool first); + void writeCT(bool first, unsigned int iSector); private: double phimin_; diff --git a/L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h b/L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h index 6179367a891be..daab972a6ff0d 100644 --- a/L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h @@ -16,7 +16,7 @@ namespace trklet { class DTCLinkMemory : public MemoryBase { public: - DTCLinkMemory(std::string name, Settings const& settings, unsigned int iSector, double, double); + DTCLinkMemory(std::string name, Settings const& settings, double, double); ~DTCLinkMemory() override = default; @@ -26,7 +26,7 @@ namespace trklet { Stub* getStub(unsigned int i) { return stubs_[i]; } - void writeStubs(bool first); + void writeStubs(bool first, unsigned int iSector); void clean() override; diff --git a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h index c9e71fa787893..e72c4cf664132 100644 --- a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h +++ b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h @@ -17,7 +17,7 @@ namespace trklet { class FitTrack : public ProcessBase { public: - FitTrack(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + FitTrack(std::string name, Settings const& settings, Globals* global); ~FitTrack() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/FullMatchMemory.h b/L1Trigger/TrackFindingTracklet/interface/FullMatchMemory.h index 10215946939c5..49f60cad58cf3 100644 --- a/L1Trigger/TrackFindingTracklet/interface/FullMatchMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/FullMatchMemory.h @@ -16,7 +16,7 @@ namespace trklet { class FullMatchMemory : public MemoryBase { public: - FullMatchMemory(std::string name, Settings const& settings, unsigned int iSector); + FullMatchMemory(std::string name, Settings const& settings); ~FullMatchMemory() override = default; @@ -30,7 +30,7 @@ namespace trklet { void clean() override { matches_.clear(); } - void writeMC(bool first); + void writeMC(bool first, unsigned int iSector); int layer() const { return layer_; } int disk() const { return disk_; } diff --git a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h index 547bc6f4e00db..82a04a6f41bd1 100644 --- a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h @@ -17,7 +17,7 @@ namespace trklet { class InputLinkMemory : public MemoryBase { public: - InputLinkMemory(std::string name, Settings const& settings, unsigned int iSector, double, double); + InputLinkMemory(std::string name, Settings const& settings, double, double); ~InputLinkMemory() override = default; @@ -27,7 +27,7 @@ namespace trklet { Stub* getStub(unsigned int i) { return stubs_[i]; } - void writeStubs(bool first); + void writeStubs(bool first, unsigned int iSector); void clean() override; diff --git a/L1Trigger/TrackFindingTracklet/interface/InputRouter.h b/L1Trigger/TrackFindingTracklet/interface/InputRouter.h index 32b1ff45112d3..c4a0533625c78 100644 --- a/L1Trigger/TrackFindingTracklet/interface/InputRouter.h +++ b/L1Trigger/TrackFindingTracklet/interface/InputRouter.h @@ -19,7 +19,7 @@ namespace trklet { class InputRouter : public ProcessBase { public: - InputRouter(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + InputRouter(std::string name, Settings const& settings, Globals* global); ~InputRouter() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h b/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h index 455aa9ca42d2c..2a4051e98cb55 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h @@ -20,7 +20,7 @@ namespace trklet { class MatchCalculator : public ProcessBase { public: - MatchCalculator(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + MatchCalculator(std::string name, Settings const& settings, Globals* global); ~MatchCalculator() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h index 84f3ab53fad15..db0ba984a85a5 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngine.h @@ -15,7 +15,7 @@ namespace trklet { class MatchEngine : public ProcessBase { public: - MatchEngine(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + MatchEngine(std::string name, Settings const& settings, Globals* global); ~MatchEngine() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index e0c4317fd53c5..3b1a936ba7984 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -23,7 +23,7 @@ namespace trklet { class MatchProcessor : public ProcessBase { public: - MatchProcessor(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + MatchProcessor(std::string name, Settings const& settings, Globals* global); ~MatchProcessor() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h b/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h index 2c92d3606d5c7..ca0280bff8911 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h +++ b/L1Trigger/TrackFindingTracklet/interface/MemoryBase.h @@ -12,7 +12,7 @@ namespace trklet { class MemoryBase { public: - MemoryBase(std::string name, Settings const& settings, unsigned int iSector); + MemoryBase(std::string name, Settings const& settings); virtual ~MemoryBase() = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h b/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h index 2391887581903..35fe4015c5e92 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProcessBase.h @@ -11,7 +11,7 @@ namespace trklet { class ProcessBase { public: - ProcessBase(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + ProcessBase(std::string name, Settings const& settings, Globals* global); virtual ~ProcessBase() = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h b/L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h index 2559a22a96fbf..7b898f1b2e7a4 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProjectionRouter.h @@ -15,7 +15,7 @@ namespace trklet { class ProjectionRouter : public ProcessBase { public: - ProjectionRouter(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + ProjectionRouter(std::string name, Settings const& settings, Globals* global); ~ProjectionRouter() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h index a643097262b8d..6600a3de15d98 100644 --- a/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h +++ b/L1Trigger/TrackFindingTracklet/interface/PurgeDuplicate.h @@ -19,7 +19,7 @@ namespace trklet { class PurgeDuplicate : public ProcessBase { public: - PurgeDuplicate(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + PurgeDuplicate(std::string name, Settings const& settings, Globals* global); ~PurgeDuplicate() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h b/L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h index cc219691a61ff..9f87f84ee490f 100644 --- a/L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/StubPairsMemory.h @@ -12,7 +12,7 @@ namespace trklet { class StubPairsMemory : public MemoryBase { public: - StubPairsMemory(std::string name, Settings const& settings, unsigned int iSector); + StubPairsMemory(std::string name, Settings const& settings); ~StubPairsMemory() override = default; @@ -39,7 +39,7 @@ namespace trklet { tedNames_.clear(); } - void writeSP(bool first); + void writeSP(bool first, unsigned int iSector); private: std::vector > stubs_; diff --git a/L1Trigger/TrackFindingTracklet/interface/StubTripletsMemory.h b/L1Trigger/TrackFindingTracklet/interface/StubTripletsMemory.h index ecb2163251a38..00e94404feadd 100644 --- a/L1Trigger/TrackFindingTracklet/interface/StubTripletsMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/StubTripletsMemory.h @@ -13,7 +13,7 @@ namespace trklet { class StubTripletsMemory : public MemoryBase { public: - StubTripletsMemory(std::string name, Settings const& settings, unsigned int iSector); + StubTripletsMemory(std::string name, Settings const& settings); ~StubTripletsMemory() override = default; @@ -35,7 +35,7 @@ namespace trklet { stubs3_.clear(); } - void writeST(bool first); + void writeST(bool first, unsigned int iSector); private: std::vector stubs1_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h b/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h index 6775080971f1a..f8c9335abd8fa 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackFitMemory.h @@ -14,7 +14,7 @@ namespace trklet { class TrackFitMemory : public MemoryBase { public: - TrackFitMemory(std::string name, Settings const& settings, unsigned int iSector, double phimin, double phimax); + TrackFitMemory(std::string name, Settings const& settings, double phimin, double phimax); ~TrackFitMemory() override = default; @@ -36,7 +36,7 @@ namespace trklet { stubidslists_.clear(); } - void writeTF(bool first); + void writeTF(bool first, unsigned int iSector); private: double phimin_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h index 327d5ad8cd2b5..a271bab238d69 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculator.h @@ -19,7 +19,7 @@ namespace trklet { class TrackletCalculator : public TrackletCalculatorBase { public: - TrackletCalculator(std::string name, Settings const& settings, Globals* globals, unsigned int iSector); + TrackletCalculator(std::string name, Settings const& settings, Globals* globals); ~TrackletCalculator() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h index b05c3e435c003..4638b07f5e5a9 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorBase.h @@ -17,7 +17,7 @@ namespace trklet { class TrackletCalculatorBase : public ProcessBase { public: - TrackletCalculatorBase(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + TrackletCalculatorBase(std::string name, Settings const& settings, Globals* global); ~TrackletCalculatorBase() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h index bf33ee9e428d2..90380054ab669 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h @@ -19,7 +19,7 @@ namespace trklet { class TrackletCalculatorDisplaced : public ProcessBase { public: - TrackletCalculatorDisplaced(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + TrackletCalculatorDisplaced(std::string name, Settings const& settings, Globals* global); ~TrackletCalculatorDisplaced() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h index a6fd3f9492fe2..e827185374716 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEngine.h @@ -16,7 +16,7 @@ namespace trklet { class TrackletEngine : public ProcessBase { public: - TrackletEngine(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + TrackletEngine(std::string name, Settings const& settings, Globals* global); ~TrackletEngine() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h index e4a27da470378..91ea9e6ad4ee8 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEngineDisplaced.h @@ -19,7 +19,7 @@ namespace trklet { class TrackletEngineDisplaced : public ProcessBase { public: - TrackletEngineDisplaced(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + TrackletEngineDisplaced(std::string name, Settings const& settings, Globals* global); ~TrackletEngineDisplaced() override; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h b/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h index 38c1b98b1c16c..7a81bececba65 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletParametersMemory.h @@ -16,7 +16,7 @@ namespace trklet { class TrackletParametersMemory : public MemoryBase { public: - TrackletParametersMemory(std::string name, Settings const &settings, unsigned int iSector); + TrackletParametersMemory(std::string name, Settings const &settings); ~TrackletParametersMemory() override = default; @@ -28,7 +28,7 @@ namespace trklet { void clean() override; - void writeTPAR(bool first); + void writeTPAR(bool first, unsigned int iSector); private: std::vector tracklets_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h index 645174f151ae2..46d03f6d72639 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h @@ -23,7 +23,7 @@ namespace trklet { class TrackletProcessor : public TrackletCalculatorBase { public: - TrackletProcessor(std::string name, Settings const& settings, Globals* globals, unsigned int iSector); + TrackletProcessor(std::string name, Settings const& settings, Globals* globals); ~TrackletProcessor() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h b/L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h index 3d376d3b98dcc..4a936c7c4f950 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h @@ -14,7 +14,7 @@ namespace trklet { class TrackletProjectionsMemory : public MemoryBase { public: - TrackletProjectionsMemory(std::string name, Settings const& settings, unsigned int iSector); + TrackletProjectionsMemory(std::string name, Settings const& settings); ~TrackletProjectionsMemory() override = default; @@ -26,7 +26,7 @@ namespace trklet { void clean() override; - void writeTPROJ(bool first); + void writeTPROJ(bool first, unsigned int iSector); int layer() const { return layer_; } int disk() const { return disk_; } diff --git a/L1Trigger/TrackFindingTracklet/interface/TripletEngine.h b/L1Trigger/TrackFindingTracklet/interface/TripletEngine.h index 1652262c1808a..ad5840af13a0e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TripletEngine.h +++ b/L1Trigger/TrackFindingTracklet/interface/TripletEngine.h @@ -17,7 +17,7 @@ namespace trklet { class TripletEngine : public ProcessBase { public: - TripletEngine(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + TripletEngine(std::string name, Settings const& settings, Globals* global); ~TripletEngine() override; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h b/L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h index 1b3e37aba7184..47f15743dc6c8 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMProjectionsMemory.h @@ -13,7 +13,7 @@ namespace trklet { class VMProjectionsMemory : public MemoryBase { public: - VMProjectionsMemory(std::string name, Settings const& settings, unsigned int iSector); + VMProjectionsMemory(std::string name, Settings const& settings); ~VMProjectionsMemory() override = default; @@ -24,7 +24,7 @@ namespace trklet { Tracklet* getTracklet(unsigned int i) { return tracklets_[i].first; } int getAllProjIndex(unsigned int i) const { return tracklets_[i].second; } - void writeVMPROJ(bool first); + void writeVMPROJ(bool first, unsigned int iSector); void clean() override { tracklets_.clear(); } diff --git a/L1Trigger/TrackFindingTracklet/interface/VMRouter.h b/L1Trigger/TrackFindingTracklet/interface/VMRouter.h index b540a3b6e3383..52811501ac88e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMRouter.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMRouter.h @@ -34,7 +34,7 @@ namespace trklet { class VMRouter : public ProcessBase { public: - VMRouter(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + VMRouter(std::string name, Settings const& settings, Globals* global); ~VMRouter() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h b/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h index f1b15c44c9a97..3322ea12019aa 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMRouterCM.h @@ -31,7 +31,7 @@ namespace trklet { class VMRouterCM : public ProcessBase { public: - VMRouterCM(std::string name, Settings const& settings, Globals* global, unsigned int iSector); + VMRouterCM(std::string name, Settings const& settings, Globals* global); ~VMRouterCM() override = default; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h b/L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h index 8c231f2909352..ee85a668da883 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h @@ -15,7 +15,7 @@ namespace trklet { class VMStubsMEMemory : public MemoryBase { public: - VMStubsMEMemory(std::string name, Settings const& settings, unsigned int iSector); + VMStubsMEMemory(std::string name, Settings const& settings); ~VMStubsMEMemory() override = default; @@ -50,7 +50,7 @@ namespace trklet { } } - void writeStubs(bool first); + void writeStubs(bool first, unsigned int iSector); private: std::vector > binnedstubs_; diff --git a/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h b/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h index 6f974bc86bd75..e77d22ba3cb02 100644 --- a/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/VMStubsTEMemory.h @@ -15,7 +15,7 @@ namespace trklet { class VMStubsTEMemory : public MemoryBase { public: - VMStubsTEMemory(std::string name, Settings const& settings, unsigned int iSector); + VMStubsTEMemory(std::string name, Settings const& settings); ~VMStubsTEMemory() override = default; @@ -37,7 +37,7 @@ namespace trklet { void clean() override; - void writeStubs(bool first); + void writeStubs(bool first, unsigned int iSector); int phibin() const { return phibin_; } diff --git a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc index f5724e72fb735..4b3b6ddc28c8b 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc @@ -6,10 +6,12 @@ using namespace std; using namespace trklet; -AllInnerStubsMemory::AllInnerStubsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} +AllInnerStubsMemory::AllInnerStubsMemory(string name, Settings const& settings) + : MemoryBase(name, settings) {} -void AllInnerStubsMemory::writeStubs(bool first) { +void AllInnerStubsMemory::writeStubs(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirS = settings_.memPath() + "Stubs/"; openFile(first, dirS, "AllInnerStubs_"); diff --git a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc index ff558f542fd00..9c1232028dbe9 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc @@ -10,12 +10,14 @@ using namespace trklet; using namespace std; -AllProjectionsMemory::AllProjectionsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) { +AllProjectionsMemory::AllProjectionsMemory(string name, Settings const& settings) + : MemoryBase(name, settings) { initLayerDisk(3, layer_, disk_); } -void AllProjectionsMemory::writeAP(bool first) { +void AllProjectionsMemory::writeAP(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirTP = settings_.memPath() + "TrackletProjections/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc index 315b7f668fbc9..ecf249f61e585 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc @@ -6,10 +6,11 @@ using namespace std; using namespace trklet; -AllStubsMemory::AllStubsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} +AllStubsMemory::AllStubsMemory(string name, Settings const& settings) + : MemoryBase(name, settings) {} -void AllStubsMemory::writeStubs(bool first) { +void AllStubsMemory::writeStubs(bool first, unsigned int iSector) { + iSector_ = iSector; const string dirS = settings_.memPath() + "Stubs/"; openFile(first, dirS, "AllStubs_"); diff --git a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc index 13454266e6f18..122d143c930ad 100644 --- a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc @@ -11,8 +11,8 @@ using namespace std; using namespace trklet; -CandidateMatchMemory::CandidateMatchMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} +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); @@ -28,7 +28,9 @@ void CandidateMatchMemory::addMatch(std::pair tracklet, const St matches_.push_back(tmp); } -void CandidateMatchMemory::writeCM(bool first) { +void CandidateMatchMemory::writeCM(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirM = settings_.memPath() + "Matches/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc index b23fc8246f440..93fcfe6879176 100644 --- a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc @@ -8,13 +8,15 @@ using namespace std; using namespace trklet; CleanTrackMemory::CleanTrackMemory( - string name, Settings const& settings, unsigned int iSector, double phimin, double phimax) - : MemoryBase(name, settings, iSector) { + string name, Settings const& settings, double phimin, double phimax) + : MemoryBase(name, settings) { phimin_ = phimin; phimax_ = phimax; } -void CleanTrackMemory::writeCT(bool first) { +void CleanTrackMemory::writeCT(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirCT = settings_.memPath() + "CleanTrack/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc index 63d6fe2a70373..7e4b516baea37 100644 --- a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc @@ -14,8 +14,8 @@ using namespace trklet; using namespace std; -DTCLinkMemory::DTCLinkMemory(string name, Settings const& settings, unsigned int iSector, double, double) - : MemoryBase(name, settings, iSector) { +DTCLinkMemory::DTCLinkMemory(string name, Settings const& settings, double, double) + : MemoryBase(name, settings) { } void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { @@ -29,8 +29,9 @@ void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { } } -void DTCLinkMemory::writeStubs(bool first) { +void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { + iSector_ = iSector; //FIXME should be in settings static map > dtclayers{{"PS10G_1", {0, 6, 8, 10}}, {"PS10G_2", {0, 7, 9}}, diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 80949fb18a9f4..d93bfca5632ae 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -11,8 +11,8 @@ using namespace std; using namespace trklet; -FitTrack::FitTrack(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector), trackfit_(nullptr) {} +FitTrack::FitTrack(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global), trackfit_(nullptr) {} void FitTrack::addOutput(MemoryBase* memory, string output) { if (settings_.writetrace()) { diff --git a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc index 68cdd5a6a7473..9c69056e2b9bb 100644 --- a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc @@ -9,8 +9,8 @@ using namespace std; using namespace trklet; -FullMatchMemory::FullMatchMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) { +FullMatchMemory::FullMatchMemory(string name, Settings const& settings) + : MemoryBase(name, settings) { size_t pos = find_nth(name, 0, "_", 1); assert(pos != string::npos); initLayerDisk(pos + 1, layer_, disk_); @@ -39,7 +39,9 @@ void FullMatchMemory::addMatch(Tracklet* tracklet, const Stub* stub) { matches_.push_back(tmp); } -void FullMatchMemory::writeMC(bool first) { +void FullMatchMemory::writeMC(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirM = settings_.memPath() + "Matches/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc index 7b5c49e6244b7..9d4c5a75fcc79 100644 --- a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc @@ -14,14 +14,16 @@ using namespace trklet; using namespace std; -InputLinkMemory::InputLinkMemory(string name, Settings const& settings, unsigned int iSector, double, double) - : MemoryBase(name, settings, iSector) {} +InputLinkMemory::InputLinkMemory(string name, Settings const& settings, double, double) + : MemoryBase(name, settings) {} void InputLinkMemory::addStub(Stub* stub) { stubs_.push_back(stub); } -void InputLinkMemory::writeStubs(bool first) { +void InputLinkMemory::writeStubs(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirIS = settings_.memPath() + "InputStubs/"; openFile(first, dirIS, "InputStubs_"); diff --git a/L1Trigger/TrackFindingTracklet/src/InputRouter.cc b/L1Trigger/TrackFindingTracklet/src/InputRouter.cc index cdd10c76c1ad9..b527e786960e6 100644 --- a/L1Trigger/TrackFindingTracklet/src/InputRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/InputRouter.cc @@ -12,8 +12,8 @@ using namespace std; using namespace trklet; -InputRouter::InputRouter(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { +InputRouter::InputRouter(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global) { } void InputRouter::addOutput(MemoryBase* memory, string output) { diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index b61b64ea8a358..bfb429c648bee 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -18,8 +18,8 @@ using namespace std; using namespace trklet; -MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { +MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global) { phiregion_ = name[8] - 'A'; layerdisk_ = initLayerDisk(3); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index 881ed4d3da6f0..fd58524e18fcf 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -15,8 +15,8 @@ using namespace std; using namespace trklet; -MatchEngine::MatchEngine(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { +MatchEngine::MatchEngine(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global) { layerdisk_ = initLayerDisk(3); barrel_ = layerdisk_ < N_LAYER; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 7c74418143733..3bdd07194556b 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -13,8 +13,8 @@ using namespace std; using namespace trklet; -MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector), fullmatches_(12), inputProjBuffer_(3) { +MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global), fullmatches_(12), inputProjBuffer_(3) { phiregion_ = name[8] - 'A'; layerdisk_ = initLayerDisk(3); diff --git a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc index 8b00125715769..580dae3a8df7f 100644 --- a/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/MemoryBase.cc @@ -10,8 +10,8 @@ using namespace trklet; using namespace std; -MemoryBase::MemoryBase(string name, Settings const& settings, unsigned int iSector) : name_(name), settings_(settings) { - iSector_ = iSector; +MemoryBase::MemoryBase(string name, Settings const& settings) : name_(name), settings_(settings) { + iSector_ = 0; bx_ = 0; event_ = 0; } diff --git a/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc b/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc index 1cfada1140ac7..20fb0b1082ce9 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProcessBase.cc @@ -11,7 +11,7 @@ using namespace trklet; using namespace std; -ProcessBase::ProcessBase(string name, Settings const& settings, Globals* global, unsigned int iSector) +ProcessBase::ProcessBase(string name, Settings const& settings, Globals* global) : name_(name), settings_(settings), globals_(global) {} unsigned int ProcessBase::nbits(unsigned int power) { diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc index 6c991a8fc23be..6bb3b84c113b0 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc @@ -10,8 +10,8 @@ using namespace std; using namespace trklet; -ProjectionRouter::ProjectionRouter(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { +ProjectionRouter::ProjectionRouter(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global) { layerdisk_ = initLayerDisk(3); vmprojs_.resize(settings_.nvmme(layerdisk_), nullptr); diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 1c6750c665890..86f4bb81ef530 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -22,8 +22,8 @@ using namespace std; using namespace trklet; -PurgeDuplicate::PurgeDuplicate(std::string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector) {} +PurgeDuplicate::PurgeDuplicate(std::string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global) {} void PurgeDuplicate::addOutput(MemoryBase* memory, std::string output) { if (settings_.writetrace()) { diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 74ae87cc6c83e..99bd964d8e66f 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -108,37 +108,37 @@ bool Sector::addStub(L1TStub stub, string dtc) { void Sector::addMem(string memType, string memName) { if (memType == "DTCLink:") { - addMemToVec(DL_, memName, settings_, isector_, phimin_, phimax_); + addMemToVec(DL_, memName, settings_, phimin_, phimax_); } else if (memType == "InputLink:") { - addMemToVec(IL_, memName, settings_, isector_, phimin_, phimax_); + addMemToVec(IL_, memName, settings_, phimin_, phimax_); } else if (memType == "AllStubs:") { - addMemToVec(AS_, memName, settings_, isector_); + addMemToVec(AS_, memName, settings_); } else if (memType == "AllInnerStubs:") { - addMemToVec(AIS_, memName, settings_, isector_); + addMemToVec(AIS_, memName, settings_); } else if (memType == "VMStubsTE:") { - addMemToVec(VMSTE_, memName, settings_, isector_); + addMemToVec(VMSTE_, memName, settings_); } else if (memType == "VMStubsME:") { - addMemToVec(VMSME_, memName, settings_, isector_); + addMemToVec(VMSME_, memName, settings_); } else if (memType == "StubPairs:" || memType == "StubPairsDisplaced:") { - addMemToVec(SP_, memName, settings_, isector_); + addMemToVec(SP_, memName, settings_); } else if (memType == "StubTriplets:") { - addMemToVec(ST_, memName, settings_, isector_); + addMemToVec(ST_, memName, settings_); } else if (memType == "TrackletParameters:") { - addMemToVec(TPAR_, memName, settings_, isector_); + addMemToVec(TPAR_, memName, settings_); } else if (memType == "TrackletProjections:") { - addMemToVec(TPROJ_, memName, settings_, isector_); + addMemToVec(TPROJ_, memName, settings_); } else if (memType == "AllProj:") { - addMemToVec(AP_, memName, settings_, isector_); + addMemToVec(AP_, memName, settings_); } else if (memType == "VMProjections:") { - addMemToVec(VMPROJ_, memName, settings_, isector_); + addMemToVec(VMPROJ_, memName, settings_); } else if (memType == "CandidateMatch:") { - addMemToVec(CM_, memName, settings_, isector_); + addMemToVec(CM_, memName, settings_); } else if (memType == "FullMatch:") { - addMemToVec(FM_, memName, settings_, isector_); + addMemToVec(FM_, memName, settings_); } else if (memType == "TrackFit:") { - addMemToVec(TF_, memName, settings_, isector_, phimin_, phimax_); + addMemToVec(TF_, memName, settings_, phimin_, phimax_); } else if (memType == "CleanTrack:") { - addMemToVec(CT_, memName, settings_, isector_, phimin_, phimax_); + addMemToVec(CT_, memName, settings_, phimin_, phimax_); } else { edm::LogPrint("Tracklet") << "Don't know of memory type: " << memType; exit(0); @@ -147,36 +147,36 @@ void Sector::addMem(string memType, string memName) { void Sector::addProc(string procType, string procName) { if (procType == "InputRouter:") { - addProcToVec(IR_, procName, settings_, globals_, isector_); + addProcToVec(IR_, procName, settings_, globals_); } else if (procType == "VMRouter:") { - addProcToVec(VMR_, procName, settings_, globals_, isector_); + addProcToVec(VMR_, procName, settings_, globals_); } else if (procType == "VMRouterCM:") { - addProcToVec(VMRCM_, procName, settings_, globals_, isector_); + addProcToVec(VMRCM_, procName, settings_, globals_); } else if (procType == "TrackletEngine:") { - addProcToVec(TE_, procName, settings_, globals_, isector_); + addProcToVec(TE_, procName, settings_, globals_); } else if (procType == "TrackletEngineDisplaced:") { - addProcToVec(TED_, procName, settings_, globals_, isector_); + addProcToVec(TED_, procName, settings_, globals_); } else if (procType == "TripletEngine:") { - addProcToVec(TRE_, procName, settings_, globals_, isector_); + addProcToVec(TRE_, procName, settings_, globals_); } else if (procType == "TrackletCalculator:") { - addProcToVec(TC_, procName, settings_, globals_, isector_); + addProcToVec(TC_, procName, settings_, globals_); } else if (procType == "TrackletProcessor:") { - addProcToVec(TP_, procName, settings_, globals_, isector_); + addProcToVec(TP_, procName, settings_, globals_); } else if (procType == "TrackletCalculatorDisplaced:") { - addProcToVec(TCD_, procName, settings_, globals_, isector_); + addProcToVec(TCD_, procName, settings_, globals_); } else if (procType == "ProjectionRouter:") { - addProcToVec(PR_, procName, settings_, globals_, isector_); + addProcToVec(PR_, procName, settings_, globals_); } else if (procType == "MatchEngine:") { - addProcToVec(ME_, procName, settings_, globals_, isector_); + addProcToVec(ME_, procName, settings_, globals_); } else if (procType == "MatchCalculator:" || procType == "DiskMatchCalculator:") { //TODO should not be used in configurations - addProcToVec(MC_, procName, settings_, globals_, isector_); + addProcToVec(MC_, procName, settings_, globals_); } else if (procType == "MatchProcessor:") { - addProcToVec(MP_, procName, settings_, globals_, isector_); + addProcToVec(MP_, procName, settings_, globals_); } else if (procType == "FitTrack:") { - addProcToVec(FT_, procName, settings_, globals_, isector_); + addProcToVec(FT_, procName, settings_, globals_); } else if (procType == "PurgeDuplicate:") { - addProcToVec(PD_, procName, settings_, globals_, isector_); + addProcToVec(PD_, procName, settings_, globals_); } else { edm::LogPrint("Tracklet") << "Don't know of processing type: " << procType; exit(0); @@ -229,97 +229,97 @@ MemoryBase* Sector::getMem(string memName) { void Sector::writeDTCStubs(bool first) { for (auto& i : DL_) { - i->writeStubs(first); + i->writeStubs(first, isector_); } } void Sector::writeIRStubs(bool first) { for (auto& i : IL_) { - i->writeStubs(first); + i->writeStubs(first, isector_); } } void Sector::writeVMSTE(bool first) { for (auto& i : VMSTE_) { - i->writeStubs(first); + i->writeStubs(first, isector_); } } void Sector::writeVMSME(bool first) { for (auto& i : VMSME_) { - i->writeStubs(first); + i->writeStubs(first, isector_); } } void Sector::writeAS(bool first) { for (auto& i : AS_) { - i->writeStubs(first); + i->writeStubs(first, isector_); } } void Sector::writeAIS(bool first) { for (auto& i : AIS_) { - i->writeStubs(first); + i->writeStubs(first, isector_); } } void Sector::writeSP(bool first) { for (auto& i : SP_) { - i->writeSP(first); + i->writeSP(first, isector_); } } void Sector::writeST(bool first) { for (auto& i : ST_) { - i->writeST(first); + i->writeST(first, isector_); } } void Sector::writeTPAR(bool first) { for (auto& i : TPAR_) { - i->writeTPAR(first); + i->writeTPAR(first, isector_); } } void Sector::writeTPROJ(bool first) { for (auto& i : TPROJ_) { - i->writeTPROJ(first); + i->writeTPROJ(first, isector_); } } void Sector::writeAP(bool first) { for (auto& i : AP_) { - i->writeAP(first); + i->writeAP(first, isector_); } } void Sector::writeVMPROJ(bool first) { for (auto& i : VMPROJ_) { - i->writeVMPROJ(first); + i->writeVMPROJ(first, isector_); } } void Sector::writeCM(bool first) { for (auto& i : CM_) { - i->writeCM(first); + i->writeCM(first, isector_); } } void Sector::writeMC(bool first) { for (auto& i : FM_) { - i->writeMC(first); + i->writeMC(first, isector_); } } void Sector::writeTF(bool first) { for (auto& i : TF_) { - i->writeTF(first); + i->writeTF(first, isector_); } } void Sector::writeCT(bool first) { for (auto& i : CT_) { - i->writeCT(first); + i->writeCT(first, isector_); } } diff --git a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc index 2ac672646e4b3..8d83dada14f49 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc @@ -6,10 +6,12 @@ using namespace std; using namespace trklet; -StubPairsMemory::StubPairsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} +StubPairsMemory::StubPairsMemory(string name, Settings const& settings) + : MemoryBase(name, settings) {} -void StubPairsMemory::writeSP(bool first) { +void StubPairsMemory::writeSP(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirSP = settings_.memPath() + "StubPairs/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc index 8ac743534d2cf..be0f9b31f86f1 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc @@ -7,10 +7,12 @@ using namespace std; using namespace trklet; -StubTripletsMemory::StubTripletsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} +StubTripletsMemory::StubTripletsMemory(string name, Settings const& settings) + : MemoryBase(name, settings) {} -void StubTripletsMemory::writeST(bool first) { +void StubTripletsMemory::writeST(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirSP = settings_.memPath() + "StubPairs/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc index 0caa8faf35288..945d4c0e940f0 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc @@ -7,13 +7,15 @@ using namespace std; using namespace trklet; -TrackFitMemory::TrackFitMemory(string name, Settings const& settings, unsigned int iSector, double phimin, double phimax) - : MemoryBase(name, settings, iSector) { +TrackFitMemory::TrackFitMemory(string name, Settings const& settings, double phimin, double phimax) + : MemoryBase(name, settings) { phimin_ = phimin; phimax_ = phimax; } -void TrackFitMemory::writeTF(bool first) { +void TrackFitMemory::writeTF(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirFT = settings_.memPath() + "FitTrack/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc index 026dca77596cb..283dbae71a2c1 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc @@ -14,8 +14,8 @@ using namespace std; using namespace trklet; -TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Globals* globals, unsigned int iSector) - : TrackletCalculatorBase(name, settings, globals, iSector) { +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); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index f8f1a40de2d92..4b9bfc270e7f4 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -16,9 +16,8 @@ using namespace trklet; TrackletCalculatorBase::TrackletCalculatorBase(string name, Settings const& settings, - Globals* global, - unsigned int iSector) - : ProcessBase(name, settings, global, iSector) {} + Globals* global) + : ProcessBase(name, settings, global) {} void TrackletCalculatorBase::exacttracklet(double r1, double z1, diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 07f2c451e431f..4ab7741d9a152 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -15,9 +15,8 @@ using namespace trklet; TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, Settings const& settings, - Globals* global, - unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { + Globals* global) + : ProcessBase(name, settings, global) { for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) { vector tmp(settings.nallstubs(ilayer), nullptr); trackletprojlayers_.push_back(tmp); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc index 38ae2fcea9117..42f5d49cc2947 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngine.cc @@ -13,8 +13,8 @@ using namespace trklet; using namespace std; -TrackletEngine::TrackletEngine(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { +TrackletEngine::TrackletEngine(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global) { stubpairs_ = nullptr; innervmstubs_ = nullptr; outervmstubs_ = nullptr; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc index de421f0aa3dcc..410a4b491c6e7 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc @@ -14,9 +14,8 @@ using namespace trklet; TrackletEngineDisplaced::TrackletEngineDisplaced(string name, Settings const& settings, - Globals* global, - unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { + Globals* global) + : ProcessBase(name, settings, global) { stubpairs_.clear(); firstvmstubs_.clear(); secondvmstubs_ = nullptr; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index 6de594a36b981..c686b67defe49 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -396,12 +396,12 @@ void TrackletEventProcessor::printSummary() { << "Add Stubs " << setw(10) << addStubTimer_.ntimes() << setw(20) << setprecision(3) << addStubTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) << addStubTimer_.tottime() << "\n" - << "VMRouter " << setw(10) << VMRouterTimer_.ntimes() << setw(20) - << setprecision(3) << VMRouterTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << VMRouterTimer_.tottime() << "\n" << "InputRouter " << setw(10) << InputRouterTimer_.ntimes() << setw(20) << setprecision(3) << InputRouterTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << InputRouterTimer_.tottime(); + << 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) @@ -411,22 +411,26 @@ void TrackletEventProcessor::printSummary() { << 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() << "\n" - << "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" - << "TrackletCalculator " << setw(10) << TCTimer_.ntimes() << setw(20) << setprecision(3) - << TCTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) << TCTimer_.tottime() << "\n" - << "TrackletCalculatorDisplaced" << setw(10) << TCDTimer_.ntimes() << setw(20) << setprecision(3) - << TCDTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) << TCDTimer_.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(); + << "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(); + } + 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(); } 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/TrackletParametersMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc index 1180abc707285..b9aed96c2f083 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc @@ -8,8 +8,8 @@ using namespace std; using namespace trklet; -TrackletParametersMemory::TrackletParametersMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) {} +TrackletParametersMemory::TrackletParametersMemory(string name, Settings const& settings) + : MemoryBase(name, settings) {} void TrackletParametersMemory::clean() { for (auto& tracklet : tracklets_) { @@ -18,7 +18,9 @@ void TrackletParametersMemory::clean() { tracklets_.clear(); } -void TrackletParametersMemory::writeTPAR(bool first) { +void TrackletParametersMemory::writeTPAR(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirTP = settings_.memPath() + "TrackletParameters/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index bcafc0cfdad7c..574680a9581b7 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -16,8 +16,8 @@ using namespace std; using namespace trklet; -TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Globals* globals, unsigned int iSector) - : TrackletCalculatorBase(name, settings, globals, iSector), +TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Globals* globals) + : TrackletCalculatorBase(name, settings, globals), tebuffer_(CircularBuffer(3), 0, 0, 0, 0), vmrtable_(settings) { iAllStub_ = -1; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc index ae621073605ec..8eb85073223a6 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc @@ -7,8 +7,8 @@ using namespace std; using namespace trklet; -TrackletProjectionsMemory::TrackletProjectionsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) { +TrackletProjectionsMemory::TrackletProjectionsMemory(string name, Settings const& settings) + : MemoryBase(name, settings) { size_t pos = find_nth(name, 0, "_", 1); assert(pos != string::npos); initLayerDisk(pos + 1, layer_, disk_); @@ -34,7 +34,9 @@ void TrackletProjectionsMemory::addProj(Tracklet* tracklet) { void TrackletProjectionsMemory::clean() { tracklets_.clear(); } -void TrackletProjectionsMemory::writeTPROJ(bool first) { +void TrackletProjectionsMemory::writeTPROJ(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirTP = settings_.memPath() + "TrackletProjections/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc b/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc index e7298c9377abd..e08cd039b9e24 100644 --- a/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/TripletEngine.cc @@ -10,8 +10,8 @@ using namespace std; using namespace trklet; -TripletEngine::TripletEngine(string name, Settings const &settings, Globals *global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector) { +TripletEngine::TripletEngine(string name, Settings const &settings, Globals *global) + : ProcessBase(name, settings, global) { stubpairs_.clear(); thirdvmstubs_.clear(); layer1_ = 0; diff --git a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc index e8f7d260c94e7..4c1074d257228 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc @@ -7,8 +7,8 @@ using namespace std; using namespace trklet; -VMProjectionsMemory::VMProjectionsMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) { +VMProjectionsMemory::VMProjectionsMemory(string name, Settings const& settings) + : MemoryBase(name, settings) { initLayerDisk(7, layer_, disk_); } @@ -21,7 +21,9 @@ void VMProjectionsMemory::addTracklet(Tracklet* tracklet, unsigned int allprojin tracklets_.push_back(tmp); } -void VMProjectionsMemory::writeVMPROJ(bool first) { +void VMProjectionsMemory::writeVMPROJ(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirVM = settings_.memPath() + "VMProjections/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc index c37c013f78f26..0d38c7adcb188 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc @@ -13,8 +13,8 @@ using namespace std; using namespace trklet; -VMRouter::VMRouter(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector), vmrtable_(settings) { +VMRouter::VMRouter(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global), vmrtable_(settings) { layerdisk_ = initLayerDisk(4); vmstubsMEPHI_.resize(settings_.nvmme(layerdisk_), nullptr); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc index 04dd5e40b86fd..76c85c9eeaf8a 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc @@ -14,8 +14,8 @@ using namespace std; using namespace trklet; -VMRouterCM::VMRouterCM(string name, Settings const& settings, Globals* global, unsigned int iSector) - : ProcessBase(name, settings, global, iSector), vmrtable_(settings) { +VMRouterCM::VMRouterCM(string name, Settings const& settings, Globals* global) + : ProcessBase(name, settings, global), vmrtable_(settings) { layerdisk_ = initLayerDisk(4); vmstubsMEPHI_.resize(1, nullptr); diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc index b3d67f896b4fd..ab76b706c1b23 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc @@ -6,8 +6,8 @@ using namespace std; using namespace trklet; -VMStubsMEMemory::VMStubsMEMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) { +VMStubsMEMemory::VMStubsMEMemory(string name, Settings const& settings) + : MemoryBase(name, settings) { unsigned int layerdisk = initLayerDisk(6); if (layerdisk < N_LAYER) { binnedstubs_.resize(settings_.NLONGVMBINS()); @@ -17,7 +17,9 @@ VMStubsMEMemory::VMStubsMEMemory(string name, Settings const& settings, unsigned } } -void VMStubsMEMemory::writeStubs(bool first) { +void VMStubsMEMemory::writeStubs(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirVM = settings_.memPath() + "VMStubsME/"; std::ostringstream oss; diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc index 425f23faca72d..b62cc2e4d3712 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc @@ -6,8 +6,8 @@ using namespace std; using namespace trklet; -VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings, unsigned int iSector) - : MemoryBase(name, settings, iSector) { +VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings) + : MemoryBase(name, settings) { //set the layer or disk that the memory is in initLayerDisk(6, layer_, disk_); @@ -218,7 +218,9 @@ void VMStubsTEMemory::clean() { } } -void VMStubsTEMemory::writeStubs(bool first) { +void VMStubsTEMemory::writeStubs(bool first, unsigned int iSector) { + + iSector_ = iSector; const string dirVM = settings_.memPath() + "VMStubsTE/"; openFile(first, dirVM, "VMStubs_"); @@ -277,7 +279,7 @@ void VMStubsTEMemory::setbendtable(std::vector vmbendtable) { vmbendtable_[i] = vmbendtable[i]; } - if (iSector_ == 0 && settings_.writeTable()) + if (settings_.writeTable()) writeVMBendTable(); } From 44ea72e1e0f84d941d96c73dccac5f147dac032e Mon Sep 17 00:00:00 2001 From: Anders Date: Mon, 15 Mar 2021 23:45:36 +0100 Subject: [PATCH 28/45] Fixes to make the HybridTracks_cfg.py run --- .../test/HybridTracks_cfg.py | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py index 7b355253cc4e5..357f01cf38584 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracks_cfg.py @@ -18,6 +18,11 @@ from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') +############################################################ +# L1 tracking: remake stubs? +############################################################ +process.load('L1Trigger.TrackTrigger.TrackTrigger_cff') + # ---------------------------------------------------------------------------------- # input @@ -27,8 +32,6 @@ ) process.source = cms.Source("PoolSource", fileNames = Source_Files) - -# ---------------------------------------------------------------------------------- # L1 tracking => hybrid emulation process.load("L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff") @@ -44,6 +47,26 @@ #process.TTTracksEmulation = cms.Path(process.L1PromptExtendedHybridTracks) #process.TTTracksEmulationWithTruth = cms.Path(process.L1PromptExtendedHybridTracksWithAssociators) +# ----------------------------------------------------------------------------------- +# DTC Emulations +process.load( 'L1Trigger.TrackerDTC.ProducerED_cff' ) +process.load( 'L1Trigger.TrackerDTC.ProducerES_cff' ) + +#--- Load code that produces DTCStubs + +# load Track Trigger Configuration +process.load( 'L1Trigger.TrackerDTC.ProducerES_cff' ) +# load code that produces DTCStubs +process.load( 'L1Trigger.TrackerDTC.ProducerED_cff' ) +# load code that analyzes DTCStubs +process.load( 'L1Trigger.TrackerDTC.Analyzer_cff' ) + +process.dtc = cms.Path( process.TrackerDTCProducer ) + + + +# ---------------------------------------------------------------------------------- + # ---------------------------------------------------------------------------------- # output module @@ -58,5 +81,5 @@ #process.schedule = cms.Schedule(process.TTTracksEmulation,process.FEVToutput_step) -process.schedule = cms.Schedule(process.TTTracksEmulationWithTruth,process.FEVToutput_step) +process.schedule = cms.Schedule(process.dtc,process.TTTracksEmulationWithTruth,process.FEVToutput_step) From 6d8b6f833203199431e391b226ee904f2edcef86 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Mon, 15 Mar 2021 22:42:36 -0400 Subject: [PATCH 29/45] Cleanup of hardcoded numbers etc. --- .../TrackFindingTracklet/interface/Settings.h | 8 +++- .../interface/TrackletProcessor.h | 2 + .../src/TrackletProcessor.cc | 44 +++++++------------ 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 275618906545d..90b20f2998800 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -30,6 +30,7 @@ namespace trklet { constexpr unsigned int NRINVBITS = 5; //number of bit for rinv in bend match table constexpr unsigned int NFINERZBITS = 3; //number of bit for r or z within a r/z bin constexpr unsigned int NFINEPHIBITS = 3; //number of bits for phi within a vm bin + constexpr unsigned int N_RZBITS = 3; //number of bit for the r/z bins constexpr unsigned int N_VMSTUBSMAX = 15; // maximum number of stubs in VM bin @@ -141,7 +142,9 @@ namespace trklet { assert(layerdisk >= 0); return layerdisk; } - + + unsigned int teunits(unsigned int iSeed) const { return teunits_[iSeed]; } + unsigned int NTC(int seed) const { return ntc_[seed]; } unsigned int projlayers(unsigned int iSeed, unsigned int i) const { return projlayers_[iSeed][i]; } @@ -553,6 +556,9 @@ namespace trklet { int chisqphifactbits_{14}; int chisqzfactbits_{14}; + std::array teunits_{ + {5, 2, 5, 3, 3, 2, 3, 2, 0, 0, 0, 0}}; //teunits used by seed + std::array vmrlutzbits_{ {7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3}}; // zbits used by LUT in VMR std::array vmrlutrbits_{ diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h index 46d03f6d72639..a7e0aceb18ebb 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h @@ -43,6 +43,8 @@ namespace trklet { int iTC_; int iAllStub_; + unsigned int maxStep_; + VMStubsTEMemory* outervmstubs_; // istub imem start imem end imem diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index 574680a9581b7..177817e5994f4 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -41,7 +41,7 @@ TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Glob vmrtable_.init(layerdisk1_); - nbitsrzbin_ = NFINERZBITS; + nbitsrzbin_ = N_RZBITS; if (iSeed_ == 4 || iSeed_ == 5) nbitsrzbin_ = 2; @@ -54,6 +54,9 @@ TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Glob TCIndex_ = (iSeed_ << 4) + iTC_; assert(TCIndex_ >= 0 && TCIndex_ <= (int)settings_.ntrackletmax()); + + maxStep_ = settings_.maxStep("TP"); + } void TrackletProcessor::addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory) { @@ -138,23 +141,9 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { pttableinnernew_, pttableouternew_, outervmstubs_); - if (iSeed_ == 0) - teunits_.resize(5, teunit); - if (iSeed_ == 1) - teunits_.resize(2, teunit); - if (iSeed_ == 2) - teunits_.resize(5, teunit); - if (iSeed_ == 3) - teunits_.resize(3, teunit); - if (iSeed_ == 4) - teunits_.resize(3, teunit); - if (iSeed_ == 5) - teunits_.resize(2, teunit); - if (iSeed_ == 6) - teunits_.resize(3, teunit); - if (iSeed_ == 7) - teunits_.resize(2, teunit); + teunits_.resize(settings_.teunits(iSeed_),teunit); + return; } @@ -183,6 +172,7 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { } void TrackletProcessor::execute(unsigned int iSector, double phimin, double phimax) { + bool print = (iSector == 3) && (getName() == "TP_L1L2D"); print = false; @@ -233,7 +223,7 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim bool tebuffernearfull; - for (unsigned int istep = 0; istep < settings_.maxStep("TP"); istep++) { + for (unsigned int istep = 0; istep < maxStep_; istep++) { if (print) { CircularBuffer& tedatabuffer = std::get<0>(tebuffer_); unsigned int& istub = std::get<1>(tebuffer_); @@ -389,23 +379,24 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim unsigned int lutwidth = settings_.lutwidthtab(0, iSeed_); FPGAWord lookupbits(lutval, lutwidth, true, __LINE__, __FILE__); - int rzfinebinfirst = lookupbits.bits(0, 3); //finephi - int next = lookupbits.bits(3, 1); //next r/z bin - int start = lookupbits.bits(4, nbitsrzbin_); - int rzdiffmax = lookupbits.bits(4 + nbitsrzbin_, 3); + int rzfinebinfirst = lookupbits.bits(0, NFINERZBITS); //finerz + int next = lookupbits.bits(NFINERZBITS, 1); //use next r/z bin + int start = lookupbits.bits(NFINERZBITS + 1, nbitsrzbin_); //rz bin + int rzdiffmax = lookupbits.bits(NFINERZBITS + 1 + nbitsrzbin_, NFINERZBITS); if ((iSeed_ == 4 || iSeed_ == 5) && negdisk) { //TODO - need to store negative disk - start += 4; + start += (1<= 4) { //FIXME If the lookupbits were rationally organized this would be much simpler - int ir = ((start & 3) << 1) + (rzfinebinfirst >> 2); - useregindex = (useregindex << 3) + ir; + unsigned int nrbits=3; + int ir = ((start & ((1<<(nrbits-1))-1)) << 1) + (rzfinebinfirst >> (NFINERZBITS-1)); + useregindex = (useregindex << nrbits) + ir; } assert(useregindex < useregion_.size()); @@ -423,7 +414,6 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim for (int ibin = start; ibin <= last; ibin++) { for (unsigned int ireg = 0; ireg < settings_.nvmte(1, iSeed_); ireg++) { - assert(ireg < 8); if (!(usereg & (1 << ireg))) { mask = "0" + mask; continue; From a40f3392652c3395380e24334366f46b1dd1f014 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Fri, 19 Mar 2021 16:54:26 -0400 Subject: [PATCH 30/45] Updates to MP to put all regions into one memory slot in the ProjectionTemp --- .../interface/MatchEngineUnit.h | 22 +++-- .../interface/MatchProcessor.h | 4 +- .../interface/ProjectionTemp.h | 13 +-- .../src/MatchEngineUnit.cc | 63 +++++++++---- .../src/MatchProcessor.cc | 90 ++++++++++--------- .../src/ProjectionTemp.cc | 17 +++- L1Trigger/TrackFindingTracklet/src/Sector.cc | 2 +- 7 files changed, 137 insertions(+), 74 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index 3cef2a1c0b2ad..55ce7564b0994 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -22,12 +22,17 @@ namespace trklet { ~MatchEngineUnit() = default; void init(VMStubsMEMemory* vmstubsmemory, - unsigned int slot, + unsigned int nrzbin, + unsigned int rzbin, + unsigned int iphi, + int shift, int projrinv, int projfinerz, int projfinephi, - int shift, - bool usesecond, + bool usefirstMinus, + bool usefirstPlus, + bool usesecondMinus, + bool usesecondPlus, bool isPSseed, Tracklet* proj); @@ -48,17 +53,20 @@ namespace trklet { private: VMStubsMEMemory* vmstubsmemory_; - //unsigned int memory slot - unsigned int slot_; + unsigned int nrzbins_; + unsigned int rzbin_; + unsigned int phibin_; + int shift_; + unsigned int istub_; + unsigned int iuse_; bool barrel_; int projrinv_; int projfinerz_; int projfinephi_; - bool usesecond_; + std::vector> use_; bool isPSseed_; - int shift_; Tracklet* proj_; bool idle_; diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index 3b1a936ba7984..f693674f71581 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -30,9 +30,9 @@ namespace trklet { void addOutput(MemoryBase* memory, std::string output) override; void addInput(MemoryBase* memory, std::string input) override; - void execute(double phimin); + void execute(unsigned int iSector, double phimin); - bool matchCalculator(Tracklet* tracklet, const Stub* fpgastub); + bool matchCalculator(Tracklet* tracklet, const Stub* fpgastub, bool print, unsigned int istep); private: unsigned int layerdisk_; diff --git a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h index 6d418058a842e..f41badeaa14df 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h @@ -14,8 +14,11 @@ namespace trklet { int projfinerz, unsigned int projfinephi, unsigned int iphi, - int shift, - bool usesecond, + int shift, + bool usefirstMinus, + bool usefirstPlus, + bool usesecondMinus, + bool usesecondPlus, bool isPSseed); ProjectionTemp(); @@ -28,8 +31,8 @@ namespace trklet { int projfinerz() const { return projfinerz_; } unsigned int projfinephi() const { return projfinephi_; } unsigned int iphi() const { return iphi_; } - unsigned int shift() const { return shift_; } - bool usesecond() const { return usesecond_; } + int shift() const { return shift_; } + bool use(unsigned int nextrzbin, unsigned int nextiphibin) const { return use_[nextrzbin][nextiphibin]; } bool isPSseed() const { return isPSseed_; } private: @@ -40,7 +43,7 @@ namespace trklet { unsigned int projfinephi_; unsigned int iphi_; int shift_; - bool usesecond_; + bool use_[2][2]; bool isPSseed_; }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc index 8f56b49198d70..9f31e54e65875 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc @@ -7,28 +7,48 @@ MatchEngineUnit::MatchEngineUnit(bool barrel, unsigned int layerdisk, vectorgetVMStubMEBin(slot_, istub_); + unsigned int slot = (phibin_+use_[iuse_].second)*nrzbins_+rzbin_+use_[iuse_].first; + + int projfinerz = projfinerz_ - (1 << NFINERZBITS) * use_[iuse_].first; + int projfinephi = projfinephi_; + if (use_[iuse_].second==0) { + if (shift_==-1) { + projfinephi -= (1 << NFINEPHIBITS); + } + } else { + //When we get here shift_ is either 1 or -1 + if (shift_==1) { + projfinephi += (1 << NFINEPHIBITS); + } + } + + const VMStubME& vmstub = vmstubsmemory_->getVMStubMEBin(slot, istub_); bool isPSmodule = vmstub.isPSmodule(); int stubfinerz = vmstub.finerz().value(); int stubfinephi = vmstub.finephi().value(); - int deltaphi = stubfinephi - projfinephi_ + (1 << NFINERZBITS) * shift_; + int deltaphi = stubfinephi - projfinephi; bool dphicut = (abs(deltaphi) < 3); @@ -54,7 +89,7 @@ void MatchEngineUnit::step() { unsigned int index = (diskps << (4 + 5)) + (projrinv_ << nbits) + vmstub.bend().value(); //Check if stub z position consistent - int idrz = stubfinerz - projfinerz_; + int idrz = stubfinerz - projfinerz; bool pass; if (barrel_) { @@ -78,12 +113,10 @@ void MatchEngineUnit::step() { } istub_++; - if (istub_ >= vmstubsmemory_->nStubsBin(slot_)) { - if (usesecond_) { - usesecond_ = false; + if (istub_ >= vmstubsmemory_->nStubsBin(slot)) { + iuse_++; + if (iuse_nTracklets(); + for (const auto& inputproj: inputprojs_) { + countinputproj += inputproj->nTracklets(); } - for (unsigned int iME = 0; iME < nMatchEngines_; iME++) { - matchengines_[iME].reset(); + for (auto& matchengine : matchengines_) { + matchengine.reset(); } for (unsigned int istep = 0; istep < settings_.maxStep("MP"); istep++) { @@ -255,6 +256,13 @@ void MatchProcessor::execute(double phimin) { FPGAWord fpgaphi = proj->proj(layerdisk_).fpgaphiproj(); + if (print) cout << "PROJECTION "<getName()<<": "<proj(layerdisk_).fpgaphiproj().value() + << " " << proj->proj(layerdisk_).fpgarzproj().value() + << " " << proj->proj(layerdisk_).fpgaphiprojder().value() + << " " << proj->proj(layerdisk_).fpgarzprojder().value() + << "TC index trackletIndex : "<TCIndex()<<" "<trackletIndex() + <> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); int nextrabits = 2; @@ -264,16 +272,15 @@ void MatchProcessor::execute(double phimin) { unsigned int ivmPlus = iphi; - int plusShift = 0; - int negShift = 0; - + int shift = 0; + if (extrabits == ((1U << nextrabits) - 1) && iphi != ((1U << settings_.nbitsvmme(layerdisk_)) - 1)) { - plusShift = 1; + shift = 1; ivmPlus++; } unsigned int ivmMinus = iphi; if (extrabits == 0 && iphi != 0) { - negShift = -1; + shift = -1; ivmMinus--; } @@ -317,31 +324,19 @@ void MatchProcessor::execute(double phimin) { nbins = 16; VMStubsMEMemory* stubmem = vmstubs_[0]; - bool usefirstPlus = stubmem->nStubsBin(ivmPlus * nbins + slot) != 0; - bool usesecondPlus = (second && (stubmem->nStubsBin(ivmPlus * nbins + slot + 1) != 0)); bool usefirstMinus = stubmem->nStubsBin(ivmMinus * nbins + slot) != 0; bool usesecondMinus = (second && (stubmem->nStubsBin(ivmMinus * nbins + slot + 1) != 0)); - - if (usefirstPlus) { - ProjectionTemp tmpProj( - proj, slot, projrinv, projfinerz, projfinephi, ivmPlus, plusShift, usesecondPlus, isPSseed); - inputProjBuffer_.store(tmpProj); - } else if (usesecondPlus) { - ProjectionTemp tmpProj( - proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmPlus, plusShift, false, isPSseed); - inputProjBuffer_.store(tmpProj); - } - if (ivmPlus != ivmMinus) { - if (usefirstMinus) { - ProjectionTemp tmpProj( - proj, slot, projrinv, projfinerz, projfinephi, ivmMinus, negShift, usesecondMinus, isPSseed); - inputProjBuffer_.store(tmpProj); - } else if (usesecondMinus) { - ProjectionTemp tmpProj( - proj, slot + 1, projrinv, projfinerz - 8, projfinephi, ivmMinus, negShift, false, isPSseed); - inputProjBuffer_.store(tmpProj); - } - } + bool usefirstPlus = ivmPlus != ivmMinus && stubmem->nStubsBin(ivmPlus * nbins + slot) != 0; + bool usesecondPlus = ivmPlus != ivmMinus && (second && (stubmem->nStubsBin(ivmPlus * nbins + slot + 1) != 0)); + + bool useProj = usefirstPlus || usesecondPlus || usefirstMinus || usesecondMinus; + + if (useProj) { + ProjectionTemp tmpProj(proj, slot, projrinv, projfinerz, projfinephi, + ivmMinus, shift, usefirstMinus, usefirstPlus, usesecondMinus, usesecondPlus, isPSseed); + inputProjBuffer_.store(tmpProj); + } + iproj++; if (iproj == projMem->nTracklets()) { iproj = 0; @@ -375,13 +370,19 @@ void MatchProcessor::execute(double phimin) { if (layerdisk_ >= 6) nbins = 16; + if (print) cout << "istep = "<l1tstub(); + if (print) cout << "matchCalculator tcid trackletindex stubindex : "<TCIndex()<<" "<trackletIndex()<<" "<allStubIndex().value()<proj(layerdisk_); int ir = fpgastub->r().value(); @@ -461,6 +465,8 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { int ideltaz = fpgastub->z().value() - iz; int ideltaphi = (fpgastub->phi().value() - iphi) << phishift_; + if (print) cout << "ideltaphi : " << fpgastub->phi().value()<<" "<phi(); @@ -521,6 +527,9 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { << endl; } + if (print) cout << "delta phi : "<< ideltaphi << " " << phimatchcut_[seedindex] << endl; + if (print) cout << "delta z : "<< (ideltaz << dzshift_) << " " << zmatchcut_[seedindex] << endl; + bool imatch = ((unsigned int)std::abs(ideltaphi) <= phimatchcut_[seedindex]) && ((unsigned int)std::abs(ideltaz << dzshift_) <= zmatchcut_[seedindex]); @@ -548,6 +557,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub) { int iSeed = tracklet->getISeed(); assert(fullmatches_[iSeed] != nullptr); + if (print) cout << "istep = "<addMatch(tracklet, fpgastub); return true; diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc index 999f4888ef88d..e9fc6201c77f0 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc @@ -9,8 +9,11 @@ ProjectionTemp::ProjectionTemp(Tracklet* proj, int projfinerz, unsigned int projfinephi, unsigned int iphi, - int shift, - bool usesecond, + int shift, + bool usefirstMinus, + bool usefirstPlus, + bool usesecondMinus, + bool usesecondPlus, bool isPSseed) { proj_ = proj; slot_ = slot; @@ -19,7 +22,10 @@ ProjectionTemp::ProjectionTemp(Tracklet* proj, projfinephi_ = projfinephi; iphi_ = iphi; shift_ = shift; - usesecond_ = usesecond; + use_[0][0] = usefirstMinus; + use_[0][1] = usefirstPlus; + use_[1][0] = usesecondMinus; + use_[1][1] = usesecondPlus; isPSseed_ = isPSseed; } @@ -31,6 +37,9 @@ ProjectionTemp::ProjectionTemp() { projfinephi_ = 0; iphi_ = 0; shift_ = 0; - usesecond_ = false; + use_[0][0] = false; + use_[0][1] = false; + use_[1][0] = false; + use_[1][1] = false; isPSseed_ = false; } diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 99bd964d8e66f..c393552953daa 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -413,7 +413,7 @@ void Sector::executeMC() { void Sector::executeMP() { for (auto& i : MP_) { - i->execute(phimin_); + i->execute(isector_, phimin_); } } From ed2269e701063b98130b4de6096927e5c3b8d83e Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Thu, 25 Mar 2021 17:30:29 -0400 Subject: [PATCH 31/45] Fix to calculation of irinv for projections - no matches what is done in HLS --- .../interface/MatchEngineUnit.h | 2 +- .../src/MatchEngineUnit.cc | 6 +++- .../src/MatchProcessor.cc | 32 ++++++++++++------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index 55ce7564b0994..af759167e4180 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -48,7 +48,7 @@ namespace trklet { void reset(); - void step(); + void step(bool print); private: VMStubsMEMemory* vmstubsmemory_; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc index 9f31e54e65875..96e62d12eae5b 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc @@ -53,7 +53,7 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, proj_ = proj; } -void MatchEngineUnit::step() { +void MatchEngineUnit::step(bool print) { if (idle() || candmatches_.almostfull()) return; @@ -106,6 +106,10 @@ void MatchEngineUnit::step() { } } + if (print) cout <<"MEU TrkId stubindex : "<<128*proj_->TCIndex()+proj_->trackletIndex()<<" "<getName()<<": "<proj(layerdisk_).fpgaphiproj().value() - << " " << proj->proj(layerdisk_).fpgarzproj().value() - << " " << proj->proj(layerdisk_).fpgaphiprojder().value() - << " " << proj->proj(layerdisk_).fpgarzprojder().value() - << "TC index trackletIndex : "<TCIndex()<<" "<trackletIndex() - <getName()<<": "<proj(layerdisk_).fpgaphiproj().value() + // << " " << proj->proj(layerdisk_).fpgarzproj().value() + // << " " << proj->proj(layerdisk_).fpgaphiprojder().value() + // << " " << proj->proj(layerdisk_).fpgarzprojder().value() + // << "TC index trackletIndex : "<TCIndex()<<" "<trackletIndex() + // <> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); @@ -270,6 +270,8 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits, nextrabits); + if (print) cout << "iphi extrabits: "<fpgarinv().value() >> (proj->fpgarinv().nbits() - nrinv_)); + FPGAWord phider = proj->proj(layerdisk_).fpgaphiprojder(); + projrinv = (1 << (nrinv_ - 1)) - 1 - (phider.value() >> (phider.nbits() - nrinv_)); } else { //The next lines looks up the predicted bend based on: // 1 - r projections @@ -314,6 +318,10 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { unsigned int slot = proj->proj(layerdisk_).fpgarzbin1projvm().value(); bool second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); + if (print) cout << "istep="<TCIndex()+proj->trackletIndex() + <<" ivmMinus ivmPlus shift "<l1tstub(); - if (print) cout << "matchCalculator tcid trackletindex stubindex : "<TCIndex()<<" "<trackletIndex()<<" "<allStubIndex().value()<TCIndex()+tracklet->trackletIndex()<<" "<allStubIndex().value()<proj(layerdisk_); @@ -465,7 +473,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b int ideltaz = fpgastub->z().value() - iz; int ideltaphi = (fpgastub->phi().value() - iphi) << phishift_; - if (print) cout << "ideltaphi : " << fpgastub->phi().value()<<" "<phi().value()<<" "< Date: Thu, 25 Mar 2021 22:11:41 -0400 Subject: [PATCH 32/45] Remove now unused file paths for the old cable mapping code --- .../TrackFindingTracklet/interface/Settings.h | 13 +------------ .../plugins/L1FPGATrackProducer.cc | 17 +---------------- .../TrackFindingTracklet/python/Tracklet_cfi.py | 3 --- .../src/TrackletEventProcessor.cc | 14 +++++++------- L1Trigger/TrackFindingTracklet/test/fpga.cc | 7 ------- 5 files changed, 9 insertions(+), 45 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 90b20f2998800..94d6caaaa061a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -50,9 +50,6 @@ namespace trklet { ~Settings() = default; // processing & memory modules, wiring, etc. - std::string DTCLinkFile() const { return DTCLinkFile_; } - std::string const& moduleCablingFile() const { return moduleCablingFile_; } - std::string const& DTCLinkLayerDiskFile() const { return DTCLinkLayerDiskFile_; } std::string const& fitPatternFile() const { return fitPatternFile_; } std::string const& processingModulesFile() const { return processingModulesFile_; } std::string const& memoryModulesFile() const { return memoryModulesFile_; } @@ -60,11 +57,6 @@ namespace trklet { std::string const& tableTEDFile() const { return tableTEDFile_; } std::string const& tableTREFile() const { return tableTREFile_; } - void setDTCLinkFile(std::string DTCLinkFileName) { DTCLinkFile_ = DTCLinkFileName; } - void setModuleCablingFile(std::string moduleCablingFileName) { moduleCablingFile_ = moduleCablingFileName; } - void setDTCLinkLayerDiskFile(std::string DTCLinkLayerDiskFileName) { - DTCLinkLayerDiskFile_ = DTCLinkLayerDiskFileName; - } void setFitPatternFile(std::string fitPatternFileName) { fitPatternFile_ = fitPatternFileName; } void setProcessingModulesFile(std::string processingModulesFileName) { processingModulesFile_ = processingModulesFileName; @@ -420,9 +412,6 @@ namespace trklet { } private: - std::string DTCLinkFile_; - std::string moduleCablingFile_; - std::string DTCLinkLayerDiskFile_; std::string fitPatternFile_; std::string processingModulesFile_; std::string memoryModulesFile_; @@ -752,7 +741,7 @@ namespace trklet { {"TPars", false}, {"TPD", false}, {"TrackletPars", false}, {"TED", false}, {"TP", false}, {"TRE", false}, {"VMR", false}, {"StubsLayer", false}, {"StubsLayerSector", false}, - {"HitEff", false}, {"MatchEff", false}, {"Cabling", false}, + {"HitEff", false}, {"MatchEff", false}, {"IFit", false}, {"AS", false}}; std::array rDSSinner_mod_{{68.9391, 78.7750, 85.4550, 96.3150, 102.3160}}; diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index de8c50a9dc106..0c0d8f91c95da 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -81,7 +81,6 @@ // Tracklet emulation #include "L1Trigger/TrackFindingTracklet/interface/Settings.h" #include "L1Trigger/TrackFindingTracklet/interface/Sector.h" -#include "L1Trigger/TrackFindingTracklet/interface/Cabling.h" #include "L1Trigger/TrackFindingTracklet/interface/Track.h" #include "L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h" @@ -151,10 +150,6 @@ class L1FPGATrackProducer : public edm::one::EDProducer { edm::FileInPath processingModulesFile; edm::FileInPath wiresFile; - edm::FileInPath DTCLinkFile; - edm::FileInPath moduleCablingFile; - edm::FileInPath DTCLinkLayerDiskFile; - edm::FileInPath tableTEDFile; edm::FileInPath tableTREFile; @@ -228,10 +223,6 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) memoryModulesFile = iConfig.getParameter("memoryModulesFile"); wiresFile = iConfig.getParameter("wiresFile"); - DTCLinkFile = iConfig.getParameter("DTCLinkFile"); - moduleCablingFile = iConfig.getParameter("moduleCablingFile"); - DTCLinkLayerDiskFile = iConfig.getParameter("DTCLinkLayerDiskFile"); - extended_ = iConfig.getParameter("Extended"); nHelixPar_ = iConfig.getParameter("Hnpar"); @@ -250,9 +241,6 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) settings.setExtended(extended_); settings.setNHelixPar(nHelixPar_); - settings.setDTCLinkFile(DTCLinkFile.fullPath()); - settings.setModuleCablingFile(moduleCablingFile.fullPath()); - settings.setDTCLinkLayerDiskFile(DTCLinkLayerDiskFile.fullPath()); settings.setFitPatternFile(fitPatternFile.fullPath()); settings.setProcessingModulesFile(processingModulesFile.fullPath()); settings.setMemoryModulesFile(memoryModulesFile.fullPath()); @@ -274,10 +262,7 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) } if (settings.debugTracklet()) { - edm::LogVerbatim("Tracklet") << "cabling DTC links : " << DTCLinkFile.fullPath() - << "\n module cabling : " << moduleCablingFile.fullPath() - << "\n DTC link layer disk : " << DTCLinkLayerDiskFile.fullPath() - << "\n fit pattern : " << fitPatternFile.fullPath() + edm::LogVerbatim("Tracklet") << "fit pattern : " << fitPatternFile.fullPath() << "\n process modules : " << processingModulesFile.fullPath() << "\n memory modules : " << memoryModulesFile.fullPath() << "\n wires : " << wiresFile.fullPath(); diff --git a/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py b/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py index 1300cc7eb8814..bf2e03815a307 100644 --- a/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py @@ -17,9 +17,6 @@ memoryModulesFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/memorymodules_hourglass.dat'), processingModulesFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/processingmodules_hourglass.dat'), wiresFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/wires_hourglass.dat'), - DTCLinkFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/calcNumDTCLinks.txt'), - DTCLinkLayerDiskFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/dtclinklayerdisk.dat'), - moduleCablingFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/modules_T5v3_27SP_nonant_tracklet.dat'), # Quality Flag and Quality params TrackQuality =cms.bool(True), TrackQualityPSet = cms.PSet(TrackQualityParams) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index c686b67defe49..5d7b350d66e2c 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -98,18 +98,18 @@ void TrackletEventProcessor::init(Settings const& theSettings) { //Write configurations to file. if (settings_->writeConfig()) { std::ofstream wires = openfile(settings_->tablePath(), "wires.dat", __FILE__, __LINE__); - std::ofstream memories = openfile(settings_->tablePath(), "memories.dat", __FILE__, __LINE__); - std::ofstream modules = openfile(settings_->tablePath(), "modules.dat", __FILE__, __LINE__); + std::ofstream memorymodules = openfile(settings_->tablePath(), "memorymodules.dat", __FILE__, __LINE__); + std::ofstream processingmodules = openfile(settings_->tablePath(), "processingmodules.dat", __FILE__, __LINE__); - config.writeAll(wires, memories, modules); + config.writeAll(wires, memorymodules, processingmodules); } std::stringstream wires; - std::stringstream memories; - std::stringstream modules; + std::stringstream memorymodules; + std::stringstream processingmodules; - config.writeAll(wires, memories, modules); - configure(wires, memories, modules); + config.writeAll(wires, memorymodules, processingmodules); + configure(wires, memorymodules, processingmodules); } } diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index 604e4fcc62691..0f869dfd36671 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -54,9 +54,6 @@ int main(const int argc, const char **argv) { // --------------------------------------------------------- // these are options that are read from python configuration files for the CMSSW running, set manually for the standalone version - settings.setDTCLinkFile("../data/calcNumDTCLinks.txt"); - settings.setModuleCablingFile("../data/modules_T5v3_27SP_nonant_tracklet.dat"); - settings.setDTCLinkLayerDiskFile("../data/dtclinklayerdisk.dat"); settings.setFitPatternFile("../data/fitpattern.txt"); settings.setProcessingModulesFile("../data/processingmodules_" + settings.geomext() + ".dat"); settings.setMemoryModulesFile("../data/memorymodules_" + settings.geomext() + ".dat"); @@ -67,10 +64,6 @@ int main(const int argc, const char **argv) { settings.setTableTREFile("../data/table_TRE/table_TRE_Dummy.txt"); } - edm::LogVerbatim("Tracklet") << "cabling DTC links : " << settings.DTCLinkFile(); - edm::LogVerbatim("Tracklet") << "module cabling : " << settings.moduleCablingFile(); - edm::LogVerbatim("Tracklet") << "DTC link layer disk : " << settings.DTCLinkLayerDiskFile(); - edm::LogVerbatim("Tracklet") << "fit pattern : " << settings.fitPatternFile(); edm::LogVerbatim("Tracklet") << "process modules : " << settings.processingModulesFile(); edm::LogVerbatim("Tracklet") << "memory modules : " << settings.memoryModulesFile(); From be7420e98581c1dfe6e56f14ebfe232ac1e879f5 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Mon, 29 Mar 2021 22:47:19 -0400 Subject: [PATCH 33/45] Correct missplaced curly bracket --- L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc index ff196500cf8c7..b8ec68163321c 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc @@ -143,11 +143,11 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { if (layerdisk == 1 || layerdisk == 2 || layerdisk == 3 || layerdisk == 5) { std::string fnamesuffix = "L" + to_string(layerdisk + 1); writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtable_); - // write disk teouter tables (D1, D2, D4) - if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { - std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); - writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); - } + } + // write disk teouter tables (D1, D2, D4) + if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { + std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); + writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); } } else { std::string fname = "VMRME_"; From c90b21623e131fee347b4f7cf08d402f109e1be3 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Fri, 2 Apr 2021 17:15:23 -0400 Subject: [PATCH 34/45] Fixes for the displaced tracking --- .../TrackFindingTracklet/interface/Settings.h | 2 +- .../src/ProjectionRouter.cc | 5 ++ .../src/TrackletCalculatorDisplaced.cc | 79 +++++++++++-------- .../TrackFindingTracklet/src/VMRouter.cc | 12 ++- L1Trigger/TrackFindingTracklet/test/fpga.cc | 4 + 5 files changed, 67 insertions(+), 35 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 94d6caaaa061a..a2b3d6c09efc0 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -837,7 +837,7 @@ namespace trklet { unsigned int nHelixPar_{4}; // 4 or 5 param helix fit bool extended_{false}; // turn on displaced tracking - bool combined_{true}; // use combined TP (TE+TC) and MP (PR+ME+MC) configuration + bool combined_{false}; // use combined TP (TE+TC) and MP (PR+ME+MC) configuration std::string skimfile_{""}; //if not empty events will be written out in ascii format to this file diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc index 6bb3b84c113b0..cbd534d581c17 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc @@ -132,6 +132,11 @@ void ProjectionRouter::execute() { vmprojs_[iphivm]->addTracklet(tracklet, allprojcount); + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " projection to " + << vmprojs_[iphivm]->getName() << " iphivm " << iphivm; + } + allprojcount++; } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 4ab7741d9a152..471ff11fbedb4 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -37,7 +37,7 @@ TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, disk_ = name1[4] - '0'; // set TC index - int iSeed_ = 0; + iSeed_ = 0; int iTC = name1[9] - 'A'; @@ -138,6 +138,7 @@ TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, for (unsigned int i = 0; i < N_DISK - 2; ++i) toZ_.push_back(zproj_[i]); } + } void TrackletCalculatorDisplaced::addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory) { @@ -150,6 +151,7 @@ void TrackletCalculatorDisplaced::addOutput(MemoryBase* memory, string output) { edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output " << output; } + if (output == "trackpar") { auto* tmp = dynamic_cast(memory); assert(tmp != nullptr); @@ -192,6 +194,7 @@ void TrackletCalculatorDisplaced::addInput(MemoryBase* memory, string input) { edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input " << input; } + if (input == "thirdallstubin") { auto* tmp = dynamic_cast(memory); assert(tmp != nullptr); @@ -301,19 +304,20 @@ void TrackletCalculatorDisplaced::execute(unsigned int iSector, double phimin, d void TrackletCalculatorDisplaced::addDiskProj(Tracklet* tracklet, int disk) { disk = std::abs(disk); - FPGAWord fpgar = tracklet->proj(disk).fpgarzproj(); + FPGAWord fpgar = tracklet->proj(N_LAYER+disk-1).fpgarzproj(); if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm()) return; if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk()) return; - FPGAWord fpgaphi = tracklet->proj(disk).fpgaphiproj(); + FPGAWord fpgaphi = tracklet->proj(N_LAYER+disk-1).fpgaphiproj(); int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5); int iphi = iphivmRaw / (32 / settings_.nallstubs(disk + N_LAYER -1)); addProjectionDisk(disk, iphi, trackletprojdisks_[disk - 1][iphi], tracklet); + } bool TrackletCalculatorDisplaced::addLayerProj(Tracklet* tracklet, int layer) { @@ -332,7 +336,7 @@ bool TrackletCalculatorDisplaced::addLayerProj(Tracklet* tracklet, int layer) { int iphi = iphivmRaw / (32 / settings_.nallstubs(layer - 1)); addProjection(layer, iphi, trackletprojlayers_[layer - 1][iphi], tracklet); - + return true; } @@ -588,9 +592,10 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, success = false; } - if (!success) + if (!success) { return false; - + } + double phicritapprox = phi0approx - asin(0.5 * settings_.rcrit() * rinvapprox); int phicrit = iphi0 - 2 * irinv; @@ -606,11 +611,13 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, "but not approximate, phicritapprox: " << phicritapprox; if (settings_.usephicritapprox()) { - if (!keepapprox) + if (!keepapprox) { return false; + } } else { - if (!keep) + if (!keep) { return false; + } } for (unsigned int i = 0; i < toR_.size(); ++i) { @@ -659,7 +666,6 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, projs[lproj_[i]-1].init(settings_, lproj_[i]-1, - rproj_[i], iphiproj[i], izproj[i], iphider[i], @@ -671,7 +677,8 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, phiprojapprox[i], zprojapprox[i], phiderapprox[i], - zderapprox[i]); + zderapprox[i], + false); } if (std::abs(it * kt) > 1.0) { @@ -707,6 +714,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, phiderdisk[i], rderdisk[i], false); + } } @@ -757,6 +765,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, bool addL6 = false; for (unsigned int j = 0; j < toR_.size(); j++) { bool added = false; + if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j]; if (tracklet->validProj(lproj_[j]-1)) { @@ -1066,7 +1075,6 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, projs[lproj_[i]-1].init(settings_, lproj_[i]-1, - rproj_[i], iphiproj[i], izproj[i], iphider[i], @@ -1078,12 +1086,14 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, phiprojapprox[i], zprojapprox[i], phiderapprox[i], - zderapprox[i]); - + zderapprox[i], + false); + } if (std::abs(it * kt) > 1.0) { for (unsigned int i = 0; i < toZ_.size(); ++i) { + iphiprojdisk[i] = phiprojdiskapprox[i] / kphiprojdisk; irprojdisk[i] = rprojdiskapprox[i] / krprojdisk; @@ -1098,8 +1108,8 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] < settings_.rmindisk() / krprojdisk || irprojdisk[i] > settings_.rmaxdisk() / krprojdisk) continue; - projs[N_LAYER + i].init(settings_, - N_LAYER + i, + projs[N_LAYER + i + 2].init(settings_, + N_LAYER + i + 2, iphiprojdisk[i], irprojdisk[i], iphiderdisk[i], @@ -1113,6 +1123,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, phiderdisk[i], rderdisk[i], false); + } } @@ -1176,7 +1187,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, disk = -disk; if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk << " " - << tracklet->validProj(N_LAYER + abs(disk) + 1); + << tracklet->validProj(N_LAYER + abs(disk) - 1); if (tracklet->validProj(N_LAYER+abs(disk)-1)) { addDiskProj(tracklet, disk); } @@ -1459,26 +1470,27 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, if (iphider[i] >= (1 << (settings_.nbitsphiprojderL456() - 1))) iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1; } - + projs[lproj_[i]-1].init(settings_, - lproj_[i]-1, - rproj_[i], - iphiproj[i], - izproj[i], - iphider[i], - izder[i], - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - phiderapprox[i], - zderapprox[i]); + lproj_[i]-1, + iphiproj[i], + izproj[i], + iphider[i], + izder[i], + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + phiderapprox[i], + zderapprox[i], + false); } if (std::abs(it * kt) > 1.0) { for (unsigned int i = 0; i < toZ_.size(); ++i) { + iphiprojdisk[i] = phiprojdiskapprox[i] / kphiprojdisk; irprojdisk[i] = rprojdiskapprox[i] / krprojdisk; @@ -1495,8 +1507,8 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] < settings_.rmindisk() / krprojdisk || irprojdisk[i] > settings_.rmaxdisk() / krprojdisk) continue; - projs[N_LAYER+i].init(settings_, - i, + projs[N_LAYER+i+1].init(settings_, + N_LAYER+i+1, iphiprojdisk[i], irprojdisk[i], iphiderdisk[i], @@ -1856,6 +1868,7 @@ void TrackletCalculatorDisplaced::approxtracklet(double r1, double rprojdisk[5], double phiderdisk[5], double rderdisk[5]) { + double a = 1.0 / ((r1 - r2) * (r1 - r3)); double b = 1.0 / ((r1 - r2) * (r2 - r3)); double c = 1.0 / ((r1 - r3) * (r2 - r3)); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc index 0d38c7adcb188..437b42a98cd9e 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc @@ -245,10 +245,20 @@ void VMRouter::execute() { assert(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) { assert(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 diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index 0f869dfd36671..e637331d5fd0e 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -109,6 +109,10 @@ int main(const int argc, const char **argv) { for (int eventnum = 0; eventnum < nevents && !in->eof(); eventnum++) { SLHCEvent ev(*in); + + //auto simtrk = ev.simtrack(0); + //if (std::abs(std::abs(simtrk.eta())-1.3)>0.1) continue; + // ----------------------------------------------------------------- // setup ROOT Tree and Add Monte Carlo tracks to the ROOT-Tree Event #ifdef USEROOT From b26fc19a5b0b57d585d8d825dcbea3945b4c4b84 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sat, 3 Apr 2021 10:38:07 -0400 Subject: [PATCH 35/45] Fix to avoid duplicate VMSTE name in D1 for standard configuration --- .../TrackFindingTracklet/src/TrackletConfigBuilder.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc index 080eba116c0cd..168a65b74cc47 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc @@ -899,8 +899,9 @@ void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& mem for (unsigned int iReg = 0; iReg < NRegions_[l2]; iReg++) { unsigned int nmem = 0; //Hack since we use same module twice - if (iSeed == 7) + if (iSeed == 7) { nmem = 2; + } for (unsigned iTC = 0; iTC < nTCReg; iTC++) { nmem++; @@ -948,6 +949,10 @@ void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& mem unsigned int nmem = 0; + if (iSeed == 7) { + nmem = 4; + } + for (unsigned int iTE = 0; iTE < TE_[iSeed].size(); iTE++) { unsigned int TE1 = TE_[iSeed][iTE].first; unsigned int TE2 = TE_[iSeed][iTE].second; From 576bda0b776ea1810e50a7a859b72e23f8518f1d Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sun, 4 Apr 2021 10:38:41 -0400 Subject: [PATCH 36/45] Address comments from Louise S. --- L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h | 2 +- L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h | 2 +- L1Trigger/TrackFindingTracklet/interface/L1TStub.h | 6 ++++-- L1Trigger/TrackFindingTracklet/src/L1TStub.cc | 5 ++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h b/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h index 267013d1783a3..e133757bbb70e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h +++ b/L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h @@ -28,7 +28,7 @@ namespace trklet { //Almost full if writer ptr incremented by 1 or 2 is same as read ptr bool almostfull() const { return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_); } - //Almost full if writer ptr incremented by 1 or 2 is same as read ptr + //near full if writer ptr incremented by 1, 2, or 3 is same as read ptr bool nearfull() const { return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_) || (((wptr_ + 3) % size_) == rptr_); } diff --git a/L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h b/L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h index 82c3c74ae3951..eddda2dbc1171 100644 --- a/L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h +++ b/L1Trigger/TrackFindingTracklet/interface/L1SimTrack.h @@ -1,4 +1,4 @@ -// This holds two classes: L1SimTrack (truth level simulated track), and SLHCEvent (support for maintaining standalone running) +// Stores MC truth information, pt, eta, phi, vx, vy, vz, as well as particle type and track id #ifndef L1Trigger_TrackFindingTracklet_interface_L1SimTrack_h #define L1Trigger_TrackFindingTracklet_interface_L1SimTrack_h diff --git a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h index 830ba732ed094..95a85bdaf4f1a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/L1TStub.h +++ b/L1Trigger/TrackFindingTracklet/interface/L1TStub.h @@ -1,6 +1,8 @@ #ifndef L1Trigger_TrackFindingTracklet_interface_L1TStub_h #define L1Trigger_TrackFindingTracklet_interface_L1TStub_h +#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" + #include #include #include @@ -38,10 +40,10 @@ namespace trklet { unsigned int layer() const { return layer_; } int disk() const { - if (layerdisk_ < 6) { + if (layerdisk_ < N_LAYER) { return 0; } - int disk = layerdisk_ - 5; + int disk = layerdisk_ - N_LAYER + 1; if (z_ < 0.0) { return -disk; } diff --git a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc index f46b219d4364b..d7cc37d26b863 100644 --- a/L1Trigger/TrackFindingTracklet/src/L1TStub.cc +++ b/L1Trigger/TrackFindingTracklet/src/L1TStub.cc @@ -1,5 +1,4 @@ #include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h" -#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" using namespace std; using namespace trklet; @@ -27,8 +26,8 @@ L1TStub::L1TStub(std::string DTClink, iphi_ = -1; iz_ = -1; layer_ = layerdisk; - if (layerdisk > 5) { - layer_ = 1000 + layerdisk - 5; + if (layerdisk >= N_LAYER) { + layer_ = 1000 + layerdisk - N_LAYER + 1; if (z < 0.0) layer_ += 1000; } From de0f8874e934db2d965bb4e0712acbb6f18added Mon Sep 17 00:00:00 2001 From: Anders Date: Sun, 4 Apr 2021 16:50:42 +0200 Subject: [PATCH 37/45] Ran scram b code-format --- .../interface/InputLinkMemory.h | 2 +- .../interface/InputRouter.h | 2 - .../interface/MatchEngineUnit.h | 6 +- .../interface/MatchProcessor.h | 2 +- .../interface/Projection.h | 3 +- .../interface/ProjectionTemp.h | 2 +- .../TrackFindingTracklet/interface/Sector.h | 3 +- .../TrackFindingTracklet/interface/Settings.h | 36 +-- .../TrackFindingTracklet/interface/Tracklet.h | 20 +- .../interface/TrackletCalculatorDisplaced.h | 2 +- .../interface/TrackletEventProcessor.h | 1 - .../interface/TrackletProcessor.h | 2 +- .../src/AllInnerStubsMemory.cc | 6 +- .../src/AllProjectionsMemory.cc | 4 +- .../src/AllStubsMemory.cc | 3 +- .../src/CandidateMatchMemory.cc | 4 +- .../src/CleanTrackMemory.cc | 4 +- .../TrackFindingTracklet/src/DTCLinkMemory.cc | 35 ++- .../TrackFindingTracklet/src/FitTrack.cc | 20 +- .../src/FullMatchMemory.cc | 4 +- .../src/InputLinkMemory.cc | 12 +- .../TrackFindingTracklet/src/InputRouter.cc | 37 ++- .../src/MatchCalculator.cc | 39 +-- .../TrackFindingTracklet/src/MatchEngine.cc | 10 +- .../src/MatchEngineUnit.cc | 32 +-- .../src/MatchProcessor.cc | 159 +++++++----- .../TrackFindingTracklet/src/Projection.cc | 92 ++++--- .../src/ProjectionRouter.cc | 14 +- .../src/ProjectionTemp.cc | 10 +- .../TrackFindingTracklet/src/Residual.cc | 18 +- L1Trigger/TrackFindingTracklet/src/Sector.cc | 8 +- .../src/StubPairsMemory.cc | 4 +- .../src/StubTripletsMemory.cc | 4 +- .../src/TrackFitMemory.cc | 1 - .../TrackFindingTracklet/src/Tracklet.cc | 85 ++++--- .../src/TrackletCalculator.cc | 4 +- .../src/TrackletCalculatorBase.cc | 215 ++++++++-------- .../src/TrackletCalculatorDisplaced.cc | 237 +++++++++--------- .../src/TrackletConfigBuilder.cc | 35 +-- .../src/TrackletEngineDisplaced.cc | 4 +- .../src/TrackletEventProcessor.cc | 117 ++++----- .../src/TrackletParametersMemory.cc | 1 - .../src/TrackletProcessor.cc | 32 ++- .../src/TrackletProjectionsMemory.cc | 11 +- .../src/VMProjectionsMemory.cc | 4 +- .../TrackFindingTracklet/src/VMRouter.cc | 26 +- .../TrackFindingTracklet/src/VMRouterTable.cc | 4 +- .../src/VMStubsMEMemory.cc | 4 +- .../src/VMStubsTEMemory.cc | 4 +- .../test/L1TrackNtupleMaker_cfg.py | 4 +- L1Trigger/TrackFindingTracklet/test/fpga.cc | 5 +- L1Trigger/TrackerDTC/src/Stub.cc | 3 +- 52 files changed, 686 insertions(+), 710 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h index 82a04a6f41bd1..90dae4b7ccf58 100644 --- a/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h +++ b/L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h @@ -21,7 +21,7 @@ namespace trklet { ~InputLinkMemory() override = default; - void addStub(Stub *stub); + void addStub(Stub* stub); unsigned int nStubs() const { return stubs_.size(); } diff --git a/L1Trigger/TrackFindingTracklet/interface/InputRouter.h b/L1Trigger/TrackFindingTracklet/interface/InputRouter.h index c4a0533625c78..55551d615ff21 100644 --- a/L1Trigger/TrackFindingTracklet/interface/InputRouter.h +++ b/L1Trigger/TrackFindingTracklet/interface/InputRouter.h @@ -29,13 +29,11 @@ namespace trklet { void execute(); private: - //The input stub memories DTCLinkMemory* dtcstubs_; //The all stub memories - the ints are layerdisk and phiregion std::vector, InputLinkMemory*> > irstubs_; - }; }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h index af759167e4180..f61a4a659ee7c 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h @@ -25,7 +25,7 @@ namespace trklet { unsigned int nrzbin, unsigned int rzbin, unsigned int iphi, - int shift, + int shift, int projrinv, int projfinerz, int projfinephi, @@ -57,7 +57,7 @@ namespace trklet { unsigned int rzbin_; unsigned int phibin_; int shift_; - + unsigned int istub_; unsigned int iuse_; @@ -77,7 +77,7 @@ namespace trklet { std::vector table_; //save the candidate matches - CircularBuffer > candmatches_; + CircularBuffer> candmatches_; }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h index f693674f71581..cbda531d96186 100644 --- a/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/MatchProcessor.h @@ -75,7 +75,7 @@ namespace trklet { std::vector table_; double phimin_; - + unsigned int nMatchEngines_; std::vector matchengines_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Projection.h b/L1Trigger/TrackFindingTracklet/interface/Projection.h index 234b17820d964..80739c56672d5 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Projection.h +++ b/L1Trigger/TrackFindingTracklet/interface/Projection.h @@ -117,7 +117,7 @@ namespace trklet { }; void setBendIndex(int bendindex) { fpgabendindex_.set(bendindex, 5, true, __LINE__, __FILE__); } - + const FPGAWord& getBendIndex() const { return fpgabendindex_; } protected: @@ -147,7 +147,6 @@ namespace trklet { //used by projections to disks FPGAWord fpgabendindex_; - }; }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h index f41badeaa14df..4ae109277ead6 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h @@ -14,7 +14,7 @@ namespace trklet { int projfinerz, unsigned int projfinephi, unsigned int iphi, - int shift, + int shift, bool usefirstMinus, bool usefirstPlus, bool usesecondMinus, diff --git a/L1Trigger/TrackFindingTracklet/interface/Sector.h b/L1Trigger/TrackFindingTracklet/interface/Sector.h index 8b336d56afb3c..ab3d67bdb39e7 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Sector.h +++ b/L1Trigger/TrackFindingTracklet/interface/Sector.h @@ -66,7 +66,7 @@ namespace trklet { //Set the sector void setSector(unsigned int isector); - + bool addStub(L1TStub stub, std::string dtc); //TODO - should be pointer or string // Creates all required memory modules based on wiring map (args: module type, module instance) @@ -180,7 +180,6 @@ namespace trklet { std::vector > MP_; std::vector > FT_; std::vector > PD_; - }; }; // namespace trklet #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index a2b3d6c09efc0..b1912dff67ee8 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -134,9 +134,9 @@ namespace trklet { assert(layerdisk >= 0); return layerdisk; } - + unsigned int teunits(unsigned int iSeed) const { return teunits_[iSeed]; } - + unsigned int NTC(int seed) const { return ntc_[seed]; } unsigned int projlayers(unsigned int iSeed, unsigned int i) const { return projlayers_[iSeed][i]; } @@ -545,9 +545,8 @@ namespace trklet { int chisqphifactbits_{14}; int chisqzfactbits_{14}; - std::array teunits_{ - {5, 2, 5, 3, 3, 2, 3, 2, 0, 0, 0, 0}}; //teunits used by seed - + std::array teunits_{{5, 2, 5, 3, 3, 2, 3, 2, 0, 0, 0, 0}}; //teunits used by seed + std::array vmrlutzbits_{ {7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3}}; // zbits used by LUT in VMR std::array vmrlutrbits_{ @@ -731,18 +730,21 @@ namespace trklet { {"TRE", 108}}; // If set to true this will generate debub printout in text files - std::unordered_map writeMonitorData_{ - {"IL", false}, {"TE", false}, {"CT", false}, - {"HitPattern", false}, {"ChiSq", false}, {"Seeds", false}, - {"FT", false}, {"Residuals", false}, {"StubBend", false}, - {"MC", false}, {"MP", false}, {"ME", false}, - {"AP", false}, {"VMP", false}, - {"TrackProjOcc", false}, {"TC", false}, {"Pars", false}, - {"TPars", false}, {"TPD", false}, {"TrackletPars", false}, - {"TED", false}, {"TP", false}, {"TRE", false}, - {"VMR", false}, {"StubsLayer", false}, {"StubsLayerSector", false}, - {"HitEff", false}, {"MatchEff", false}, - {"IFit", false}, {"AS", false}}; + std::unordered_map writeMonitorData_{{"IL", false}, {"TE", false}, + {"CT", false}, {"HitPattern", false}, + {"ChiSq", false}, {"Seeds", false}, + {"FT", false}, {"Residuals", false}, + {"StubBend", false}, {"MC", false}, + {"MP", false}, {"ME", false}, + {"AP", false}, {"VMP", false}, + {"TrackProjOcc", false}, {"TC", false}, + {"Pars", false}, {"TPars", false}, + {"TPD", false}, {"TrackletPars", false}, + {"TED", false}, {"TP", false}, + {"TRE", false}, {"VMR", false}, + {"StubsLayer", false}, {"StubsLayerSector", false}, + {"HitEff", false}, {"MatchEff", false}, + {"IFit", false}, {"AS", false}}; std::array rDSSinner_mod_{{68.9391, 78.7750, 85.4550, 96.3150, 102.3160}}; std::array rDSSouter_mod_{{66.4903, 76.7750, 84.4562, 94.9920, 102.3160}}; diff --git a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h index 7b42b1b7e7f01..30e1ae3900ec3 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Tracklet.h +++ b/L1Trigger/TrackFindingTracklet/interface/Tracklet.h @@ -27,7 +27,7 @@ namespace trklet { class Tracklet { public: Tracklet(Settings const& settings, - unsigned int iSeed, + unsigned int iSeed, const Stub* innerFPGAStub, const Stub* middleFPGAStub, const Stub* outerFPGAStub, @@ -46,7 +46,7 @@ namespace trklet { int id0, int iz0, int it, - Projection projs[N_LAYER+N_DISK], + Projection projs[N_LAYER + N_DISK], bool disk, bool overlap = false); @@ -80,7 +80,7 @@ namespace trklet { std::string trackletprojstrdisk(int disk) const { return trackletprojstrD(disk); } bool validProj(int layerdisk) const { - assert(layerdisk >= 0 && layerdisk < N_LAYER+N_DISK); + assert(layerdisk >= 0 && layerdisk < N_LAYER + N_DISK); return proj_[layerdisk].valid(); } @@ -89,9 +89,15 @@ namespace trklet { return proj_[layerdisk]; } - void addMatch(unsigned int layerdisk, int ideltaphi, int ideltarz, - double dphi, double drz, double dphiapprox, double drzapprox, - int stubid, const trklet::Stub* stubptr); + void addMatch(unsigned int layerdisk, + int ideltaphi, + int ideltarz, + double dphi, + double drz, + double dphiapprox, + double drzapprox, + int stubid, + const trklet::Stub* stubptr); std::string fullmatchstr(int layer); std::string fullmatchdiskstr(int disk); @@ -260,7 +266,7 @@ namespace trklet { std::unique_ptr fpgatrack_; Projection proj_[N_LAYER + N_DISK]; - + Residual resid_[N_LAYER + N_DISK]; Settings const& settings_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h index 90380054ab669..9bc51a81d34c8 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletCalculatorDisplaced.h @@ -168,7 +168,7 @@ namespace trklet { unsigned int iSector_; double phimin_, phimax_; - + std::vector toR_; std::vector toZ_; diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h index 8e3fe01adc5ed..114b2f0e32dc5 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletEventProcessor.h @@ -63,7 +63,6 @@ namespace trklet { Timer PDTimer_; std::vector tracks_; - }; }; // namespace trklet diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h index a7e0aceb18ebb..c32a718681fc1 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h @@ -44,7 +44,7 @@ namespace trklet { int iAllStub_; unsigned int maxStep_; - + VMStubsTEMemory* outervmstubs_; // istub imem start imem end imem diff --git a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc index 4b3b6ddc28c8b..5ee9e5b1cda63 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllInnerStubsMemory.cc @@ -6,12 +6,10 @@ using namespace std; using namespace trklet; -AllInnerStubsMemory::AllInnerStubsMemory(string name, Settings const& settings) - : MemoryBase(name, settings) {} +AllInnerStubsMemory::AllInnerStubsMemory(string name, Settings const& settings) : MemoryBase(name, settings) {} void AllInnerStubsMemory::writeStubs(bool first, unsigned int iSector) { - - iSector_ = iSector; + iSector_ = iSector; const string dirS = settings_.memPath() + "Stubs/"; openFile(first, dirS, "AllInnerStubs_"); diff --git a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc index 9c1232028dbe9..d15cb03d753de 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllProjectionsMemory.cc @@ -10,13 +10,11 @@ using namespace trklet; using namespace std; -AllProjectionsMemory::AllProjectionsMemory(string name, Settings const& settings) - : MemoryBase(name, settings) { +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/"; diff --git a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc index ecf249f61e585..db3993fdd74c5 100644 --- a/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/AllStubsMemory.cc @@ -6,8 +6,7 @@ using namespace std; using namespace trklet; -AllStubsMemory::AllStubsMemory(string name, Settings const& settings) - : MemoryBase(name, settings) {} +AllStubsMemory::AllStubsMemory(string name, Settings const& settings) : MemoryBase(name, settings) {} void AllStubsMemory::writeStubs(bool first, unsigned int iSector) { iSector_ = iSector; diff --git a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc index 122d143c930ad..06092b28350ed 100644 --- a/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CandidateMatchMemory.cc @@ -11,8 +11,7 @@ using namespace std; using namespace trklet; -CandidateMatchMemory::CandidateMatchMemory(string name, Settings const& settings) - : MemoryBase(name, settings) {} +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); @@ -29,7 +28,6 @@ void CandidateMatchMemory::addMatch(std::pair tracklet, const St } void CandidateMatchMemory::writeCM(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirM = settings_.memPath() + "Matches/"; diff --git a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc index 93fcfe6879176..b5adf1859e29c 100644 --- a/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/CleanTrackMemory.cc @@ -7,15 +7,13 @@ using namespace std; using namespace trklet; -CleanTrackMemory::CleanTrackMemory( - string name, Settings const& settings, double phimin, double phimax) +CleanTrackMemory::CleanTrackMemory(string name, Settings const& settings, double phimin, double phimax) : MemoryBase(name, settings) { phimin_ = phimin; phimax_ = phimax; } void CleanTrackMemory::writeCT(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirCT = settings_.memPath() + "CleanTrack/"; diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc index 7e4b516baea37..ff092e5f90c21 100644 --- a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc @@ -14,12 +14,9 @@ using namespace trklet; using namespace std; -DTCLinkMemory::DTCLinkMemory(string name, Settings const& settings, double, double) - : MemoryBase(name, settings) { -} +DTCLinkMemory::DTCLinkMemory(string name, Settings const& settings, double, double) : MemoryBase(name, settings) {} void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { - //Make new objects owned by the dtclink memory and save in list of stubs if (stubs_.size() < settings_.maxStep("IR")) { Stub* stubptr = new Stub(stub); @@ -30,23 +27,21 @@ void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { } void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { - iSector_ = iSector; //FIXME should be in settings static map > dtclayers{{"PS10G_1", {0, 6, 8, 10}}, {"PS10G_2", {0, 7, 9}}, - {"PS10G_3", {1, 7}}, - {"PS10G_4", {6, 8, 10}}, - {"PS_1", {2, 7}}, - {"PS_2", {2, 9}}, - {"2S_1", {3, 4}}, - {"2S_2", {4}}, - {"2S_3", {5}}, - {"2S_4", {5, 8}}, - {"2S_5", {6, 9}}, - {"2S_6", {7, 10}}}; - - + {"PS10G_3", {1, 7}}, + {"PS10G_4", {6, 8, 10}}, + {"PS_1", {2, 7}}, + {"PS_2", {2, 9}}, + {"2S_1", {3, 4}}, + {"2S_2", {4}}, + {"2S_3", {5}}, + {"2S_4", {5, 8}}, + {"2S_5", {6, 9}}, + {"2S_6", {7, 10}}}; + const string dirIS = settings_.memPath() + "InputStubs/"; openFile(first, dirIS, "Link_"); @@ -63,14 +58,14 @@ void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { int lcode = -1; for (unsigned int index = 0; index < layers.size(); index++) { if (layerdisk == layers[index]) { - lcode = index; + lcode = index; } } assert(lcode != -1); FPGAWord ldcode(lcode, 2, true); - - string stub = stubs_[j]->str()+"|"+ldcode.str()+"|1"; + + string stub = stubs_[j]->str() + "|" + ldcode.str() + "|1"; out_ << std::setfill('0') << std::setw(2); out_ << hex << j << dec; out_ << " " << stub << " " << trklet::hexFormat(stub) << endl; diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index d93bfca5632ae..6b362683478fb 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -200,8 +200,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: layers[nlayers++] = l; continue; } - if (tracklet->match(l-1)) { - const Residual& resid = tracklet->resid(l-1); + if (tracklet->match(l - 1)) { + const Residual& resid = tracklet->resid(l - 1); lmatches.set(N_LAYER - l); layermask |= (1 << (N_LAYER - l)); phiresid[nlayers] = resid.phiresidapprox(); @@ -226,7 +226,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: continue; if (tracklet->match(N_LAYER + d - 1)) { const Residual& resid = tracklet->resid(N_LAYER + d - 1); - double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); + double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * d - 1); diskmask |= (1 << (2 * (N_DISK - d) + 1)); @@ -301,7 +301,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: continue; if (tracklet->match(N_LAYER + abs(d) - 1)) { const Residual& resid = tracklet->resid(N_LAYER + abs(d) - 1); - double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); + double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * d1 - 1); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); @@ -376,7 +376,7 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: continue; if (tracklet->match(N_LAYER + abs(d) - 1)) { const Residual& resid = tracklet->resid(N_LAYER + abs(d) - 1); - double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); + double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule()); if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) { dmatches.set(2 * (N_DISK - d1)); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); @@ -874,14 +874,14 @@ void FitTrack::execute(unsigned int iSector) { const std::vector& matches3 = orderedMatches(fullmatch3_); const std::vector& matches4 = orderedMatches(fullmatch4_); - iSector_ = iSector; + iSector_ = iSector; if (settings_.debugTracklet() && (matches1.size() + matches2.size() + matches3.size() + matches4.size()) > 0) { for (auto& imatch : fullmatch1_) { edm::LogVerbatim("Tracklet") << imatch->getName() << " " << imatch->nMatches(); } - edm::LogVerbatim("Tracklet") << getName() << " matches : " << matches1.size() << " " - << matches2.size() << " " << matches3.size() << " " << matches4.size(); + edm::LogVerbatim("Tracklet") << getName() << " matches : " << matches1.size() << " " << matches2.size() << " " + << matches3.size() << " " << matches4.size(); } unsigned int indexArray[4]; @@ -1012,8 +1012,8 @@ void FitTrack::execute(unsigned int iSector) { assert(trackfit_ != nullptr); if (settings_.writeMonitorData("Seeds")) { ofstream fout("seeds.txt", ofstream::app); - fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << " " << bestTracklet->getISeed() - << endl; + fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" + << " " << bestTracklet->getISeed() << endl; fout.close(); } bestTracklet->setTrackIndex(trackfit_->nTracks()); diff --git a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc index 9c69056e2b9bb..f4bf27d54e5e1 100644 --- a/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/FullMatchMemory.cc @@ -9,8 +9,7 @@ using namespace std; using namespace trklet; -FullMatchMemory::FullMatchMemory(string name, Settings const& settings) - : MemoryBase(name, settings) { +FullMatchMemory::FullMatchMemory(string name, Settings const& settings) : MemoryBase(name, settings) { size_t pos = find_nth(name, 0, "_", 1); assert(pos != string::npos); initLayerDisk(pos + 1, layer_, disk_); @@ -40,7 +39,6 @@ void FullMatchMemory::addMatch(Tracklet* tracklet, const Stub* stub) { } void FullMatchMemory::writeMC(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirM = settings_.memPath() + "Matches/"; diff --git a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc index 9d4c5a75fcc79..92affaed962c9 100644 --- a/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/InputLinkMemory.cc @@ -14,15 +14,11 @@ using namespace trklet; using namespace std; -InputLinkMemory::InputLinkMemory(string name, Settings const& settings, double, double) - : MemoryBase(name, settings) {} +InputLinkMemory::InputLinkMemory(string name, Settings const& settings, double, double) : MemoryBase(name, settings) {} -void InputLinkMemory::addStub(Stub* stub) { - stubs_.push_back(stub); -} +void InputLinkMemory::addStub(Stub* stub) { stubs_.push_back(stub); } void InputLinkMemory::writeStubs(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirIS = settings_.memPath() + "InputStubs/"; openFile(first, dirIS, "InputStubs_"); @@ -36,6 +32,4 @@ void InputLinkMemory::writeStubs(bool first, unsigned int iSector) { out_.close(); } -void InputLinkMemory::clean() { - stubs_.clear(); -} +void InputLinkMemory::clean() { stubs_.clear(); } diff --git a/L1Trigger/TrackFindingTracklet/src/InputRouter.cc b/L1Trigger/TrackFindingTracklet/src/InputRouter.cc index b527e786960e6..2ee8e965a90c1 100644 --- a/L1Trigger/TrackFindingTracklet/src/InputRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/InputRouter.cc @@ -13,8 +13,7 @@ using namespace std; using namespace trklet; InputRouter::InputRouter(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global) { -} + : ProcessBase(name, settings, global) {} void InputRouter::addOutput(MemoryBase* memory, string output) { if (settings_.writetrace()) { @@ -25,18 +24,17 @@ void InputRouter::addOutput(MemoryBase* memory, string output) { if (output == "stubout") { InputLinkMemory* tmp = dynamic_cast(memory); assert(tmp != nullptr); - unsigned int layerdisk=tmp->getName()[4]-'1'; - if (tmp->getName()[3]=='D') { - layerdisk+=N_LAYER; + unsigned int layerdisk = tmp->getName()[4] - '1'; + if (tmp->getName()[3] == 'D') { + layerdisk += N_LAYER; } assert(layerdisk < N_LAYER + N_DISK); - unsigned int phireg = tmp->getName()[8]-'A'; - std::pair layerphireg(layerdisk,phireg); + unsigned int phireg = tmp->getName()[8] - 'A'; + std::pair layerphireg(layerdisk, phireg); irstubs_.emplace_back(layerphireg, tmp); return; } - throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output; } @@ -54,31 +52,28 @@ void InputRouter::addInput(MemoryBase* memory, string input) { } void InputRouter::execute() { - for (unsigned int i = 0; i < settings_.maxStep("IR"); i++) { - - if (i>=dtcstubs_->nStubs()) { + if (i >= dtcstubs_->nStubs()) { break; } - + Stub* stub = dtcstubs_->getStub(i); - unsigned int layerdisk = stub->l1tstub()->layerdisk(); + unsigned int layerdisk = stub->l1tstub()->layerdisk(); FPGAWord iphi = stub->phicorr(); - unsigned int iphipos = iphi.value()>>(iphi.nbits() - settings_.nbitsallstubs(layerdisk)); + unsigned int iphipos = iphi.value() >> (iphi.nbits() - settings_.nbitsallstubs(layerdisk)); - std::pair layerphireg(layerdisk,iphipos); + std::pair layerphireg(layerdisk, iphipos); //Fill inner allstubs memories - in HLS this is the same write to multiple memories - int iadd=0; + int iadd = 0; for (auto& irstubmem : irstubs_) { - if (layerphireg==irstubmem.first) { - irstubmem.second->addStub(stub); - iadd++; + if (layerphireg == irstubmem.first) { + irstubmem.second->addStub(stub); + iadd++; } } - assert(iadd==1); + assert(iadd == 1); } - } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index bfb429c648bee..9a968e103284c 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -20,7 +20,6 @@ using namespace trklet; MatchCalculator::MatchCalculator(string name, Settings const& settings, Globals* global) : ProcessBase(name, settings, global) { - phiregion_ = name[8] - 'A'; layerdisk_ = initLayerDisk(3); @@ -248,13 +247,11 @@ void MatchCalculator::execute(double phioffset) { double dr = r - settings_.rmean(layerdisk_); assert(std::abs(dr) < settings_.drmax()); - double dphi = - reco::reduceRange(phi - (proj.phiproj() + dr * proj.phiprojder())); + double dphi = reco::reduceRange(phi - (proj.phiproj() + dr * proj.phiprojder())); double dz = z - (proj.rzproj() + dr * proj.rzprojder()); - double dphiapprox = reco::reduceRange( - phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox())); double dzapprox = z - (proj.rzprojapprox() + dr * proj.rzprojderapprox()); @@ -318,8 +315,13 @@ void MatchCalculator::execute(double phioffset) { if (imatch) { countsel++; - tracklet->addMatch(layerdisk_, ideltaphi, ideltaz, - dphi, dz, dphiapprox, dzapprox, + tracklet->addMatch(layerdisk_, + ideltaphi, + ideltaz, + dphi, + dz, + dphiapprox, + dzapprox, (phiregion_ << 7) + fpgastub->stubindex().value(), mergedMatches[j].second); @@ -403,9 +405,8 @@ void MatchCalculator::execute(double phioffset) { 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; + throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " " << name_ << " " << tracklet->getISeed() + << "\n stub " << stub->z() << " disk " << disk << " " << dz; } double phiproj = proj.phiproj() + dz * proj.phiprojder(); @@ -418,8 +419,7 @@ void MatchCalculator::execute(double phioffset) { double dphi = reco::reduceRange(phi - phiproj); - double dphiapprox = - reco::reduceRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox())); double drapprox = stub->r() - (proj.rzprojapprox() + dz * proj.rzprojderapprox()); @@ -480,11 +480,16 @@ void MatchCalculator::execute(double phioffset) { 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); - + 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; } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index fd58524e18fcf..f0594443943de 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -15,8 +15,7 @@ using namespace std; using namespace trklet; -MatchEngine::MatchEngine(string name, Settings const& settings, Globals* global) - : ProcessBase(name, settings, global) { +MatchEngine::MatchEngine(string name, Settings const& settings, Globals* global) : ProcessBase(name, settings, global) { layerdisk_ = initLayerDisk(3); barrel_ = layerdisk_ < N_LAYER; @@ -245,10 +244,9 @@ void MatchEngine::execute() { 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(); + 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()) { diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc index 96e62d12eae5b..6bea2f165c795 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc @@ -14,7 +14,7 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, unsigned int nrzbins, unsigned int rzbin, unsigned int phibin, - int shift, + int shift, int projrinv, int projfinerz, int projfinephi, @@ -37,18 +37,18 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory, projfinephi_ = projfinephi; use_.clear(); if (usefirstMinus) { - use_.emplace_back(0,0); + use_.emplace_back(0, 0); } if (usefirstPlus) { - use_.emplace_back(0,1); + use_.emplace_back(0, 1); } if (usesecondMinus) { - use_.emplace_back(1,0); + use_.emplace_back(1, 0); } if (usesecondPlus) { - use_.emplace_back(1,1); + use_.emplace_back(1, 1); } - assert(use_.size()!=0); + assert(use_.size() != 0); isPSseed_ = isPSseed; proj_ = proj; } @@ -57,17 +57,17 @@ void MatchEngineUnit::step(bool print) { if (idle() || candmatches_.almostfull()) return; - unsigned int slot = (phibin_+use_[iuse_].second)*nrzbins_+rzbin_+use_[iuse_].first; + unsigned int slot = (phibin_ + use_[iuse_].second) * nrzbins_ + rzbin_ + use_[iuse_].first; int projfinerz = projfinerz_ - (1 << NFINERZBITS) * use_[iuse_].first; int projfinephi = projfinephi_; - if (use_[iuse_].second==0) { - if (shift_==-1) { + if (use_[iuse_].second == 0) { + if (shift_ == -1) { projfinephi -= (1 << NFINEPHIBITS); } } else { //When we get here shift_ is either 1 or -1 - if (shift_==1) { + if (shift_ == 1) { projfinephi += (1 << NFINEPHIBITS); } } @@ -78,7 +78,7 @@ void MatchEngineUnit::step(bool print) { int stubfinerz = vmstub.finerz().value(); int stubfinephi = vmstub.finephi().value(); - int deltaphi = stubfinephi - projfinephi; + int deltaphi = stubfinephi - projfinephi; bool dphicut = (abs(deltaphi) < 3); @@ -106,9 +106,11 @@ void MatchEngineUnit::step(bool print) { } } - if (print) cout <<"MEU TrkId stubindex : "<<128*proj_->TCIndex()+proj_->trackletIndex()<<" "<TCIndex() + proj_->trackletIndex() << " " + << vmstub.stubindex().value() << " " << ((pass && dphicut) && table_[index]) << " index=" << index + << " projrinv bend : " << projrinv_ << " " << vmstub.bend().value() << " shift_ isPSseed_ :" << shift_ << " " + << isPSseed_ << " slot=" << slot << endl; //Check if stub bend and proj rinv consistent if ((pass && dphicut) && table_[index]) { @@ -119,7 +121,7 @@ void MatchEngineUnit::step(bool print) { istub_++; if (istub_ >= vmstubsmemory_->nStubsBin(slot)) { iuse_++; - if (iuse_nTracklets(); } @@ -256,13 +256,13 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { FPGAWord fpgaphi = proj->proj(layerdisk_).fpgaphiproj(); - //if (print) cout << "PROJECTION "<getName()<<": "<proj(layerdisk_).fpgaphiproj().value() - // << " " << proj->proj(layerdisk_).fpgarzproj().value() - // << " " << proj->proj(layerdisk_).fpgaphiprojder().value() - // << " " << proj->proj(layerdisk_).fpgarzprojder().value() - // << "TC index trackletIndex : "<TCIndex()<<" "<trackletIndex() - // <getName()<<": "<proj(layerdisk_).fpgaphiproj().value() + // << " " << proj->proj(layerdisk_).fpgarzproj().value() + // << " " << proj->proj(layerdisk_).fpgaphiprojder().value() + // << " " << proj->proj(layerdisk_).fpgarzprojder().value() + // << "TC index trackletIndex : "<TCIndex()<<" "<trackletIndex() + // <> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); int nextrabits = 2; @@ -270,40 +270,41 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits, nextrabits); - if (print) cout << "iphi extrabits: "<proj(layerdisk_).fpgaphiprojder(); - projrinv = (1 << (nrinv_ - 1)) - 1 - (phider.value() >> (phider.nbits() - nrinv_)); + FPGAWord phider = proj->proj(layerdisk_).fpgaphiprojder(); + projrinv = (1 << (nrinv_ - 1)) - 1 - (phider.value() >> (phider.nbits() - nrinv_)); } else { //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->proj(layerdisk_).fpgarzproj().value() >> (proj->proj(layerdisk_).fpgarzproj().nbits() - nrbits_)) & + int rindex = (proj->proj(layerdisk_).fpgarzproj().value() >> + (proj->proj(layerdisk_).fpgarzproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); int phiderindex = (proj->proj(layerdisk_).fpgaphiprojder().value() >> (proj->proj(layerdisk_).fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); - + int signindex = proj->proj(layerdisk_).fpgarzprojder().value() < 0; int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex; @@ -311,16 +312,16 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { projrinv = globals_->projectionRouterBendTable()->bendLoookup(layerdisk_ - N_LAYER, bendindex); proj->proj(layerdisk_).setBendIndex(projrinv); - } assert(projrinv >= 0); unsigned int slot = proj->proj(layerdisk_).fpgarzbin1projvm().value(); bool second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); - if (print) cout << "istep="<TCIndex()+proj->trackletIndex() - <<" ivmMinus ivmPlus shift "<TCIndex() + proj->trackletIndex() + << " ivmMinus ivmPlus shift " << ivmMinus << " " << ivmPlus << " " << shift << "second: " << second + << " iphiproj=" << fpgaphi.value() << endl; unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + 3))) & 7; int projfinerz = proj->proj(layerdisk_).fpgafinerzvm().value(); @@ -335,16 +336,27 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { bool usefirstMinus = stubmem->nStubsBin(ivmMinus * nbins + slot) != 0; bool usesecondMinus = (second && (stubmem->nStubsBin(ivmMinus * nbins + slot + 1) != 0)); bool usefirstPlus = ivmPlus != ivmMinus && stubmem->nStubsBin(ivmPlus * nbins + slot) != 0; - bool usesecondPlus = ivmPlus != ivmMinus && (second && (stubmem->nStubsBin(ivmPlus * nbins + slot + 1) != 0)); - - bool useProj = usefirstPlus || usesecondPlus || usefirstMinus || usesecondMinus; - - if (useProj) { - ProjectionTemp tmpProj(proj, slot, projrinv, projfinerz, projfinephi, - ivmMinus, shift, usefirstMinus, usefirstPlus, usesecondMinus, usesecondPlus, isPSseed); - inputProjBuffer_.store(tmpProj); - } - + bool usesecondPlus = + ivmPlus != ivmMinus && (second && (stubmem->nStubsBin(ivmPlus * nbins + slot + 1) != 0)); + + bool useProj = usefirstPlus || usesecondPlus || usefirstMinus || usesecondMinus; + + if (useProj) { + ProjectionTemp tmpProj(proj, + slot, + projrinv, + projfinerz, + projfinephi, + ivmMinus, + shift, + usefirstMinus, + usefirstPlus, + usesecondMinus, + usesecondPlus, + isPSseed); + inputProjBuffer_.store(tmpProj); + } + iproj++; if (iproj == projMem->nTracklets()) { iproj = 0; @@ -378,19 +390,19 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { if (layerdisk_ >= 6) nbins = 16; - //if (print) cout << "istep = "<l1tstub(); - if (print) cout << "MatchCalculator istep="<TCIndex()+tracklet->trackletIndex()<<" "<allStubIndex().value()<TCIndex() + tracklet->trackletIndex() << " " + << fpgastub->allStubIndex().value() << endl; + if (layerdisk_ < N_LAYER) { const Projection& proj = tracklet->proj(layerdisk_); int ir = fpgastub->r().value(); @@ -474,7 +489,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b int ideltaphi = (fpgastub->phi().value() - iphi) << phishift_; //if (print) cout << "ideltaphi : " << fpgastub->phi().value()<<" "<phi(); @@ -500,8 +515,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b double dz = z - (proj.rzproj() + dr * proj.rzprojder()); - double dphiapprox = - reco::reduceRange(phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox())); double dzapprox = z - (proj.rzprojapprox() + dr * proj.rzprojderapprox()); @@ -535,9 +549,11 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b << endl; } - if (print) cout << "delta phi : "<< ideltaphi << " " << phimatchcut_[seedindex] << endl; - if (print) cout << "delta z : "<< (ideltaz << dzshift_) << " " << zmatchcut_[seedindex] << endl; - + if (print) + cout << "delta phi : " << ideltaphi << " " << phimatchcut_[seedindex] << endl; + if (print) + cout << "delta z : " << (ideltaz << dzshift_) << " " << zmatchcut_[seedindex] << endl; + bool imatch = ((unsigned int)std::abs(ideltaphi) <= phimatchcut_[seedindex]) && ((unsigned int)std::abs(ideltaz << dzshift_) <= zmatchcut_[seedindex]); @@ -554,18 +570,24 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b } if (imatch) { - tracklet->addMatch(layerdisk_, ideltaphi, ideltaz, - dphi, dz, dphiapprox, dzapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), - fpgastub); - + tracklet->addMatch(layerdisk_, + ideltaphi, + ideltaz, + dphi, + dz, + dphiapprox, + dzapprox, + (phiregion_ << 7) + fpgastub->stubindex().value(), + fpgastub); + if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet; } int iSeed = tracklet->getISeed(); assert(fullmatches_[iSeed] != nullptr); - if (print) cout << "istep = "<addMatch(tracklet, fpgastub); return true; @@ -586,7 +608,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b int iz = fpgastub->z().value(); const Projection& proj = tracklet->proj(layerdisk_); - + int iphi = proj.fpgaphiproj().value(); int iphicorr = (iz * proj.fpgaphiprojder().value()) >> icorrshift_; @@ -640,8 +662,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b double dz = z - sign * settings_.zmean(layerdisk_ - N_LAYER); if (std::abs(dz) > settings_.dzmax()) { - edm::LogProblem("Tracklet") << __FILE__ << ":" << __LINE__ << " " << name_ << " " - << tracklet->getISeed(); + edm::LogProblem("Tracklet") << __FILE__ << ":" << __LINE__ << " " << name_ << " " << tracklet->getISeed(); edm::LogProblem("Tracklet") << "stub " << stub->z() << " disk " << disk << " " << dz; assert(std::abs(dz) < settings_.dzmax()); } @@ -655,8 +676,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b double dphi = reco::reduceRange(phi - phiproj); - double dphiapprox = - reco::reduceRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox())); + double dphiapprox = reco::reduceRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox())); double drphi = dphi * stub->r(); double drphiapprox = dphiapprox * stub->r(); @@ -713,11 +733,16 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b assert(std::abs(dphi) < 0.25); assert(std::abs(dphiapprox) < 0.25); - tracklet->addMatch(layerdisk_, ideltaphi, ideltar, - drphi / stub->r(), dr, drphiapprox / stub->r(), drapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), - fpgastub); - + 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; } diff --git a/L1Trigger/TrackFindingTracklet/src/Projection.cc b/L1Trigger/TrackFindingTracklet/src/Projection.cc index a6b68dec55551..48dbb93cf0e4e 100644 --- a/L1Trigger/TrackFindingTracklet/src/Projection.cc +++ b/L1Trigger/TrackFindingTracklet/src/Projection.cc @@ -9,24 +9,24 @@ using namespace std; using namespace trklet; void Projection::init(Settings const& settings, - unsigned int layerdisk, - int iphiproj, - int irzproj, - int iphider, - int irzder, - double phiproj, - double rzproj, - double phiprojder, - double rzprojder, - double phiprojapprox, - double rzprojapprox, - double phiprojderapprox, - double rzprojderapprox, - bool isPSseed) { - assert(layerdisk < N_LAYER+N_DISK); + unsigned int layerdisk, + int iphiproj, + int irzproj, + int iphider, + int irzder, + double phiproj, + double rzproj, + double phiprojder, + double rzprojder, + double phiprojapprox, + double rzprojapprox, + double phiprojderapprox, + double rzprojderapprox, + bool isPSseed) { + assert(layerdisk < N_LAYER + N_DISK); valid_ = true; - + fpgaphiproj_.set(iphiproj, settings.nphibitsstub(layerdisk), true, __LINE__, __FILE__); if (layerdisk < N_LAYER) { @@ -35,7 +35,6 @@ void Projection::init(Settings const& settings, fpgarzproj_.set(irzproj, settings.nrbitsstub(layerdisk), false, __LINE__, __FILE__); } - if (layerdisk < N_LAYER) { if (layerdisk < N_PSLAYER) { fpgaphiprojder_.set(iphider, settings.nbitsphiprojderL123(), false, __LINE__, __FILE__); @@ -50,65 +49,63 @@ void Projection::init(Settings const& settings, } if (layerdisk < N_LAYER) { - ////Separate the vm projections into zbins ////This determines the central bin: ////int zbin=4+(zproj.value()>>(zproj.nbits()-3)); ////But we need some range (particularly for L5L6 seed projecting to L1-L3): - int offset = isPSseed?1:4; - + int offset = isPSseed ? 1 : 4; + int ztemp = fpgarzproj_.value() >> (fpgarzproj_.nbits() - settings.MEBinsBits() - NFINERZBITS); - unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp - offset) >> NFINERZBITS); - unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + (( ztemp + offset) >> NFINERZBITS); - + unsigned int zbin1 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp - offset) >> NFINERZBITS); + unsigned int zbin2 = (1 << (settings.MEBinsBits() - 1)) + ((ztemp + offset) >> NFINERZBITS); + if (zbin1 >= settings.MEBins()) { zbin1 = 0; //note that zbin1 is unsigned } if (zbin2 >= settings.MEBins()) { zbin2 = settings.MEBins() - 1; } - + assert(zbin1 <= zbin2); assert(zbin2 - zbin1 <= 1); - + fpgarzbin1projvm_.set(zbin1, settings.MEBinsBits(), true, __LINE__, __FILE__); // first z bin - - int nextbin = zbin1 != zbin2; + + int nextbin = zbin1 != zbin2; fpgarzbin2projvm_.set(nextbin, 1, true, __LINE__, __FILE__); // need to check adjacent z bin? - + //fine vm z bits. Use 4 bits for fine position. starting at zbin 1 int finez = ((1 << (settings.MEBinsBits() + NFINERZBITS - 1)) + ztemp) - (zbin1 << NFINERZBITS); - - fpgafinerzvm_.set(finez, NFINERZBITS+1, true, __LINE__, __FILE__); // fine z postions starting at zbin1 - } else { + fpgafinerzvm_.set(finez, NFINERZBITS + 1, true, __LINE__, __FILE__); // fine z postions starting at zbin1 + } else { //TODO the -3 and +3 should be evaluated and efficiency for matching hits checked. //This code should be migrated in the ProjectionRouter double roffset = 3.0; int rbin1 = 8.0 * (irzproj * settings.krprojshiftdisk() - roffset - settings.rmindiskvm()) / - (settings.rmaxdisk() - settings.rmindiskvm()); + (settings.rmaxdisk() - settings.rmindiskvm()); int rbin2 = 8.0 * (irzproj * settings.krprojshiftdisk() + roffset - settings.rmindiskvm()) / - (settings.rmaxdisk() - settings.rmindiskvm()); - + (settings.rmaxdisk() - settings.rmindiskvm()); + if (irzproj * settings.krprojshiftdisk() < 20.0) { - edm::LogPrint("Tracklet") << " WARNING : irproj = " << irzproj << " " << irzproj * settings.krprojshiftdisk() << " " - << layerdisk; + edm::LogPrint("Tracklet") << " WARNING : irproj = " << irzproj << " " << irzproj * settings.krprojshiftdisk() + << " " << layerdisk; } if (rbin1 < 0) { rbin1 = 0; } rbin2 = clamp(rbin2, 0, 7); - + assert(rbin1 <= rbin2); assert(rbin2 - rbin1 <= 1); int finer = 64 * - ((irzproj * settings.krprojshiftdisk() - settings.rmindiskvm()) - - rbin1 * (settings.rmaxdisk() - settings.rmindiskvm()) / 8.0) / - (settings.rmaxdisk() - settings.rmindiskvm()); - + ((irzproj * settings.krprojshiftdisk() - settings.rmindiskvm()) - + rbin1 * (settings.rmaxdisk() - settings.rmindiskvm()) / 8.0) / + (settings.rmaxdisk() - settings.rmindiskvm()); + finer = clamp(finer, 0, 15); int diff = rbin1 != rbin2; @@ -117,16 +114,17 @@ void Projection::init(Settings const& settings, fpgarzbin1projvm_.set(rbin1, 4, true, __LINE__, __FILE__); // first r bin fpgarzbin2projvm_.set(diff, 1, true, __LINE__, __FILE__); // need to check adjacent r bin - - fpgafinerzvm_.set(finer, 4, true, __LINE__, __FILE__); // fine r postions starting at rbin1 + fpgafinerzvm_.set(finer, 4, true, __LINE__, __FILE__); // fine r postions starting at rbin1 } - + //fine phi bits - int projfinephi = (fpgaphiproj_.value() >> (fpgaphiproj_.nbits() - (settings.nbitsallstubs(layerdisk) + settings.nbitsvmme(layerdisk) + NFINEPHIBITS ))) & ((1<> + (fpgaphiproj_.nbits() - (settings.nbitsallstubs(layerdisk) + settings.nbitsvmme(layerdisk) + NFINEPHIBITS))) & + ((1 << NFINEPHIBITS) - 1); fpgafinephivm_.set(projfinephi, NFINEPHIBITS, true, __LINE__, __FILE__); // fine phi postions - - + phiproj_ = phiproj; rzproj_ = rzproj; phiprojder_ = phiprojder; diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc index cbd534d581c17..711b0972bf715 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionRouter.cc @@ -93,7 +93,7 @@ void ProjectionRouter::execute() { } else { int disk = layerdisk_ - (N_LAYER - 1); - Projection& proj = tracklet->proj(layerdisk_); + Projection& proj = tracklet->proj(layerdisk_); fpgaphi = proj.fpgaphiproj(); //The next lines looks up the predicted bend based on: @@ -101,11 +101,9 @@ void ProjectionRouter::execute() { // 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 rindex = (proj.fpgarzproj().value() >> (proj.fpgarzproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1); - int phiderindex = (proj.fpgaphiprojder().value() >> - (proj.fpgaphiprojder().nbits() - nphiderbits_)) & + int phiderindex = (proj.fpgaphiprojder().value() >> (proj.fpgaphiprojder().nbits() - nphiderbits_)) & ((1 << nphiderbits_) - 1); int signindex = (proj.fpgarzprojder().value() < 0); @@ -133,10 +131,10 @@ void ProjectionRouter::execute() { vmprojs_[iphivm]->addTracklet(tracklet, allprojcount); if (settings_.debugTracklet()) { - edm::LogVerbatim("Tracklet") << getName() << " projection to " - << vmprojs_[iphivm]->getName() << " iphivm " << iphivm; + edm::LogVerbatim("Tracklet") << getName() << " projection to " << vmprojs_[iphivm]->getName() << " iphivm " + << iphivm; } - + allprojcount++; } } diff --git a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc index e9fc6201c77f0..f43b6fd2056c6 100644 --- a/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc +++ b/L1Trigger/TrackFindingTracklet/src/ProjectionTemp.cc @@ -9,11 +9,11 @@ ProjectionTemp::ProjectionTemp(Tracklet* proj, int projfinerz, unsigned int projfinephi, unsigned int iphi, - int shift, - bool usefirstMinus, - bool usefirstPlus, - bool usesecondMinus, - bool usesecondPlus, + int shift, + bool usefirstMinus, + bool usefirstPlus, + bool usesecondMinus, + bool usesecondPlus, bool isPSseed) { proj_ = proj; slot_ = slot; diff --git a/L1Trigger/TrackFindingTracklet/src/Residual.cc b/L1Trigger/TrackFindingTracklet/src/Residual.cc index 224d836185b19..1507d73bc4e6b 100644 --- a/L1Trigger/TrackFindingTracklet/src/Residual.cc +++ b/L1Trigger/TrackFindingTracklet/src/Residual.cc @@ -5,15 +5,15 @@ using namespace std; using namespace trklet; void Residual::init(Settings const& settings, - unsigned int layerdisk, - int iphiresid, - int irzresid, - int istubid, - double phiresid, - double rzresid, - double phiresidapprox, - double rzresidapprox, - const Stub* stubptr) { + unsigned int layerdisk, + int iphiresid, + int irzresid, + int istubid, + double phiresid, + double rzresid, + double phiresidapprox, + double rzresidapprox, + const Stub* stubptr) { assert(layerdisk < N_LAYER + N_DISK); if (valid_ && (std::abs(iphiresid) > std::abs(fpgaphiresid_.value()))) diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index c393552953daa..c0d874d16d8de 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -49,8 +49,8 @@ Sector::Sector(Settings const& settings, Globals* globals) : isector_(-1), setti Sector::~Sector() = default; -void Sector::setSector(unsigned int isector){ - assert(isector phimax_) { phimin_ -= 2 * M_PI; } - } - - bool Sector::addStub(L1TStub stub, string dtc) { unsigned int layerdisk = stub.layerdisk(); @@ -105,7 +102,6 @@ bool Sector::addStub(L1TStub stub, string dtc) { return true; } - void Sector::addMem(string memType, string memName) { if (memType == "DTCLink:") { addMemToVec(DL_, memName, settings_, phimin_, phimax_); diff --git a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc index 8d83dada14f49..40d81f17e3147 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubPairsMemory.cc @@ -6,11 +6,9 @@ using namespace std; using namespace trklet; -StubPairsMemory::StubPairsMemory(string name, Settings const& settings) - : MemoryBase(name, settings) {} +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/"; diff --git a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc index be0f9b31f86f1..73a63404b83c5 100644 --- a/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/StubTripletsMemory.cc @@ -7,11 +7,9 @@ using namespace std; using namespace trklet; -StubTripletsMemory::StubTripletsMemory(string name, Settings const& settings) - : MemoryBase(name, settings) {} +StubTripletsMemory::StubTripletsMemory(string name, Settings const& settings) : MemoryBase(name, settings) {} void StubTripletsMemory::writeST(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirSP = settings_.memPath() + "StubPairs/"; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc index 945d4c0e940f0..55e95adadf29d 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackFitMemory.cc @@ -14,7 +14,6 @@ TrackFitMemory::TrackFitMemory(string name, Settings const& settings, double phi } void TrackFitMemory::writeTF(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirFT = settings_.memPath() + "FitTrack/"; diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index ac3a8de2484cf..8bcdd3604055a 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -14,7 +14,7 @@ using namespace std; using namespace trklet; Tracklet::Tracklet(Settings const& settings, - unsigned int iSeed, + unsigned int iSeed, const Stub* innerFPGAStub, const Stub* middleFPGAStub, const Stub* outerFPGAStub, @@ -33,13 +33,12 @@ Tracklet::Tracklet(Settings const& settings, int id0, int iz0, int it, - Projection projs[N_LAYER+N_DISK], + Projection projs[N_LAYER + N_DISK], bool disk, bool overlap) : settings_(settings) { - seedIndex_ = iSeed; - + overlap_ = overlap; disk_ = disk; assert(!(disk && overlap)); @@ -86,7 +85,7 @@ Tracklet::Tracklet(Settings const& settings, for (unsigned int i = 0; i < N_LAYER - 2; i++) { if (projlayer_[i] == 0) continue; - if (!projs[projlayer_[i]-1].valid()) + if (!projs[projlayer_[i] - 1].valid()) continue; proj_[projlayer_[i] - 1] = projs[projlayer_[i] - 1]; @@ -95,10 +94,10 @@ Tracklet::Tracklet(Settings const& settings, for (unsigned int i = 0; i < N_DISK; i++) { if (projdisk_[i] == 0) continue; - if (!projs[N_LAYER + projdisk_[i] -1].valid()) + if (!projs[N_LAYER + projdisk_[i] - 1].valid()) continue; - proj_[N_LAYER + projdisk_[i] - 1] = projs[N_LAYER + projdisk_[i] -1]; + proj_[N_LAYER + projdisk_[i] - 1] = projs[N_LAYER + projdisk_[i] - 1]; } ichisqrphifit_.set(-1, 8, false); @@ -237,8 +236,8 @@ std::string Tracklet::vmstrlayer(int layer, unsigned int allstubindex) { FPGAWord tmp; tmp.set(irinvvm, 5, true, __LINE__, __FILE__); std::string oss = index.str() + "|" + proj_[layer - 1].fpgarzbin1projvm().str() + "|" + - proj_[layer - 1].fpgarzbin2projvm().str() + "|" + proj_[layer - 1].fpgafinerzvm().str() - + "|" + proj_[layer-1].fpgafinephivm().str() + "|" + tmp.str() + "|" + std::to_string(PSseed()); + proj_[layer - 1].fpgarzbin2projvm().str() + "|" + proj_[layer - 1].fpgafinerzvm().str() + "|" + + proj_[layer - 1].fpgafinephivm().str() + "|" + tmp.str() + "|" + std::to_string(PSseed()); return oss; } @@ -250,9 +249,10 @@ std::string Tracklet::vmstrdisk(int disk, unsigned int allstubindex) { } else { index.set(allstubindex, 7, true, __LINE__, __FILE__); } - std::string oss = index.str() + "|" + proj_[N_LAYER + disk - 1].fpgarzbin1projvm().str() + "|" + - proj_[N_LAYER + disk - 1].fpgarzbin2projvm().str() + "|" + proj_[N_LAYER + disk - 1].fpgafinerzvm().str() - + "|" + proj_[N_LAYER + disk - 1].fpgafinephivm().str() + "|" + proj_[N_LAYER + disk - 1].getBendIndex().str(); + std::string oss = + index.str() + "|" + proj_[N_LAYER + disk - 1].fpgarzbin1projvm().str() + "|" + + proj_[N_LAYER + disk - 1].fpgarzbin2projvm().str() + "|" + proj_[N_LAYER + disk - 1].fpgafinerzvm().str() + "|" + + proj_[N_LAYER + disk - 1].fpgafinephivm().str() + "|" + proj_[N_LAYER + disk - 1].getBendIndex().str(); return oss; } @@ -286,17 +286,23 @@ std::string Tracklet::trackletprojstrD(int disk) const { tcid.set(TCIndex_, 7, true, __LINE__, __FILE__); } std::string oss = tcid.str() + "|" + tmp.str() + "|" + proj_[N_LAYER + abs(disk) - 1].fpgaphiproj().str() + "|" + - proj_[N_LAYER + abs(disk) - 1].fpgarzproj().str() + "|" + proj_[N_LAYER + abs(disk) - 1].fpgaphiprojder().str() + - "|" + proj_[N_LAYER + abs(disk) - 1].fpgarzprojder().str(); + proj_[N_LAYER + abs(disk) - 1].fpgarzproj().str() + "|" + + proj_[N_LAYER + abs(disk) - 1].fpgaphiprojder().str() + "|" + + proj_[N_LAYER + abs(disk) - 1].fpgarzprojder().str(); return oss; } -void Tracklet::addMatch(unsigned int layerdisk, int ideltaphi, int ideltarz, - double dphi, double drz, double dphiapprox, double drzapprox, - int stubid, const trklet::Stub* stubptr) { +void Tracklet::addMatch(unsigned int layerdisk, + int ideltaphi, + int ideltarz, + double dphi, + double drz, + double dphiapprox, + double drzapprox, + int stubid, + const trklet::Stub* stubptr) { assert(layerdisk < N_LAYER + N_DISK); - resid_[layerdisk].init(settings_, layerdisk, ideltaphi, ideltarz, - stubid, dphi, drz, dphiapprox, drzapprox, stubptr); + resid_[layerdisk].init(settings_, layerdisk, ideltaphi, ideltarz, stubid, dphi, drz, dphiapprox, drzapprox, stubptr); } std::string Tracklet::fullmatchstr(int layer) { @@ -310,8 +316,8 @@ std::string Tracklet::fullmatchstr(int layer) { FPGAWord tcid; tcid.set(TCIndex_, settings_.nbitstcindex(), true, __LINE__, __FILE__); std::string oss = tcid.str() + "|" + tmp.str() + "|" + resid_[layer - 1].fpgastubid().str() + "|" + - resid_[layer - 1].stubptr()->r().str() + "|" + resid_[layer - 1].fpgaphiresid().str() + - "|" + resid_[layer - 1].fpgarzresid().str(); + resid_[layer - 1].stubptr()->r().str() + "|" + resid_[layer - 1].fpgaphiresid().str() + "|" + + resid_[layer - 1].fpgarzresid().str(); return oss; } @@ -329,7 +335,8 @@ std::string Tracklet::fullmatchdiskstr(int disk) { const bool isPS = resid_[N_LAYER + disk - 1].stubptr()->isPSmodule(); std::string oss = tcid.str() + "|" + tmp.str() + "|" + resid_[N_LAYER + disk - 1].fpgastubid().str() + "|" + (isPS ? stubr.str() : ("00000000" + stubr.str())) + "|" + - resid_[N_LAYER + disk - 1].fpgaphiresid().str() + "|" + resid_[N_LAYER + disk - 1].fpgarzresid().str(); + resid_[N_LAYER + disk - 1].fpgaphiresid().str() + "|" + + resid_[N_LAYER + disk - 1].fpgarzresid().str(); return oss; } @@ -736,33 +743,33 @@ Track Tracklet::makeTrack(const vector& l1stubs) { fpgafitpars_.d0().value(), fpgafitpars_.t().value(), fpgafitpars_.z0().value()); - + // If fitter produced no stub list, take it from original tracklet. - vector tmp= l1stubs.empty() ? getL1Stubs() : l1stubs; + vector tmp = l1stubs.empty() ? getL1Stubs() : l1stubs; vector tmp2; - for(auto stub : tmp) { + for (auto stub : tmp) { tmp2.push_back(*stub); } - - Track tmpTrack( - ipars, - ichisqrphifit_.value(), - ichisqrzfit_.value(), - chisqrphifit_, - chisqrzfit_, - hitpattern_, - getStubIDs(), - tmp2, - getISeed()); + + Track tmpTrack(ipars, + ichisqrphifit_.value(), + ichisqrzfit_.value(), + chisqrphifit_, + chisqrzfit_, + hitpattern_, + getStubIDs(), + tmp2, + getISeed()); return tmpTrack; } int Tracklet::layer() const { int l1 = (innerFPGAStub_ && innerFPGAStub_->layerdisk() < N_LAYER) ? innerFPGAStub_->l1tstub()->layerdisk() + 1 : 999, - l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleFPGAStub_->l1tstub()->layerdisk() + 1 : 999, + l2 = (middleFPGAStub_ && middleFPGAStub_->layerdisk() < N_LAYER) ? middleFPGAStub_->l1tstub()->layerdisk() + 1 + : 999, l3 = (outerFPGAStub_ && outerFPGAStub_->layerdisk() < N_LAYER) ? outerFPGAStub_->l1tstub()->layerdisk() + 1 : 999, l = min(min(l1, l2), l3); return (l < 999 ? l : 0); @@ -771,7 +778,8 @@ int Tracklet::layer() const { int Tracklet::disk() const { int d1 = (innerFPGAStub_ && (innerFPGAStub_->layerdisk() >= N_LAYER)) ? innerFPGAStub_->l1tstub()->disk() : 999, d2 = (middleFPGAStub_ && (middleFPGAStub_->layerdisk() >= N_LAYER)) ? middleFPGAStub_->l1tstub()->disk() : 999, - d3 = (outerFPGAStub_ && (outerFPGAStub_->layerdisk() >= N_LAYER)) ? outerFPGAStub_->l1tstub()->disk() : 999, d = 999; + d3 = (outerFPGAStub_ && (outerFPGAStub_->layerdisk() >= N_LAYER)) ? outerFPGAStub_->l1tstub()->disk() : 999, + d = 999; if (abs(d1) < min(abs(d2), abs(d3))) d = d1; if (abs(d2) < min(abs(d1), abs(d3))) @@ -804,4 +812,3 @@ void Tracklet::setTrackIndex(int index) { } int Tracklet::trackIndex() const { return trackIndex_; } - diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc index 283dbae71a2c1..7f75b31fb1ad1 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc @@ -43,7 +43,7 @@ TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Gl } // write the drinv and invt inverse tables - if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable()) && iTC_ == 0 ) { + if ((settings_.writeInvTable() || settings_.writeHLSInvTable() || settings_.writeTable()) && iTC_ == 0) { void (*writeLUT)(const VarInv&, const string&) = nullptr; if (settings.writeInvTable()) { // Verilog version writeLUT = [](const VarInv& x, const string& basename) -> void { @@ -158,7 +158,7 @@ void TrackletCalculator::execute(unsigned int iSector, double phimin, double phi phimin_ = phimin; phimax_ = phimax; iSector_ = iSector; - + bool print = (iSector == 3) && (getName() == "TC_L1L2G"); print = false; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc index 4b9bfc270e7f4..24e397c30d433 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorBase.cc @@ -14,9 +14,7 @@ using namespace std; using namespace trklet; -TrackletCalculatorBase::TrackletCalculatorBase(string name, - Settings const& settings, - Globals* global) +TrackletCalculatorBase::TrackletCalculatorBase(string name, Settings const& settings, Globals* global) : ProcessBase(name, settings, global) {} void TrackletCalculatorBase::exacttracklet(double r1, @@ -210,17 +208,16 @@ void TrackletCalculatorBase::exactprojdisk(double zproj, } void TrackletCalculatorBase::addDiskProj(Tracklet* tracklet, int disk) { + disk = std::abs(disk); - disk=std::abs(disk); - - FPGAWord fpgar = tracklet->proj(N_LAYER+disk-1).fpgarzproj(); + FPGAWord fpgar = tracklet->proj(N_LAYER + disk - 1).fpgarzproj(); if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm()) return; if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk()) return; - FPGAWord fpgaphi = tracklet->proj(N_LAYER+disk-1).fpgaphiproj(); + FPGAWord fpgaphi = tracklet->proj(N_LAYER + disk - 1).fpgaphiproj(); int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5); @@ -232,8 +229,8 @@ void TrackletCalculatorBase::addDiskProj(Tracklet* tracklet, int disk) { bool TrackletCalculatorBase::addLayerProj(Tracklet* tracklet, int layer) { assert(layer > 0); - FPGAWord fpgaz = tracklet->proj(layer-1).fpgarzproj(); - FPGAWord fpgaphi = tracklet->proj(layer-1).fpgaphiproj(); + FPGAWord fpgaz = tracklet->proj(layer - 1).fpgarzproj(); + FPGAWord fpgaphi = tracklet->proj(layer - 1).fpgaphiproj(); if (fpgaphi.atExtreme()) edm::LogProblem("Tracklet") << "at extreme! " << fpgaphi.value(); @@ -485,7 +482,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, //now binary int irinv, iphi0, it, iz0; - Projection projs[N_LAYER+N_DISK]; + Projection projs[N_LAYER + N_DISK]; int iphiproj[N_LAYER - 2], izproj[N_LAYER - 2]; int iphiprojdisk[N_DISK], irprojdisk[N_DISK]; @@ -595,21 +592,21 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, izproj[i] >>= (settings_.nzbitsstub(0) - settings_.nzbitsstub(5)); } - projs[settings_.projlayers(iSeed_, i)-1].init(settings_, - settings_.projlayers(iSeed_, i)-1, - iphiproj[i], - izproj[i], - ITC->der_phiL_final.ival(), - ITC->der_zL_final.ival(), - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - ITC->der_phiL_final.fval(), - ITC->der_zL_final.fval(), - !(iSeed_ == 2 || iSeed_ == 3)); + projs[settings_.projlayers(iSeed_, i) - 1].init(settings_, + settings_.projlayers(iSeed_, i) - 1, + iphiproj[i], + izproj[i], + ITC->der_phiL_final.ival(), + ITC->der_zL_final.ival(), + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + ITC->der_phiL_final.fval(), + ITC->der_zL_final.fval(), + !(iSeed_ == 2 || iSeed_ == 3)); } iphiprojdisk[0] = ITC->phiD_0_final.ival(); @@ -634,24 +631,22 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] < settings_.rmindisk() / ITC->rD_0_final.K() || irprojdisk[i] > settings_.rmaxdisk() / ITC->rD_0_final.K()) continue; - - projs[i+N_LAYER].init(settings_, - i+N_LAYER, - iphiprojdisk[i], - irprojdisk[i], - ITC->der_phiD_final.ival(), - ITC->der_rD_final.ival(), - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - ITC->der_phiD_final.fval(), - ITC->der_rD_final.fval(), - !(iSeed_ == 2 || iSeed_ == 3)); - + projs[i + N_LAYER].init(settings_, + i + N_LAYER, + iphiprojdisk[i], + irprojdisk[i], + ITC->der_phiD_final.ival(), + ITC->der_rD_final.ival(), + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + ITC->der_phiD_final.fval(), + ITC->der_rD_final.fval(), + !(iSeed_ == 2 || iSeed_ == 3)); } } @@ -663,7 +658,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - iSeed_, + iSeed_, innerFPGAStub, nullptr, outerFPGAStub, @@ -682,7 +677,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, 0, iz0, it, - projs, + projs, false); if (settings_.debugTracklet()) { @@ -725,7 +720,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, for (unsigned int j = 0; j < N_LAYER - 2; j++) { int lproj = settings_.projlayers(iSeed_, j); bool added = false; - if (tracklet->validProj(lproj-1)) { + if (tracklet->validProj(lproj - 1)) { added = addLayerProj(tracklet, lproj); if (added && lproj == 3) addL3 = true; @@ -750,7 +745,7 @@ bool TrackletCalculatorBase::barrelSeeding(const Stub* innerFPGAStub, continue; if (it < 0) disk = -disk; - if (tracklet->validProj(N_LAYER + abs(disk) -1 )) { + if (tracklet->validProj(N_LAYER + abs(disk) - 1)) { addDiskProj(tracklet, disk); } } @@ -976,7 +971,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, if (!inSector(iphi0, irinv, phi0approx, rinvapprox)) return false; - Projection projs[N_LAYER+N_DISK]; + Projection projs[N_LAYER + N_DISK]; for (unsigned int i = 0; i < N_DISK - 2; ++i) { //Check is outside z range @@ -995,21 +990,21 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, iphiproj[i] >>= (settings_.nphibitsstub(5) - settings_.nphibitsstub(0)); projs[i].init(settings_, - i, - iphiproj[i], - izproj[i], - ITC->der_phiL_final.ival(), - ITC->der_zL_final.ival(), - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - ITC->der_phiL_final.fval(), - ITC->der_zL_final.fval(), - true); -} + i, + iphiproj[i], + izproj[i], + ITC->der_phiL_final.ival(), + ITC->der_zL_final.ival(), + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + ITC->der_phiL_final.fval(), + ITC->der_zL_final.fval(), + true); + } iphiprojdisk[0] = ITC->phiD_0_final.ival(); iphiprojdisk[1] = ITC->phiD_1_final.ival(); @@ -1030,21 +1025,21 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] <= 0 || irprojdisk[i] > settings_.rmaxdisk() / ITC->rD_0_final.K()) continue; - projs[settings_.projdisks(iSeed_, i)+N_LAYER-1].init(settings_, - settings_.projdisks(iSeed_, i)+N_LAYER-1, - iphiprojdisk[i], - irprojdisk[i], - ITC->der_phiD_final.ival(), - ITC->der_rD_final.ival(), - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - ITC->der_phiD_final.fval(), - ITC->der_rD_final.fval(), - true); + projs[settings_.projdisks(iSeed_, i) + N_LAYER - 1].init(settings_, + settings_.projdisks(iSeed_, i) + N_LAYER - 1, + iphiprojdisk[i], + irprojdisk[i], + ITC->der_phiD_final.ival(), + ITC->der_rD_final.ival(), + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + ITC->der_phiD_final.fval(), + ITC->der_rD_final.fval(), + true); } if (settings_.writeMonitorData("TPars")) { @@ -1056,7 +1051,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - iSeed_, + iSeed_, innerFPGAStub, nullptr, outerFPGAStub, @@ -1075,7 +1070,7 @@ bool TrackletCalculatorBase::diskSeeding(const Stub* innerFPGAStub, 0, iz0, it, - projs, + projs, true); if (settings_.debugTracklet()) { @@ -1345,7 +1340,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, if (!inSector(iphi0, irinv, phi0approx, rinvapprox)) return false; - Projection projs[N_LAYER+N_DISK]; + Projection projs[N_LAYER + N_DISK]; for (unsigned int i = 0; i < N_DISK - 2; ++i) { //check that zproj is in range @@ -1364,20 +1359,20 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, iphiproj[i] >>= (settings_.nphibitsstub(5) - settings_.nphibitsstub(0)); projs[i].init(settings_, - i, - iphiproj[i], - izproj[i], - ITC->der_phiL_final.ival(), - ITC->der_zL_final.ival(), - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - ITC->der_phiL_final.fval(), - ITC->der_zL_final.fval(), - true); + i, + iphiproj[i], + izproj[i], + ITC->der_phiL_final.ival(), + ITC->der_zL_final.ival(), + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + ITC->der_phiL_final.fval(), + ITC->der_zL_final.fval(), + true); } for (int i = 0; i < 4; ++i) { @@ -1391,21 +1386,21 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] <= 0 || irprojdisk[i] > settings_.rmaxdisk() / ITC->rD_0_final.K()) continue; - projs[N_LAYER+i+1].init(settings_, - N_LAYER+i+1, - iphiprojdisk[i], - irprojdisk[i], - ITC->der_phiD_final.ival(), - ITC->der_rD_final.ival(), - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - ITC->der_phiD_final.fval(), - ITC->der_rD_final.fval(), - true); + projs[N_LAYER + i + 1].init(settings_, + N_LAYER + i + 1, + iphiprojdisk[i], + irprojdisk[i], + ITC->der_phiD_final.ival(), + ITC->der_rD_final.ival(), + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + ITC->der_phiD_final.fval(), + ITC->der_rD_final.fval(), + true); } if (settings_.writeMonitorData("TPars")) { @@ -1416,7 +1411,7 @@ bool TrackletCalculatorBase::overlapSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - iSeed_, + iSeed_, innerFPGAStub, nullptr, outerFPGAStub, diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc index 471ff11fbedb4..56fd768ef6163 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculatorDisplaced.cc @@ -13,9 +13,7 @@ using namespace std; using namespace trklet; -TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, - Settings const& settings, - Globals* global) +TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, Settings const& settings, Globals* global) : ProcessBase(name, settings, global) { for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) { vector tmp(settings.nallstubs(ilayer), nullptr); @@ -51,7 +49,7 @@ TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, iSeed_ = 11; assert(iSeed_ != 0); - + TCIndex_ = (iSeed_ << 4) + iTC; assert(TCIndex_ >= 128 && TCIndex_ < 191); @@ -138,7 +136,6 @@ TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(string name, for (unsigned int i = 0; i < N_DISK - 2; ++i) toZ_.push_back(zproj_[i]); } - } void TrackletCalculatorDisplaced::addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory) { @@ -302,29 +299,27 @@ void TrackletCalculatorDisplaced::execute(unsigned int iSector, double phimin, d } void TrackletCalculatorDisplaced::addDiskProj(Tracklet* tracklet, int disk) { - disk = std::abs(disk); - FPGAWord fpgar = tracklet->proj(N_LAYER+disk-1).fpgarzproj(); + FPGAWord fpgar = tracklet->proj(N_LAYER + disk - 1).fpgarzproj(); if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm()) return; if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk()) return; - FPGAWord fpgaphi = tracklet->proj(N_LAYER+disk-1).fpgaphiproj(); + FPGAWord fpgaphi = tracklet->proj(N_LAYER + disk - 1).fpgaphiproj(); int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5); - int iphi = iphivmRaw / (32 / settings_.nallstubs(disk + N_LAYER -1)); + int iphi = iphivmRaw / (32 / settings_.nallstubs(disk + N_LAYER - 1)); addProjectionDisk(disk, iphi, trackletprojdisks_[disk - 1][iphi], tracklet); - } bool TrackletCalculatorDisplaced::addLayerProj(Tracklet* tracklet, int layer) { assert(layer > 0); - FPGAWord fpgaz = tracklet->proj(layer-1).fpgarzproj(); - FPGAWord fpgaphi = tracklet->proj(layer-1).fpgaphiproj(); + FPGAWord fpgaz = tracklet->proj(layer - 1).fpgarzproj(); + FPGAWord fpgaphi = tracklet->proj(layer - 1).fpgaphiproj(); if (fpgaz.atExtreme()) return false; @@ -336,7 +331,7 @@ bool TrackletCalculatorDisplaced::addLayerProj(Tracklet* tracklet, int layer) { int iphi = iphivmRaw / (32 / settings_.nallstubs(layer - 1)); addProjection(layer, iphi, trackletprojlayers_[layer - 1][iphi], tracklet); - + return true; } @@ -406,7 +401,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, double rinv, phi0, d0, t, z0; - Projection projs[N_LAYER+N_DISK]; + Projection projs[N_LAYER + N_DISK]; double phiproj[N_LAYER - 2], zproj[N_LAYER - 2], phider[N_LAYER - 2], zder[N_LAYER - 2]; double phiprojdisk[N_DISK], rprojdisk[N_DISK], phiderdisk[N_DISK], rderdisk[N_DISK]; @@ -595,7 +590,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, if (!success) { return false; } - + double phicritapprox = phi0approx - asin(0.5 * settings_.rcrit() * rinvapprox); int phicrit = iphi0 - 2 * irinv; @@ -664,21 +659,21 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, } } - projs[lproj_[i]-1].init(settings_, - lproj_[i]-1, - iphiproj[i], - izproj[i], - iphider[i], - izder[i], - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - phiderapprox[i], - zderapprox[i], - false); + projs[lproj_[i] - 1].init(settings_, + lproj_[i] - 1, + iphiproj[i], + izproj[i], + iphider[i], + izder[i], + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + phiderapprox[i], + zderapprox[i], + false); } if (std::abs(it * kt) > 1.0) { @@ -700,21 +695,20 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, continue; projs[N_LAYER + i].init(settings_, - N_LAYER + i, - iphiprojdisk[i], - irprojdisk[i], - iphiderdisk[i], - irderdisk[i], - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - phiderdisk[i], - rderdisk[i], - false); - + N_LAYER + i, + iphiprojdisk[i], + irprojdisk[i], + iphiderdisk[i], + irderdisk[i], + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + phiderdisk[i], + rderdisk[i], + false); } } @@ -725,7 +719,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - iSeed_, + iSeed_, innerFPGAStub, middleFPGAStub, outerFPGAStub, @@ -744,7 +738,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, id0, iz0, it, - projs, + projs, false); if (settings_.debugTracklet()) @@ -768,7 +762,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j]; - if (tracklet->validProj(lproj_[j]-1)) { + if (tracklet->validProj(lproj_[j] - 1)) { added = addLayerProj(tracklet, lproj_[j]); if (added && lproj_[j] == 5) addL5 = true; @@ -789,7 +783,7 @@ bool TrackletCalculatorDisplaced::LLLSeeding(const Stub* innerFPGAStub, disk = -disk; if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk; - if (tracklet->validProj(N_LAYER + abs(disk) -1)) { + if (tracklet->validProj(N_LAYER + abs(disk) - 1)) { addDiskProj(tracklet, disk); } } @@ -1034,7 +1028,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, return false; } - Projection projs[N_LAYER+N_DISK]; + Projection projs[N_LAYER + N_DISK]; for (unsigned int i = 0; i < toR_.size(); ++i) { iphiproj[i] = phiprojapprox[i] / kphiproj; @@ -1073,27 +1067,25 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1; } - projs[lproj_[i]-1].init(settings_, - lproj_[i]-1, - iphiproj[i], - izproj[i], - iphider[i], - izder[i], - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - phiderapprox[i], - zderapprox[i], - false); - + projs[lproj_[i] - 1].init(settings_, + lproj_[i] - 1, + iphiproj[i], + izproj[i], + iphider[i], + izder[i], + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + phiderapprox[i], + zderapprox[i], + false); } if (std::abs(it * kt) > 1.0) { for (unsigned int i = 0; i < toZ_.size(); ++i) { - iphiprojdisk[i] = phiprojdiskapprox[i] / kphiprojdisk; irprojdisk[i] = rprojdiskapprox[i] / krprojdisk; @@ -1109,21 +1101,20 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, continue; projs[N_LAYER + i + 2].init(settings_, - N_LAYER + i + 2, - iphiprojdisk[i], - irprojdisk[i], - iphiderdisk[i], - irderdisk[i], - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - phiderdisk[i], - rderdisk[i], - false); - + N_LAYER + i + 2, + iphiprojdisk[i], + irprojdisk[i], + iphiderdisk[i], + irderdisk[i], + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + phiderdisk[i], + rderdisk[i], + false); } } @@ -1134,7 +1125,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - iSeed_, + iSeed_, innerFPGAStub, middleFPGAStub, outerFPGAStub, @@ -1153,7 +1144,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, id0, iz0, it, - projs, + projs, true); if (settings_.debugTracklet()) @@ -1173,8 +1164,8 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, for (unsigned int j = 0; j < toR_.size(); j++) { if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j] << " " - << tracklet->validProj(lproj_[j]-1); - if (tracklet->validProj(lproj_[j]-1)) { + << tracklet->validProj(lproj_[j] - 1); + if (tracklet->validProj(lproj_[j] - 1)) { addLayerProj(tracklet, lproj_[j]); } } @@ -1188,7 +1179,7 @@ bool TrackletCalculatorDisplaced::DDLSeeding(const Stub* innerFPGAStub, if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk << " " << tracklet->validProj(N_LAYER + abs(disk) - 1); - if (tracklet->validProj(N_LAYER+abs(disk)-1)) { + if (tracklet->validProj(N_LAYER + abs(disk) - 1)) { addDiskProj(tracklet, disk); } } @@ -1433,7 +1424,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, return false; } - Projection projs[N_LAYER+N_DISK]; + Projection projs[N_LAYER + N_DISK]; for (unsigned int i = 0; i < toR_.size(); ++i) { iphiproj[i] = phiprojapprox[i] / kphiproj; @@ -1470,27 +1461,26 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, if (iphider[i] >= (1 << (settings_.nbitsphiprojderL456() - 1))) iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1; } - - projs[lproj_[i]-1].init(settings_, - lproj_[i]-1, - iphiproj[i], - izproj[i], - iphider[i], - izder[i], - phiproj[i], - zproj[i], - phider[i], - zder[i], - phiprojapprox[i], - zprojapprox[i], - phiderapprox[i], - zderapprox[i], - false); + + projs[lproj_[i] - 1].init(settings_, + lproj_[i] - 1, + iphiproj[i], + izproj[i], + iphider[i], + izder[i], + phiproj[i], + zproj[i], + phider[i], + zder[i], + phiprojapprox[i], + zprojapprox[i], + phiderapprox[i], + zderapprox[i], + false); } if (std::abs(it * kt) > 1.0) { for (unsigned int i = 0; i < toZ_.size(); ++i) { - iphiprojdisk[i] = phiprojdiskapprox[i] / kphiprojdisk; irprojdisk[i] = rprojdiskapprox[i] / krprojdisk; @@ -1507,21 +1497,21 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, if (irprojdisk[i] < settings_.rmindisk() / krprojdisk || irprojdisk[i] > settings_.rmaxdisk() / krprojdisk) continue; - projs[N_LAYER+i+1].init(settings_, - N_LAYER+i+1, - iphiprojdisk[i], - irprojdisk[i], - iphiderdisk[i], - irderdisk[i], - phiprojdisk[i], - rprojdisk[i], - phiderdisk[i], - rderdisk[i], - phiprojdiskapprox[i], - rprojdiskapprox[i], - phiderdisk[i], - rderdisk[i], - false); + projs[N_LAYER + i + 1].init(settings_, + N_LAYER + i + 1, + iphiprojdisk[i], + irprojdisk[i], + iphiderdisk[i], + irderdisk[i], + phiprojdisk[i], + rprojdisk[i], + phiderdisk[i], + rderdisk[i], + phiprojdiskapprox[i], + rprojdiskapprox[i], + phiderdisk[i], + rderdisk[i], + false); } } @@ -1532,7 +1522,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, } Tracklet* tracklet = new Tracklet(settings_, - iSeed_, + iSeed_, innerFPGAStub, middleFPGAStub, outerFPGAStub, @@ -1551,7 +1541,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, id0, iz0, it, - projs, + projs, false); if (settings_.debugTracklet()) @@ -1571,7 +1561,7 @@ bool TrackletCalculatorDisplaced::LLDSeeding(const Stub* innerFPGAStub, for (unsigned int j = 0; j < toR_.size(); j++) { if (settings_.debugTracklet()) edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j]; - if (tracklet->validProj(lproj_[j]-1)) { + if (tracklet->validProj(lproj_[j] - 1)) { addLayerProj(tracklet, lproj_[j]); } } @@ -1868,7 +1858,6 @@ void TrackletCalculatorDisplaced::approxtracklet(double r1, double rprojdisk[5], double phiderdisk[5], double rderdisk[5]) { - double a = 1.0 / ((r1 - r2) * (r1 - r3)); double b = 1.0 / ((r1 - r2) * (r2 - r3)); double c = 1.0 / ((r1 - r3) * (r2 - r3)); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc index 168a65b74cc47..b41f391cfa4ed 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc @@ -901,7 +901,7 @@ void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& mem //Hack since we use same module twice if (iSeed == 7) { nmem = 2; - } + } for (unsigned iTC = 0; iTC < nTCReg; iTC++) { nmem++; @@ -949,10 +949,10 @@ void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& mem unsigned int nmem = 0; - if (iSeed == 7) { - nmem = 4; - } - + if (iSeed == 7) { + nmem = 4; + } + for (unsigned int iTE = 0; iTE < TE_[iSeed].size(); iTE++) { unsigned int TE1 = TE_[iSeed][iTE].first; unsigned int TE2 = TE_[iSeed][iTE].second; @@ -1242,22 +1242,21 @@ void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memo double dphi = 0.5 * dphisectorHG_ - M_PI / NSector_; - string olddtc=""; + string olddtc = ""; for (unsigned int i = 0; i < 52; i++) { - if (olddtc!=dtcname[i]) { - modules << "InputRouter: IR_"< output=> IR_" << dtcname[i] << "_A.stubin" << std::endl; + << " input=> output=> IR_" << dtcname[i] << "_A.stubin" << std::endl; os << "DL_" << dtcname[i] << "_B" - << " input=> output=> IR_" << dtcname[i] << "_B.stubin" << std::endl; + << " input=> output=> IR_" << dtcname[i] << "_B.stubin" << std::endl; } - olddtc=dtcname[i]; + olddtc = dtcname[i]; } - for (unsigned int i = 0; i < 52; i++) { double phimintmp = phimin[i] + dphi; double phimaxtmp = phimax[i] + dphi; @@ -1270,14 +1269,16 @@ void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memo memories << "InputLink: IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_A" << " [36]" << std::endl; os << "IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_A" - << " input=> IR_"< VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; + << " input=> IR_" << dtcname[i] << "_A.stubout output=> VMR_" << LayerName(layerdisk[i]) << "PHI" + << iTCStr(iReg) << ".stubin" << std::endl; } if (allStubs_[layerdisk[i]][iReg].first > phimintmp) { memories << "InputLink: IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_B" << " [36]" << std::endl; os << "IL_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << "_" << dtcname[i] << "_B" - << " input=> IR_"< VMR_" << LayerName(layerdisk[i]) << "PHI" << iTCStr(iReg) << ".stubin" << std::endl; + << " input=> IR_" << dtcname[i] << "_B.stubout output=> VMR_" << LayerName(layerdisk[i]) << "PHI" + << iTCStr(iReg) << ".stubin" << std::endl; } } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc index 410a4b491c6e7..927cd2b43505a 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc @@ -12,9 +12,7 @@ using namespace std; using namespace trklet; -TrackletEngineDisplaced::TrackletEngineDisplaced(string name, - Settings const& settings, - Globals* global) +TrackletEngineDisplaced::TrackletEngineDisplaced(string name, Settings const& settings, Globals* global) : ProcessBase(name, settings, global) { stubpairs_.clear(); firstvmstubs_.clear(); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc index 5d7b350d66e2c..19286102bbaf3 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc @@ -182,45 +182,44 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { bool first = (eventnum_ == 1); for (unsigned int k = 0; k < N_SECTOR; k++) { - sector_->setSector(k); cleanTimer_.start(); sector_->clean(); cleanTimer_.stop(); - + addStubTimer_.start(); - + vector layerstubs(N_LAYER + N_DISK, 0); vector layerstubssector(N_SECTOR * (N_LAYER + N_DISK), 0); - + for (int j = 0; j < ev.nstubs(); j++) { L1TStub stub = ev.stub(j); unsigned int isector = stub.region(); - if (isector!=k) { - continue; + if (isector != k) { + continue; } - + string dtc = stub.DTClink(); - + layerstubs[stub.layerdisk()]++; layerstubssector[isector * (N_LAYER + N_DISK) + stub.layerdisk()]++; - + sector_->addStub(stub, dtc); } - + if (settings_->writeMonitorData("StubsLayerSector")) { for (unsigned int index = 0; index < layerstubssector.size(); index++) { - int layerdisk = index % (N_LAYER + N_DISK); - int sector = index / (N_LAYER + N_DISK); - globals_->ofstream("stubslayersector.txt") - << layerdisk << " " << sector << " " << layerstubssector[index] << endl; + int layerdisk = index % (N_LAYER + N_DISK); + int sector = index / (N_LAYER + N_DISK); + globals_->ofstream("stubslayersector.txt") + << layerdisk << " " << sector << " " << layerstubssector[index] << endl; } } if (settings_->writeMonitorData("StubsLayer")) { for (unsigned int layerdisk = 0; layerdisk < layerstubs.size(); layerdisk++) { - globals_->ofstream("stubslayer.txt") << layerdisk << " " << layerstubs[layerdisk] << endl; + globals_->ofstream("stubslayer.txt") << layerdisk << " " << layerstubs[layerdisk] << endl; } } @@ -238,7 +237,6 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { } InputRouterTimer_.stop(); - VMRouterTimer_.start(); sector_->executeVMR(); if (settings_->writeMem() && k == settings_->writememsect()) { @@ -253,7 +251,7 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { TETimer_.start(); sector_->executeTE(); TETimer_.stop(); - + // tracklet engine displaced TEDTimer_.start(); sector_->executeTED(); @@ -275,50 +273,51 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { if (settings_->writeMem() && k == settings_->writememsect()) { sector_->writeSP(first); } - + // tracklet calculator TCTimer_.start(); sector_->executeTC(); TCTimer_.stop(); - + int nTP = globals_->event()->nsimtracks(); for (int iTP = 0; iTP < nTP; iTP++) { L1SimTrack simtrk = globals_->event()->simtrack(iTP); if (simtrk.pt() < 2.0) - continue; + continue; if (std::abs(simtrk.vz()) > 15.0) - continue; + continue; if (hypot(simtrk.vx(), simtrk.vy()) > 0.1) - continue; + continue; bool electron = (abs(simtrk.type()) == 11); bool muon = (abs(simtrk.type()) == 13); bool pion = (abs(simtrk.type()) == 211); bool kaon = (abs(simtrk.type()) == 321); bool proton = (abs(simtrk.type()) == 2212); if (!(electron || muon || pion || kaon || proton)) - continue; + continue; int nlayers = 0; int ndisks = 0; int simtrackid = simtrk.trackid(); unsigned int hitmask = ev.layersHit(simtrackid, nlayers, ndisks); if (nlayers + ndisks < 4) - continue; - + continue; + if (settings_->writeMonitorData("HitEff")) { - static ofstream outhit("hiteff.txt"); - outhit << simtrk.eta() << " " << (hitmask & 1) << " " << (hitmask & 2) << " " << (hitmask & 4) << " " - << (hitmask & 8) << " " << (hitmask & 16) << " " << (hitmask & 32) << " " << (hitmask & 64) << " " - << (hitmask & 128) << " " << (hitmask & 256) << " " << (hitmask & 512) << " " << (hitmask & 1024) << endl; + static ofstream outhit("hiteff.txt"); + outhit << simtrk.eta() << " " << (hitmask & 1) << " " << (hitmask & 2) << " " << (hitmask & 4) << " " + << (hitmask & 8) << " " << (hitmask & 16) << " " << (hitmask & 32) << " " << (hitmask & 64) << " " + << (hitmask & 128) << " " << (hitmask & 256) << " " << (hitmask & 512) << " " << (hitmask & 1024) + << endl; } - + std::unordered_set matchseed; std::unordered_set matchseedtmp = sector_->seedMatch(iTP); matchseed.insert(matchseedtmp.begin(), matchseedtmp.end()); if (settings_->bookHistos()) { - for (int iseed = 0; iseed < 8; iseed++) { - bool eff = matchseed.find(iseed) != matchseed.end(); - globals_->histograms()->fillSeedEff(iseed, simtrk.eta(), eff); - } + for (int iseed = 0; iseed < 8; iseed++) { + bool eff = matchseed.find(iseed) != matchseed.end(); + globals_->histograms()->fillSeedEff(iseed, simtrk.eta(), eff); + } } } @@ -353,7 +352,7 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { MCTimer_.start(); sector_->executeMC(); MCTimer_.stop(); - + // match processor (alternative to ME+MC) MPTimer_.start(); sector_->executeMP(); @@ -375,7 +374,7 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { PDTimer_.start(); sector_->executePD(tracks_); if (((settings_->writeMem() || settings_->writeMonitorData("IFit")) && k == settings_->writememsect()) || - settings_->writeMonitorData("CT")) { + settings_->writeMonitorData("CT")) { sector_->writeCT(first); } PDTimer_.stop(); @@ -383,7 +382,6 @@ void TrackletEventProcessor::event(SLHCEvent& ev) { } void TrackletEventProcessor::printSummary() { - if (settings_->bookHistos()) { globals_->histograms()->close(); } @@ -398,7 +396,7 @@ void TrackletEventProcessor::printSummary() { << addStubTimer_.tottime() << "\n" << "InputRouter " << setw(10) << InputRouterTimer_.ntimes() << setw(20) << setprecision(3) << InputRouterTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) - << InputRouterTimer_.tottime() << "\n" + << InputRouterTimer_.tottime() << "\n" << "VMRouter " << setw(10) << VMRouterTimer_.ntimes() << setw(20) << setprecision(3) << VMRouterTimer_.avgtime() * 1000.0 << setw(20) << setprecision(3) << VMRouterTimer_.tottime(); @@ -410,27 +408,32 @@ void TrackletEventProcessor::printSummary() { << 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(); + 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(); + 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(); } - 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(); + 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(); } 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/TrackletParametersMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc index b9aed96c2f083..7667f26038a97 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletParametersMemory.cc @@ -19,7 +19,6 @@ void TrackletParametersMemory::clean() { } void TrackletParametersMemory::writeTPAR(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirTP = settings_.memPath() + "TrackletParameters/"; diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index 177817e5994f4..025b5df6a5d43 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -56,7 +56,6 @@ TrackletProcessor::TrackletProcessor(string name, Settings const& settings, Glob assert(TCIndex_ >= 0 && TCIndex_ <= (int)settings_.ntrackletmax()); maxStep_ = settings_.maxStep("TP"); - } void TrackletProcessor::addOutputProjection(TrackletProjectionsMemory*& outputProj, MemoryBase* memory) { @@ -142,8 +141,8 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { pttableouternew_, outervmstubs_); - teunits_.resize(settings_.teunits(iSeed_),teunit); - + teunits_.resize(settings_.teunits(iSeed_), teunit); + return; } @@ -172,14 +171,13 @@ void TrackletProcessor::addInput(MemoryBase* memory, string input) { } void TrackletProcessor::execute(unsigned int iSector, double phimin, double phimax) { - bool print = (iSector == 3) && (getName() == "TP_L1L2D"); print = false; phimin_ = phimin; phimax_ = phimax; iSector_ = iSector; - + if (!settings_.useSeed(iSeed_)) return; @@ -222,7 +220,7 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim bool goodtedata___ = false; bool tebuffernearfull; - + for (unsigned int istep = 0; istep < maxStep_; istep++) { if (print) { CircularBuffer& tedatabuffer = std::get<0>(tebuffer_); @@ -303,7 +301,7 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim edm::LogVerbatim("Tracklet") << "TrackletProcessor execute done"; } } - + // // The second block fills the teunit if data in buffer and process TEUnit step // @@ -330,7 +328,7 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim // The third block here checks if we have input stubs to process // // - + if (goodtedata___) tedatabuffer.store(tedata___); @@ -379,23 +377,23 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim unsigned int lutwidth = settings_.lutwidthtab(0, iSeed_); FPGAWord lookupbits(lutval, lutwidth, true, __LINE__, __FILE__); - int rzfinebinfirst = lookupbits.bits(0, NFINERZBITS); //finerz - int next = lookupbits.bits(NFINERZBITS, 1); //use next r/z bin - int start = lookupbits.bits(NFINERZBITS + 1, nbitsrzbin_); //rz bin + int rzfinebinfirst = lookupbits.bits(0, NFINERZBITS); //finerz + int next = lookupbits.bits(NFINERZBITS, 1); //use next r/z bin + int start = lookupbits.bits(NFINERZBITS + 1, nbitsrzbin_); //rz bin int rzdiffmax = lookupbits.bits(NFINERZBITS + 1 + nbitsrzbin_, NFINERZBITS); if ((iSeed_ == 4 || iSeed_ == 5) && negdisk) { //TODO - need to store negative disk - start += (1<= 4) { //FIXME If the lookupbits were rationally organized this would be much simpler - unsigned int nrbits=3; - int ir = ((start & ((1<<(nrbits-1))-1)) << 1) + (rzfinebinfirst >> (NFINERZBITS-1)); + unsigned int nrbits = 3; + int ir = ((start & ((1 << (nrbits - 1)) - 1)) << 1) + (rzfinebinfirst >> (NFINERZBITS - 1)); useregindex = (useregindex << nrbits) + ir; } @@ -453,7 +451,7 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim } else if ((!tebuffernearfull) && imem < imemend && istub == 0) { imem++; } - + goodtedata___ = goodtedata__; goodtedata__ = goodtedata; @@ -488,7 +486,7 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim // // Done with processing - collect performance statistics // - + if (settings_.writeMonitorData("TP")) { globals_->ofstream("trackletprocessor.txt") << getName() << " " << ninnerstubs //# inner stubs << " " << outervmstubs_->nVMStubs() //# outer stubs diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc index 8eb85073223a6..b1861fdc64dab 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProjectionsMemory.cc @@ -16,11 +16,11 @@ TrackletProjectionsMemory::TrackletProjectionsMemory(string name, Settings const void TrackletProjectionsMemory::addProj(Tracklet* tracklet) { if (layer_ != 0 && disk_ == 0) - assert(tracklet->validProj(layer_-1)); + assert(tracklet->validProj(layer_ - 1)); if (layer_ == 0 && disk_ != 0) - assert(tracklet->validProj(N_LAYER + abs(disk_) -1 )); + assert(tracklet->validProj(N_LAYER + abs(disk_) - 1)); if (layer_ != 0 && disk_ != 0) - assert(tracklet->validProj(layer_-1) || tracklet->validProj(N_LAYER+abs(disk_)-1)); + assert(tracklet->validProj(layer_ - 1) || tracklet->validProj(N_LAYER + abs(disk_) - 1)); for (auto& itracklet : tracklets_) { if (itracklet == tracklet) { @@ -35,7 +35,6 @@ void TrackletProjectionsMemory::addProj(Tracklet* tracklet) { void TrackletProjectionsMemory::clean() { tracklets_.clear(); } void TrackletProjectionsMemory::writeTPROJ(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirTP = settings_.memPath() + "TrackletProjections/"; @@ -49,8 +48,8 @@ void TrackletProjectionsMemory::writeTPROJ(bool first, unsigned int iSector) { out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl; for (unsigned int j = 0; j < tracklets_.size(); j++) { - string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_-1)) ? tracklets_[j]->trackletprojstrlayer(layer_) - : tracklets_[j]->trackletprojstrdisk(disk_); + string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_ - 1)) ? tracklets_[j]->trackletprojstrlayer(layer_) + : tracklets_[j]->trackletprojstrdisk(disk_); out_ << "0x"; out_ << std::setfill('0') << std::setw(2); out_ << hex << j << dec; diff --git a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc index 4c1074d257228..3541d9ce522f6 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMProjectionsMemory.cc @@ -7,8 +7,7 @@ using namespace std; using namespace trklet; -VMProjectionsMemory::VMProjectionsMemory(string name, Settings const& settings) - : MemoryBase(name, settings) { +VMProjectionsMemory::VMProjectionsMemory(string name, Settings const& settings) : MemoryBase(name, settings) { initLayerDisk(7, layer_, disk_); } @@ -22,7 +21,6 @@ void VMProjectionsMemory::addTracklet(Tracklet* tracklet, unsigned int allprojin } void VMProjectionsMemory::writeVMPROJ(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirVM = settings_.memPath() + "VMProjections/"; diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc index 437b42a98cd9e..484bd3ad549fe 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouter.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouter.cc @@ -136,16 +136,16 @@ void VMRouter::addInput(MemoryBase* memory, string input) { 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); + if (layerdisk_ > N_LAYER && tmp1->getName().find("2S_") != string::npos) { + stubinputdisk2stmp_.push_back(tmp1); } else { - stubinputtmp_.push_back(tmp1); + 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_ = stubinputtmp_; + for (auto& mem : stubinputdisk2stmp_) { stubinputs_.push_back(mem); } return; @@ -246,19 +246,17 @@ void VMRouter::execute() { assert(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; + edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << vmstubsMEPHI_[ivmPlus]->getName() + << " ivmPlus" << ivmPlus << " bin=" << vmbin; } - + if (ivmMinus != ivmPlus) { assert(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; - } + if (settings_.debugTracklet()) { + edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << vmstubsMEPHI_[ivmMinus]->getName() + << " ivmMinus" << ivmMinus << " bin=" << vmbin; + } } //Fill the TE VM memories diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc index b8ec68163321c..95471679fb5f4 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc @@ -146,8 +146,8 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { } // write disk teouter tables (D1, D2, D4) if (layerdisk == 6 || layerdisk == 7 || layerdisk == 9) { - std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); - writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); + std::string fnamesuffix = "D" + to_string(layerdisk - N_LAYER + 1); + writeVMTable(settings_.tablePath(), "VMTableOuter" + fnamesuffix + ".tab", vmrtabletedisk_); } } else { std::string fname = "VMRME_"; diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc index ab76b706c1b23..9ac11723a6fcf 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsMEMemory.cc @@ -6,8 +6,7 @@ using namespace std; using namespace trklet; -VMStubsMEMemory::VMStubsMEMemory(string name, Settings const& settings) - : MemoryBase(name, settings) { +VMStubsMEMemory::VMStubsMEMemory(string name, Settings const& settings) : MemoryBase(name, settings) { unsigned int layerdisk = initLayerDisk(6); if (layerdisk < N_LAYER) { binnedstubs_.resize(settings_.NLONGVMBINS()); @@ -18,7 +17,6 @@ VMStubsMEMemory::VMStubsMEMemory(string name, Settings const& settings) } void VMStubsMEMemory::writeStubs(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirVM = settings_.memPath() + "VMStubsME/"; diff --git a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc index b62cc2e4d3712..47c70a825d5b4 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMStubsTEMemory.cc @@ -6,8 +6,7 @@ using namespace std; using namespace trklet; -VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings) - : MemoryBase(name, settings) { +VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings) : MemoryBase(name, settings) { //set the layer or disk that the memory is in initLayerDisk(6, layer_, disk_); @@ -219,7 +218,6 @@ void VMStubsTEMemory::clean() { } void VMStubsTEMemory::writeStubs(bool first, unsigned int iSector) { - iSector_ = iSector; const string dirVM = settings_.memPath() + "VMStubsTE/"; openFile(first, dirVM, "VMStubs_"); diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index ab4700cc12ce0..6663f0e2463a0 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -15,7 +15,7 @@ # Set L1 tracking algorithm: # 'HYBRID' (baseline, 4par fit) or 'HYBRID_DISPLACED' (extended, 5par fit). # (Or legacy algos 'TMTT' or 'TRACKLET'). -L1TRKALGO = 'HYBRID' +L1TRKALGO = 'HYBRID_DISPLACED' WRITE_DATA = False @@ -72,6 +72,8 @@ # Or read specified .root file: inputMC = ["/store/relval/CMSSW_11_3_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v3_2026D49PU200-v1/00000/001edbad-174e-46af-932a-6ce8e04aee1c.root"] + #inputMC = ["/store/relval/CMSSW_11_2_0_pre8/RelValSingleMuPt10/GEN-SIM-RECO/112X_mcRun4_realistic_v3_2026D49noPU-v1/00000/007d817e-9c59-4dec-959b-0f227942cdf0.root"] + #inputMC = ["/store/relval/CMSSW_11_3_0_pre3/RelValSingleMuPt10/GEN-SIM-DIGI-RAW/113X_mcRun4_realistic_v3_2026D49noPU-v1/00000/04514913-efc7-49fc-8df4-90efe43ca047.root"] else: print "this is not a valid geometry!!!" diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index e637331d5fd0e..69736de2f3adf 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -109,10 +109,9 @@ int main(const int argc, const char **argv) { for (int eventnum = 0; eventnum < nevents && !in->eof(); eventnum++) { SLHCEvent ev(*in); - //auto simtrk = ev.simtrack(0); //if (std::abs(std::abs(simtrk.eta())-1.3)>0.1) continue; - + // ----------------------------------------------------------------- // setup ROOT Tree and Add Monte Carlo tracks to the ROOT-Tree Event #ifdef USEROOT @@ -211,7 +210,7 @@ int main(const int argc, const char **argv) { eventProcessor.event(ev); - const std::vector& tracks = eventProcessor.tracks(); + const std::vector &tracks = eventProcessor.tracks(); // --------------------------------------------------------- // Block for producing ROOT-Tree diff --git a/L1Trigger/TrackerDTC/src/Stub.cc b/L1Trigger/TrackerDTC/src/Stub.cc index 4f50ff9189dae..5647a6a74027d 100644 --- a/L1Trigger/TrackerDTC/src/Stub.cc +++ b/L1Trigger/TrackerDTC/src/Stub.cc @@ -149,7 +149,8 @@ namespace trackerDTC { TTDTC::BV Stub::formatHybrid(int region) const { const SensorModule::Type type = sm_->type(); // stub phi w.r.t. processing region centre in rad - const double phi = phi_ - (region - .5) * setup_->baseRegion() + 0.5 * setup_->hybridBasePhi(type) * (1<hybridWidthPhi(type)); + const double phi = phi_ - (region - .5) * setup_->baseRegion() + + 0.5 * setup_->hybridBasePhi(type) * (1 << setup_->hybridWidthPhi(type)); // convert stub variables into bit vectors const TTBV hwR(r_, setup_->hybridBaseR(type), setup_->hybridWidthR(type), true); From 2a823e0cba412821064e9b9aacc88bd52bb21ffa Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sun, 4 Apr 2021 11:14:02 -0400 Subject: [PATCH 38/45] Address comments from Louise S. --- .../TrackFindingTracklet/interface/ProjectionTemp.h | 2 ++ L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h | 2 -- L1Trigger/TrackFindingTracklet/interface/Settings.h | 12 +++++++----- L1Trigger/TrackFindingTracklet/interface/Stub.h | 2 +- L1Trigger/TrackFindingTracklet/src/FitTrack.cc | 12 ++++++------ .../TrackFindingTracklet/src/MatchCalculator.cc | 4 ++-- L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc | 4 ++-- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h index 4ae109277ead6..e34786d37587e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h +++ b/L1Trigger/TrackFindingTracklet/interface/ProjectionTemp.h @@ -43,6 +43,8 @@ namespace trklet { unsigned int projfinephi_; unsigned int iphi_; int shift_; + //Projection may use two bins in rz and phi if the projection is near a boundary + //The use_[rz][phi] array indicates which bins are used. bool use_[2][2]; bool isPSseed_; }; diff --git a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h index 29f8768fb1455..74dfc0d22d3fd 100644 --- a/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h +++ b/L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h @@ -62,8 +62,6 @@ namespace trklet { int eventnum() const { return eventnum_; } - //int getSimtrackFromSimtrackid(int simtrackid, int eventid = 0) const; - private: int eventnum_; std::vector simtracks_; diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index b1912dff67ee8..d74d2a2d1ec95 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -266,6 +266,7 @@ namespace trklet { void setNbitsseedextended(unsigned int nbitsseed) { nbitsseedextended_ = nbitsseed; } double dphisectorHG() const { + //These values are used in the DTC emulation code. double rsectmin = 21.8; double rsectmax = 112.7; return 2 * M_PI / N_SECTOR + rinvmax() * std::max(rcrit_ - rsectmin, rsectmax - rcrit_); @@ -386,16 +387,16 @@ namespace trklet { double krprojshiftdisk() const { return 2 * kr(); } double benddecode(int ibend, int layerdisk, bool isPSmodule) const { - if (layerdisk > 5 && (!isPSmodule)) - layerdisk += 5; + if (layerdisk >= N_LAYER && (!isPSmodule)) + layerdisk += (N_LAYER - 1); double bend = benddecode_[layerdisk][ibend]; assert(bend < 99.0); return bend; } double bendcut(int ibend, int layerdisk, bool isPSmodule) const { - if (layerdisk > 5 && (!isPSmodule)) - layerdisk += 5; + if (layerdisk >= N_LAYER && (!isPSmodule)) + layerdisk += (N_LAYER - 1); double bendcut = bendcut_[layerdisk][ibend]; if (bendcut <= 0.0) std::cout << "bendcut : " << layerdisk << " " << ibend << " " << isPSmodule << std::endl; @@ -718,7 +719,8 @@ namespace trklet { unsigned int maxstepoffset_{0}; //Number of processing steps for one event (108=18TM*240MHz/40MHz) - std::unordered_map maxstep_{{"IR", 168}, + std::unordered_map maxstep_{{"IR", 168}, //IR will run at a higher clock speed to handle + //input links running at 25 Gbits/s {"VMR", 108}, {"TE", 108}, {"TC", 108}, diff --git a/L1Trigger/TrackFindingTracklet/interface/Stub.h b/L1Trigger/TrackFindingTracklet/interface/Stub.h index 35f9a3dbfc206..90c8f7f1dbd80 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Stub.h +++ b/L1Trigger/TrackFindingTracklet/interface/Stub.h @@ -61,7 +61,7 @@ namespace trklet { const FPGAWord& z() const { return z_; } const FPGAWord& phi() const { return phi_; } const FPGAWord& phicorr() const { return phicorr_; } - const FPGAWord& alphanew() const { return alpha_; } //FIXME should remove new + const FPGAWord& alpha() const { return alpha_; } const FPGAWord& stubindex() const { return stubindex_; } const FPGAWord& layer() const { return layer_; } diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 6b362683478fb..20bf5e741e2b6 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -231,8 +231,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: dmatches.set(2 * d - 1); diskmask |= (1 << (2 * (N_DISK - d) + 1)); } else { - int ialpha = resid.stubptr()->alphanew().value(); - int nalpha = resid.stubptr()->alphanew().nbits(); + int ialpha = resid.stubptr()->alpha().value(); + int nalpha = resid.stubptr()->alpha().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -306,8 +306,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: dmatches.set(2 * d1 - 1); diskmask |= (1 << (2 * (N_DISK - d1) + 1)); } else { - int ialpha = resid.stubptr()->alphanew().value(); - int nalpha = resid.stubptr()->alphanew().nbits(); + int ialpha = resid.stubptr()->alpha().value(); + int nalpha = resid.stubptr()->alpha().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); @@ -383,8 +383,8 @@ void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector&, std: FPGAWord tmp; tmp.set(diskmask, 10); } else { - int ialpha = resid.stubptr()->alphanew().value(); - int nalpha = resid.stubptr()->alphanew().nbits(); + int ialpha = resid.stubptr()->alpha().value(); + int nalpha = resid.stubptr()->alpha().nbits(); nalpha = nalpha - settings_.alphaBitsTable(); ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 9a968e103284c..4b4dcfe3e20ba 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -380,8 +380,8 @@ void MatchCalculator::execute(double phioffset) { int ideltar = (irstub >> 1) - ir; if (!stub->isPSmodule()) { - int ialphanew = fpgastub->alphanew().value(); - int iphialphacor = ((ideltar * ialphanew * ialphafact) >> settings_.alphashift()); + int ialpha = fpgastub->alpha().value(); + int iphialphacor = ((ideltar * ialpha * ialphafact) >> settings_.alphashift()); ideltaphi += iphialphacor; } diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 24975d63c7a51..d567b2c5d7501 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -636,8 +636,8 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b int ideltar = (irstub * settings_.kr()) / settings_.krprojshiftdisk() - ir; if (!stub->isPSmodule()) { - int ialphanew = fpgastub->alphanew().value(); - int iphialphacor = ((ideltar * ialphanew * ialphafact) >> settings_.alphashift()); + int ialpha = fpgastub->alpha().value(); + int iphialphacor = ((ideltar * ialpha * ialphafact) >> settings_.alphashift()); ideltaphi += iphialphacor; } From 64cd6023d65613de47abf0ba4f1b31635fd5b64c Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sun, 4 Apr 2021 22:50:35 -0400 Subject: [PATCH 39/45] Addressing more comments from Louise S. --- .../TrackFindingTracklet/interface/Settings.h | 1 + .../interface/TrackletConfigBuilder.h | 20 +++++++ .../plugins/L1FPGATrackProducer.cc | 5 +- .../python/Tracklet_cfi.py | 2 +- .../TrackFindingTracklet/src/DTCLinkMemory.cc | 4 +- .../TrackFindingTracklet/src/MatchEngine.cc | 8 --- .../src/MatchProcessor.cc | 60 +++++-------------- 7 files changed, 45 insertions(+), 55 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index d74d2a2d1ec95..ad212043e68e7 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -33,6 +33,7 @@ namespace trklet { constexpr unsigned int N_RZBITS = 3; //number of bit for the r/z bins constexpr unsigned int N_VMSTUBSMAX = 15; // maximum number of stubs in VM bin + constexpr unsigned int N_BITSMEMADDRESS = 7; // Number of bits for address in memories constexpr double sixth = 1.0 / 6.0; //Commonly used factor diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h b/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h index 509e777326813..f1734c35f2cd3 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h @@ -81,22 +81,32 @@ namespace trklet { // The next group of fcn formats a string to write out names of different // memories and processing modules // + + //Seed string, eg. L1L2 std::string iSeedStr(unsigned int iSeed); + //Return unsigned as string std::string numStr(unsigned int i); + //Retunr iTC as string - ie A, B, C, etc std::string iTCStr(unsigned int iTC); + //The region string A, B, C etc for layers and disks; X, Y, Z etc for overlap std::string iRegStr(unsigned int iReg, unsigned int iSeed); + //TC Name std::string TCName(unsigned int iSeed, unsigned int iTC); + //Name of layer or disk, e.g. L1 or D1 std::string LayerName(unsigned int ilayer); + //Tracklet projection name std::string TPROJName(unsigned int iSeed, unsigned int iTC, unsigned int ilayer, unsigned int ireg); + //Projection router name std::string PRName(unsigned int ilayer, unsigned int ireg); + //StubPair Name std::string SPName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, @@ -105,6 +115,7 @@ namespace trklet { unsigned int ivm2, unsigned int iseed); + //StubPaur displaced name std::string SPDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, @@ -116,6 +127,7 @@ namespace trklet { unsigned int ivm3, unsigned int iseed); + //Stub Triplet name std::string STName(unsigned int l1, unsigned int ireg1, unsigned int l2, @@ -125,6 +137,7 @@ namespace trklet { unsigned int iseed, unsigned int count); + //TrackletEngine name std::string TEName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, @@ -133,6 +146,7 @@ namespace trklet { unsigned int ivm2, unsigned int iseed); + //Triplet engine name std::string TREName(unsigned int l1, unsigned int ireg1, unsigned int l2, @@ -140,6 +154,7 @@ namespace trklet { unsigned int iseed, unsigned int count); + //TrackletEngine displaced name std::string TEDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, @@ -148,10 +163,13 @@ namespace trklet { unsigned int ivm2, unsigned int iseed); + //Tracklet parameter memory name std::string TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc); + //TrackletCalculator displaced name std::string TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc); + //TrackletProjection name std::string TPROJName(unsigned int l1, unsigned int l2, unsigned int l3, @@ -159,8 +177,10 @@ namespace trklet { unsigned int projlay, unsigned int projreg); + //FitTrack module name std::string FTName(unsigned int l1, unsigned int l2, unsigned int l3); + //TrackletCalculator name std::string TCNAme(unsigned int iseed, unsigned int iTC); // diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 0c0d8f91c95da..ad83e1ec15f16 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -460,7 +460,10 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe assert(layerdisk != -1); //Get the 36 bit word - skip the lowest 3 buts (status and layer code) - string stubword = stub.second.to_string().substr(64 - 36 - 3, 36); + constexpr int DTCLinkWordSize = 64; + constexpr int StubWordSize = 36; + constexpr int LayerandStatusCodeSize = 3; + string stubword = stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize); string stubwordhex = ""; //Loop over the 9 words in the 36 bit stub word diff --git a/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py b/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py index bf2e03815a307..0ca90046d6e93 100644 --- a/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/Tracklet_cfi.py @@ -9,7 +9,7 @@ MCTruthStubInputTag = cms.InputTag("TTStubAssociatorFromPixelDigis", "StubAccepted"), TrackingParticleInputTag = cms.InputTag("mix", "MergedTrackTruth"), BeamSpotSource = cms.InputTag("offlineBeamSpot"), - asciiFileName = cms.untracked.string("evtlist.txt"), + asciiFileName = cms.untracked.string(""), # (if running on CRAB use "../../fitpattern.txt" etc instead) Extended=cms.bool(False), Hnpar=cms.uint32(4), diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc index ff092e5f90c21..ed45616953958 100644 --- a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc @@ -28,7 +28,7 @@ void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { iSector_ = iSector; - //FIXME should be in settings + static map > dtclayers{{"PS10G_1", {0, 6, 8, 10}}, {"PS10G_2", {0, 7, 9}}, {"PS10G_3", {1, 7}}, @@ -49,8 +49,10 @@ void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { string dtcname = stubs_[j]->l1tstub()->DTClink(); int layerdisk = stubs_[j]->l1tstub()->layerdisk(); + //If the string starts with 'neg' skip the first three character int start = dtcname.substr(0, 3) == "neg" ? 3 : 0; + //For the dtcbase name remove the leading 'neg' if in the name and the trailing '_A' or '_B' string dtcbase = dtcname.substr(start, dtcname.size() - 2 - start); vector layers = dtclayers[dtcbase]; diff --git a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc index f0594443943de..2668c2e646761 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchEngine.cc @@ -186,10 +186,6 @@ void MatchEngine::execute() { if (second) rzlast += 1; - if (print) { - cout << "istep rzfirst rzlast : " << istep << " " << rzfirst << " " << rzlast << endl; - } - //Check if there are stubs in the memory int nstubfirst = vmstubs_->nStubsBin(rzfirst); int nstublast = vmstubs_->nStubsBin(rzlast); @@ -297,10 +293,6 @@ void MatchEngine::execute() { unsigned int index = (projrinv << nbits) + vmstub.bend().value(); - //if (layerdisk_>5) { - // cout << "layerdisk: "<proj(layerdisk_).fpgaphiproj(); - //if (print) cout << "PROJECTION "<getName()<<": "<proj(layerdisk_).fpgaphiproj().value() - // << " " << proj->proj(layerdisk_).fpgarzproj().value() - // << " " << proj->proj(layerdisk_).fpgaphiprojder().value() - // << " " << proj->proj(layerdisk_).fpgarzprojder().value() - // << "TC index trackletIndex : "<TCIndex()<<" "<trackletIndex() - // <> (fpgaphi.nbits() - nvmbits_)) & (nvmbins_ - 1); int nextrabits = 2; @@ -270,9 +266,6 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits, nextrabits); - if (print) - cout << "iphi extrabits: " << iphi << " " << extrabits << endl; - unsigned int ivmPlus = iphi; int shift = 0; @@ -318,19 +311,14 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { unsigned int slot = proj->proj(layerdisk_).fpgarzbin1projvm().value(); bool second = proj->proj(layerdisk_).fpgarzbin2projvm().value(); - if (print) - cout << "istep=" << istep << " TrkId stubindex : " << 128 * proj->TCIndex() + proj->trackletIndex() - << " ivmMinus ivmPlus shift " << ivmMinus << " " << ivmPlus << " " << shift << "second: " << second - << " iphiproj=" << fpgaphi.value() << endl; - - unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + 3))) & 7; + unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + NFINEPHIBITS))) & ((1<proj(layerdisk_).fpgafinerzvm().value(); bool isPSseed = proj->PSseed(); - int nbins = 8; - if (layerdisk_ >= 6) - nbins = 16; + int nbins = (1= N_LAYER) + nbins*=2; //twice as many bins in disks (since there are two disks) VMStubsMEMemory* stubmem = vmstubs_[0]; bool usefirstMinus = stubmem->nStubsBin(ivmMinus * nbins + slot) != 0; @@ -390,7 +378,6 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { if (layerdisk_ >= 6) nbins = 16; - //if (print) cout << "istep = "<l1tstub(); - if (print) - cout << "MatchCalculator istep=" << istep - << " TrkId stubindex : " << 128 * tracklet->TCIndex() + tracklet->trackletIndex() << " " - << fpgastub->allStubIndex().value() << endl; - if (layerdisk_ < N_LAYER) { const Projection& proj = tracklet->proj(layerdisk_); int ir = fpgastub->r().value(); @@ -488,8 +469,6 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b int ideltaz = fpgastub->z().value() - iz; int ideltaphi = (fpgastub->phi().value() - iphi) << phishift_; - //if (print) cout << "ideltaphi : " << fpgastub->phi().value()<<" "<phi(); @@ -549,11 +528,6 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b << endl; } - if (print) - cout << "delta phi : " << ideltaphi << " " << phimatchcut_[seedindex] << endl; - if (print) - cout << "delta z : " << (ideltaz << dzshift_) << " " << zmatchcut_[seedindex] << endl; - bool imatch = ((unsigned int)std::abs(ideltaphi) <= phimatchcut_[seedindex]) && ((unsigned int)std::abs(ideltaz << dzshift_) <= zmatchcut_[seedindex]); @@ -577,7 +551,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b dz, dphiapprox, dzapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), + (phiregion_ << N_BITSMEMADDRESS) + fpgastub->stubindex().value(), fpgastub); if (settings_.debugTracklet()) { @@ -586,8 +560,6 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b int iSeed = tracklet->getISeed(); assert(fullmatches_[iSeed] != nullptr); - if (print) - cout << "istep = " << istep << " Add match for iSeed : " << iSeed << endl; fullmatches_[iSeed]->addMatch(tracklet, fpgastub); return true; @@ -740,7 +712,7 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b dr, drphiapprox / stub->r(), drapprox, - (phiregion_ << 7) + fpgastub->stubindex().value(), + (phiregion_ << N_BITSMEMADDRESS) + fpgastub->stubindex().value(), fpgastub); if (settings_.debugTracklet()) { From cc9e791515983806eb4620d90cc80ba59bede967 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sun, 4 Apr 2021 23:38:28 -0400 Subject: [PATCH 40/45] More fixes to comments --- L1Trigger/TrackFindingTracklet/interface/Settings.h | 5 +++++ L1Trigger/TrackFindingTracklet/src/Projection.cc | 5 ----- .../TrackFindingTracklet/src/PurgeDuplicate.cc | 4 ++-- L1Trigger/TrackFindingTracklet/src/Stub.cc | 6 +----- L1Trigger/TrackFindingTracklet/src/Tracklet.cc | 10 +++++----- .../TrackFindingTracklet/src/TrackletCalculator.cc | 10 +++------- .../src/TrackletConfigBuilder.cc | 7 ------- .../TrackFindingTracklet/src/TrackletEngineUnit.cc | 13 +------------ .../TrackFindingTracklet/src/TrackletProcessor.cc | 3 +-- L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc | 10 +++++----- L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc | 1 - 11 files changed, 23 insertions(+), 51 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index ad212043e68e7..5adb3fd6ec5ef 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -37,6 +37,11 @@ namespace trklet { constexpr double sixth = 1.0 / 6.0; //Commonly used factor + constexpr double VMROUTERCUTZL2 = 50.0; //Min L2 z for inner allstub + constexpr double VMROUTERCUTZL1L3L5 = 95.0; //Max z for inner barrel layers + constexpr double VMROUTERCUTZL1 = 70.0; //Max z for L1 barrel seeding + constexpr double VMROUTERCUTRD1D3 = 55.0; //Max r for disk seeds + class Settings { public: Settings() { diff --git a/L1Trigger/TrackFindingTracklet/src/Projection.cc b/L1Trigger/TrackFindingTracklet/src/Projection.cc index 48dbb93cf0e4e..2f08e1a5348a2 100644 --- a/L1Trigger/TrackFindingTracklet/src/Projection.cc +++ b/L1Trigger/TrackFindingTracklet/src/Projection.cc @@ -88,11 +88,6 @@ void Projection::init(Settings const& settings, int rbin2 = 8.0 * (irzproj * settings.krprojshiftdisk() + roffset - settings.rmindiskvm()) / (settings.rmaxdisk() - settings.rmindiskvm()); - if (irzproj * settings.krprojshiftdisk() < 20.0) { - edm::LogPrint("Tracklet") << " WARNING : irproj = " << irzproj << " " << irzproj * settings.krprojshiftdisk() - << " " << layerdisk; - } - if (rbin1 < 0) { rbin1 = 0; } diff --git a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc index 86f4bb81ef530..94adc29e7d126 100644 --- a/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc +++ b/L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc @@ -484,10 +484,10 @@ double PurgeDuplicate::getPhiRes(Tracklet* curTracklet, const Stub* curStub) { stubphi = curStub->l1tstub()->phi(); // Get region that the stub is in (Layer 1->6, Disk 1->5) int Layer = curStub->layerdisk() + 1; - if (Layer > 6) { + if (Layer > N_LAYER) { Layer = 0; } - int Disk = curStub->layerdisk() - 5; + int Disk = curStub->layerdisk() - (N_LAYER - 1); if (Disk < 0) { Disk = 0; } diff --git a/L1Trigger/TrackFindingTracklet/src/Stub.cc b/L1Trigger/TrackFindingTracklet/src/Stub.cc index 3d116ae9867a2..fe7595a7dd784 100644 --- a/L1Trigger/TrackFindingTracklet/src/Stub.cc +++ b/L1Trigger/TrackFindingTracklet/src/Stub.cc @@ -60,14 +60,12 @@ Stub::Stub(L1TStub& stub, Settings const& settings, Globals& globals) : settings int newphi = phibits.to_ulong(); - int newalpha = alphabits.to_ulong(); //-(1<<(nalphabits-1)); + int newalpha = alphabits.to_ulong(); if (newalpha >= (1 << (nalphabits - 1))) newalpha = newalpha - (1 << nalphabits); l1tstub_ = &stub; - //int ibendnew = bendencode(newbend*bendfact, stub.isPSmodule()); - bend_.set(newbend, nbendbits, true, __LINE__, __FILE__); phi_.set(newphi, nphibits, true, __LINE__, __FILE__); @@ -93,8 +91,6 @@ Stub::Stub(L1TStub& stub, Settings const& settings, Globals& globals) : settings if (settings.writeMonitorData("StubBend")) { unsigned int nsimtrks = globals.event()->nsimtracks(); - //cout << "Have L1 stub" << endl; - for (unsigned int isimtrk = 0; isimtrk < nsimtrks; isimtrk++) { const L1SimTrack& simtrk = globals.event()->simtrack(isimtrk); if (stub.tpmatch2(simtrk.trackid())) { diff --git a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc index 8bcdd3604055a..bc7ba9f5d1f1a 100644 --- a/L1Trigger/TrackFindingTracklet/src/Tracklet.cc +++ b/L1Trigger/TrackFindingTracklet/src/Tracklet.cc @@ -366,11 +366,11 @@ std::map Tracklet::getStubIDs() { // E.g. An L3L4 track has 0=L1, 1=L2, 2=L4, 3=L5 for the barrels (for proj*_[i]) if (innerFPGAStub_) - assert(innerFPGAStub_->stubindex().nbits() == 7); + assert(innerFPGAStub_->stubindex().nbits() == N_BITSMEMADDRESS); if (middleFPGAStub_) - assert(middleFPGAStub_->stubindex().nbits() == 7); + assert(middleFPGAStub_->stubindex().nbits() == N_BITSMEMADDRESS); if (outerFPGAStub_) - assert(outerFPGAStub_->stubindex().nbits() == 7); + assert(outerFPGAStub_->stubindex().nbits() == N_BITSMEMADDRESS); if (barrel_) { for (int i = 0; i < N_LAYER; i++) { @@ -394,9 +394,9 @@ std::map Tracklet::getStubIDs() { location <<= resid_[N_LAYER + i].fpgastubid().nbits(); if (itfit().value() < 0) { - stubIDs[-11 - i] = resid_[N_LAYER + i].fpgastubid().value() + location; + stubIDs[-(N_LAYER + N_DISK) - i] = resid_[N_LAYER + i].fpgastubid().value() + location; } else { - stubIDs[11 + i] = resid_[N_LAYER + i].fpgastubid().value() + location; + stubIDs[N_LAYER + N_DISK + i] = resid_[N_LAYER + i].fpgastubid().value() + location; } } } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc index 7f75b31fb1ad1..2ad45e30c6717 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletCalculator.cc @@ -159,8 +159,9 @@ void TrackletCalculator::execute(unsigned int iSector, double phimin, double phi phimax_ = phimax; iSector_ = iSector; - bool print = (iSector == 3) && (getName() == "TC_L1L2G"); - print = false; + //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()) { @@ -188,11 +189,6 @@ void TrackletCalculator::execute(unsigned int iSector, double phimin, double phi } else { //barrel+barrel seeding bool accept = barrelSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub); - if (print) { - cout << stubpair->getName() << " i inner outer : " << countall << " " - << innerFPGAStub->allStubIndex().value() << " " << outerFPGAStub->allStubIndex().value() - << " accept = " << accept << endl; - } if (accept) countsel++; } diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc index b41f391cfa4ed..cfed9abbcaebb 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc @@ -486,10 +486,6 @@ void TrackletConfigBuilder::writeSPDMemories(std::ostream& wires, std::ostream& for (unsigned int ivm2 = 0; ivm2 < nvm2; ivm2++) { int count = 0; - std::cout << "layerdisk1 layerdisk2 TEDName : " << layerdisk1 << " " << layerdisk2 << " " - << TEDName(layerdisk1, ireg1, ireg1 * nvm1 + ivm1, layerdisk2, ireg2, ireg2 * nvm2 + ivm2, iSeed) - << std::endl; - modules << "TrackletEngineDisplaced: " << TEDName(layerdisk1, ireg1, ireg1 * nvm1 + ivm1, layerdisk2, ireg2, ireg2 * nvm2 + ivm2, iSeed) << std::endl; @@ -570,7 +566,6 @@ void TrackletConfigBuilder::writeSPDMemories(std::ostream& wires, std::ostream& } unsigned int nST = stubTriplets[iSeed].size(); - cout << "iSeed nST : " << iSeed << " " << nST << endl; for (unsigned int iST = 0; iST < nST; iST++) { unsigned int iTC = (iST * nTC) / nST; assert(iTC < nTC); @@ -723,7 +718,6 @@ void TrackletConfigBuilder::writeASMemories(std::ostream& os, std::ostream& memo if (ilayer == l1) { int ratio = NRegions_[l1] / NRegions_[l2]; - //std::cout << "ratio : "< max) @@ -774,7 +768,6 @@ void TrackletConfigBuilder::writeASMemories(std::ostream& os, std::ostream& memo } } } - //cout << "iseed ratio max min : "<allStubIndex().value() << " " << candpair__.second->allStubIndex().value() << endl; candpairs_.store(candpair__); } @@ -60,9 +56,6 @@ void TrackletEngineUnit::step(bool print, int istep, int iTE) { goodpair_ = false; if (idle_ || nearfull_) { - if (print) - cout << "istep=" << istep << " TEUnit step iTE=" << iTE << " idle nearfull: " << idle_ << " " << nearfull_ - << " rptr wptr:" << candpairs_.rptr() << " " << candpairs_.wptr() << endl; return; } @@ -123,10 +116,6 @@ void TrackletEngineUnit::step(bool print, int istep, int iTE) { goodpair_ = true; } } - if (print) - cout << "istep=" << istep << " TEUnit step iTE=" << iTE - << " inner istub nstub : " << tedata_.stub_->allStubIndex().value() << " " << istub_ << " " << nstub_ - << " nreg regionsize" << nreg_ << " " << tedata_.regions_.size() << endl; istub_++; assert(nstub_ <= N_VMSTUBSMAX); diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc index 025b5df6a5d43..ee937c120033f 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletProcessor.cc @@ -342,7 +342,6 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim ninnerstubs++; const Stub* stub = innerallstubs_[imem]->getStub(istub); - //const Stub* stub = innerallstubs_[imem]->getStub(innerallstubs_[imem]->nStubs()-istub-1); if (settings_.debugTracklet()) { edm::LogVerbatim("Tracklet") << getName() << " Have stub in " << innerallstubs_[imem]->getName(); @@ -367,7 +366,7 @@ void TrackletProcessor::execute(unsigned int iSector, double phimin, double phim } int lutval = -1; - if (iSeed_ < 6) { //FIXME should only be one table... + if (iSeed_ < 6) { //FIXME should only be one table - but will need coordination with HLS code. lutval = vmrtable_.lookupinner(indexz, indexr); } else { lutval = vmrtable_.lookupinneroverlap(indexz, indexr); diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc index 76c85c9eeaf8a..b2025b7d0067f 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc @@ -182,20 +182,20 @@ void VMRouterCM::execute() { continue; int absz = std::abs(stub->z().value()); - if (layerdisk_ == 1 && absz < 50.0 / settings_.kz(layerdisk_)) + if (layerdisk_ == 1 && absz < VMROUTERCUTZL2 / settings_.kz(layerdisk_)) continue; - if ((layerdisk_ == 2 || layerdisk_ == 4) && absz > 95.0 / settings_.kz(layerdisk_)) + if ((layerdisk_ == 2 || layerdisk_ == 4) && absz > VMROUTERCUTZL1L3L5 / settings_.kz(layerdisk_)) continue; - if ((layerdisk_ == 6 || layerdisk_ == 8) && stub->r().value() > 55.0 / settings_.kr()) + if ((layerdisk_ == 6 || layerdisk_ == 8) && stub->r().value() > VMROUTERCUTRD1D3 / settings_.kr()) continue; if ((layerdisk_ == 6 || layerdisk_ == 8) && stub->r().value() < 2 * int(N_DSS_MOD)) continue; if (layerdisk_ == 0) { if (memtype == 'M' || memtype == 'R' || memtype == 'L') { - if (absz < 70.0 / settings_.kz(layerdisk_)) + if (absz < VMROUTERCUTZL1 / settings_.kz(layerdisk_)) continue; } else { - if (absz > 95.0 / settings_.kz(layerdisk_)) + if (absz > VMROUTERCUTZL1L3L5 / settings_.kz(layerdisk_)) continue; } } diff --git a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc index 95471679fb5f4..1853a01f71f6b 100644 --- a/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc +++ b/L1Trigger/TrackFindingTracklet/src/VMRouterTable.cc @@ -85,7 +85,6 @@ void VMRouterTable::init(unsigned int layerdisk, std::string const& name) { if (bin < 0) bin = 0; if (bin >= NBINS / 2) - //bin = NBINS / 2 - 1; bin = 0; vmrtabletedisk_.push_back(bin); } From e164c32d2e681b53c4fabd90a3b7ff3136625234 Mon Sep 17 00:00:00 2001 From: Anders Date: Mon, 5 Apr 2021 20:20:31 +0200 Subject: [PATCH 41/45] Make running hybrid default (not displaced) --- L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py index 6663f0e2463a0..494fdfc7e4470 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py @@ -15,7 +15,7 @@ # Set L1 tracking algorithm: # 'HYBRID' (baseline, 4par fit) or 'HYBRID_DISPLACED' (extended, 5par fit). # (Or legacy algos 'TMTT' or 'TRACKLET'). -L1TRKALGO = 'HYBRID_DISPLACED' +L1TRKALGO = 'HYBRID' WRITE_DATA = False From 0c972b5bc89270348c401d2fe7e333b1cd010a77 Mon Sep 17 00:00:00 2001 From: Louise Skinnari Date: Wed, 7 Apr 2021 00:23:22 +0200 Subject: [PATCH 42/45] restore buildfile --- .../TrackFindingTracklet/test/BuildFile.xml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml index aee5c63f06ded..29aaa5e4ee8ec 100644 --- a/L1Trigger/TrackFindingTracklet/test/BuildFile.xml +++ b/L1Trigger/TrackFindingTracklet/test/BuildFile.xml @@ -7,15 +7,9 @@ - - - - - - - + @@ -24,18 +18,8 @@ - - - - - - - - - - From 35928d13555c5eb093ce145c510b0a69739d55dd Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Thu, 8 Apr 2021 14:17:41 -0400 Subject: [PATCH 43/45] Add DTC link config to Settings.h --- .../TrackFindingTracklet/interface/Settings.h | 23 ++++++++++++++++++- .../TrackFindingTracklet/src/DTCLinkMemory.cc | 15 +----------- .../src/TrackletEngineUnit.cc | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 5adb3fd6ec5ef..6adb9d98e4386 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" @@ -409,7 +411,13 @@ namespace trklet { assert(bendcut > 0.0); return bendcut; } - + + const std::vector& dtcLayers(const std::string& dtcName) const { + auto iter=dtclayers_.find(dtcName); + assert(iter!=dtclayers_.end()); + return iter->second; + } + double bendcutte(int ibend, int layerdisk, bool isPSmodule) const { return bendcut(ibend, layerdisk, isPSmodule); } double bendcutme(int ibend, int layerdisk, bool isPSmodule) const { @@ -464,6 +472,19 @@ namespace trklet { {{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2}}, {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}}}}; + std::map > dtclayers_{{"PS10G_1", {0, 6, 8, 10}}, + {"PS10G_2", {0, 7, 9}}, + {"PS10G_3", {1, 7}}, + {"PS10G_4", {6, 8, 10}}, + {"PS_1", {2, 7}}, + {"PS_2", {2, 9}}, + {"2S_1", {3, 4}}, + {"2S_2", {4}}, + {"2S_3", {5}}, + {"2S_4", {5, 8}}, + {"2S_5", {6, 9}}, + {"2S_6", {7, 10}}}; + double rmindiskvm_{22.5}; double rmaxdiskvm_{67.0}; diff --git a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc index ed45616953958..d80531fa86687 100644 --- a/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc +++ b/L1Trigger/TrackFindingTracklet/src/DTCLinkMemory.cc @@ -29,19 +29,6 @@ void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) { void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { iSector_ = iSector; - static map > dtclayers{{"PS10G_1", {0, 6, 8, 10}}, - {"PS10G_2", {0, 7, 9}}, - {"PS10G_3", {1, 7}}, - {"PS10G_4", {6, 8, 10}}, - {"PS_1", {2, 7}}, - {"PS_2", {2, 9}}, - {"2S_1", {3, 4}}, - {"2S_2", {4}}, - {"2S_3", {5}}, - {"2S_4", {5, 8}}, - {"2S_5", {6, 9}}, - {"2S_6", {7, 10}}}; - const string dirIS = settings_.memPath() + "InputStubs/"; openFile(first, dirIS, "Link_"); @@ -55,7 +42,7 @@ void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) { //For the dtcbase name remove the leading 'neg' if in the name and the trailing '_A' or '_B' string dtcbase = dtcname.substr(start, dtcname.size() - 2 - start); - vector layers = dtclayers[dtcbase]; + const vector& layers = settings_.dtcLayers(dtcbase); int lcode = -1; for (unsigned int index = 0; index < layers.size(); index++) { diff --git a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc index a303db8dab247..291d47b7ad5cc 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackletEngineUnit.cc @@ -44,7 +44,7 @@ void TrackletEngineUnit::reset() { candpairs_.reset(); } -void TrackletEngineUnit::step(bool, int, int iTE) { +void TrackletEngineUnit::step(bool, int, int) { if (goodpair__) { candpairs_.store(candpair__); From adcfecf9e076de785609ee0135b6c420acee31cf Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Fri, 9 Apr 2021 14:11:46 -0400 Subject: [PATCH 44/45] Changes to suppress warning in MatchCalculator when running displaced tracking --- L1Trigger/TrackFindingTracklet/interface/Settings.h | 1 + L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc | 2 +- L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/Settings.h b/L1Trigger/TrackFindingTracklet/interface/Settings.h index 6adb9d98e4386..0759b7ebcf279 100644 --- a/L1Trigger/TrackFindingTracklet/interface/Settings.h +++ b/L1Trigger/TrackFindingTracklet/interface/Settings.h @@ -38,6 +38,7 @@ namespace trklet { constexpr unsigned int N_BITSMEMADDRESS = 7; // Number of bits for address in memories constexpr double sixth = 1.0 / 6.0; //Commonly used factor + constexpr double third = 1.0 / 3.0; //Commonly used factor constexpr double VMROUTERCUTZL2 = 50.0; //Min L2 z for inner allstub constexpr double VMROUTERCUTZL1L3L5 = 95.0; //Max z for inner barrel layers diff --git a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc index 4b4dcfe3e20ba..86549eac723bf 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc @@ -448,7 +448,7 @@ void MatchCalculator::execute(double phioffset) { double drcut = idrcut * settings_.krprojshiftdisk(); bool match, imatch; - if (std::abs(dphi) < 0.25 && std::abs(dphiapprox) < 0.25) { //Changed the Asserts into if statements + 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()); diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 4055584d9687a..4e8bc1f170481 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -699,11 +699,11 @@ bool MatchProcessor::matchCalculator(Tracklet* tracklet, const Stub* fpgastub, b edm::LogVerbatim("Tracklet") << "MatchCalculator found match in disk " << getName(); } - if (std::abs(dphi) >= 0.25) { + if (std::abs(dphi) >= third*settings_.dphisectorHG()) { edm::LogPrint("Tracklet") << "dphi " << dphi << " ISeed " << tracklet->getISeed(); } - assert(std::abs(dphi) < 0.25); - assert(std::abs(dphiapprox) < 0.25); + assert(std::abs(dphi) < third*settings_.dphisectorHG()); + assert(std::abs(dphiapprox) < third*settings_.dphisectorHG()); tracklet->addMatch(layerdisk_, ideltaphi, From d51d818adee1e2d37c1a983bab9762af0b09561d Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Sat, 10 Apr 2021 10:39:02 -0400 Subject: [PATCH 45/45] Fix typo introduced in code cleanup for MatchProcessor --- .../TrackFindingTracklet/src/MatchProcessor.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc index 4e8bc1f170481..b2f7722a5b1d5 100644 --- a/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc +++ b/L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc @@ -89,9 +89,9 @@ MatchProcessor::MatchProcessor(string name, Settings const& settings, Globals* g } } } else { - constexpr int nprojbends = 1<PSseed(); - int nbins = (1= N_LAYER) + int nbins = (1 << N_RZBITS); + if (layerdisk_ >= N_LAYER) { nbins*=2; //twice as many bins in disks (since there are two disks) + } VMStubsMEMemory* stubmem = vmstubs_[0]; bool usefirstMinus = stubmem->nStubsBin(ivmMinus * nbins + slot) != 0; @@ -374,9 +375,10 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) { edm::LogVerbatim("Tracklet") << getName() << " adding projection to match engine"; } - int nbins = 8; - if (layerdisk_ >= 6) - nbins = 16; + int nbins = (1 << N_RZBITS); + if (layerdisk_ >= N_LAYER) { + nbins*=2; //twice as many bins in disks (since there are two disks) + } matchengines_[iME].init(stubmem, nbins,