diff --git a/DataFormats/L1TMuonPhase2/interface/Constants.h b/DataFormats/L1TMuonPhase2/interface/Constants.h index ea8c2f4c0c5cb..8f4ec6c8c2fe7 100644 --- a/DataFormats/L1TMuonPhase2/interface/Constants.h +++ b/DataFormats/L1TMuonPhase2/interface/Constants.h @@ -28,9 +28,9 @@ namespace Phase2L1GMT { const int BITSD0 = 12; //Muon ROI - const int BITSSTUBCOORD = 8; + const int BITSSTUBCOORD = 10; const int BITSSTUBETA = 8; - const int BITSSTUBID = 9; + const int BITSSTUBID = 12; const int BITSSTUBPHIQUALITY = 4; const int BITSSTUBETAQUALITY = 4; const int BITSSTUBTIME = 8; @@ -45,8 +45,8 @@ namespace Phase2L1GMT { const int BITSSIGMAETA = 4; const int BITSSIGMACOORD = 4; const int BITSPROPCOORD = 9; - const int BITSPROPSIGMACOORD_A = 5; - const int BITSPROPSIGMACOORD_B = 5; + const int BITSPROPSIGMACOORD_A = 6; + const int BITSPROPSIGMACOORD_B = 6; const int BITSPROPSIGMAETA_A = 5; const int BITSPROPSIGMAETA_B = 5; @@ -62,8 +62,9 @@ namespace Phase2L1GMT { const int BITSGTETA = 14; const int BITSGTZ0 = 10; const int BITSGTD0 = 10; - const int BITSGTQUAL = 8; - const int BITSGTISO = 4; + const int BITSGTQUAL = 6; + const int BITSGTQUALSC = 7; + const int BITSGTISO = 6; const int BITSGTBETA = 4; // Bitwidth for Tau->3mu object @@ -91,22 +92,24 @@ namespace Phase2L1GMT { const float LSBpt = 0.03125; const float LSBphi = 2. * M_PI / pow(2, BITSPHI); const float LSBeta = 2. * M_PI / pow(2, BITSETA); - const float LSBGTz0 = 0.05; // 0.5mm, in sync with GTT and Correlator - const float LSBGTd0 = 0.03; // from GT interface doc - const float LSBSAz0 = 1.6; // 0.05 * 32 cm, with range +- 25.6 - const float LSBSAd0 = 3.84; // 0.03 * 128 cm, with range +- 245.76 + const float LSBGTiso = 0.25; // 0.25GeV, LSBphi * 8 + const float LSBGTz0 = 0.05; // 0.5mm, in sync with GTT and Correlator + const float LSBGTd0 = 0.03; // from GT interface doc + const float LSBSAz0 = 1.6; // 0.05 * 32 cm, with range +- 25.6 + const float LSBSAd0 = 3.84; // 0.03 * 128 cm, with range +- 245.76 typedef ap_uint<64> wordtype; - typedef ap_uint<1> valid_gt_t; //valid - typedef ap_uint<1> q_gt_t; //charge - typedef ap_uint pt_gt_t; //pt of tracker muon - typedef ap_int phi_gt_t; //phi of tracker muon - typedef ap_int eta_gt_t; //eta of tracker muon - typedef ap_int z0_gt_t; //z0 of tracker muon - typedef ap_int d0_gt_t; //d0 of tracker muon - typedef ap_uint iso_gt_t; //isolation of tracker muon - typedef ap_uint beta_gt_t; //beta of tracker muon - typedef ap_uint qual_gt_t; //quality of tracker muon + typedef ap_uint<1> valid_gt_t; //valid + typedef ap_uint<1> q_gt_t; //charge + typedef ap_uint pt_gt_t; //pt of tracker muon + typedef ap_int phi_gt_t; //phi of tracker muon + typedef ap_int eta_gt_t; //eta of tracker muon + typedef ap_int z0_gt_t; //z0 of tracker muon + typedef ap_int d0_gt_t; //d0 of tracker muon + typedef ap_uint iso_gt_t; //isolation of tracker muon + typedef ap_uint beta_gt_t; //beta of tracker muon + typedef ap_uint qual_gt_t; //quality of tracker muon + typedef ap_int qualsc_gt_t; //quality score of tracker muon (qual/q) //Standalone muon datatype typedef ap_uint<1> valid_sa_t; //valid diff --git a/DataFormats/L1TMuonPhase2/interface/KMTFTrack.h b/DataFormats/L1TMuonPhase2/interface/KMTFTrack.h new file mode 100644 index 0000000000000..7e6197eea6d9e --- /dev/null +++ b/DataFormats/L1TMuonPhase2/interface/KMTFTrack.h @@ -0,0 +1,399 @@ +#ifndef DataFormats_L1TMuonPhase2_KMTFTrack_h +#define DataFormats_L1TMuonPhase2_KMTFTrack_h + +#include "DataFormats/Candidate/interface/LeafCandidate.h" +#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" +#include "DataFormats/L1Trigger/interface/BXVector.h" + +namespace l1t { + + class KMTFTrack; + typedef std::vector KMTFTrackCollection; + typedef BXVector KMTFTrackBxCollection; + + class KMTFTrack : public reco::LeafCandidate { + public: + KMTFTrack() + : reco::LeafCandidate(-1, reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)), + unconstrainedP4_(reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)), + covariance_(std::vector(6, 0.0)), + curvVertex_(0), + ptC_(0), + phiVertex_(0), + dxy_(0), + curvMuon_(0), + ptU_(0), + phiMuon_(0), + phiBMuon_(0), + curv_(0), + phi_(0), + phiB_(0), + coarseEta_(0), + approxPromptChi2_(0), + approxPromptErrChi2_(0), + approxDispChi2_(0), + approxDispErrChi2_(0), + hitPattern_(0), + step_(1), + sector_(0), + wheel_(0), + quality_(0), + hasFineEta_(false), + bx_(0), + rankPrompt_(0), + rankDisp_(0), + idFlag_(0) {} + + ~KMTFTrack() override = default; + + KMTFTrack(const l1t::MuonStubRef& seed, int phi, int phiB) + : reco::LeafCandidate(-1, reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)), + unconstrainedP4_(reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)), + covariance_(std::vector(6, 0.0)), + curvVertex_(0), + ptC_(0), + phiVertex_(0), + dxy_(0), + curvMuon_(0), + ptU_(0), + phiMuon_(0), + phiBMuon_(0), + curv_(0), + phi_(phi), + phiB_(phiB), + coarseEta_(0), + approxPromptChi2_(0), + approxPromptErrChi2_(0), + approxDispChi2_(0), + approxDispErrChi2_(0), + hitPattern_(0), + step_(seed->depthRegion()), + sector_(seed->phiRegion()), + wheel_(seed->etaRegion()), + quality_(seed->quality()), + hasFineEta_(false), + bx_(seed->bxNum()), + rankPrompt_(0), + rankDisp_(0), + idFlag_(0) { + stubs_.push_back(seed); + residuals_.push_back(0); + residuals_.push_back(0); + residuals_.push_back(0); + } + + reco::LeafCandidate::PolarLorentzVector displacedP4() const { return unconstrainedP4_; } + + //unconstrained pt + int ptDisplaced() const { return ptU_; } + //unconstrained curvature at station 1 + int curvatureAtMuon() const { return curvMuon_; } + //unconstrained phi at station 1 + int phiAtMuon() const { return phiMuon_; } + //unconstrained phiB at station 1 + int phiBAtMuon() const { return phiBMuon_; } + + //constrained pt + int ptPrompt() const { return ptC_; } + //Constrained curvature at vertex + int curvatureAtVertex() const { return curvVertex_; } + //constrained phi at the vertex + int phiAtVertex() const { return phiVertex_; } + //Impact parameter as calculated from the muon track + int dxy() const { return dxy_; } + //Unconstrained curvature at the Muon systen + int curvature() const { return curv_; } + //Unconstrained phi at the Muon systen + int positionAngle() const { return phi_; } + //Unconstrained bending angle at the Muon systen + int bendingAngle() const { return phiB_; } + //Coarse eta caluclated only using phi segments + int coarseEta() const { return coarseEta_; } + //Approximate Chi2 metrics + int approxPromptChi2() const { return approxPromptChi2_; } + int approxPromptErrChi2() const { return approxPromptErrChi2_; } + int approxDispChi2() const { return approxDispChi2_; } + int approxDispErrChi2() const { return approxDispErrChi2_; } + + int hitPattern() const { return hitPattern_; } + //step; + int step() const { return step_; } + //sector; + int sector() const { return sector_; } + //wheel + int wheel() const { return wheel_; } + //quality + int quality() const { return quality_; } + + //fine eta + int fineEta() const { return fineEta_; } + bool hasFineEta() const { return hasFineEta_; } + + //BX + int bx() const { return bx_; } + + //rank + int rankPrompt() const { return rankPrompt_; } + int rankDisp() const { return rankDisp_; } + + int id() const { return idFlag_; } + + //Associated stubs + const l1t::MuonStubRefVector& stubs() const { return stubs_; } + + //get Kalman gain + const std::vector& kalmanGain(unsigned int step) const { + switch (step) { + case 3: + return kalmanGain3_; + case 2: + return kalmanGain2_; + case 1: + return kalmanGain1_; + case 0: + return kalmanGain0_; + } + return kalmanGain0_; + } + + //get covariance + const std::vector& covariance() const { return covariance_; } + + //get residual + int residual(uint i) const { return residuals_[i]; } + + //check overlap + bool overlapTrack(const KMTFTrack& other) const { + for (const auto& s1 : stubs_) { + for (const auto& s2 : other.stubs()) { + if (s1->phiRegion() == s2->phiRegion() && s1->etaRegion() == s2->etaRegion() && + s1->depthRegion() == s2->depthRegion() && s1->id() == s2->id()) + return true; + } + } + return false; + } + + bool operator==(const KMTFTrack& t2) const { + if (this->stubs().size() != t2.stubs().size()) + return false; + for (unsigned int i = 0; i < this->stubs().size(); ++i) { + const l1t::MuonStubRef& s1 = this->stubs()[i]; + const l1t::MuonStubRef& s2 = t2.stubs()[i]; + if (s1->phiRegion() != s2->phiRegion() || s1->etaRegion() != s2->etaRegion() || + s1->depthRegion() != s2->depthRegion() || s1->id() != s2->id() || s1->tfLayer() != s2->tfLayer()) + return false; + } + return true; + } + + //Set coordinates general + void setCoordinates(int step, int curv, int phi, int phiB) { + step_ = step; + curv_ = curv; + phiB_ = phiB; + phi_ = phi; + } + + void setCoordinatesAtVertex(int curv, int phi, int dxy) { + curvVertex_ = curv; + phiVertex_ = phi; + dxy_ = dxy; + } + + void setCoordinatesAtMuon(int curv, int phi, int phiB) { + curvMuon_ = curv; + phiMuon_ = phi; + phiBMuon_ = phiB; + } + + void setPt(int ptC, int ptU) { + ptC_ = ptC; + ptU_ = ptU; + } + + void setCoarseEta(int eta) { coarseEta_ = eta; } + + void setHitPattern(int pattern) { hitPattern_ = pattern; } + + void setApproxChi2(int chi, int chiErr, bool prompt) { + if (prompt) { + approxPromptChi2_ = chi; + approxPromptErrChi2_ = chiErr; + } else { + approxDispChi2_ = chi; + approxDispErrChi2_ = chiErr; + } + } + + void setPtEtaPhi(double pt, double eta, double phi) { + PolarLorentzVector v(pt, eta, phi, 0.105); + setP4(v); + } + void setPtEtaPhiDisplaced(double pt, double eta, double phi) { + unconstrainedP4_.SetPt(pt); + unconstrainedP4_.SetEta(eta); + unconstrainedP4_.SetPhi(phi); + } + + void addStub(const l1t::MuonStubRef& stub) { + if (stub->quality() < quality_) + quality_ = stub->quality(); + stubs_.push_back(stub); + } + + void setStubs(const l1t::MuonStubRefVector& stubs) { stubs_ = stubs; } + + void setRank(int rank, bool vertex) { + if (vertex) + rankPrompt_ = rank; + else + rankDisp_ = rank; + } + + void setIDFlag(bool passPrompt, bool passDisp) { + unsigned p0 = 0; + unsigned p1 = 0; + + if (passPrompt) + p0 = 1; + if (passDisp) + p1 = 2; + + idFlag_ = p0 | p1; + } + + void setKalmanGain( + unsigned int step, unsigned int K, float a1, float a2, float a3 = 0, float a4 = 0, float a5 = 0, float a6 = 0) { + switch (step) { + case 3: + kalmanGain3_.push_back(K); + kalmanGain3_.push_back(a1); + kalmanGain3_.push_back(a2); + kalmanGain3_.push_back(a3); + kalmanGain3_.push_back(a4); + kalmanGain3_.push_back(a5); + kalmanGain3_.push_back(a6); + break; + case 2: + kalmanGain2_.push_back(K); + kalmanGain2_.push_back(a1); + kalmanGain2_.push_back(a2); + kalmanGain2_.push_back(a3); + kalmanGain2_.push_back(a4); + kalmanGain2_.push_back(a5); + kalmanGain2_.push_back(a6); + break; + case 1: + kalmanGain1_.push_back(K); + kalmanGain1_.push_back(a1); + kalmanGain1_.push_back(a2); + kalmanGain1_.push_back(a3); + kalmanGain1_.push_back(a4); + kalmanGain1_.push_back(a5); + kalmanGain1_.push_back(a6); + break; + case 0: + kalmanGain0_.push_back(K); + kalmanGain0_.push_back(a1); + kalmanGain0_.push_back(a2); + kalmanGain0_.push_back(a3); + break; + + default: + throw cms::Exception("WrongCondition") << "Critical ERROR on setting the Kalman gain\n"; + } + } + + //set covariance + void setCovariance(const CovarianceMatrix& c) { + covariance_[0] = c(0, 0); + covariance_[1] = c(0, 1); + covariance_[2] = c(1, 1); + covariance_[3] = c(0, 2); + covariance_[4] = c(1, 2); + covariance_[5] = c(2, 2); + } + + //set fine eta + void setFineEta(int eta) { + fineEta_ = eta; + hasFineEta_ = true; + } + + //set residual + void setResidual(uint i, int val) { residuals_[i] = val; } + + private: + reco::LeafCandidate::PolarLorentzVector unconstrainedP4_; + + //Covariance matrix for studies + std::vector covariance_; + l1t::MuonStubRefVector stubs_; + + //vertex coordinates + int curvVertex_; + int ptC_; + int phiVertex_; + int dxy_; + + //muon coordinates + int curvMuon_; + int ptU_; + int phiMuon_; + int phiBMuon_; + + //generic coordinates + int curv_; + int phi_; + int phiB_; + //common coordinates + int coarseEta_; + + //Approximate Chi2 metric + int approxPromptChi2_; + int approxPromptErrChi2_; + int approxDispChi2_; + int approxDispErrChi2_; + + //phi bitmask + int hitPattern_; + + //propagation step + int step_; + + //sector + int sector_; + //wheel + int wheel_; + + //quality + int quality_; + + //Fine eta + int fineEta_; + + //has fine eta? + bool hasFineEta_; + + //BX + int bx_; + + //rank + int rankPrompt_; + int rankDisp_; + + //flag + int idFlag_; + + //Kalman Gain for making LUTs + std::vector kalmanGain0_; + std::vector kalmanGain1_; + std::vector kalmanGain2_; + std::vector kalmanGain3_; + + std::vector residuals_; + }; + +} // namespace l1t +#endif diff --git a/DataFormats/L1TMuonPhase2/interface/MuonStub.h b/DataFormats/L1TMuonPhase2/interface/MuonStub.h index eb571d3ca0598..70902648a96b0 100644 --- a/DataFormats/L1TMuonPhase2/interface/MuonStub.h +++ b/DataFormats/L1TMuonPhase2/interface/MuonStub.h @@ -79,6 +79,28 @@ namespace l1t { inline int quality() const { return quality_; } /// return tag (second TS tag) inline int id() const { return id_; } + inline int index() const { return id_; } + /// return address + inline int address() const { + int addr = id_ | (phiRegion_ << 2); + if (etaRegion_ >= 0) { + return addr | (etaRegion_ << 8); + } else { + int twos_comp = ((-etaRegion_) ^ 0xf) + 1; + return addr | (twos_comp << 8); + } + } + + inline int kmtf_address() const { + int addr = id_ | (phiRegion_ << 2); + if (etaRegion_ >= 0) { + return addr | (etaRegion_ << 6); + } else { + int twos_comp = ((-etaRegion_) ^ 0x7) + 1; + return addr | (twos_comp << 6); + } + } + /// return bunch crossing inline int bxNum() const { return bxNum_; } diff --git a/DataFormats/L1TMuonPhase2/interface/SAMuon.h b/DataFormats/L1TMuonPhase2/interface/SAMuon.h index 12ea802dae04f..98019e3aee367 100644 --- a/DataFormats/L1TMuonPhase2/interface/SAMuon.h +++ b/DataFormats/L1TMuonPhase2/interface/SAMuon.h @@ -8,6 +8,7 @@ #include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h" #include "DataFormats/L1TMuonPhase2/interface/Constants.h" +#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" namespace l1t { @@ -30,7 +31,12 @@ namespace l1t { const int hwD0() const { return hwD0_; } const uint hwBeta() const { return hwBeta_; } void setBeta(uint beta) { hwBeta_ = beta; } + void setTF(tftype tf) { tf_ = tf; } + unsigned int trackID() const { return trackID_; } + void setTrackID(unsigned int ID) { trackID_ = ID; } + + const tftype tfType() const { return tf_; } // For GT, returning ap_ type const Phase2L1GMT::valid_sa_t apValid() const { return Phase2L1GMT::valid_sa_t(hwPt() > 0); }; const Phase2L1GMT::pt_sa_t apPt() const { return Phase2L1GMT::pt_sa_t(hwPt()); }; @@ -66,12 +72,19 @@ namespace l1t { return (hwPt() > other.hwPt()); } + void addStub(const MuonStubRef& stub) { stubs_.push_back(stub); } + void setStubs(const MuonStubRefVector& stubs) { stubs_ = stubs; } + const MuonStubRefVector stubs() const { return stubs_; } + private: bool hwCharge_; int hwZ0_; int hwD0_; uint hwBeta_; uint64_t word_; + MuonStubRefVector stubs_; + unsigned int trackID_; + tftype tf_; }; } // namespace l1t diff --git a/DataFormats/L1TMuonPhase2/interface/TrackerMuon.h b/DataFormats/L1TMuonPhase2/interface/TrackerMuon.h index 1dd8cc90bf344..2a3126c08ff87 100644 --- a/DataFormats/L1TMuonPhase2/interface/TrackerMuon.h +++ b/DataFormats/L1TMuonPhase2/interface/TrackerMuon.h @@ -8,6 +8,7 @@ #include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h" #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/L1TMuonPhase2/interface/Constants.h" @@ -32,7 +33,7 @@ namespace l1t { ~TrackerMuon() override; const edm::Ptr& trkPtr() const { return trkPtr_; } - const std::vector& muonRef() const { return muRef_; } + const SAMuonRefVector muonRef() const { return muRef_; } const bool hwCharge() const { return hwCharge_; } const int hwZ0() const { return hwZ0_; } @@ -41,7 +42,7 @@ namespace l1t { const int hwIsoSumAp() const { return hwIsoSumAp_; } const uint hwBeta() const { return hwBeta_; } void setBeta(uint beta) { hwBeta_ = beta; } - void setMuonRef(const std::vector& p) { muRef_ = p; } + void setMuonRef(const l1t::SAMuonRefVector& p) { muRef_ = p; } void setHwIsoSum(int isoSum) { hwIsoSum_ = isoSum; } void setHwIsoSumAp(int isoSum) { hwIsoSumAp_ = isoSum; } @@ -54,7 +55,10 @@ namespace l1t { const Phase2L1GMT::d0_gt_t apD0() const { return Phase2L1GMT::d0_gt_t(hwD0()); }; const Phase2L1GMT::q_gt_t apCharge() const { return Phase2L1GMT::q_gt_t(hwCharge()); }; const Phase2L1GMT::qual_gt_t apQual() const { return Phase2L1GMT::qual_gt_t(hwQual()); }; - const Phase2L1GMT::iso_gt_t apIso() const { return Phase2L1GMT::iso_gt_t(hwIso()); }; + const Phase2L1GMT::qualsc_gt_t apQualSC() const { + return Phase2L1GMT::qualsc_gt_t(hwQual() | (hwCharge() << Phase2L1GMT::BITSGTQUAL)); + }; + const Phase2L1GMT::iso_gt_t apIso() const { return Phase2L1GMT::iso_gt_t(hwIsoSumAp()); }; const Phase2L1GMT::beta_gt_t apBeta() const { return Phase2L1GMT::beta_gt_t(hwBeta()); }; // For HLT @@ -63,14 +67,16 @@ namespace l1t { const double phPt() const { return Phase2L1GMT::LSBpt * hwPt(); } const double phEta() const { return Phase2L1GMT::LSBeta * hwEta(); } const double phPhi() const { return Phase2L1GMT::LSBphi * hwPhi(); } + const double phIso() const { return Phase2L1GMT::LSBGTiso * hwIsoSumAp(); } const int phCharge() const { return pow(-1, hwCharge()); } - + const uint numberOfMatches() const { return numberOfMatches_; } + const uint numberOfStations() const { return stubs_.size(); } const std::array word() const { return word_; } void setWord(std::array word) { word_ = word; } void print() const; const MuonStubRefVector stubs() const { return stubs_; } void addStub(const MuonStubRef& stub) { stubs_.push_back(stub); } - + void setNumberOfMatches(uint matches) { numberOfMatches_ = matches; } bool operator<(const TrackerMuon& other) const { return (hwPt() < other.hwPt()); } bool operator>(const TrackerMuon& other) const { return (hwPt() > other.hwPt()); } @@ -87,8 +93,9 @@ namespace l1t { int hwIsoSum_; //Store the eneryg sum for isolation with ap_type int hwIsoSumAp_; - - std::vector muRef_; + uint numberOfMatches_; + uint numberOfStations_; + SAMuonRefVector muRef_; MuonStubRefVector stubs_; }; } // namespace l1t diff --git a/DataFormats/L1TMuonPhase2/src/SAMuon.cc b/DataFormats/L1TMuonPhase2/src/SAMuon.cc index b759b84ce1c45..8c5287605a525 100644 --- a/DataFormats/L1TMuonPhase2/src/SAMuon.cc +++ b/DataFormats/L1TMuonPhase2/src/SAMuon.cc @@ -6,7 +6,7 @@ using namespace l1t; SAMuon::SAMuon() : hwZ0_(0), hwD0_(0), word_(0) {} SAMuon::SAMuon(const l1t::Muon& mu, bool charge, uint pt, int eta, int phi, int z0, int d0, uint quality) - : L1Candidate(mu.p4(), pt, eta, phi, quality), hwCharge_(charge), hwZ0_(z0), hwD0_(d0), word_(0) {} + : L1Candidate(mu.p4(), pt, eta, phi, quality), hwCharge_(charge), hwZ0_(z0), hwD0_(d0), word_(0), trackID_(0) {} SAMuon::~SAMuon() {} diff --git a/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc b/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc index 916eb797b8e8e..cf86bdb8a16bd 100644 --- a/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc +++ b/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc @@ -2,7 +2,7 @@ using namespace l1t; -TrackerMuon::TrackerMuon() : hwZ0_(0), hwD0_(0) {} +TrackerMuon::TrackerMuon() : hwZ0_(0), hwD0_(0), numberOfMatches_(0) {} TrackerMuon::TrackerMuon( const edm::Ptr& trk, bool charge, uint pt, int eta, int phi, int z0, int d0, uint quality) @@ -15,7 +15,8 @@ TrackerMuon::TrackerMuon( hwCharge_(charge), hwZ0_(z0), hwD0_(d0), - hwBeta_(15) {} + hwBeta_(15), + numberOfMatches_(0) {} TrackerMuon::~TrackerMuon() {} diff --git a/DataFormats/L1TMuonPhase2/src/classes.h b/DataFormats/L1TMuonPhase2/src/classes.h index 2c0dd2a390149..360e5f3df8586 100644 --- a/DataFormats/L1TMuonPhase2/src/classes.h +++ b/DataFormats/L1TMuonPhase2/src/classes.h @@ -4,6 +4,7 @@ #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" #include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" +#include "DataFormats/L1TMuonPhase2/interface/KMTFTrack.h" #include "DataFormats/L1TMuonPhase2/interface/EMTFHit.h" #include "DataFormats/L1TMuonPhase2/interface/EMTFTrack.h" diff --git a/DataFormats/L1TMuonPhase2/src/classes_def.xml b/DataFormats/L1TMuonPhase2/src/classes_def.xml index 23c286c1d736c..ce8ae1b7b2e2f 100644 --- a/DataFormats/L1TMuonPhase2/src/classes_def.xml +++ b/DataFormats/L1TMuonPhase2/src/classes_def.xml @@ -7,21 +7,33 @@ - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + diff --git a/L1Trigger/Configuration/python/SimL1Emulator_cff.py b/L1Trigger/Configuration/python/SimL1Emulator_cff.py index 24636ed020c47..1ed499015f5f1 100644 --- a/L1Trigger/Configuration/python/SimL1Emulator_cff.py +++ b/L1Trigger/Configuration/python/SimL1Emulator_cff.py @@ -2,7 +2,7 @@ # Defines the L1 Emulator sequence for simulation use-case subsystem emulators # run on the results of previous (in the hardware chain) subsystem emulator: -# +# # SimL1Emulator = cms.Sequence(...) # # properly configured for the current Era (e.g. Run1, 2015, or 2016). Also @@ -17,7 +17,7 @@ # Notes on Inputs: -# ECAL TPG emulator and HCAL TPG run in the simulation sequence in order to be able +# ECAL TPG emulator and HCAL TPG run in the simulation sequence in order to be able # to use unsuppressed digis produced by ECAL and HCAL simulation, respectively # in Configuration/StandardSequences/python/Digi_cff.py # SimCalorimetry.Configuration.SimCalorimetry_cff @@ -48,7 +48,7 @@ SimL1EmulatorTask = cms.Task(SimL1EmulatorCoreTask) SimL1Emulator = cms.Sequence( SimL1EmulatorTask ) -# +# # Emulators are configured from DB (GlobalTags) # @@ -63,7 +63,7 @@ # ######################################################################## # ######################################################################## # -# Phase-2 +# Phase-2 # # ######################################################################## # ######################################################################## @@ -77,11 +77,11 @@ from L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi import * _phase2_siml1emulator.add(dtTriggerPhase2PrimitiveDigis) -# HGCAL TP +# HGCAL TP # ######################################################################## from L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff import * _phase2_siml1emulator.add(L1THGCalTriggerPrimitivesTask) - + # ######################################################################## # Phase 2 L1T # ######################################################################## @@ -111,7 +111,7 @@ # ---- Produce the simulated CaloJet HTT Sums from L1Trigger.L1CaloTrigger.l1tCaloJetHTTProducer_cfi import * l1tCaloJetHTT = l1tCaloJetHTTProducer.clone( - BXVCaloJetsInputTag = ("L1CaloJet", "CaloJets") + BXVCaloJetsInputTag = ("L1CaloJet", "CaloJets") ) # ---- Produce the NNCaloTau from L1Trigger.L1CaloTrigger.l1tNNCaloTauProducer_cfi import * @@ -128,6 +128,18 @@ _phase2_siml1emulator.add(l1tCaloJetHTT) _phase2_siml1emulator.add(l1tPhase2CaloJetEmulator) +# Overlap and EndCap Muon Track Finder +# ######################################################################## +from L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_cfi import * +_phase2_siml1emulator.add(simOmtfPhase2Digis) + +from L1Trigger.L1TMuonEndCapPhase2.simCscTriggerPrimitiveDigisForEMTF_cfi import * +from L1Trigger.L1TMuonEndCapPhase2.rpcRecHitsForEMTF_cfi import * +from L1Trigger.L1TMuonEndCapPhase2.simEmtfDigisPhase2_cfi import * + +_phase2_siml1emulator.add(simCscTriggerPrimitiveDigisForEMTF) +_phase2_siml1emulator.add(rpcRecHitsForEMTF) +_phase2_siml1emulator.add(simEmtfDigisPhase2) # ######################################################################## # Phase-2 L1T - TrackTrigger dependent modules @@ -150,19 +162,27 @@ # Emulated GMT Muons (Tk + Stub, Tk + MuonTFT, StandaloneMuon) # ######################################################################## from L1Trigger.Phase2L1GMT.gmt_cfi import * -l1tTkStubsGmt = l1tGMTStubs.clone() -l1tTkMuonsGmt = l1tGMTMuons.clone( - srcStubs = 'l1tTkStubsGmt' +l1tStubsGmt = gmtStubs.clone() +l1tKMTFMuonsGmt = gmtKMTFMuons.clone( + stubs = cms.InputTag('l1tStubsGmt','kmtf'), ) -l1tSAMuonsGmt = l1tStandaloneMuons.clone() -_phase2_siml1emulator.add( l1tTkStubsGmt ) -_phase2_siml1emulator.add( l1tTkMuonsGmt ) +l1tFwdMuonsGmt = gmtFwdMuons.clone( + stubs = 'l1tStubsGmt:tps' +) +l1tSAMuonsGmt = gmtSAMuons.clone( + barrelPrompt = cms.InputTag('l1tKMTFMuonsGmt:prompt'), + barrelDisp = cms.InputTag('l1tKMTFMuonsGmt:displaced'), + forwardPrompt = cms.InputTag('l1tFwdMuonsGmt:prompt'), + forwardDisp = cms.InputTag('l1tFwdMuonsGmt:displaced') +) +l1tTkMuonsGmt = gmtTkMuons.clone( + srcStubs = 'l1tStubsGmt:tps' +) +_phase2_siml1emulator.add( l1tStubsGmt ) +_phase2_siml1emulator.add( l1tKMTFMuonsGmt ) +_phase2_siml1emulator.add( l1tFwdMuonsGmt ) _phase2_siml1emulator.add( l1tSAMuonsGmt ) - -## fix for low-pt muons, this collection is a copy of the l1tTkMuonsGmt collection -## in which we only keep those low pt muons with an SA muon associated to it. -l1tTkMuonsGmtLowPtFix = l1tGMTFilteredMuons.clone() -_phase2_siml1emulator.add( l1tTkMuonsGmtLowPtFix ) +_phase2_siml1emulator.add( l1tTkMuonsGmt ) # Tracker Objects # ######################################################################## diff --git a/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml b/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml index 8bc523a4c4b2d..8d0f1f91b4eab 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml +++ b/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml @@ -9,5 +9,4 @@ - diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h index 1b3fc1e65cfea..70504aed4faa2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h @@ -1,6 +1,7 @@ #ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h #define L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" namespace emtf::phase2 { @@ -42,6 +43,12 @@ namespace emtf::phase2 { int gem_bx_shift_; int me0_bx_shift_; + edm::InputTag csc_input_; + edm::InputTag rpc_input_; + edm::InputTag gem_input_; + edm::InputTag me0_input_; + edm::InputTag ge0_input_; + // Primitive Selectoin bool include_neighbor_en_; }; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h index 6346e5fa66998..c45b2c528b2e7 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h @@ -32,9 +32,6 @@ namespace emtf::phase2 { // Event configuration void update(const edm::Event&, const edm::EventSetup&); - // Parameter Set - const edm::ParameterSet& pset_; - // Helpers GeometryTranslator geometry_translator_; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc index d1c61765fe995..90980efbca7ed 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" @@ -16,8 +15,7 @@ using namespace emtf::phase2; CSCTPCollector::CSCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("CSCInput"))) {} + input_token_(i_consumes_collector.consumes(context.config_.csc_input_)) {} void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { edm::Handle csc_digis; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc index eb7c5df2c9ef1..3c1754ca97da2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -16,8 +15,7 @@ using namespace emtf::phase2; GE0TPCollector::GE0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GE0Input"))) {} + input_token_(i_consumes_collector.consumes(context.config_.ge0_input_)) {} void GE0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc index 3c4c985e8feb9..38b21a0589fa4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -14,8 +13,7 @@ using namespace emtf::phase2; GEMTPCollector::GEMTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GEMInput"))) {} + input_token_(i_consumes_collector.consumes(context.config_.gem_input_)) {} void GEMTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc index 46631c33b8774..a6bed4b686dd5 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -16,8 +15,7 @@ using namespace emtf::phase2; ME0TPCollector::ME0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("ME0Input"))) {} + input_token_(i_consumes_collector.consumes(context.config_.me0_input_)) {} void ME0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc index b6dc2fa31800f..c2e936be44e14 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -15,8 +14,7 @@ using namespace emtf::phase2; RPCTPCollector::RPCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("RPCInput"))) {} + input_token_(i_consumes_collector.consumes(context.config_.rpc_input_)) {} void RPCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc index 5e3902a573d3f..7a98785970b05 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc @@ -35,6 +35,12 @@ EMTFConfiguration::EMTFConfiguration(const edm::ParameterSet& pset) { gem_bx_shift_ = pset.getParameter("GEMInputBXShift"); me0_bx_shift_ = pset.getParameter("ME0InputBXShift"); + csc_input_ = pset.getParameter("CSCInput"); + rpc_input_ = pset.getParameter("RPCInput"); + gem_input_ = pset.getParameter("GEMInput"); + me0_input_ = pset.getParameter("ME0Input"); + ge0_input_ = pset.getParameter("GE0Input"); + // Primitive Selection include_neighbor_en_ = pset.getParameter("IncludeNeighborEnabled"); } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc index 7bdd58f00557c..c2171473846ba 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc @@ -11,10 +11,7 @@ using namespace emtf::phase2; EMTFContext::EMTFContext(const edm::ParameterSet& pset, edm::ConsumesCollector i_consumes_collector) - : // Parameter Set - pset_(pset), - - // Helpers + : // Helpers geometry_translator_(i_consumes_collector), // EMTF diff --git a/L1Trigger/Phase2L1GMT/BuildFile.xml b/L1Trigger/Phase2L1GMT/BuildFile.xml index bca0bcd832660..8bab30271e844 100644 --- a/L1Trigger/Phase2L1GMT/BuildFile.xml +++ b/L1Trigger/Phase2L1GMT/BuildFile.xml @@ -1,8 +1,10 @@ + + diff --git a/L1Trigger/Phase2L1GMT/data/packedGainLUTs.root b/L1Trigger/Phase2L1GMT/data/packedGainLUTs.root new file mode 100644 index 0000000000000..bbfcdf841d55a Binary files /dev/null and b/L1Trigger/Phase2L1GMT/data/packedGainLUTs.root differ diff --git a/L1Trigger/Phase2L1GMT/plugins/ConvertedTTTrack.h b/L1Trigger/Phase2L1GMT/interface/ConvertedTTTrack.h similarity index 63% rename from L1Trigger/Phase2L1GMT/plugins/ConvertedTTTrack.h rename to L1Trigger/Phase2L1GMT/interface/ConvertedTTTrack.h index 0deebe6b2bc98..af1e253f037b2 100644 --- a/L1Trigger/Phase2L1GMT/plugins/ConvertedTTTrack.h +++ b/L1Trigger/Phase2L1GMT/interface/ConvertedTTTrack.h @@ -3,20 +3,21 @@ #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" #include "DataFormats/L1TMuonPhase2/interface/Constants.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include namespace Phase2L1GMT { class ConvertedTTTrack { public: - ConvertedTTTrack(const uint& charge, - const int& curvature, - const uint& abseta, - const uint& pt, - const int& eta, - const int& phi, - const int& z0, - const int& d0, - const int& quality, + ConvertedTTTrack(const ap_uint<1>& charge, + const ap_int& curvature, + const ap_int& abseta, + const ap_uint& pt, + const ap_int& eta, + const ap_int& phi, + const ap_int& z0, + const ap_int& d0, + const ap_uint<1>& quality, const ap_uint<96>& word) : charge_(charge), curvature_(curvature), @@ -29,21 +30,21 @@ namespace Phase2L1GMT { quality_(quality), word_(word) {} - const uint charge() const { return charge_; } + const ap_uint<1> charge() const { return charge_; } - const int curvature() const { return curvature_; } - const uint abseta() const { return abseta_; } + const ap_int curvature() const { return curvature_; } + const ap_uint abseta() const { return abseta_; } - const uint pt() const { return pt_; } + const ap_uint pt() const { return pt_; } - const int eta() const { return eta_; } - const int phi() const { return phi_; } + const ap_int eta() const { return eta_; } + const ap_int phi() const { return phi_; } - void setPhi(int phi) { phi_ = phi; } + void setPhi(ap_int phi) { phi_ = phi; } - const int z0() const { return z0_; } - const int d0() const { return d0_; } - const int quality() const { return quality_; } + const ap_int z0() const { return z0_; } + const ap_int d0() const { return d0_; } + const ap_uint<1> quality() const { return quality_; } const float offline_pt() const { return offline_pt_; } const float offline_eta() const { return offline_eta_; } const float offline_phi() const { return offline_phi_; } @@ -74,15 +75,15 @@ namespace Phase2L1GMT { const edm::Ptr > trkPtr() const { return trkPtr_; } private: - uint charge_; - int curvature_; - uint abseta_; - uint pt_; - int eta_; - int phi_; - int z0_; - int d0_; - uint quality_; + ap_uint<1> charge_; + ap_int curvature_; + ap_uint abseta_; + ap_uint pt_; + ap_int eta_; + ap_int phi_; + ap_int z0_; + ap_int d0_; + ap_uint<1> quality_; float offline_pt_; float offline_eta_; float offline_phi_; diff --git a/L1Trigger/Phase2L1GMT/plugins/Isolation.h b/L1Trigger/Phase2L1GMT/interface/Isolation.h similarity index 96% rename from L1Trigger/Phase2L1GMT/plugins/Isolation.h rename to L1Trigger/Phase2L1GMT/interface/Isolation.h index 7d17fe1050687..447aff5fd1ea0 100644 --- a/L1Trigger/Phase2L1GMT/plugins/Isolation.h +++ b/L1Trigger/Phase2L1GMT/interface/Isolation.h @@ -150,7 +150,6 @@ namespace Phase2L1GMT { for (auto &mu : trkMus) { int accum = 0; - int iso_ = 0; std::vector overlaps; for (auto t : convertedTracks) { unsigned ovrl = compute_trk_iso(mu, t); @@ -159,18 +158,19 @@ namespace Phase2L1GMT { } } - // Only 8 bit for accumation? + // Accumation without fixed bit width mu.setHwIsoSum(accum); + // Accumation with fixed bit width + // Bit shifts with 3 bits with LSB of 0.25GeV iso_accum_t temp(accum); - accum = temp.to_int(); + mu.setHwIsoSumAp(temp.to_int() >> 3); - mu.setHwIsoSumAp(accum); + //Disable isolation bit, sending isolation sumPT to GT + //iso_ |= SetAbsIsolationBits(accum); + //iso_ |= SetRelIsolationBits(accum, mu.hwPt()); - iso_ |= SetAbsIsolationBits(accum); - iso_ |= SetRelIsolationBits(accum, mu.hwPt()); - - mu.setHwIso(iso_); + //mu.setHwIso(iso_); } if (dumpForHLS_) { diff --git a/L1Trigger/Phase2L1GMT/interface/KMTF.h b/L1Trigger/Phase2L1GMT/interface/KMTF.h new file mode 100644 index 0000000000000..8b9ef11d26ae7 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/interface/KMTF.h @@ -0,0 +1,36 @@ +#ifndef L1Trigger_Phase2L1GMT_KMTF_h +#define L1Trigger_Phase2L1GMT_KMTF_h +#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" +#include "L1Trigger/Phase2L1GMT/interface/KMTFCore.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include + +namespace Phase2L1GMT { + + class KMTF { + public: + KMTF(int verbose, const edm::ParameterSet& iConfig); + ~KMTF(); + std::pair, std::vector > process(const l1t::MuonStubRefVector& stubsAll, + int bx, + unsigned int MAXN); + + private: + int verbose_; + std::unique_ptr trackMaker_; + void overlapCleanTrack(l1t::KMTFTrack& source, const l1t::KMTFTrack& other, bool eq, bool vertex); + std::vector cleanRegion(const std::vector& tracks2, + const std::vector& tracks3, + const std::vector& tracks4, + bool vertex); + void sort(std::vector& in, bool vertex); + void swap(std::vector& list, int i, int j, bool vertex); + + class SeedSorter { + public: + SeedSorter() {} + bool operator()(const l1t::MuonStubRef& a, const l1t::MuonStubRef& b) { return (a->id() < b->id()); } + }; + }; +} // namespace Phase2L1GMT +#endif diff --git a/L1Trigger/Phase2L1GMT/interface/KMTFCore.h b/L1Trigger/Phase2L1GMT/interface/KMTFCore.h new file mode 100644 index 0000000000000..19291d1f53031 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/interface/KMTFCore.h @@ -0,0 +1,171 @@ +/* +Kalman Filter L1 Muon algorithm +Tyler Lam (UCLA) +Sep. 2021 +*/ +#ifndef L1Trigger_Phase2L1GMT_KMTFCore_h +#define L1Trigger_Phase2L1GMT_KMTFCore_h +#include "L1Trigger/Phase2L1GMT/interface/KMTFLUTs.h" +#include "DataFormats/L1TMuonPhase2/interface/KMTFTrack.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include +#include "ap_fixed.h" + +namespace Phase2L1GMT { + + class KMTFCore { + public: + typedef ROOT::Math::SVector Vector2; + typedef ROOT::Math::SMatrix > CovarianceMatrix2; + typedef ROOT::Math::SMatrix Matrix32; + typedef ROOT::Math::SMatrix Matrix23; + typedef ROOT::Math::SMatrix Matrix13; + typedef ROOT::Math::SMatrix Matrix31; + typedef ROOT::Math::SMatrix Matrix33; + + KMTFCore(const edm::ParameterSet& settings); + + std::pair chain(const l1t::MuonStubRef& seed, const l1t::MuonStubRefVector& stubs); + + std::vector clean(const std::vector& tracks, uint seed, bool vertex); + + private: + std::unique_ptr lutService_; + + std::pair match(const l1t::MuonStubRef& seed, const l1t::MuonStubRefVector& stubs, int step); + + int correctedPhiB(const l1t::MuonStubRef& stub); + void propagate(l1t::KMTFTrack& track); + bool update(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub, int mask, int seedQual); + bool updateOffline(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub); + bool updateOffline1D(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub); + bool updateLUT(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub, int mask, int seedQual); + void vertexConstraint(l1t::KMTFTrack& track); + void vertexConstraintOffline(l1t::KMTFTrack& track); + void vertexConstraintLUT(l1t::KMTFTrack& track); + int hitPattern(const l1t::KMTFTrack& track); + int customBitmask(unsigned int bit1, unsigned int bit2, unsigned int bit3, unsigned int bit4); + bool getBit(int bitmask, int pos); + void setFourVectors(l1t::KMTFTrack& track); + bool estimateChiSquare(l1t::KMTFTrack& track, bool vertex); + void setRank(l1t::KMTFTrack& track, bool vertex); + int wrapAround(int value, int maximum); + int encode(bool ownwheel, int sector, int tag); + std::pair getByCode(const std::vector& tracks, int mask); + uint twosCompToBits(int q); + uint etaStubRank(const l1t::MuonStubRef& stub); + void calculateEta(l1t::KMTFTrack& track); + uint matchAbs(std::map& info, uint i, uint j); + int ptLUT(int K); + + bool verbose_; + + //Initial Curvature + std::vector initK_; + std::vector initK2_; + + //propagation coefficients + std::vector eLoss_; + std::vector aPhi_; + std::vector aPhiB_; + std::vector aPhiBNLO_; + std::vector bPhi_; + std::vector bPhiB_; + double phiAt2_; + std::vector etaLUT0_; + std::vector etaLUT1_; + + //Chi Square estimator input + uint globalChi2Cut_; + uint globalChi2CutLimit_; + + std::vector chiSquareDisp1_; + std::vector chiSquareDisp2_; + std::vector chiSquareDisp3_; + std::vector chiSquareErrADisp1_; + std::vector chiSquareErrADisp2_; + std::vector chiSquareErrADisp3_; + std::vector chiSquareErrBDisp1_; + std::vector chiSquareErrBDisp2_; + std::vector chiSquareErrBDisp3_; + + std::vector chiSquarePrompt1_; + std::vector chiSquarePrompt2_; + std::vector chiSquarePrompt3_; + std::vector chiSquareErrAPrompt1_; + std::vector chiSquareErrAPrompt2_; + std::vector chiSquareErrAPrompt3_; + std::vector chiSquareErrBPrompt1_; + std::vector chiSquareErrBPrompt2_; + std::vector chiSquareErrBPrompt3_; + + std::vector chiSquareCutDispPattern_; + std::vector chiSquareCutOffDisp_; + std::vector chiSquareCutDisp_; + std::vector chiSquareCutPromptPattern_; + std::vector chiSquareCutOffPrompt_; + std::vector chiSquareCutPrompt_; + + //bitmasks to run== diferent combinations for a given seed in a given station + std::vector combos4_; + std::vector combos3_; + std::vector combos2_; + std::vector combos1_; + + //bits for fixed point precision + static const int PHIBSCALE = 16; + static const int PHIBSCALE_INT = 5; + static const int BITSCURV = 16; + static const int BITSPHI = 18; + static const int BITSPHIB = 17; // 12 bits *28 (+5 bits) + static const int BITSPARAM = 14; + static const int GAIN_0 = 9; + static const int GAIN_0INT = 6; + static const int GAIN_4 = 9; + static const int GAIN_4INT = 4; + static const int GAIN_V0 = 9; + static const int GAIN_V0INT = 0; + + static const int GAIN2_0 = 12; + static const int GAIN2_0INT = 6; + static const int GAIN2_1 = 12; + static const int GAIN2_1INT = 3; + static const int GAIN2_4 = 12; + static const int GAIN2_4INT = 4; + static const int GAIN2_5 = 12; + static const int GAIN2_5INT = 0; + //STUFF NOT USED IN THE FIRMWARE BUT ONLY FOR DEBUGGING + /////////////////////////////////////////////////////// + + bool useOfflineAlgo_; + std::vector mScatteringPhi_; + std::vector mScatteringPhiB_; + //point resolution for phi + double pointResolutionPhi_; + //point resolution for phiB + double pointResolutionPhiB_; + std::vector pointResolutionPhiBH_; + std::vector pointResolutionPhiBL_; + //double pointResolutionPhiB_; + //point resolution for vertex + double pointResolutionVertex_; + std::vector curvResolution1_; + std::vector curvResolution2_; + //Sorter + class StubSorter { + public: + StubSorter(uint sector) { sec_ = sector; } + + bool operator()(const l1t::MuonStubRef& a, const l1t::MuonStubRef& b) { + if (a->coord1() < b->coord1()) + return true; + return false; + } + + private: + int sec_; + }; + }; + +} // namespace Phase2L1GMT +#endif diff --git a/L1Trigger/Phase2L1GMT/interface/KMTFLUTs.h b/L1Trigger/Phase2L1GMT/interface/KMTFLUTs.h new file mode 100644 index 0000000000000..06bad605d4ea4 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/interface/KMTFLUTs.h @@ -0,0 +1,122 @@ +#ifndef L1Trigger_Phase2L1GMT_KMTFLUTS_h +#define L1Trigger_Phase2L1GMT_KMTFLUTS_h +#include +#include "TH1.h" +#include "TFile.h" +#include +#include "FWCore/ParameterSet/interface/FileInPath.h" + +namespace Phase2L1GMT { + + class KMTFLUTs { + public: + KMTFLUTs(const std::string &filename) { + edm::FileInPath path(filename); + lutFile_ = new TFile(path.fullPath().c_str()); + lut_[3 * 64 + 8] = (TH1 *)lutFile_->Get("gain_8_3"); + lut_[2 * 64 + 8] = (TH1 *)lutFile_->Get("gain_8_2"); + lut_[2 * 64 + 12] = (TH1 *)lutFile_->Get("gain_12_2"); + lut_[2 * 64 + 4] = (TH1 *)lutFile_->Get("gain_4_2"); + lut_[1 * 64 + 12] = (TH1 *)lutFile_->Get("gain_12_1"); + lut_[1 * 64 + 10] = (TH1 *)lutFile_->Get("gain_10_1"); + lut_[1 * 64 + 6] = (TH1 *)lutFile_->Get("gain_6_1"); + lut_[1 * 64 + 14] = (TH1 *)lutFile_->Get("gain_14_1"); + lut_[3] = (TH1 *)lutFile_->Get("gain_3_0"); + lut_[5] = (TH1 *)lutFile_->Get("gain_5_0"); + lut_[6] = (TH1 *)lutFile_->Get("gain_6_0"); + lut_[7] = (TH1 *)lutFile_->Get("gain_7_0"); + lut_[9] = (TH1 *)lutFile_->Get("gain_9_0"); + lut_[10] = (TH1 *)lutFile_->Get("gain_10_0"); + lut_[11] = (TH1 *)lutFile_->Get("gain_11_0"); + lut_[12] = (TH1 *)lutFile_->Get("gain_12_0"); + lut_[13] = (TH1 *)lutFile_->Get("gain_13_0"); + lut_[14] = (TH1 *)lutFile_->Get("gain_14_0"); + lut_[15] = (TH1 *)lutFile_->Get("gain_15_0"); + + lut2HH_[3 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_3_HH"); + lut2HH_[2 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_2_HH"); + lut2HH_[2 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_2_HH"); + lut2HH_[1 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_1_HH"); + lut2HH_[1 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_1_HH"); + lut2HH_[1 * 64 + 2] = (TH1 *)lutFile_->Get("gain2_2_1_HH"); + + lut2LH_[3 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_3_LH"); + lut2LH_[2 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_2_LH"); + lut2LH_[2 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_2_LH"); + lut2LH_[1 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_1_LH"); + lut2LH_[1 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_1_LH"); + lut2LH_[1 * 64 + 2] = (TH1 *)lutFile_->Get("gain2_2_1_LH"); + + lut2HL_[3 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_3_HL"); + lut2HL_[2 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_2_HL"); + lut2HL_[2 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_2_HL"); + lut2HL_[1 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_1_HL"); + lut2HL_[1 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_1_HL"); + lut2HL_[1 * 64 + 2] = (TH1 *)lutFile_->Get("gain2_2_1_HL"); + + lut2LL_[3 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_3_LL"); + lut2LL_[2 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_2_LL"); + lut2LL_[2 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_2_LL"); + lut2LL_[1 * 64 + 8] = (TH1 *)lutFile_->Get("gain2_8_1_LL"); + lut2LL_[1 * 64 + 4] = (TH1 *)lutFile_->Get("gain2_4_1_LL"); + lut2LL_[1 * 64 + 2] = (TH1 *)lutFile_->Get("gain2_2_1_LL"); + + coarseEta_ = (TH1 *)lutFile_->Get("coarseETALUT"); + } + + ~KMTFLUTs() { + lutFile_->Close(); + if (lutFile_ != nullptr) + delete lutFile_; + } + + std::vector trackGain(uint step, uint bitmask, uint K) { + std::vector gain(4, 0.0); + const TH1 *h = lut_[64 * step + bitmask]; + gain[0] = h->GetBinContent(K + 1); + gain[2] = h->GetBinContent(1024 + K + 1); + return gain; + } + + std::vector trackGain2(uint step, uint bitmask, uint K, uint qual1, uint qual2) { + std::vector gain(4, 0.0); + const TH1 *h; + if (qual1 < 6) { + if (qual2 < 6) + h = lut2LL_[64 * step + bitmask]; + else + h = lut2LH_[64 * step + bitmask]; + } else { + if (qual2 < 6) + h = lut2HL_[64 * step + bitmask]; + else + h = lut2HH_[64 * step + bitmask]; + } + gain[0] = h->GetBinContent(K + 1); + gain[1] = h->GetBinContent(512 + K + 1); + gain[2] = h->GetBinContent(2 * 512 + K + 1); + gain[3] = h->GetBinContent(3 * 512 + K + 1); + return gain; + } + + std::pair vertexGain(uint bitmask, uint K) { + const TH1 *h = lut_[bitmask]; + std::pair gain(-h->GetBinContent(K + 1), -h->GetBinContent(1024 + K + 1)); + return gain; + } + + uint coarseEta(uint mask) { + return uint((1 << 12) * coarseEta_->GetBinContent(coarseEta_->GetXaxis()->FindBin(mask)) / M_PI); + } + + TFile *lutFile_; + std::map lut_; + std::map lut2HH_; + std::map lut2LH_; + std::map lut2HL_; + std::map lut2LL_; + const TH1 *coarseEta_; + }; + +} // namespace Phase2L1GMT +#endif diff --git a/L1Trigger/Phase2L1GMT/interface/L1TPhase2GMTEndcapStubProcessor.h b/L1Trigger/Phase2L1GMT/interface/L1TPhase2GMTEndcapStubProcessor.h index a4402827fce10..aa4502b9d574d 100644 --- a/L1Trigger/Phase2L1GMT/interface/L1TPhase2GMTEndcapStubProcessor.h +++ b/L1Trigger/Phase2L1GMT/interface/L1TPhase2GMTEndcapStubProcessor.h @@ -25,7 +25,10 @@ class L1TPhase2GMTEndcapStubProcessor { const edm::EventSetup& iSetup); private: - l1t::MuonStub buildCSCOnlyStub(const CSCDetId&, const CSCCorrelatedLCTDigi&, const L1TMuon::GeometryTranslator*); + l1t::MuonStub buildCSCOnlyStub(const CSCDetId&, + const CSCCorrelatedLCTDigi&, + const L1TMuon::GeometryTranslator*, + unsigned int); l1t::MuonStub buildRPCOnlyStub(const RPCDetId&, const RPCDigi&, const L1TMuon::GeometryTranslator*); l1t::MuonStubCollection combineStubs(const l1t::MuonStubCollection&, const l1t::MuonStubCollection&); diff --git a/L1Trigger/Phase2L1GMT/plugins/PreTrackMatchedMuon.h b/L1Trigger/Phase2L1GMT/interface/PreTrackMatchedMuon.h similarity index 65% rename from L1Trigger/Phase2L1GMT/plugins/PreTrackMatchedMuon.h rename to L1Trigger/Phase2L1GMT/interface/PreTrackMatchedMuon.h index 26781736ad6e3..927e8f9f1cf82 100644 --- a/L1Trigger/Phase2L1GMT/plugins/PreTrackMatchedMuon.h +++ b/L1Trigger/Phase2L1GMT/interface/PreTrackMatchedMuon.h @@ -3,8 +3,8 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/L1TMuonPhase2/interface/Constants.h" -#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h" #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/L1TrackTrigger/interface/TTTrack.h" #include "DataFormats/L1TrackTrigger/interface/TTStub.h" @@ -35,11 +35,12 @@ namespace Phase2L1GMT { beta_(beta), isGlobal_(false), quality_(0), - stubID0_(511), - stubID1_(511), - stubID2_(511), - stubID3_(511), - stubID4_(511), + stubID0_(4095), + stubID1_(4095), + stubID2_(4095), + stubID3_(4095), + stubID4_(4095), + matchMask_(0), valid_(false) {} const uint charge() const { return charge_; } @@ -61,6 +62,8 @@ namespace Phase2L1GMT { const uint stubID2() const { return stubID2_; } const uint stubID3() const { return stubID3_; } const uint stubID4() const { return stubID4_; } + const uint matchMask() const { return matchMask_; } + bool valid() const { return valid_; } void setQuality(uint quality) { quality_ = quality; } @@ -72,26 +75,29 @@ namespace Phase2L1GMT { offline_phi_ = phi; } - void addMuonRef(const l1t::RegionalMuonCandRef& ref) { - muRef_.push_back(ref); - isGlobal_ = true; - } + void addMuonRef(const l1t::SAMuonRef& ref) { muRef_.push_back(ref); } void resetGlobal() { isGlobal_ = false; } - const std::vector& muonRef() const { return muRef_; } - void addStub(const l1t::MuonStubRef& stub) { + const l1t::SAMuonRefVector& muonRef() const { return muRef_; } + void addStub(const l1t::MuonStubRef& stub, uint mask) { stubs_.push_back(stub); - if (stub->tfLayer() == 0) - stubID0_ = stub->id(); - else if (stub->tfLayer() == 1) - stubID1_ = stub->id(); - else if (stub->tfLayer() == 2) - stubID2_ = stub->id(); - else if (stub->tfLayer() == 3) - stubID3_ = stub->id(); - else if (stub->tfLayer() == 4) - stubID4_ = stub->id(); + if (stub->tfLayer() == 0) { + stubID0_ = stub->address(); + matchMask_ = matchMask_ | (mask); + } else if (stub->tfLayer() == 1) { + stubID1_ = stub->address(); + matchMask_ = matchMask_ | (mask << 2); + } else if (stub->tfLayer() == 2) { + stubID2_ = stub->address(); + matchMask_ = matchMask_ | (mask << 4); + } else if (stub->tfLayer() == 3) { + stubID3_ = stub->address(); + matchMask_ = matchMask_ | (mask << 6); + } else if (stub->tfLayer() == 4) { + stubID4_ = stub->address(); + matchMask_ = matchMask_ | (mask << 8); + } } const l1t::MuonStubRefVector& stubs() const { return stubs_; } @@ -109,27 +115,31 @@ namespace Phase2L1GMT { } uint64_t lsb() const { - uint64_t w = charge_ & 0x1; - w = w | (twos_complement(pt_, BITSPT) << 1); - w = w | (twos_complement(phi_, BITSPHI) << (BITSPT + 1)); - w = w | (twos_complement(eta_, BITSETA) << (BITSPHI + BITSPT + 1)); - w = w | (twos_complement(z0_, BITSZ0) << (BITSETA + BITSPHI + BITSPT + 1)); - w = w | (twos_complement(d0_, BITSD0) << (BITSZ0 + BITSETA + BITSPHI + BITSPT + 1)); - return w; + wordtype w = 0; + int bstart = 0; + bstart = wordconcat(w, bstart, charge_ & 0x1, 1); + bstart = wordconcat(w, bstart, pt_, BITSPT); + bstart = wordconcat(w, bstart, phi_, BITSPHI); + bstart = wordconcat(w, bstart, eta_, BITSETA); + bstart = wordconcat(w, bstart, z0_, BITSZ0); + bstart = wordconcat(w, bstart, d0_, BITSD0); + return w.to_int(); } uint64_t msb() const { - uint64_t w2 = 0; - w2 = twos_complement(stubID0_, BITSSTUBID); - w2 = w2 | (twos_complement(stubID1_, BITSSTUBID) << BITSSTUBID); - w2 = w2 | (twos_complement(stubID2_, BITSSTUBID) << (2 * BITSSTUBID)); - w2 = w2 | (twos_complement(stubID3_, BITSSTUBID) << (3 * BITSSTUBID)); - w2 = w2 | (twos_complement(stubID4_, BITSSTUBID) << (4 * BITSSTUBID)); - w2 = w2 | (twos_complement(isGlobal_, 1) << (5 * BITSSTUBID)); - w2 = w2 | (twos_complement(beta_, BITSMUONBETA) << (5 * BITSSTUBID + 1)); - w2 = w2 | (twos_complement(quality_, BITSMATCHQUALITY) << (BITSMUONBETA + 5 * BITSSTUBID + 1)); - w2 = w2 | (twos_complement(valid_, 1) << (BITSMATCHQUALITY + BITSMUONBETA + 5 * BITSSTUBID + 1)); - return w2; + wordtype w2 = 0; + int bstart = 0; + bstart = wordconcat(w2, bstart, stubID0_, BITSSTUBID); + bstart = wordconcat(w2, bstart, stubID1_, BITSSTUBID); + bstart = wordconcat(w2, bstart, stubID2_, BITSSTUBID); + bstart = wordconcat(w2, bstart, stubID3_, BITSSTUBID); + bstart = wordconcat(w2, bstart, stubID4_, BITSSTUBID); + bstart = wordconcat(w2, bstart, isGlobal_, 1); + bstart = wordconcat(w2, bstart, beta_, BITSMUONBETA); + bstart = wordconcat(w2, bstart, quality_, BITSMATCHQUALITY); + bstart = wordconcat(w2, bstart, valid_, 1); + + return w2.to_int(); } void printWord() const { @@ -157,9 +167,11 @@ namespace Phase2L1GMT { uint stubID2_; uint stubID3_; uint stubID4_; + uint matchMask_; + bool valid_; l1t::MuonStubRefVector stubs_; - std::vector muRef_; + l1t::SAMuonRefVector muRef_; edm::Ptr > trkPtr_; }; } // namespace Phase2L1GMT diff --git a/L1Trigger/Phase2L1GMT/interface/SAMuonCleaner.h b/L1Trigger/Phase2L1GMT/interface/SAMuonCleaner.h new file mode 100644 index 0000000000000..7ba695f225138 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/interface/SAMuonCleaner.h @@ -0,0 +1,24 @@ +#ifndef L1Trigger_Phase2L1GMT_SAMuonCleaner_h +#define L1Trigger_Phase2L1GMT_SAMuonCleaner_h + +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" + +class SAMuonCleaner { +public: + SAMuonCleaner() = default; + ~SAMuonCleaner() = default; + + std::vector cleanTFMuons(const std::vector& muons); + +private: + std::vector cleanTF(const std::vector& tfMuons); + void overlapCleanTrack(l1t::SAMuon& source, const l1t::SAMuon& other, bool eq); + void overlapCleanTrackInter(l1t::SAMuon& source, const l1t::SAMuon& other); + std::vector interTFClean(const std::vector& bmtf, + const std::vector& omtf, + const std::vector& emtf); + void swap(std::vector&, int i, int j); + void sort(std::vector& in); +}; + +#endif diff --git a/L1Trigger/Phase2L1GMT/interface/TPS.h b/L1Trigger/Phase2L1GMT/interface/TPS.h new file mode 100644 index 0000000000000..91f65f8620f8e --- /dev/null +++ b/L1Trigger/Phase2L1GMT/interface/TPS.h @@ -0,0 +1,30 @@ +#ifndef L1Trigger_Phase2L1GMT_TPS_h +#define L1Trigger_Phase2L1GMT_TPS_h +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" +#include "L1Trigger/Phase2L1GMT/interface/TrackConverter.h" +#include "L1Trigger/Phase2L1GMT/interface/TPSAlgorithm.h" +#include "L1Trigger/Phase2L1GMT/interface/Isolation.h" + +namespace Phase2L1GMT { + + class TPS { + public: + TPS(const edm::ParameterSet& iConfig); + ~TPS() = default; + std::vector processEvent(const std::vector >&, + const l1t::MuonStubRefVector&); + + private: + int verbose_; + std::unique_ptr tt_track_converter_; + std::unique_ptr tps_; + std::unique_ptr isolation_; + std::vector > associateTracksWithNonant( + const std::vector >& tracks, uint processor); + l1t::SAMuonRefVector associateMuonsWithNonant(const l1t::SAMuonRefVector&, uint); + l1t::MuonStubRefVector associateStubsWithNonant(const l1t::MuonStubRefVector&, uint); + }; +} // namespace Phase2L1GMT + +#endif diff --git a/L1Trigger/Phase2L1GMT/interface/TPSAlgorithm.h b/L1Trigger/Phase2L1GMT/interface/TPSAlgorithm.h new file mode 100644 index 0000000000000..bec3898fc1086 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/interface/TPSAlgorithm.h @@ -0,0 +1,77 @@ +#ifndef L1Trigger_Phase2GMT_TPSAlgorithm_h +#define L1Trigger_Phase2GMT_TPSAlgorithm_h + +#include "DataFormats/L1TrackTrigger/interface/TTTrack.h" +#include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h" +#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" +#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" +#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" +#include "DataFormats/L1Trigger/interface/L1TObjComparison.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "L1Trigger/Phase2L1GMT/interface/ConvertedTTTrack.h" +#include "L1Trigger/Phase2L1GMT/interface/PreTrackMatchedMuon.h" +#include "L1Trigger/Phase2L1GMT/interface/TPSLUTs.h" +#include +#include + +namespace Phase2L1GMT { + + const unsigned int PHIDIVIDER = 1 << (BITSPHI - BITSSTUBCOORD); + const unsigned int ETADIVIDER = 1 << (BITSETA - BITSSTUBETA); + + typedef struct { + ap_int coord1; + ap_uint sigma_coord1; + ap_int coord2; + ap_uint sigma_coord2; + ap_int eta; + ap_uint sigma_eta1; + ap_uint sigma_eta2; + ap_uint<1> valid; + ap_uint<1> is_barrel; + } propagation_t; + + typedef struct { + ap_uint quality; + ap_uint id; + ap_uint<2> valid; + bool isGlobal; + l1t::SAMuonRef muRef; + l1t::MuonStubRef stubRef; + + } match_t; + + class TPSAlgorithm { + public: + TPSAlgorithm(const edm::ParameterSet& iConfig); + ~TPSAlgorithm(); + + std::vector processNonant(const std::vector& convertedTracks, + const l1t::MuonStubRefVector& stubs); + + std::vector cleanNeighbor(const std::vector& muons, + const std::vector& muonsPrevious, + const std::vector& muonsNext, + bool equality); + std::vector convert(std::vector& muons, uint maximum); + bool outputGT(std::vector& muons); + void SetQualityBits(std::vector& muons); + std::vector sort(std::vector& muons, uint maximum); + + private: + int verbose_; + propagation_t propagate(const ConvertedTTTrack& track, uint layer); + ap_uint deltaEta(const ap_int& eta1, const ap_int& eta2); + ap_uint deltaCoord(const ap_int& phi1, const ap_int& phi2); + match_t match(const propagation_t prop, const l1t::MuonStubRef& stub, uint trackID); + match_t propagateAndMatch(const ConvertedTTTrack& track, const l1t::MuonStubRef& stub, uint trackID); + match_t getBest(const std::vector matches); + PreTrackMatchedMuon processTrack(const ConvertedTTTrack&, const l1t::MuonStubRefVector&); + ap_uint<5> cleanMuon(const PreTrackMatchedMuon& mu, const PreTrackMatchedMuon& other, bool eq); + void matchingInfos(std::vector matchInfo, PreTrackMatchedMuon& muon, ap_uint& quality); + std::vector clean(std::vector& muons); + }; +} // namespace Phase2L1GMT + +#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/Constants.h b/L1Trigger/Phase2L1GMT/interface/TPSLUTs.h similarity index 52% rename from L1Trigger/Phase2L1GMT/plugins/Constants.h rename to L1Trigger/Phase2L1GMT/interface/TPSLUTs.h index 9251abc3d0f0f..0db5b9b2d7c4a 100644 --- a/L1Trigger/Phase2L1GMT/plugins/Constants.h +++ b/L1Trigger/Phase2L1GMT/interface/TPSLUTs.h @@ -2,6 +2,7 @@ #define PHASE2L1GMT_PHASE2GMT_CONSTANTS #include "ap_int.h" +#include "DataFormats/L1TMuonPhase2/interface/Constants.h" namespace Phase2L1GMT { @@ -336,418 +337,593 @@ namespace Phase2L1GMT { 3182, 3183, 3184, 3185, 3186, 3187, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3194, 3194}; const ap_uint lt_prop_coord1_0[512] = { - 163, 163, 163, 163, 163, 163, 163, 163, 163, 164, 164, 164, 164, 164, 164, 164, 165, 165, 165, 165, 165, 164, 164, - 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 165, 165, 165, - 165, 166, 166, 166, 166, 166, 167, 167, 167, 166, 166, 166, 166, 166, 165, 165, 164, 164, 163, 163, 163, 162, 162, - 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 162, 162, 162, 162, 162, 162, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 162, 162, 162, 162, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 162, 162, 162, 162, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 160, 160, 159, 159, - 158, 158, 157, 156, 155, 154, 154, 153, 152, 151, 149, 148, 147, 146, 145, 144, 142, 141, 140, 139, 137, 136, 135, - 133, 132, 131, 130, 128, 127, 126, 124, 123, 122, 121, 119, 118, 117, 116, 115, 113, 112, 111, 110, 109, 108, 107, - 105, 104, 103, 102, 101, 100, 99, 98, 98, 97, 96, 95, 94, 93, 93, 92, 91, 91, 90, 89, 89, 88, 88, - 87, 87, 87, 86, 86, 85, 85, 85, 84, 84, 83, 82, 82, 81, 81, 80, 80, 80, 79, 79, 78, 78, 78, - 77, 76, 76, 75, 75, 74, 73, 73, 72, 72, 71, 71, 71, 70, 70, 70, 69, 69, 68, 67, 67, 66, 65, - 65, 64, 64, 63, 63, 62, 62, 62, 61, 61, 61, 60, 60, 60, 59, 59, 58, 58, 58, 57, 57, 57, 56, - 56, 56, 56, 55, 55, 55, 55, 54, 54, 54, 54, 53, 53, 52, 52, 52, 51, 51, 50, 50, 49, 48, 48, - 47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45, 44, 44, 44, 43, 43, 43, 43, 42, 42, 42, - 42, 41, 41, 41, 41, 40, 40, 40, 40, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38}; - + 103, 103, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 100, 100, 100, 100, 100, 100, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, + 99, 100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 98, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 97, 97, 97, 96, 96, 96, 96, 96, 96, 96, + 96, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 94, 94, 94, 94, 93, 93, 93, 93, 93, 92, 92, 92, 92, 91, 91, 91, 90, 90, 89, 88, 88, 87, + 87, 86, 85, 85, 84, 84, 83, 82, 82, 81, 81, 80, 80, 79, 78, 78, 77, 77, 76, 75, 75, 74, 74, + 73, 72, 72, 71, 71, 70, 70, 69, 68, 68, 67, 67, 66, 65, 65, 64, 64, 63, 62, 62, 61, 61, 60, + 60, 59, 58, 58, 57, 57, 56, 55, 55, 54, 54, 53, 53, 53, 52, 52, 52, 51, 51, 51, 50, 50, 50, + 49, 49, 49, 48, 48, 48, 48, 47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 45, 44, 44, 43, 43, + 43, 42, 42, 42, 41, 41, 40, 40, 40, 39, 39, 38, 38, 38, 38, 37, 37, 37, 36, 36, 36, 36, 35, + 35, 35, 34, 34, 34, 34, 33, 33, 33, 33, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 30, + 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 26, 26, + 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 24, 24, 24, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, + 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18}; const ap_uint lt_prop_coord1_1[512] = { - 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, - 175, 175, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 177, 177, 178, 178, 179, 179, 179, 180, 180, - 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 182, 182, 182, 182, 182, 183, 183, 183, 184, 184, - 184, 184, 184, 184, 183, 183, 183, 183, 183, 183, 183, 183, 183, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, - 182, 182, 182, 182, 182, 182, 181, 181, 181, 181, 180, 180, 180, 180, 179, 179, 179, 179, 179, 179, 179, 179, 179, - 179, 179, 179, 179, 179, 179, 178, 178, 178, 178, 177, 177, 177, 176, 176, 176, 176, 175, 175, 175, 175, 175, 175, - 175, 174, 174, 174, 174, 174, 174, 174, 174, 174, 173, 173, 173, 172, 172, 172, 171, 170, 170, 169, 169, 169, 168, - 168, 168, 167, 167, 166, 165, 165, 164, 163, 162, 161, 160, 159, 158, 158, 157, 156, 156, 155, 154, 154, 153, 153, - 153, 152, 152, 152, 152, 151, 151, 151, 150, 150, 149, 149, 148, 147, 147, 146, 145, 144, 144, 143, 142, 142, 141, - 141, 140, 140, 139, 138, 138, 137, 136, 135, 134, 133, 131, 130, 129, 128, 127, 126, 125, 124, 124, 123, 123, 122, - 122, 122, 122, 121, 121, 121, 120, 120, 119, 118, 117, 116, 115, 114, 114, 113, 113, 112, 112, 112, 112, 111, 111, - 111, 110, 109, 109, 108, 108, 107, 106, 106, 105, 104, 103, 103, 102, 101, 100, 99, 98, 97, 95, 94, 94, 93, - 93, 92, 92, 93, 93, 93, 93, 94, 93, 93, 92, 92, 91, 90, 89, 88, 87, 86, 85, 85, 84, 84, 83, - 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, - 72, 71, 71, 71, 70, 70, 70, 70, 70, 69, 69, 69, 68, 68, 67, 67, 66, 66, 65, 64, 64, 63, 63, - 62, 62, 61, 61, 61, 60, 60, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 54, 54, - 53, 53, 53, 53, 53, 52, 52, 52, 51, 51, 50, 50, 49, 49, 48, 48, 47, 47, 46, 46, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45}; - + 109, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 108, 108, 108, 108, 108, 108, 108, 108, 108, 107, 107, 107, 108, 108, 108, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 108, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 106, 106, 106, 106, 106, 106, 106, + 106, 106, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 104, 104, 104, 104, 104, 104, 103, 103, 103, 103, 103, + 103, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 102, 102, 102, 101, 101, 101, 100, 100, 100, 99, 99, 99, 98, 98, 98, 97, 97, 96, 96, 95, 95, + 94, 94, 93, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, + 83, 83, 82, 82, 82, 81, 81, 81, 80, 80, 79, 79, 79, 78, 78, 78, 77, 77, 76, 76, 76, 75, 75, + 75, 74, 74, 74, 73, 73, 73, 72, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 68, 67, 67, 66, 66, + 65, 65, 64, 64, 64, 63, 63, 62, 62, 62, 61, 61, 61, 60, 60, 60, 59, 59, 58, 58, 58, 57, 57, + 57, 56, 56, 55, 55, 55, 54, 54, 54, 53, 53, 52, 52, 52, 51, 51, 51, 51, 50, 50, 50, 49, 49, + 49, 49, 48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 44, 44, 44, 44, 43, 43, 43, 42, + 42, 42, 41, 41, 41, 40, 40, 40, 39, 39, 39, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 36, 35, + 35, 35, 35, 34, 34, 34, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, + 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30}; const ap_uint lt_prop_coord1_2[512] = { - 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 188, 188, 188, 188, 188, 188, 188, 188, 188, 187, 187, 187, 187, - 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 185, 185, 184, 183, 183, 183, 183, 183, 183, - 183, 183, 183, 183, 183, 183, 182, 182, 182, 181, 181, 181, 181, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, - 180, 180, 179, 179, 179, 179, 178, 178, 177, 177, 176, 175, 175, 174, 174, 174, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 172, 172, - 172, 172, 172, 172, 172, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 172, 172, 172, 172, 172, 172, 172, 171, - 171, 171, 171, 171, 170, 170, 169, 169, 168, 168, 168, 167, 167, 166, 166, 166, 165, 164, 163, 162, 162, 161, 160, - 159, 158, 158, 158, 158, 158, 159, 159, 159, 160, 160, 160, 159, 158, 157, 156, 155, 154, 154, 153, 153, 153, 153, - 153, 153, 154, 154, 154, 154, 154, 153, 153, 152, 151, 150, 149, 147, 146, 145, 143, 142, 141, 140, 139, 139, 138, - 138, 138, 138, 138, 138, 137, 136, 136, 134, 133, 132, 131, 130, 129, 128, 128, 127, 127, 127, 126, 126, 126, 125, - 125, 124, 123, 123, 122, 121, 119, 118, 117, 115, 114, 113, 112, 111, 110, 110, 110, 109, 109, 110, 110, 109, 109, - 109, 108, 107, 106, 105, 104, 103, 103, 102, 102, 102, 102, 102, 102, 102, 101, 101, 100, 99, 98, 97, 95, 94, - 93, 93, 92, 91, 91, 91, 90, 90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 85, 85, 84, 83, 82, 82, - 81, 81, 80, 80, 79, 79, 79, 78, 78, 77, 77, 76, 75, 75, 74, 73, 72, 72, 71, 71, 70, 70, 70, - 70, 69, 69, 69, 68, 68, 67, 67, 66, 66, 66, 65, 65, 65, 65, 64, 64, 63, 63, 62, 62, 61, 60, - 60, 59, 58, 58, 58, 57, 57, 57, 57, 57, 57, 56, 56, 55, 55, 54, 53, 52, 52, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 50, 50, 50, 49, 48, 48, 47, 47, 46, 46, 45, 45, 45, 45, 45, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46}; - + 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 118, 118, 118, 118, 118, + 118, 118, 118, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 116, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 116, 116, 116, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, + 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 114, 114, 114, 114, 114, 114, 114, 114, 114, 113, 113, 113, + 113, 113, 113, 113, 113, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 111, + 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 110, 110, 110, 110, 110, 110, 110, 109, + 109, 109, 109, 109, 109, 109, 108, 108, 108, 108, 107, 107, 107, 106, 106, 106, 105, 105, 105, 104, 104, 104, 104, + 103, 103, 103, 102, 102, 101, 101, 101, 100, 100, 100, 99, 99, 99, 98, 98, 98, 97, 97, 96, 96, 95, 95, + 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 85, 84, 84, 83, 83, + 82, 82, 81, 81, 81, 80, 80, 80, 79, 79, 79, 78, 78, 77, 77, 77, 76, 76, 75, 75, 74, 74, 73, + 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 67, 66, 66, 66, 65, 65, 65, 64, 64, 64, + 64, 63, 63, 62, 62, 62, 61, 61, 60, 60, 59, 59, 59, 58, 58, 57, 57, 56, 56, 56, 55, 55, 54, + 54, 54, 53, 53, 53, 52, 52, 52, 51, 51, 51, 50, 50, 50, 50, 49, 49, 49, 48, 48, 48, 48, 47, + 47, 47, 47, 46, 46, 46, 45, 45, 45, 44, 44, 44, 43, 43, 42, 42, 42, 41, 41, 41, 40, 40, 40, + 39, 39, 39, 39, 38, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 35, 35, 35, 35, 34, 34, 34, 33, + 33, 33, 32, 32, 32, 31, 31, 31, 30, 30, 30, 29, 29, 29, 28, 28, 28, 27, 27, 26, 26, 26, 25, + 25, 25, 24, 24, 24, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22}; const ap_uint lt_prop_coord1_3[512] = { - 177, 177, 177, 177, 177, 177, 178, 178, 178, 179, 179, 179, 180, 180, 180, 181, 181, 181, 182, 182, 182, 182, 182, - 182, 182, 182, 182, 182, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 180, 180, 179, 179, 179, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 178, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 178, 178, 178, 178, 179, - 179, 179, 179, 179, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 179, 179, - 179, 179, 179, 180, 180, 180, 180, 180, 180, 179, 179, 179, 178, 178, 177, 176, 176, 176, 175, 175, 175, 175, 174, - 174, 174, 174, 174, 173, 173, 173, 172, 172, 172, 172, 171, 171, 171, 170, 170, 170, 170, 169, 169, 169, 169, 168, - 168, 168, 167, 167, 167, 167, 166, 166, 166, 166, 165, 165, 165, 164, 164, 164, 163, 163, 163, 162, 162, 162, 161, - 161, 161, 160, 160, 160, 159, 159, 159, 158, 158, 158, 157, 157, 157, 156, 156, 155, 155, 155, 154, 154, 153, 153, - 152, 152, 152, 151, 151, 150, 150, 149, 149, 148, 147, 147, 146, 145, 144, 143, 142, 141, 141, 140, 139, 138, 138, - 137, 137, 136, 136, 135, 135, 134, 134, 133, 133, 132, 132, 131, 130, 129, 129, 128, 127, 126, 125, 125, 124, 123, - 123, 122, 121, 121, 120, 119, 119, 118, 117, 116, 115, 115, 114, 113, 113, 112, 112, 112, 111, 111, 111, 111, 110, - 109, 109, 108, 107, 106, 105, 104, 104, 103, 103, 103, 102, 102, 102, 102, 102, 101, 101, 100, 100, 99, 98, 98, - 97, 96, 95, 95, 94, 93, 93, 92, 92, 91, 91, 90, 90, 90, 89, 89, 88, 88, 87, 86, 85, 84, 84, - 83, 82, 81, 81, 80, 80, 79, 79, 78, 78, 78, 78, 77, 77, 76, 76, 76, 75, 74, 74, 73, 72, 72, - 71, 70, 70, 70, 69, 69, 69, 69, 69, 69, 69, 68, 68, 67, 66, 66, 65, 64, 64, 63, 63, 63, 62, - 62, 62, 61, 61, 61, 61, 60, 60, 60, 59, 59, 59, 58, 58, 57, 57, 56, 55, 55, 55, 54, 54, 54, - 54, 54, 54, 54, 54, 53, 53, 53, 52, 52, 51, 50, 50, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48}; - + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 117, 117, 117, 117, 117, 117, 117, 117, + 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 116, 116, 116, 116, 116, 116, 116, 116, 116, 115, + 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 114, 114, 114, 114, 114, 114, 114, 114, + 114, 113, 113, 113, 112, 112, 112, 112, 111, 111, 111, 111, 110, 110, 110, 110, 109, 109, 109, 109, 108, 108, 108, + 108, 107, 107, 107, 107, 106, 106, 106, 106, 105, 105, 105, 105, 104, 104, 104, 104, 103, 103, 103, 103, 102, 102, + 102, 102, 101, 101, 101, 101, 100, 100, 100, 100, 99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 96, 95, 95, + 94, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 88, 87, 87, 86, 86, 85, 85, 84, + 84, 83, 83, 83, 82, 82, 81, 81, 81, 80, 80, 79, 79, 79, 78, 78, 78, 77, 77, 76, 76, 76, 75, + 75, 75, 74, 74, 73, 73, 73, 72, 72, 72, 71, 71, 71, 70, 70, 69, 69, 69, 68, 68, 68, 67, 67, + 67, 66, 66, 66, 65, 65, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 58, 58, 57, 57, 56, 56, 56, + 56, 55, 55, 55, 55, 54, 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 51, 51, 51, 50, 50, 50, 49, + 49, 49, 48, 48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 44, 44, 44, 44, 43, 43, 43, + 42, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 39, 39, 39, 38, 38, 38, 38, 37, 37, 37, 36, 36, + 36, 35, 35, 35, 35, 34, 34, 34, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, + 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30}; const ap_uint lt_prop_coord1_4[512] = { - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 165, 165, 165, 165, 165, 165, 164, 164, 164, 164, 164, - 163, 163, 163, 163, 163, 162, 162, 162, 161, 161, 160, 160, 159, 159, 158, 158, 157, 157, 157, 156, 156, 155, 155, - 155, 155, 154, 154, 154, 154, 153, 153, 152, 152, 151, 150, 149, 148, 147, 146, 144, 143, 142, 140, 139, 138, 137, - 135, 134, 133, 132, 131, 131, 130, 129, 128, 127, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 116, - 115, 114, 113, 113, 112, 111, 111, 110, 109, 108, 108, 107, 106, 106, 105, 104, 104, 103, 103, 103, 102, 102, 101, - 101, 100, 100, 99, 99, 98, 98, 97, 97, 97, 96, 96, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95}; - + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 112, 112, 112, 111, 111, 111, 110, 110, 110, 109, 109, 109, 108, 108, 107, + 107, 107, 106, 106, 106, 105, 105, 105, 105, 104, 104, 104, 104, 104, 103, 103, 103, 103, 102, 102, 102, 102, 101, + 101, 100, 100, 99, 99, 98, 97, 97, 96, 95, 95, 94, 94, 93, 92, 92, 91, 91, 91, 90, 90, 89, 89, + 88, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, + 77, 77, 76, 76, 76, 75, 75, 75, 74, 74, 74, 73, 73, 73, 72, 72, 72, 71, 71, 70, 70, 70, 69, + 69, 69, 68, 68, 67, 67, 67, 66, 66, 66, 65, 65, 64, 64, 64, 63, 63, 63, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62}; const ap_uint lt_prop_coord2_0[512] = { - 203, 203, 203, 203, 203, 203, 203, 203, 204, 204, 205, 205, 206, 207, 208, 208, 209, 210, 211, 212, 212, 213, 213, - 214, 214, 215, 215, 215, 216, 216, 216, 217, 217, 217, 218, 219, 219, 220, 221, 222, 222, 223, 224, 225, 226, 226, - 226, 227, 227, 227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, - 226, 226, 226, 225, 225, 225, 225, 225, 225, 225, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 223, 223, 223, 223, 222, 222, 222, 222, 222, 222, 222, 223, 223, 223, 223, 223, 223, 223, 223, 222, 222, 221, 221, - 220, 219, 219, 218, 217, 217, 216, 215, 214, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 204, 203, 202, - 202, 201, 201, 201, 200, 200, 199, 198, 198, 197, 195, 194, 192, 190, 188, 185, 183, 181, 179, 178, 176, 175, 174, - 172, 171, 170, 169, 168, 166, 165, 164, 162, 161, 159, 158, 156, 155, 153, 152, 150, 149, 147, 146, 145, 144, 143, - 142, 141, 140, 140, 139, 138, 137, 136, 136, 135, 134, 133, 133, 132, 131, 130, 129, 129, 128, 127, 126, 126, 125, - 124, 123, 123, 122, 121, 121, 120, 119, 118, 118, 117, 116, 116, 115, 114, 114, 113, 113, 112, 111, 111, 110, 110, - 109, 109, 108, 107, 107, 106, 106, 105, 105, 104, 104, 104, 103, 103, 102, 102, 101, 101, 101, 100, 100, 100, 99, - 99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 94, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93}; + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 93, 93, 93, 93, 93, 93, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 91, + 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 89, 88, 88, 88, 87, 87, 87, 86, 86, 86, 85, 85, 85, 85, 84, + 84, 84, 84, 84, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 81, 81, 81, 80, 80, 80, 79, 79, + 79, 78, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 69, 69, 69, 69, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65}; const ap_uint lt_prop_coord2_1[512] = { - 148, 148, 148, 148, 148, 149, 149, 149, 149, 149, 149, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 150, 150, 150, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, 152, 152, 152, 152, 152, 152, 152, 152, - 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, - 154, 154, 154, 154, 154, 154, 154, 155, 155, 155, 155, 155, 155, 155, 155, 154, 154, 154, 154, 154, 154, 155, 155, - 155, 155, 155, 154, 154, 154, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 152, - 152, 152, 152, 151, 151, 150, 150, 150, 149, 148, 148, 147, 147, 146, 145, 145, 144, 143, 143, 142, 141, 141, 140, - 140, 139, 138, 138, 137, 137, 136, 136, 135, 134, 133, 133, 132, 131, 130, 129, 127, 126, 125, 124, 123, 123, 122, - 122, 121, 121, 121, 120, 120, 119, 119, 118, 117, 116, 115, 114, 113, 112, 112, 112, 112, 112, 112, 111, 111, 111, - 111, 110, 109, 108, 107, 107, 106, 105, 104, 104, 103, 103, 102, 102, 101, 100, 100, 99, 98, 97, 96, 96, 95, - 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 85, 84, 83, - 83, 82, 82, 82, 81, 81, 80, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, - 72, 72, 71, 71, 71, 70, 70, 70, 70, 70, 69, 69, 69, 69, 68, 68, 68, 67, 67, 66, 66, 65, 65, - 64, 63, 63, 62, 62, 61, 61, 61, 60, 60, 59, 59, 58, 58, 57, 56, 56, 55, 55, 54, 54, 54, 54, - 54, 54, 54, 54, 53, 53, 53, 52, 52, 51, 51, 50, 50, 49, 48, 48, 47, 47, 46, 46, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45}; - + 67, 67, 67, 68, 68, 68, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, 70, + 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, + 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 62, 62, 62, 61, 61, 61, 61, 60, 60, + 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 58, 57, 57, 57, 57, 56, 56, 56, + 55, 55, 55, 55, 54, 54, 54, 53, 53, 53, 53, 53, 52, 52, 52, 52, 52, 51, 51, 51, 51, 51, 50, 50, + 50, 50, 49, 49, 49, 49, 49, 76, 104, 104, 104, 103, 103, 103, 103, 102, 102, 102, 102, 101, 101, 101, 101, 100, + 100, 100, 100, 99, 99, 99, 99, 98, 98, 97, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 92, 91, + 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 83, 83, 83, 82, 82, 82, 81, 81, 80, 80, + 80, 79, 79, 79, 78, 78, 78, 77, 77, 76, 76, 76, 75, 75, 75, 74, 74, 73, 73, 73, 72, 72, 71, 71, + 71, 70, 70, 70, 69, 69, 68, 68, 68, 67, 67, 67, 66, 66, 66, 65, 65, 65, 64, 64, 64, 63, 63, 63, + 62, 62, 62, 61, 61, 61, 61, 60, 60, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 53, 53, 52, 52, 51, + 51, 51, 51, 50, 50, 50, 50, 50, 49, 49, 49, 49, 49, 48, 48, 48, 48, 47, 47, 47, 46, 46, 46, 46, + 45, 45, 45, 44, 44, 44, 43, 43, 43, 43, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 39, 39, 39, 38, + 38, 38, 38, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33}; const ap_uint lt_prop_coord2_2[512] = { - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 76, 76, 76, 76, 75, 75, 74, 73, 73, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 74, 74, 74, 74, 74, - 74, 73, 72, 72, 71, 70, 69, 69, 68, 68, 68, 68, 68, 68, 68, 67, 67, 67, 66, 66, 66, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 66, - 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 69, 69, 69, 69, 68, 68, 67, - 67, 66, 66, 65, 65, 66, 67, 69, 72, 75, 79, 84, 89, 95, 101, 107, 114, 120, 127, 133, 139, 144, 149, - 154, 158, 161, 163, 165, 165, 165, 165, 164, 163, 162, 160, 160, 159, 158, 158, 158, 158, 157, 157, 157, 157, 158, - 158, 158, 158, 158, 158, 158, 157, 157, 157, 156, 156, 155, 154, 152, 151, 149, 147, 145, 143, 142, 140, 139, 138, - 137, 136, 135, 134, 134, 133, 133, 132, 131, 131, 130, 129, 129, 128, 127, 126, 126, 125, 124, 124, 123, 123, 122, - 122, 121, 121, 120, 120, 119, 118, 118, 117, 116, 115, 113, 112, 111, 110, 109, 109, 108, 107, 107, 107, 107, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108}; - + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36, 36, 36, 36, 36, + 36, 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 32, + 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 71, 111, + 110, 110, 110, 109, 109, 109, 108, 108, 108, 107, 107, 107, 106, 106, 106, 105, 105, 105, 104, 104, 104, 103, 103, + 103, 102, 102, 101, 101, 101, 100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 96, 96, 96, 95, 95, 94, 94, + 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, + 82, 82, 81, 81, 80, 80, 80, 79, 79, 78, 78, 78, 77, 77, 76, 76, 76, 75, 75, 75, 74, 74, 74, + 73, 73, 73, 72, 72, 72, 71, 71, 71, 70, 70, 70, 69, 69, 69, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68}; const ap_uint lt_prop_coord2_3[512] = { - 25, 25, 25, 25, 25, 25, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 24, 24, 24, - 24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 22, 22, 23, 23, 23, - 23, 23, 23, 22, 21, 20, 20, 19, 18, 18, 17, 17, 17, 18, 18, 19, 20, 21, 22, 23, 24, 26, 27, - 28, 30, 32, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 58, 60, 62, 65, 67, 70, 72, 74, - 77, 79, 82, 84, 86, 89, 91, 94, 96, 98, 101, 103, 105, 107, 110, 112, 114, 116, 118, 120, 122, 124, 125, - 127, 129, 130, 132, 133, 134, 136, 137, 138, 139, 140, 141, 141, 142, 142, 143, 143, 143, 143, 142, 142, 141, 140, - 139, 138, 136, 135, 134, 133, 132, 131, 131, 130, 130, 129, 129, 129, 128, 128, 127, 127, 127, 126, 125, 124, 124, - 123, 122, 120, 119, 118, 117, 116, 115, 114, 114, 113, 112, 112, 111, 111, 111, 111, 111, 111, 111, 111, 111, 110, - 110, 109, 109, 108, 107, 106, 105, 104, 103, 103, 102, 101, 100, 99, 99, 98, 97, 97, 96, 96, 95, 94, 94, - 93, 93, 92, 91, 91, 90, 89, 89, 88, 88, 88, 87, 87, 87, 86, 86, 86, 86, 85, 85, 84, 84, 84, - 83, 82, 82, 81, 81, 80, 79, 79, 78, 78, 78, 77, 77, 76, 76, 76, 75, 75, 75, 74, 74, 73, 72, - 72, 72, 71, 71, 71, 71, 70, 70, 70, 70, 69, 69, 69, 68, 68, 67, 66, 66, 65, 64, 63, 63, 62, - 62, 61, 61, 60, 60, 60, 59, 59, 59, 59, 59, 58, 58, 58, 57, 57, 57, 56, 56, 56, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 54, 54, 54, 53, 53, 52, 51, 50, 49, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47}; - + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 18, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 64, 109, 108, 108, 108, 107, 107, 106, 106, 106, 105, 105, 105, 104, 104, 103, 103, + 103, 102, 102, 102, 101, 101, 100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 95, 95, 95, 94, + 94, 94, 93, 93, 92, 92, 92, 91, 91, 90, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, + 84, 84, 83, 83, 82, 82, 82, 81, 81, 80, 80, 80, 79, 79, 78, 78, 78, 77, 77, 76, 76, 76, 75, + 75, 75, 74, 74, 74, 73, 73, 73, 72, 72, 72, 71, 71, 70, 70, 70, 69, 69, 68, 68, 67, 67, 67, + 66, 66, 65, 65, 65, 64, 64, 63, 63, 63, 62, 62, 61, 61, 61, 60, 60, 59, 59, 59, 58, 58, 58, + 57, 57, 57, 56, 56, 56, 55, 55, 55, 55, 54, 54, 54, 53, 53, 53, 52, 52, 52, 51, 51, 50, 50, + 50, 49, 49, 49, 48, 48, 48, 47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 44, 44, 44, 44, 43, + 43, 43, 42, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 39, 39, 39, 38, 38, 38, 38, 37, 37, 37, + 36, 36, 36, 36, 35, 35, 35, 35, 34, 34, 34, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32}; const ap_uint lt_prop_coord2_4[512] = { - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 172, 172, 171, 171, 171, 170, 170, 170, 169, 169, 169, 168, - 168, 167, 167, 166, 166, 165, 164, 164, 163, 162, 161, 160, 160, 159, 158, 157, 156, 156, 155, 154, 153, 152, 152, - 151, 150, 149, 149, 148, 147, 146, 146, 145, 144, 144, 143, 142, 141, 141, 140, 139, 139, 138, 137, 136, 136, 135, - 134, 133, 133, 132, 131, 130, 130, 129, 128, 128, 127, 126, 126, 125, 124, 123, 122, 121, 120, 119, 119, 118, 117, - 116, 116, 115, 115, 114, 113, 113, 112, 111, 111, 110, 109, 108, 108, 107, 106, 106, 105, 104, 104, 103, 103, 103, - 102, 102, 102, 102, 101, 101, 101, 100, 100, 100, 99, 98, 97, 96, 95, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93}; + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + 114, 114, 114, 114, 114, 114, 113, 113, 113, 113, 112, 112, 112, 111, 111, 111, 111, 110, 110, 110, 109, 109, 109, + 109, 108, 108, 108, 107, 107, 107, 106, 106, 106, 106, 105, 105, 105, 104, 104, 104, 103, 103, 103, 102, 102, 102, + 101, 101, 100, 100, 99, 98, 98, 97, 97, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 91, 90, 90, + 90, 89, 89, 88, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 81, 81, 80, 80, 79, 79, + 78, 78, 77, 77, 76, 76, 76, 75, 75, 75, 74, 74, 73, 73, 73, 72, 72, 72, 71, 71, 71, 70, 70, + 69, 69, 69, 68, 68, 67, 67, 67, 66, 66, 65, 65, 65, 65, 64, 64, 64, 63, 63, 63, 63, 62, 62, + 62, 62, 61, 61, 61, 61, 60, 60, 60, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59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5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; - + 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 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 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; - + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 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 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; - + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14}; const ap_uint lt_res0_coord1_3[512] = { - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, - 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; - + 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, + 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}; const ap_uint lt_res0_coord1_4[512] = { - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,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14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}; const ap_uint lt_res0_coord2_0[512] = { - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, - 5, 5, 5, 5, 5, 5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13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 26, 27, 27, 28, 29, 29, 30, 31, + 31, 32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 35, 34, 34, 33, 32, 31, 31, 30, 29, 29, 28, 27, 27, 26, 25, 25, + 24, 23, 23, 22, 21, 21, 20, 19, 19, 18, 17, 16, 16, 16, 17, 18, 19, 21, 22, 24, 25, 26, 28, 29, 31, 32, 34, + 35, 36, 38, 39, 41, 42, 43, 45, 46, 48, 49, 51, 52, 53, 55, 56, 58, 59, 59, 60, 59, 59, 58, 57, 57, 56, 55, + 55, 54, 53, 53, 52, 51, 51, 50, 49, 49, 48, 47, 47, 46, 45, 45, 44, 43, 43, 42, 41, 41, 40, 39, 39, 38, 37, + 37, 36, 35, 35, 34, 33, 33, 32, 31, 31, 30, 29, 29, 28, 27, 27, 26, 25, 25, 24, 23, 23, 22, 22, 21, 20, 20, + 19, 18, 18, 17, 16, 16, 15, 14, 14, 13, 12, 12, 11, 10, 10, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 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 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 18, 19, 19, + 19, 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 30, 30, 31, 31, 32, 33, 33, 34, 35, 35, + 36, 36, 37, 37, 37, 36, 36, 35, 34, 34, 33, 32, 32, 31, 30, 30, 29, 28, 28, 27, 27, 26, 25, 25, 24, 23, 23, + 22, 21, 21, 20, 19, 19, 18, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, + 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, + 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17}; const ap_uint lt_res0_coord2_2[512] = { - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, - 4, 4, 4, 4, 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 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18, + 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20}; const ap_uint lt_res0_coord2_3[512] = { - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 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, 5, 5, 5}; - + 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 16, 16, + 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 28, 28, + 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, + 14, 14, 13, 13, 13, 14, 15, 15, 16, 17, 17, 18, 18, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, + 28, 29, 29, 30, 30, 31, 32, 32, 33, 33, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29, 28, 28, + 28, 27, 27, 27, 27, 26, 26, 26, 25, 25, 25, 25, 24, 24, 24, 24, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, + 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17}; const ap_uint lt_res0_coord2_4[512] = { - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5,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5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19}; + + const ap_uint lt_res1_coord1_0[512] = { + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2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, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, - 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, - 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, - 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, - 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, - 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, - 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3,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, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, - 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; - - const ap_uint lt_res1_coord1_4[512] = { - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, - 10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 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, - 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}; - - const ap_uint lt_res1_coord2_2[512] = { - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, - 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, - 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11, 10, 9, 8, 8, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,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@@ namespace Phase2L1GMT { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13}; - // const ap_uint<8> lt_tpsID[256] = { - // 40, 56, 64, 88, 64, 32, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, 28, 56, 56, 54, 36, 36, 36, 36, 36, 36, - // 36, 36, 32, 28, 28, 28, 28, 52, 56, 52, 52, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 28, 56, 52, 52, - // 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 28, 52, 36, 36, 36, 36, 36, 36, 36, 36, 56, 56, 36, 56, - // 36, 36, 28, 60, 60, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 28, 120, 120, 120, 92, 92, 64, 64, - // 64, 64, 64, 64, 64, 64, 64, 64, 28, 120, 152, 128, 100, 124, 80, 80, 64, 100, 64, 64, 64, 64, 64, 64, 28, 88, - // 92, 64, 92, 60, 60, 60, 92, 60, 60, 60, 60, 60, 60, 60, 36, 88, 88, 64, 64, 60, 60, 60, 60, 60, 60, 60, - // 92, 92, 92, 92, 28, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 92, 92, 92, 92, 92, - // 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 28, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, - // 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - // 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}; - // NEW LUT with Low Pt (Bin 0, Pt<8 GeV) increased quality requirement. WP95. No changes for Pt>8 const ap_uint<8> lt_tpsID[256] = { 59, 56, 64, 88, 64, 32, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, 33, 56, 56, 54, 36, 36, 36, 36, 36, 36, @@ -1220,4 +1184,5 @@ namespace Phase2L1GMT { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}; } // namespace Phase2L1GMT + #endif diff --git a/L1Trigger/Phase2L1GMT/plugins/TopologicalAlgorithm.h b/L1Trigger/Phase2L1GMT/interface/TopologicalAlgorithm.h similarity index 100% rename from L1Trigger/Phase2L1GMT/plugins/TopologicalAlgorithm.h rename to L1Trigger/Phase2L1GMT/interface/TopologicalAlgorithm.h diff --git a/L1Trigger/Phase2L1GMT/interface/TrackConverter.h b/L1Trigger/Phase2L1GMT/interface/TrackConverter.h new file mode 100644 index 0000000000000..a12a2a5ed213f --- /dev/null +++ b/L1Trigger/Phase2L1GMT/interface/TrackConverter.h @@ -0,0 +1,52 @@ +#ifndef L1Trigger_Phase2L1GMT_TrackConverter_h +#define L1Trigger_Phase2L1GMT_TrackConverter_h + +#include "L1Trigger/Phase2L1GMT/interface/ConvertedTTTrack.h" +#include "L1Trigger/Phase2L1GMT/interface/TPSLUTs.h" +#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +namespace Phase2L1GMT { + + class TrackConverter { + public: + TrackConverter(const edm::ParameterSet& iConfig); + ~TrackConverter() = default; + + std::vector convertTracks(const std::vector >& tracks); + + private: + int verbose_; + typedef ap_uint<96> wordtype; + + uint generateQuality(const edm::Ptr >& track) { return 1; } + + uint ptLookup(uint absCurv) { + for (auto i : ptShifts) { + if (absCurv >= uint(i[0]) && absCurv < uint(i[1])) { + if (i[2] < 0) + return i[4]; + else + return (absCurv >> i[2]) + i[3]; + } + } + return 0; + } + + uint etaLookup(uint absTanL) { + for (auto i : etaShifts) { + if (absTanL >= uint(i[0]) && absTanL < uint(i[1])) { + if (i[2] < 0) + return i[4]; + else + return (absTanL >> i[2]) + i[3]; + } + } + return 0; + } + + ConvertedTTTrack convert(const edm::Ptr >& track); + }; +} // namespace Phase2L1GMT + +#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/MuonROI.h b/L1Trigger/Phase2L1GMT/plugins/MuonROI.h deleted file mode 100644 index f0d0989af6f92..0000000000000 --- a/L1Trigger/Phase2L1GMT/plugins/MuonROI.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef PHASE2GMT_MUONROI -#define PHASE2GMT_MUONROI -#include -#include "DataFormats/L1TMuonPhase2/interface/Constants.h" -#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" -#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" -#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h" -#include "DataFormats/L1Trigger/interface/L1TObjComparison.h" -#include "DataFormats/L1Trigger/interface/BXVector.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -namespace Phase2L1GMT { - - class MuonROI { - public: - MuonROI(int bx, uint charge, uint pt, uint quality) : bx_(bx), charge_(charge), pt_(pt), quality_(quality) {} - - const int bx() const { return bx_; } - - const uint charge() const { return charge_; } - - const uint pt() const { return pt_; } - const int quality() const { return quality_; } - - const float offline_pt() const { return offline_pt_; } - - void setOfflinePt(float pt) { offline_pt_ = pt; } - - void addStub(const l1t::MuonStubRef& stub) { stubs_.push_back(stub); } - - void setMuonRef(const l1t::RegionalMuonCandRef& ref) { - muRef_ = ref; - isGlobal_ = true; - } - bool isGlobalMuon() const { return isGlobal_; } - - const l1t::RegionalMuonCandRef& muonRef() const { return muRef_; } - - friend std::ostream& operator<<(std::ostream& s, const MuonROI& id) { - s.setf(ios::right, ios::adjustfield); - s << "ROI:" - << " " - << "BX: " << setw(5) << id.bx_ << " " - << "charge:" << setw(5) << id.charge_ << " " - << "pt:" << setw(5) << id.pt_ << " " - << "quality:" << setw(5) << id.quality_ << " " - << "offline pt:" << setw(5) << id.offline_pt_; - return s; - } - - const l1t::MuonStubRefVector& stubs() const { return stubs_; } - - ap_uint<64> stubWord(const l1t::MuonStubRef& stub) const { - ap_uint<64> word = 0; - word = word | twos_complement(stub->coord1(), BITSSTUBCOORD); - word = word | (twos_complement(stub->coord2(), BITSSTUBCOORD) << BITSSTUBCOORD); - word = word | (twos_complement(stub->eta1(), BITSSTUBETA) << (2 * BITSSTUBCOORD)); - word = word | (twos_complement(stub->eta2(), BITSSTUBETA) << (2 * BITSSTUBCOORD + BITSSTUBETA)); - word = word | (twos_complement(stub->quality(), BITSSTUBPHIQUALITY) << (2 * BITSSTUBCOORD + 2 * BITSSTUBETA)); - word = word | (twos_complement(stub->etaQuality(), BITSSTUBETAQUALITY) - << (2 * BITSSTUBCOORD + 2 * BITSSTUBETA + BITSSTUBPHIQUALITY)); - word = word | (twos_complement(stub->bxNum(), BITSSTUBTIME) - << (2 * BITSSTUBCOORD + 2 * BITSSTUBETA + BITSSTUBPHIQUALITY + BITSSTUBETAQUALITY)); - word = word | (twos_complement(stub->id(), BITSSTUBID) - << (2 * BITSSTUBCOORD + 2 * BITSSTUBETA + BITSSTUBPHIQUALITY + BITSSTUBETAQUALITY + BITSSTUBTIME)); - return word; - } - - ap_uint<32> roiWord() const { - ap_uint<32> word = 0; - word = word | twos_complement(bx_, BITSMUONBX); - word = word | (twos_complement(isGlobal_, 1) << (BITSMUONBX)); - word = word | (twos_complement(charge_, 1) << (BITSMUONBX + 1)); - word = word | (twos_complement(pt_, BITSPT) << (BITSMUONBX + 2)); - word = word | (twos_complement(quality_, BITSSTAMUONQUALITY) << (BITSMUONBX + 2 + BITSPT)); - return word; - } - - void printROILine() const { - ap_uint<64> s0 = 0x1ff000000000000; - ap_uint<64> s1 = 0x1ff000000000000; - ap_uint<64> s2 = 0x1ff000000000000; - ap_uint<64> s3 = 0x1ff000000000000; - ap_uint<64> s4 = 0x1ff000000000000; - for (const auto& s : stubs_) { - if (s->tfLayer() == 0) - s0 = stubWord(s); - if (s->tfLayer() == 1) - s1 = stubWord(s); - if (s->tfLayer() == 2) - s2 = stubWord(s); - if (s->tfLayer() == 3) - s3 = stubWord(s); - if (s->tfLayer() == 4) - s4 = stubWord(s); - } - LogDebug("MuonROI") << "MuonROI " << std::setfill('0') << std::setw(8) << std::hex - << (long long unsigned int)(roiWord().to_uint64()) << std::setfill('0') << std::setw(16) - << std::hex << (long long unsigned int)(s4.to_uint64()) << std::setfill('0') << std::setw(16) - << std::hex << (long long unsigned int)(s3.to_uint64()) << std::setfill('0') << std::setw(16) - << std::hex << (long long unsigned int)(s2.to_uint64()) << std::setfill('0') << std::setw(16) - << std::hex << (long long unsigned int)(s1.to_uint64()) << std::setfill('0') << std::setw(16) - << std::hex << (long long unsigned int)(s0.to_uint64()); - } - - private: - int bx_; - uint charge_; - uint pt_; - uint quality_; - bool isGlobal_; - float offline_pt_; - - l1t::MuonStubRefVector stubs_; - l1t::RegionalMuonCandRef muRef_; - }; -} // namespace Phase2L1GMT - -#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/Node.h b/L1Trigger/Phase2L1GMT/plugins/Node.h deleted file mode 100644 index f28a287f54074..0000000000000 --- a/L1Trigger/Phase2L1GMT/plugins/Node.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef PHASE2GMT_NODE -#define PHASE2GMT_NODE -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "TrackConverter.h" -#include "ROITempAssociator.h" -#include "TrackMuonMatchAlgorithm.h" -#include "Isolation.h" -#include "Tauto3Mu.h" -#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" - -namespace Phase2L1GMT { - - class Node { - public: - Node(const edm::ParameterSet& iConfig) - : verbose_(iConfig.getParameter("verbose")), - tt_track_converter_(new TrackConverter(iConfig.getParameter("trackConverter"))), - roi_assoc_(new ROITempAssociator(iConfig.getParameter("roiTrackAssociator"))), - track_mu_match_(new TrackMuonMatchAlgorithm(iConfig.getParameter("trackMatching"))), - isolation_(new Isolation(iConfig.getParameter("isolation"))), - tauto3mu_(new Tauto3Mu(iConfig.getParameter("tauto3mu"))) {} - - ~Node() {} - - std::vector processEvent(const std::vector >& tracks, - const l1t::ObjectRefBxCollection& muonTracks, - const l1t::MuonStubRefVector& stubs) { - //Split tracks to the links as they come - std::vector > tracks0 = associateTracksWithNonant(tracks, 0); - std::vector > tracks1 = associateTracksWithNonant(tracks, 1); - std::vector > tracks2 = associateTracksWithNonant(tracks, 2); - std::vector > tracks3 = associateTracksWithNonant(tracks, 3); - std::vector > tracks4 = associateTracksWithNonant(tracks, 4); - std::vector > tracks5 = associateTracksWithNonant(tracks, 5); - std::vector > tracks6 = associateTracksWithNonant(tracks, 6); - std::vector > tracks7 = associateTracksWithNonant(tracks, 7); - std::vector > tracks8 = associateTracksWithNonant(tracks, 8); - - //Transition stubs to different nonants with overlap - l1t::MuonStubRefVector stubs0 = associateStubsWithNonant(stubs, 0); - l1t::MuonStubRefVector stubs1 = associateStubsWithNonant(stubs, 1); - l1t::MuonStubRefVector stubs2 = associateStubsWithNonant(stubs, 2); - l1t::MuonStubRefVector stubs3 = associateStubsWithNonant(stubs, 3); - l1t::MuonStubRefVector stubs4 = associateStubsWithNonant(stubs, 4); - l1t::MuonStubRefVector stubs5 = associateStubsWithNonant(stubs, 5); - l1t::MuonStubRefVector stubs6 = associateStubsWithNonant(stubs, 6); - l1t::MuonStubRefVector stubs7 = associateStubsWithNonant(stubs, 7); - l1t::MuonStubRefVector stubs8 = associateStubsWithNonant(stubs, 8); - - //Convert TT tracks to our internal tracking format - std::vector convertedTracks0 = tt_track_converter_->convertTracks(tracks0); - std::vector convertedTracks1 = tt_track_converter_->convertTracks(tracks1); - std::vector convertedTracks2 = tt_track_converter_->convertTracks(tracks2); - std::vector convertedTracks3 = tt_track_converter_->convertTracks(tracks3); - std::vector convertedTracks4 = tt_track_converter_->convertTracks(tracks4); - std::vector convertedTracks5 = tt_track_converter_->convertTracks(tracks5); - std::vector convertedTracks6 = tt_track_converter_->convertTracks(tracks6); - std::vector convertedTracks7 = tt_track_converter_->convertTracks(tracks7); - std::vector convertedTracks8 = tt_track_converter_->convertTracks(tracks8); - - //Build ROIs per nonant - std::vector rois0 = roi_assoc_->associate(0, muonTracks, stubs0); - std::vector rois1 = roi_assoc_->associate(0, muonTracks, stubs1); - std::vector rois2 = roi_assoc_->associate(0, muonTracks, stubs2); - std::vector rois3 = roi_assoc_->associate(0, muonTracks, stubs3); - std::vector rois4 = roi_assoc_->associate(0, muonTracks, stubs4); - std::vector rois5 = roi_assoc_->associate(0, muonTracks, stubs5); - std::vector rois6 = roi_assoc_->associate(0, muonTracks, stubs6); - std::vector rois7 = roi_assoc_->associate(0, muonTracks, stubs7); - std::vector rois8 = roi_assoc_->associate(0, muonTracks, stubs8); - - //run track - muon matching per nonant - std::vector mu0 = track_mu_match_->processNonant(convertedTracks0, rois0); - std::vector mu1 = track_mu_match_->processNonant(convertedTracks1, rois1); - std::vector mu2 = track_mu_match_->processNonant(convertedTracks2, rois2); - std::vector mu3 = track_mu_match_->processNonant(convertedTracks3, rois3); - std::vector mu4 = track_mu_match_->processNonant(convertedTracks4, rois4); - std::vector mu5 = track_mu_match_->processNonant(convertedTracks5, rois5); - std::vector mu6 = track_mu_match_->processNonant(convertedTracks6, rois6); - std::vector mu7 = track_mu_match_->processNonant(convertedTracks7, rois7); - std::vector mu8 = track_mu_match_->processNonant(convertedTracks8, rois8); - if (verbose_) - printf("Matching Nonant 5 with %zu tracks and %zu rois and %zu stubs\n", - convertedTracks5.size(), - rois5.size(), - stubs5.size()); - - //clean neighboring nonants - std::vector muCleaned = track_mu_match_->cleanNeighbor(mu0, mu8, mu1, true); - std::vector muCleaned1 = track_mu_match_->cleanNeighbor(mu1, mu0, mu2, false); - std::vector muCleaned2 = track_mu_match_->cleanNeighbor(mu2, mu1, mu3, true); - std::vector muCleaned3 = track_mu_match_->cleanNeighbor(mu3, mu2, mu4, false); - std::vector muCleaned4 = track_mu_match_->cleanNeighbor(mu4, mu3, mu5, true); - std::vector muCleaned5 = track_mu_match_->cleanNeighbor(mu5, mu4, mu6, false); - std::vector muCleaned6 = track_mu_match_->cleanNeighbor(mu6, mu5, mu7, true); - std::vector muCleaned7 = track_mu_match_->cleanNeighbor(mu7, mu6, mu8, false); - std::vector muCleaned8 = - track_mu_match_->cleanNeighbor(mu8, mu7, mu0, false); //ARGH! 9 sectors - so some duplicates very rarely - - //merge all the collections - std::copy(muCleaned1.begin(), muCleaned1.end(), std::back_inserter(muCleaned)); - std::copy(muCleaned2.begin(), muCleaned2.end(), std::back_inserter(muCleaned)); - std::copy(muCleaned3.begin(), muCleaned3.end(), std::back_inserter(muCleaned)); - std::copy(muCleaned4.begin(), muCleaned4.end(), std::back_inserter(muCleaned)); - std::copy(muCleaned5.begin(), muCleaned5.end(), std::back_inserter(muCleaned)); - std::copy(muCleaned6.begin(), muCleaned6.end(), std::back_inserter(muCleaned)); - std::copy(muCleaned7.begin(), muCleaned7.end(), std::back_inserter(muCleaned)); - std::copy(muCleaned8.begin(), muCleaned8.end(), std::back_inserter(muCleaned)); - - std::vector trackMatchedMuonsNoIso = track_mu_match_->convert(muCleaned, 32); - - //Isolation and tau3mu will read those muons and all 9 collections of convertedTracks* - std::vector convertedTracks = convertedTracks0; - std::copy(convertedTracks1.begin(), convertedTracks1.end(), std::back_inserter(convertedTracks)); - std::copy(convertedTracks2.begin(), convertedTracks2.end(), std::back_inserter(convertedTracks)); - std::copy(convertedTracks3.begin(), convertedTracks3.end(), std::back_inserter(convertedTracks)); - std::copy(convertedTracks4.begin(), convertedTracks4.end(), std::back_inserter(convertedTracks)); - std::copy(convertedTracks5.begin(), convertedTracks5.end(), std::back_inserter(convertedTracks)); - std::copy(convertedTracks6.begin(), convertedTracks6.end(), std::back_inserter(convertedTracks)); - std::copy(convertedTracks7.begin(), convertedTracks7.end(), std::back_inserter(convertedTracks)); - std::copy(convertedTracks8.begin(), convertedTracks8.end(), std::back_inserter(convertedTracks)); - - //sorter here: - std::vector sortedTrackMuonsNoIso = track_mu_match_->sort(trackMatchedMuonsNoIso, 12); - - isolation_->isolation_allmu_alltrk(sortedTrackMuonsNoIso, convertedTracks); - - //tauto3mu_->GetTau3Mu(sortedTrackMuonsNoIso, convertedTracks); - - track_mu_match_->outputGT(sortedTrackMuonsNoIso); - - return sortedTrackMuonsNoIso; //when we add more collections like tau3mu etc we change that - } - - private: - int verbose_; - std::unique_ptr tt_track_converter_; - std::unique_ptr roi_assoc_; - std::unique_ptr track_mu_match_; - std::unique_ptr isolation_; - std::unique_ptr tauto3mu_; - - std::vector > associateTracksWithNonant( - const std::vector >& tracks, uint processor) { - std::vector > out; - for (const auto& track : tracks) { - if (track->phiSector() == processor) { - out.push_back(track); - } - } - return out; - } - - l1t::MuonStubRefVector associateStubsWithNonant(const l1t::MuonStubRefVector& allStubs, uint processor) { - l1t::MuonStubRefVector out; - - ap_int center = ap_int((processor * 910) / 32); - - for (const auto& s : allStubs) { - ap_int phi = 0; - if (s->quality() & 0x1) - phi = s->coord1(); - else - phi = s->coord2(); - - ap_int deltaPhi = phi - center; - ap_uint absDeltaPhi = - (deltaPhi < 0) ? ap_uint(-deltaPhi) : ap_uint(deltaPhi); - if (absDeltaPhi < 42) - out.push_back(s); - - /* if (processor==0 && phi>=-3000/32 && phi<=3000/32 ) */ - /* out.push_back(s); */ - /* else if (processor==1 && (phi>=-1000/32 && phi<=5000/32) ) */ - /* out.push_back(s); */ - /* else if (processor==2 && (phi>=500/32 && phi<=6500/32) ) */ - /* out.push_back(s); */ - /* else if (processor==3 && (phi>=2000/32 || phi<=-8000/32) ) */ - /* out.push_back(s); */ - /* else if (processor==4 && (phi>=4500/32 || phi<=-6000/32) ) */ - /* out.push_back(s); */ - /* else if (processor==5 && (phi>=6000/32 || phi<=-4500/32) ) */ - /* out.push_back(s); */ - /* else if (processor==6 && (phi>=8000/32 || phi<=-2000/32) ) */ - /* out.push_back(s); */ - /* else if (processor==7 && (phi>=-7000/32 && phi<=0) ) */ - /* out.push_back(s); */ - /* else if (processor==8 && (phi>=-4500/32 && phi<=1000/32) ) */ - /* out.push_back(s); */ - } - return out; - } - }; -} // namespace Phase2L1GMT - -#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc index ea0d9617e7cb7..dfe0d16a91388 100644 --- a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc @@ -9,7 +9,6 @@ #include "FWCore/Utilities/interface/StreamID.h" #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" #include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" -#include "Node.h" // // class declaration diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFwdMuonTranslator.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFwdMuonTranslator.cc new file mode 100644 index 0000000000000..4f1cf8d11c34c --- /dev/null +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFwdMuonTranslator.cc @@ -0,0 +1,295 @@ +// -*- C++ -*- + +#ifndef PHASE2GMT_SAFWDMUONTRANSLATOR +#define PHASE2GMT_SAFWDMUONTRANSLATOR + +// system include files +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" +#include "DataFormats/L1Trigger/interface/Muon.h" +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" +#include "DataFormats/L1TMuonPhase2/interface/EMTFTrack.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h" + +// +// class declaration +// +using namespace Phase2L1GMT; +using namespace l1t; + +class Phase2L1TGMTFwdMuonTranslator : public edm::stream::EDProducer<> { +public: + explicit Phase2L1TGMTFwdMuonTranslator(const edm::ParameterSet&); + ~Phase2L1TGMTFwdMuonTranslator() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + + l1t::SAMuon Convertl1tMuon(const l1t::RegionalMuonCand& mu, const int bx_, bool isDisplaced = false); + l1t::MuonStubRefVector selectLayerBX(const l1t::MuonStubRefVector& all, int bx, uint layer); + void associateStubs(l1t::SAMuon&, const l1t::MuonStubRefVector&); + + l1t::SAMuon ConvertEMTFTrack(const l1t::phase2::EMTFTrack& track, const int bx_); + + // ----------member data --------------------------- + edm::EDGetTokenT stubToken_; + edm::EDGetTokenT omtfTrackToken_; + edm::EDGetTokenT emtfTrackToken_; +}; +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +Phase2L1TGMTFwdMuonTranslator::Phase2L1TGMTFwdMuonTranslator(const edm::ParameterSet& iConfig) + : stubToken_(consumes(iConfig.getParameter("stubs"))), + omtfTrackToken_(consumes(iConfig.getParameter("omtfTracks"))), + emtfTrackToken_(consumes(iConfig.getParameter("emtfTracks"))) { + produces >("prompt").setBranchAlias("prompt"); + produces >("displaced").setBranchAlias("displaced"); +} + +// ------------ method called to produce the data ------------ +void Phase2L1TGMTFwdMuonTranslator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + + edm::Handle stubHandle; + iEvent.getByToken(stubToken_, stubHandle); + + edm::Handle emtf_tracks; + iEvent.getByToken(emtfTrackToken_, emtf_tracks); + + edm::Handle omtf_tracks; + iEvent.getByToken(omtfTrackToken_, omtf_tracks); + + // Process Stubs + l1t::MuonStubRefVector stubs; + + for (uint i = 0; i < stubHandle->size(); ++i) { + l1t::MuonStubRef stub(stubHandle, i); + + if (stub->bxNum() == 0) + stubs.push_back(stub); + } + + // Collect Muons + std::vector prompt; + + // TODO: Will receive hybrid stubs from OMTF/EMTF + std::vector displaced; + + // Convert OMTF Muons to SAMuons + for (unsigned int i = 0; i < omtf_tracks->size(0); ++i) { + const l1t::RegionalMuonCand& mu = omtf_tracks->at(0, i); + // Since OMTF is using Phase-1 LSB, will convert to SAMuon locally + // We should move to passing words in future + l1t::SAMuon samuon; + if (mu.hwPt() > 0) + samuon = Convertl1tMuon(mu, 0); + else if (mu.hwPtUnconstrained() > 0) //Assume exculsive, need double check + samuon = Convertl1tMuon(mu, 0, true); + + //now associate the stubs + associateStubs(samuon, stubs); + + // Add To Collections + if (mu.hwPt() > 0) + prompt.push_back(samuon); + else if (mu.hwPtUnconstrained() > 0) + displaced.push_back(samuon); + } + + // Convert EMTF++ Tracks to SAMuons + for (unsigned int track_id = 0; track_id < emtf_tracks->size(); ++track_id) { + const auto& track = emtf_tracks->at(track_id); + + if (track.valid() == 0) { + continue; + } + + auto samuon = ConvertEMTFTrack(track, 0); + + //now associate the stubs + associateStubs(samuon, stubs); + + // Add To Collections + if (track.unconstrained()) { + displaced.push_back(samuon); + } else { + prompt.push_back(samuon); + } + } + + // Output Prompt Muon Collection + std::unique_ptr > prompt_ptr = std::make_unique >(prompt); + std::unique_ptr > displaced_ptr = std::make_unique >(displaced); + iEvent.put(std::move(prompt_ptr), "prompt"); + iEvent.put(std::move(displaced_ptr), "displaced"); +} + +// === FUNCTION ============================================================ +// Name: Phase2L1TGMTFwdMuonTranslator::Convertl1tMuon +// Description: +// =========================================================================== +SAMuon Phase2L1TGMTFwdMuonTranslator::Convertl1tMuon(const l1t::RegionalMuonCand& mu, const int bx_, bool isDisplaced) { + ap_uint qual = mu.hwQual(); + int charge = mu.hwSign(); + + ap_uint pt = 0; + if (!isDisplaced && mu.hwPt() > 0) + pt = round(mu.hwPt() * 0.5 / LSBpt); // Phase-1 LSB 0.5GeV + if (isDisplaced && mu.hwPtUnconstrained() > 0) + pt = round(mu.hwPtUnconstrained() * 0.5 / LSBpt); // Phase-1 LSB 0.5GeV + + constexpr double p1phiLSB = 2 * M_PI / 576; + ap_int phi = round(mu.hwPhi() * p1phiLSB / LSBphi); // Phase-1 LSB (2*pi/576) + ap_int eta = round(mu.hwEta() * 0.010875 / LSBeta); // Phase-1 LSB 0.010875 + + // FIXME: Below are not well defined in phase1 GMT + // Using the version from Correlator for now + ap_int z0 = 0; // No tracks info in Phase 1 + // Use 2 bits with LSB = 30cm for BMTF and 25cm for EMTF currently, but subjet to change + ap_int d0 = mu.hwDXY(); + + //Here do not use the word format to GT but use the word format expected by GMT + int bstart = 0; + wordtype word(0); + bstart = wordconcat(word, bstart, 1, 1); + bstart = wordconcat(word, bstart, pt, BITSGTPT); + bstart = wordconcat(word, bstart, phi, BITSGTPHI); + bstart = wordconcat(word, bstart, eta, BITSGTETA); + bstart = wordconcat(word, bstart, z0, BITSSAZ0); + bstart = wordconcat(word, bstart, d0, BITSSAD0); + bstart = wordconcat(word, bstart, charge, 1); + bstart = wordconcat(word, bstart, qual, BITSSAQUAL); + + // Calculate Lorentz Vector + math::PtEtaPhiMLorentzVector p4(pt * LSBpt, eta * LSBeta, phi * LSBphi, 0.0); + SAMuon samuon(p4, charge, pt.to_uint(), eta.to_int(), phi.to_int(), z0.to_int(), d0.to_int(), qual.to_uint()); + samuon.setTF(mu.trackFinderType()); + samuon.setWord(word); + + return samuon; +} // ----- end of function Phase2L1TGMTFwdMuonTranslator::Convertl1tMuon ----- + +l1t::MuonStubRefVector Phase2L1TGMTFwdMuonTranslator::selectLayerBX(const l1t::MuonStubRefVector& all, + int bx, + uint layer) { + l1t::MuonStubRefVector out; + for (const auto& stub : all) { + if (stub->bxNum() == bx && stub->tfLayer() == layer) + out.push_back(stub); + } + return out; +} + +void Phase2L1TGMTFwdMuonTranslator::associateStubs(l1t::SAMuon& mu, const l1t::MuonStubRefVector& stubs) { + for (unsigned int layer = 0; layer <= 4; ++layer) { + l1t::MuonStubRefVector selectedStubs = selectLayerBX(stubs, 0, layer); + int bestStubINT = -1; + float dPhi = 1000.0; + for (uint i = 0; i < selectedStubs.size(); ++i) { + const l1t::MuonStubRef& stub = selectedStubs[i]; + float deltaPhi = + (stub->quality() & 0x1) ? stub->offline_coord1() - mu.p4().phi() : stub->offline_coord2() - mu.p4().phi(); + if (deltaPhi > M_PI) + deltaPhi = deltaPhi - 2 * M_PI; + if (deltaPhi < -M_PI) + deltaPhi = deltaPhi + 2 * M_PI; + deltaPhi = fabs(deltaPhi); + float deltaEta = (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1)) + ? fabs(stub->offline_eta1() - mu.p4().eta()) + : fabs(stub->offline_eta2() - mu.p4().eta()); + if (deltaPhi < 0.3 && deltaEta < 0.3 && deltaPhi < dPhi) { + dPhi = deltaPhi; + bestStubINT = i; + } + } + if (bestStubINT >= 0) { + mu.addStub(selectedStubs[bestStubINT]); + } + } +} + +SAMuon Phase2L1TGMTFwdMuonTranslator::ConvertEMTFTrack(const l1t::phase2::EMTFTrack& track, const int bx_) { + // Convert EMTF Phi and Theta to Global Phi and Eta + float track_phi = emtf::phase2::tp::calc_phi_glob_rad_from_loc( + track.sector(), emtf::phase2::tp::calc_phi_loc_deg_from_int(track.modelPhi())); + float track_theta = emtf::phase2::tp::calc_theta_rad_from_int(track.modelEta()); + float track_eta = -1 * std::log(std::tan(track_theta / 2)); + + track_theta *= track.endcap(); + track_eta *= track.endcap(); + + // Calculate Lorentz Vector + // Muon mass taken from L1Trigger/L1TMuon/plugins/L1TMuonProducer.cc + math::PtEtaPhiMLorentzVector p4(track.emtfPt() * LSBpt, track_eta, track_phi, 0.0); + + // Quantize Values + ap_uint qual = track.emtfModeV2(); // Not sure how this should be handled; using mode for now + int charge = track.emtfQ(); // EMTF uses the same convention + ap_uint pt = track.emtfPt(); // Quantized by EMTF in the same units + ap_int phi = round(track_phi / LSBphi); + ap_int eta = round(track_eta / LSBeta); + ap_int z0 = track.emtfZ0(); // Quantized by EMTF in the same units + ap_int d0 = track.emtfD0(); // Quantized by EMTF in the same units + + //Here do not use the word format to GT but use the word format expected by GMT + int bstart = 0; + wordtype word(0); + bstart = wordconcat(word, bstart, 1, 1); + bstart = wordconcat(word, bstart, pt, BITSPT); + bstart = wordconcat(word, bstart, phi, BITSPHI); + bstart = wordconcat(word, bstart, eta, BITSETA); + bstart = wordconcat(word, bstart, z0, BITSSAZ0); + bstart = wordconcat(word, bstart, d0, BITSSAD0); + bstart = wordconcat(word, bstart, charge, 1); + bstart = wordconcat(word, bstart, qual, BITSSAQUAL); + + SAMuon samuon(p4, charge, pt.to_uint(), eta.to_int(), phi.to_int(), z0.to_int(), d0.to_int(), qual.to_uint()); + + // +1=Positive Endcap and -1=Negative Endcap + if (track.endcap() == 1) + samuon.setTF(tftype::emtf_pos); + else + samuon.setTF(tftype::emtf_neg); + + samuon.setWord(word); + + return samuon; +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void Phase2L1TGMTFwdMuonTranslator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + + // Input Collections + desc.add("stubs", edm::InputTag("gmtStubs")); + desc.add("emtfTracks", edm::InputTag("simEmtfDigisPhase2")); + desc.add("omtfTracks", edm::InputTag("simOmtfPhase2Digis")); + + // Register + descriptions.add("Phase2L1TGMTFwdMuonTranslator", desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(Phase2L1TGMTFwdMuonTranslator); +#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTKMTFProducer.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTKMTFProducer.cc new file mode 100644 index 0000000000000..2eb12259867f5 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTKMTFProducer.cc @@ -0,0 +1,160 @@ +// -*- C++ -*- +// +// Package: L1Trigger/Phase2L1GMT +// Class: Phase2L1TGMTSAMuonProducer +// Original Author: Michalis Bachtis + +#ifndef PHASE2GMT_KMTFPRODUCER +#define PHASE2GMT_KMTFPRODUCER + +// system include files +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include "DataFormats/L1Trigger/interface/Muon.h" +#include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" +#include "DataFormats/L1Trigger/interface/L1MuonParticle.h" + +#include "DataFormats/L1TMuonPhase2/interface/Constants.h" +#include "L1Trigger/Phase2L1GMT/interface/KMTF.h" +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" + +// +// class declaration +// +using namespace Phase2L1GMT; +using namespace l1t; + +class Phase2L1TGMTKMTFProducer : public edm::stream::EDProducer<> { +public: + explicit Phase2L1TGMTKMTFProducer(const edm::ParameterSet&); + ~Phase2L1TGMTKMTFProducer() override = default; + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + + // ----------member data --------------------------- + edm::EDGetTokenT stubToken_; + std::unique_ptr kmtf_; + unsigned int Nprompt; + unsigned int Ndisplaced; +}; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +Phase2L1TGMTKMTFProducer::Phase2L1TGMTKMTFProducer(const edm::ParameterSet& iConfig) + : stubToken_(consumes(iConfig.getParameter("stubs"))), + kmtf_(new KMTF(iConfig.getParameter("verbose"), iConfig.getParameter("algo"))), + Nprompt(iConfig.getParameter("Nprompt")), + Ndisplaced(iConfig.getParameter("Ndisplaced")) { + produces >("prompt").setBranchAlias("prompt"); + produces >("displaced").setBranchAlias("displaced"); + produces >("kmtfTracks"); +} + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void Phase2L1TGMTKMTFProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + edm::Handle stubHandle; + iEvent.getByToken(stubToken_, stubHandle); + + l1t::MuonStubRefVector stubs; + for (uint i = 0; i < stubHandle->size(); ++i) { + l1t::MuonStubRef stub(stubHandle, i); + if (stub->bxNum() == 0) + stubs.push_back(stub); + } + + // KMTF + std::vector prompt; + std::vector displaced; + std::pair, std::vector > kmtfOutput = kmtf_->process(stubs, 0, 32); + std::vector kmtfTracks; + for (const auto& track : kmtfOutput.first) { + kmtfTracks.push_back(track); + l1t::SAMuon p(track.p4(), + (track.curvatureAtVertex() < 0), + track.ptPrompt(), + track.coarseEta(), + track.phiAtMuon() / (1 << 5), + 0, + 0, + track.stubs().size() - 1); + p.setTF(l1t::tftype::bmtf); + int bstart = 0; + wordtype word(0); + bstart = wordconcat(word, bstart, 1, 1); + bstart = wordconcat(word, bstart, p.hwCharge(), 1); + bstart = wordconcat(word, bstart, p.hwPt(), BITSPT); + bstart = wordconcat(word, bstart, p.hwPhi(), BITSPHI); + bstart = wordconcat(word, bstart, p.hwEta(), BITSETA); + bstart = wordconcat(word, bstart, p.hwD0(), BITSSAD0); + bstart = wordconcat(word, bstart, track.rankPrompt(), 8); + + for (const auto& stub : track.stubs()) + p.addStub(stub); + p.setWord(word); + prompt.push_back(p); + } + + for (const auto& track : kmtfOutput.second) { + kmtfTracks.push_back(track); + ap_int<7> dxy = track.dxy() * ap_ufixed<8, 1>(1.606); + l1t::SAMuon p(track.displacedP4(), + (track.curvatureAtMuon() < 0), + track.ptDisplaced(), + track.coarseEta(), + track.phiAtMuon() / (1 << 5), + 0, + dxy, + track.approxDispChi2()); + int bstart = 0; + wordtype word(0); + bstart = wordconcat(word, bstart, 1, 1); + bstart = wordconcat(word, bstart, p.hwCharge(), 1); + bstart = wordconcat(word, bstart, p.hwPt(), BITSPT); + bstart = wordconcat(word, bstart, p.hwPhi(), BITSPHI); + bstart = wordconcat(word, bstart, p.hwEta(), BITSETA); + bstart = wordconcat(word, bstart, p.hwD0(), BITSSAD0); + bstart = wordconcat(word, bstart, track.rankDisp(), 8); + + for (const auto& stub : track.stubs()) { + p.addStub(stub); + } + p.setWord(word); + displaced.push_back(p); + } + std::unique_ptr > prompt_ptr = std::make_unique >(prompt); + std::unique_ptr > displaced_ptr = std::make_unique >(displaced); + std::unique_ptr > kmtf_ptr = std::make_unique >(kmtfTracks); + iEvent.put(std::move(prompt_ptr), "prompt"); + iEvent.put(std::move(displaced_ptr), "displaced"); + iEvent.put(std::move(kmtf_ptr), "kmtfTracks"); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(Phase2L1TGMTKMTFProducer); +#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTSAMuonGhostCleaner.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTSAMuonGhostCleaner.cc new file mode 100644 index 0000000000000..fb215300c8722 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTSAMuonGhostCleaner.cc @@ -0,0 +1,126 @@ +// -*- C++ -*- +#ifndef PHASE2GMT_SAMUONGHOSTCLEANER +#define PHASE2GMT_SAMUONGHOSTCLEANER + +// system include files +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" +#include "DataFormats/L1Trigger/interface/Muon.h" +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" +#include "L1Trigger/Phase2L1GMT/interface/SAMuonCleaner.h" +// +// class declaration +// +using namespace Phase2L1GMT; +using namespace l1t; + +class Phase2L1TGMTSAMuonGhostCleaner : public edm::stream::EDProducer<> { +public: + explicit Phase2L1TGMTSAMuonGhostCleaner(const edm::ParameterSet&); + ~Phase2L1TGMTSAMuonGhostCleaner() override = default; + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + + std::vector prodMuons(std::vector& muons); + + // ----------member data --------------------------- + edm::EDGetTokenT > barrelTokenPrompt_; + edm::EDGetTokenT > barrelTokenDisp_; + edm::EDGetTokenT > fwdTokenPrompt_; + edm::EDGetTokenT > fwdTokenDisp_; + + SAMuonCleaner ghostCleaner; +}; +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +Phase2L1TGMTSAMuonGhostCleaner::Phase2L1TGMTSAMuonGhostCleaner(const edm::ParameterSet& iConfig) + : barrelTokenPrompt_(consumes >(iConfig.getParameter("barrelPrompt"))), + barrelTokenDisp_(consumes >(iConfig.getParameter("barrelDisp"))), + fwdTokenPrompt_(consumes >(iConfig.getParameter("forwardPrompt"))), + fwdTokenDisp_(consumes >(iConfig.getParameter("forwardDisp"))) { + produces >("prompt"); + produces >("displaced"); +} + +// === FUNCTION ============================================================ +// Name: Phase2L1TGMTSAMuonGhostCleaner::prodMuons +// Description: +// =========================================================================== +std::vector Phase2L1TGMTSAMuonGhostCleaner::prodMuons(std::vector& muons) { + std::vector cleanedMuons = ghostCleaner.cleanTFMuons(muons); + //here switch to the offical word required by the GT + std::vector finalMuons; + for (const auto& mu : cleanedMuons) { + l1t::SAMuon m = mu; + if (m.tfType() == l1t::tftype::bmtf) + m.setHwQual(m.hwQual() >> 4); + int bstart = 0; + wordtype word(0); + bstart = wordconcat(word, bstart, 1, 1); + bstart = wordconcat(word, bstart, m.hwPt(), BITSGTPT); + bstart = wordconcat(word, bstart, m.hwPhi(), BITSGTPHI); + bstart = wordconcat(word, bstart, m.hwEta(), BITSGTETA); + bstart = wordconcat(word, bstart, m.hwZ0(), BITSSAZ0); + bstart = wordconcat(word, bstart, m.hwD0(), BITSSAD0); + bstart = wordconcat(word, bstart, m.hwCharge(), 1); + bstart = wordconcat(word, bstart, m.hwQual(), BITSSAQUAL); + m.setWord(word); + finalMuons.push_back(m); + } + return finalMuons; +} // ----- end of function Phase2L1TGMTSAMuonGhostCleaner::prodMuons ----- + +// ------------ method called to produce the data ------------ +void Phase2L1TGMTSAMuonGhostCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + + edm::Handle > barrelPrompt; + iEvent.getByToken(barrelTokenPrompt_, barrelPrompt); + + edm::Handle > barrelDisp; + iEvent.getByToken(barrelTokenDisp_, barrelDisp); + + edm::Handle > forwardPrompt; + iEvent.getByToken(fwdTokenPrompt_, forwardPrompt); + + edm::Handle > forwardDisp; + iEvent.getByToken(fwdTokenDisp_, forwardDisp); + + // Prompt muons + std::vector muons = *barrelPrompt.product(); + muons.insert(muons.end(), forwardPrompt->begin(), forwardPrompt->end()); + std::vector finalPrompt = prodMuons(muons); + + // Displace muons + muons.clear(); + muons = *barrelDisp.product(); + muons.insert(muons.end(), forwardDisp->begin(), forwardDisp->end()); + std::vector finalDisp = prodMuons(muons); + + std::unique_ptr > prompt_ptr = std::make_unique >(finalPrompt); + std::unique_ptr > disp_ptr = std::make_unique >(finalDisp); + iEvent.put(std::move(prompt_ptr), "prompt"); + iEvent.put(std::move(disp_ptr), "displaced"); +} + +DEFINE_FWK_MODULE(Phase2L1TGMTSAMuonGhostCleaner); + +#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTSAMuonProducer.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTSAMuonProducer.cc deleted file mode 100644 index c6284873729c5..0000000000000 --- a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTSAMuonProducer.cc +++ /dev/null @@ -1,179 +0,0 @@ -// -*- C++ -*- -// -// Package: L1Trigger/Phase2L1GMT -// Class: Phase2L1TGMTSAMuonProducer -// -/**\class Phase2L1TGMTSAMuonProducer Phase2L1TGMTSAMuonProducer.cc L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTSAMuonProducer.cc - - Description: [one line class summary] - - Implementation: - [Notes on implementation] -*/ -// -// Original Author: Zhenbin Wu -// Created: Fri, 30 Apr 2021 19:10:59 GMT -// -// - -#ifndef PHASE2GMT_SAMUONPRODUCER -#define PHASE2GMT_SAMUONPRODUCER - -// system include files -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/StreamID.h" - -#include "DataFormats/L1Trigger/interface/Muon.h" -#include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" -#include "DataFormats/L1Trigger/interface/L1MuonParticle.h" - -#include "DataFormats/L1TMuonPhase2/interface/Constants.h" -#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" -// -// class declaration -// -using namespace Phase2L1GMT; -using namespace l1t; - -class Phase2L1TGMTSAMuonProducer : public edm::stream::EDProducer<> { -public: - explicit Phase2L1TGMTSAMuonProducer(const edm::ParameterSet&); - ~Phase2L1TGMTSAMuonProducer() override = default; - - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - void beginStream(edm::StreamID) override; - void produce(edm::Event&, const edm::EventSetup&) override; - void endStream() override; - - l1t::SAMuon Convertl1tMuon(const l1t::Muon& mu, const int bx_); - - // ----------member data --------------------------- - edm::EDGetTokenT > muonToken_; - unsigned int Nprompt; - unsigned int Ndisplaced; -}; - -Phase2L1TGMTSAMuonProducer::Phase2L1TGMTSAMuonProducer(const edm::ParameterSet& iConfig) - : muonToken_(consumes(iConfig.getParameter("muonToken"))), - Nprompt(iConfig.getParameter("Nprompt")), - Ndisplaced(iConfig.getParameter("Ndisplaced")) { - produces >("promptSAMuons").setBranchAlias("prompt"); - produces >("displacedSAMuons").setBranchAlias("displaced"); -} - -// -// member functions -// - -// ------------ method called to produce the data ------------ -void Phase2L1TGMTSAMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; - edm::Handle muon; - iEvent.getByToken(muonToken_, muon); - - // Output - std::vector prompt; - std::vector displaced; - - for (int bx = muon->getFirstBX(); bx <= muon->getLastBX(); ++bx) { - //TODO: We are expecting to send all BX. Using bx0 for now - if (bx != 0) { - continue; - } - - for (uint i = 0; i < muon->size(bx); ++i) { - const l1t::Muon& mu = muon->at(bx, i); - - //TODO: Still looking for a way to get displaced muon - if (abs(mu.hwDXY()) > 0) - displaced.push_back(Convertl1tMuon(mu, bx)); - else - prompt.push_back(Convertl1tMuon(mu, bx)); - } - - // Sort by hwPt - std::sort(prompt.begin(), prompt.end(), std::greater<>()); - std::sort(displaced.begin(), displaced.end(), std::greater<>()); - - // Store into output, allow up to 18 prompt + 18 displayed - if (prompt.size() > Nprompt) { - prompt.resize(Nprompt); - } - if (displaced.size() > Ndisplaced) { - displaced.resize(Ndisplaced); - } - } - - std::unique_ptr > prompt_ptr = std::make_unique >(prompt); - std::unique_ptr > displaced_ptr = std::make_unique >(displaced); - iEvent.put(std::move(prompt_ptr), "promptSAMuons"); - iEvent.put(std::move(displaced_ptr), "displacedSAMuons"); -} - -// === FUNCTION ============================================================ -// Name: Phase2L1TGMTSAMuonProducer::Convertl1tMuon -// Description: -// =========================================================================== -SAMuon Phase2L1TGMTSAMuonProducer::Convertl1tMuon(const l1t::Muon& mu, const int bx_) { - qual_sa_t qual = mu.hwQual(); - int charge = mu.charge() > 0 ? 0 : 1; - - pt_sa_t pt = round(mu.pt() / LSBpt); - phi_sa_t phi = round(mu.phi() / LSBphi); - eta_sa_t eta = round(mu.eta() / LSBeta); - // FIXME: Below are not well defined in phase1 GMT - // Using the version from Correlator for now - z0_sa_t z0 = 0; // No tracks info in Phase 1 - // Use 2 bits with LSB = 30cm for BMTF and 25cm for EMTF currently, but subjet to change - d0_sa_t d0 = mu.hwDXY(); - - int bstart = 0; - wordtype word(0); - bstart = wordconcat(word, bstart, pt > 0, 1); - bstart = wordconcat(word, bstart, pt, BITSGTPT); - bstart = wordconcat(word, bstart, phi, BITSGTPHI); - bstart = wordconcat(word, bstart, eta, BITSGTETA); - bstart = wordconcat(word, bstart, z0, BITSSAZ0); - bstart = wordconcat(word, bstart, d0, BITSSAD0); - bstart = wordconcat(word, bstart, charge, 1); - bstart = wordconcat(word, bstart, qual, BITSSAQUAL); - - SAMuon samuon(mu, charge, pt.to_uint(), eta.to_int(), phi.to_int(), z0.to_int(), d0.to_int(), qual.to_uint()); - samuon.setWord(word); - return samuon; -} // ----- end of function Phase2L1TGMTSAMuonProducer::Convertl1tMuon ----- - -// ------------ method called once each stream before processing any runs, lumis or events ------------ -void Phase2L1TGMTSAMuonProducer::beginStream(edm::StreamID) { - // please remove this method if not needed -} - -// ------------ method called once each stream after processing all runs, lumis and events ------------ -void Phase2L1TGMTSAMuonProducer::endStream() { - // please remove this method if not needed -} - -// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ -void Phase2L1TGMTSAMuonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("muonToken", edm::InputTag("simGmtStage2Digis")); - desc.add("Nprompt", 12); - desc.add("Ndisplaced", 12); - descriptions.add("standaloneMuons", desc); -} - -//define this as a plug-in -DEFINE_FWK_MODULE(Phase2L1TGMTSAMuonProducer); -#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTStubProducer.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTStubProducer.cc index 44d0d8d84f9c1..6b1c78c4a158e 100644 --- a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTStubProducer.cc +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTStubProducer.cc @@ -30,7 +30,7 @@ class Phase2L1TGMTStubProducer : public edm::stream::EDProducer<> { void beginStream(edm::StreamID) override; void produce(edm::Event&, const edm::EventSetup&) override; void endStream() override; - + l1t::MuonStub convertToHybrid(const l1t::MuonStub& stub); edm::EDGetTokenT> srcCSC_; edm::EDGetTokenT srcDT_; edm::EDGetTokenT srcDTTheta_; @@ -51,7 +51,8 @@ Phase2L1TGMTStubProducer::Phase2L1TGMTStubProducer(const edm::ParameterSet& iCon procEndcap_(new L1TPhase2GMTEndcapStubProcessor(iConfig.getParameter("Endcap"))), procBarrel_(new L1TPhase2GMTBarrelStubProcessor(iConfig.getParameter("Barrel"))), verbose_(iConfig.getParameter("verbose")) { - produces(); + produces("kmtf"); + produces("tps"); edm::ConsumesCollector consumesColl(consumesCollector()); translator_ = new L1TMuon::GeometryTranslator(consumesColl); } @@ -71,6 +72,24 @@ Phase2L1TGMTStubProducer::~Phase2L1TGMTStubProducer() { // member functions // +l1t::MuonStub Phase2L1TGMTStubProducer::convertToHybrid(const l1t::MuonStub& stub) { + l1t::MuonStub hybrid(stub.etaRegion(), + stub.phiRegion(), + stub.depthRegion(), + stub.tfLayer(), + stub.coord1() / 256, //for track matching was 1024 + stub.coord2() / 256, //for track matching was 1024 + stub.id(), + stub.bxNum(), + 0x3, //for track matching + stub.eta1(), + stub.eta2(), + stub.etaQuality(), + stub.type()); + hybrid.setOfflineQuantities(stub.offline_coord1(), stub.offline_coord2(), stub.offline_eta1(), stub.offline_eta2()); + return hybrid; +} + // ------------ method called to produce the data ------------ void Phase2L1TGMTStubProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; @@ -90,6 +109,7 @@ void Phase2L1TGMTStubProducer::produce(edm::Event& iEvent, const edm::EventSetup //Generate a unique stub ID l1t::MuonStubCollection stubs; + l1t::MuonStubCollection stubsKMTF; uint count0 = 0; uint count1 = 0; @@ -99,46 +119,17 @@ void Phase2L1TGMTStubProducer::produce(edm::Event& iEvent, const edm::EventSetup l1t::MuonStubCollection stubsEndcap = procEndcap_->makeStubs(*cscDigis, *rpcDigis, translator_, iSetup); for (auto& stub : stubsEndcap) { - if (stub.tfLayer() == 0) { - stub.setID(count0); - count0++; - } else if (stub.tfLayer() == 1) { - stub.setID(count1); - count1++; - } else if (stub.tfLayer() == 2) { - stub.setID(count2); - count2++; - } else if (stub.tfLayer() == 3) { - stub.setID(count3); - count3++; - } else { - stub.setID(count4); - count4++; - } stubs.push_back(stub); } l1t::MuonStubCollection stubsBarrel = procBarrel_->makeStubs(dtDigis.product(), dtThetaDigis.product()); for (auto& stub : stubsBarrel) { - if (stub.tfLayer() == 0) { - stub.setID(count0); - count0++; - } else if (stub.tfLayer() == 1) { - stub.setID(count1); - count1++; - } else if (stub.tfLayer() == 2) { - stub.setID(count2); - count2++; - } else if (stub.tfLayer() == 3) { - stub.setID(count3); - count3++; - } else { - stub.setID(count4); - count4++; - } - stubs.push_back(stub); + //convert to Hybrid + stubs.push_back(convertToHybrid(stub)); + stubsKMTF.push_back(stub); } - iEvent.put(std::make_unique(stubs)); + iEvent.put(std::make_unique(stubs), "tps"); + iEvent.put(std::make_unique(stubsKMTF), "kmtf"); } // ------------ method called once each stream before processing any runs, lumis or events ------------ diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTProducer.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTTkMuonProducer.cc similarity index 51% rename from L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTProducer.cc rename to L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTTkMuonProducer.cc index 5595b20e9c0b1..36957153d86b4 100644 --- a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTProducer.cc +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTTkMuonProducer.cc @@ -8,7 +8,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" -#include "Node.h" +#include "L1Trigger/Phase2L1GMT/interface/TPS.h" // // class declaration @@ -16,10 +16,10 @@ using namespace Phase2L1GMT; using namespace l1t; -class Phase2L1TGMTProducer : public edm::stream::EDProducer<> { +class Phase2L1TGMTTkMuonProducer : public edm::stream::EDProducer<> { public: - explicit Phase2L1TGMTProducer(const edm::ParameterSet&); - ~Phase2L1TGMTProducer() override; + explicit Phase2L1TGMTTkMuonProducer(const edm::ParameterSet&); + ~Phase2L1TGMTTkMuonProducer() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); @@ -27,24 +27,18 @@ class Phase2L1TGMTProducer : public edm::stream::EDProducer<> { void beginStream(edm::StreamID) override; void produce(edm::Event&, const edm::EventSetup&) override; void endStream() override; - std::unique_ptr node_; + std::unique_ptr tps_; edm::EDGetTokenT srcTracks_; edm::EDGetTokenT > srcStubs_; - edm::EDGetTokenT > bmtfTracks_; - edm::EDGetTokenT > emtfTracks_; - edm::EDGetTokenT > omtfTracks_; int minTrackStubs_; int bxMin_; int bxMax_; }; -Phase2L1TGMTProducer::Phase2L1TGMTProducer(const edm::ParameterSet& iConfig) - : node_(new Node(iConfig)), +Phase2L1TGMTTkMuonProducer::Phase2L1TGMTTkMuonProducer(const edm::ParameterSet& iConfig) + : tps_(new TPS(iConfig)), srcTracks_(consumes(iConfig.getParameter("srcTracks"))), srcStubs_(consumes >(iConfig.getParameter("srcStubs"))), - bmtfTracks_(consumes >(iConfig.getParameter("srcBMTF"))), - emtfTracks_(consumes >(iConfig.getParameter("srcEMTF"))), - omtfTracks_(consumes >(iConfig.getParameter("srcOMTF"))), minTrackStubs_(iConfig.getParameter("minTrackStubs")), bxMin_(iConfig.getParameter("muonBXMin")), bxMax_(iConfig.getParameter("muonBXMax")) @@ -53,7 +47,7 @@ Phase2L1TGMTProducer::Phase2L1TGMTProducer(const edm::ParameterSet& iConfig) produces >(); } -Phase2L1TGMTProducer::~Phase2L1TGMTProducer() { +Phase2L1TGMTTkMuonProducer::~Phase2L1TGMTTkMuonProducer() { // do anything here that needs to be done at destruction time // (e.g. close files, deallocate resources etc.) } @@ -63,7 +57,7 @@ Phase2L1TGMTProducer::~Phase2L1TGMTProducer() { // // ------------ method called to produce the data ------------ -void Phase2L1TGMTProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void Phase2L1TGMTTkMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; Handle trackHandle; iEvent.getByToken(srcTracks_, trackHandle); @@ -76,55 +70,26 @@ void Phase2L1TGMTProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS tracks.push_back(track); } + l1t::MuonStubRefVector muonStubs; Handle > stubHandle; iEvent.getByToken(srcStubs_, stubHandle); - l1t::MuonStubRefVector stubs; - for (uint i = 0; i < stubHandle->size(); ++i) { - l1t::MuonStubRef stub(stubHandle, i); - if (stub->bxNum() >= bxMin_ && stub->bxNum() <= bxMax_) - stubs.push_back(stub); + for (size_t i = 0; i < stubHandle->size(); ++i) { + MuonStubRef stub(stubHandle, i); + muonStubs.push_back(stub); } - ObjectRefBxCollection muonTracks; - // BXVector muonTracks; - - Handle > bmtfHandle; - iEvent.getByToken(bmtfTracks_, bmtfHandle); - Handle > emtfHandle; - iEvent.getByToken(emtfTracks_, emtfHandle); - Handle > omtfHandle; - iEvent.getByToken(omtfTracks_, omtfHandle); - - for (int bx = bxMin_; bx <= bxMax_; ++bx) { - if (bx >= bmtfHandle->getFirstBX() && bx <= bmtfHandle->getLastBX()) - for (size_t i = 0; i < bmtfHandle->size(bx); ++i) { - RegionalMuonCandRef muon(bmtfHandle, i); - muonTracks.push_back(bx, muon); - } - if (bx >= omtfHandle->getFirstBX() && bx <= omtfHandle->getLastBX()) - for (size_t i = 0; i < omtfHandle->size(bx); ++i) { - RegionalMuonCandRef muon(omtfHandle, i); - muonTracks.push_back(bx, muon); - } - if (bx >= emtfHandle->getFirstBX() && bx <= emtfHandle->getLastBX()) - for (size_t i = 0; i < emtfHandle->size(bx); ++i) { - RegionalMuonCandRef muon(emtfHandle, i); - muonTracks.push_back(bx, muon); - } - } - - std::vector out = node_->processEvent(tracks, muonTracks, stubs); + std::vector out = tps_->processEvent(tracks, muonStubs); std::unique_ptr > out1 = std::make_unique >(out); iEvent.put(std::move(out1)); } // ------------ method called once each stream before processing any runs, lumis or events ------------ -void Phase2L1TGMTProducer::beginStream(edm::StreamID) {} +void Phase2L1TGMTTkMuonProducer::beginStream(edm::StreamID) {} // ------------ method called once each stream after processing all runs, lumis and events ------------ -void Phase2L1TGMTProducer::endStream() {} +void Phase2L1TGMTTkMuonProducer::endStream() {} -void Phase2L1TGMTProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void Phase2L1TGMTTkMuonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { //The following says we do not know what parameters are allowed so do no validation // Please change this to state exactly what you do use, even if it is no parameters edm::ParameterSetDescription desc; @@ -133,4 +98,4 @@ void Phase2L1TGMTProducer::fillDescriptions(edm::ConfigurationDescriptions& desc } //define this as a plug-in -DEFINE_FWK_MODULE(Phase2L1TGMTProducer); +DEFINE_FWK_MODULE(Phase2L1TGMTTkMuonProducer); diff --git a/L1Trigger/Phase2L1GMT/plugins/ROITempAssociator.h b/L1Trigger/Phase2L1GMT/plugins/ROITempAssociator.h deleted file mode 100644 index 633064697db20..0000000000000 --- a/L1Trigger/Phase2L1GMT/plugins/ROITempAssociator.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef PHASE2GMT_TEMPORARY_ASSOCIATOR -#define PHASE2GMT_TEMPORARY_ASSOCIATOR - -#include "ap_int.h" -#include "MuonROI.h" -#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -namespace Phase2L1GMT { - - class ROITempAssociator { - public: - ROITempAssociator(const edm::ParameterSet& iConfig) {} - ~ROITempAssociator() {} - - std::vector associate(int bx, - const l1t::ObjectRefBxCollection& muons, - const l1t::MuonStubRefVector& stubs) { - std::vector out; - l1t::MuonStubRefVector usedStubs; - - if (muons.size() > 0) { - for (unsigned int i = 0; i < muons.size(bx); ++i) { - const l1t::RegionalMuonCandRef& mu = muons.at(bx, i); - uint pt = mu->hwPt(); - uint charge = mu->hwSign(); - - float eta = mu->hwEta() * 0.010875; - - int globalPhi = 0; - if (mu->trackFinderType() == l1t::bmtf) { - globalPhi = mu->processor() * 48 + mu->hwPhi() - 24; - } else { - globalPhi = mu->processor() * 96 + mu->hwPhi() + 24; - } - - float phi = globalPhi * 2 * M_PI / 576.0; - if (phi > (M_PI)) - phi = phi - 2 * M_PI; - else if (phi < (-M_PI)) - phi = phi + 2 * M_PI; - - MuonROI roi(bx, charge, pt, 1); - roi.setMuonRef(mu); - l1t::MuonStubRefVector cleanedStubs = clean(stubs, usedStubs); - - for (unsigned int layer = 0; layer <= 4; ++layer) { - l1t::MuonStubRefVector selectedStubs = selectLayerBX(cleanedStubs, bx, layer); - int bestStubINT = -1; - float dPhi = 1000.0; - - for (uint i = 0; i < selectedStubs.size(); ++i) { - const l1t::MuonStubRef& stub = selectedStubs[i]; - float deltaPhi = (stub->quality() & 0x1) ? stub->offline_coord1() - phi : stub->offline_coord2() - phi; - if (deltaPhi > M_PI) - deltaPhi = deltaPhi - 2 * M_PI; - else if (deltaPhi < -M_PI) - deltaPhi = deltaPhi + 2 * M_PI; - deltaPhi = fabs(deltaPhi); - float deltaEta = (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1)) - ? fabs(stub->offline_eta1() - eta) - : fabs(stub->offline_eta2() - eta); - if (deltaPhi < (M_PI / 6.0) && deltaEta < 0.3 && deltaPhi < dPhi) { - dPhi = deltaPhi; - bestStubINT = i; - } - } - if (bestStubINT >= 0) { - roi.addStub(selectedStubs[bestStubINT]); - usedStubs.push_back(selectedStubs[bestStubINT]); - } - } - if (out.size() < 16 && !roi.stubs().empty()) - out.push_back(roi); - } - } - //Now the stubs only . Find per layer - - l1t::MuonStubRefVector cleanedStubs = clean(stubs, usedStubs); - - while (!cleanedStubs.empty()) { - MuonROI roi(bx, 0, 0, 0); - roi.addStub(cleanedStubs[0]); - usedStubs.push_back(cleanedStubs[0]); - for (unsigned int layer = 0; layer <= 4; ++layer) { - if (layer == cleanedStubs[0]->tfLayer()) - continue; - l1t::MuonStubRefVector selectedStubs = selectLayerBX(cleanedStubs, bx, layer); - if (!selectedStubs.empty()) { - roi.addStub(selectedStubs[0]); - usedStubs.push_back(selectedStubs[0]); - } - } - if (!roi.stubs().empty()) - if (out.size() < 16) - out.push_back(roi); - cleanedStubs = clean(cleanedStubs, usedStubs); - } - return out; - } - - private: - l1t::MuonStubRefVector selectLayerBX(const l1t::MuonStubRefVector& all, int bx, uint layer) { - l1t::MuonStubRefVector out; - for (const auto& stub : all) { - if (stub->bxNum() == bx && stub->tfLayer() == layer) - out.push_back(stub); - } - return out; - } - - l1t::MuonStubRefVector clean(const l1t::MuonStubRefVector& all, const l1t::MuonStubRefVector& used) { - l1t::MuonStubRefVector out; - for (const auto& stub : all) { - bool keep = true; - for (const auto& st : used) { - if (st == stub) { - keep = false; - break; - } - } - if (keep) - out.push_back(stub); - } - return out; - } - }; -} // namespace Phase2L1GMT - -#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/TrackConverter.h b/L1Trigger/Phase2L1GMT/plugins/TrackConverter.h deleted file mode 100644 index d175f34da179c..0000000000000 --- a/L1Trigger/Phase2L1GMT/plugins/TrackConverter.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef PHASE2GMT_TRACKCONVERTER -#define PHASE2GMT_TRACKCONVERTER - -#include "ConvertedTTTrack.h" -#include "Constants.h" -#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -namespace Phase2L1GMT { - - class TrackConverter { - public: - TrackConverter(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter("verbose")) {} - ~TrackConverter() {} - - std::vector convertTracks(const std::vector >& tracks) { - std::vector out; - out.reserve(tracks.size()); - for (const auto& t : tracks) - out.push_back(convert(t)); - return out; - } - - private: - int verbose_; - typedef ap_uint<96> wordtype; - - uint generateQuality(const edm::Ptr >& track) { return 1; } - - uint ptLookup(uint absCurv) { - for (auto i : ptShifts) { - if (absCurv >= uint(i[0]) && absCurv < uint(i[1])) { - if (i[2] < 0) - return i[4]; - else - return (absCurv >> i[2]) + i[3]; - } - } - return 0; - } - - uint etaLookup(uint absTanL) { - for (auto i : etaShifts) { - if (absTanL >= uint(i[0]) && absTanL < uint(i[1])) { - if (i[2] < 0) - return i[4]; - else - return (absTanL >> i[2]) + i[3]; - } - } - return 0; - } - - ConvertedTTTrack convert(const edm::Ptr >& track) { - uint charge = (track->rInv() < 0) ? 1 : 0; - int curvature = track->rInv() * (1 << (BITSTTCURV - 1)) / maxCurv_; - int phi = track->phi() * (1 << (BITSPHI - 1)) / (M_PI); - int tanLambda = track->tanL() * (1 << (BITSTTTANL - 1)) / maxTanl_; - int z0 = track->z0() * (1 << (BITSZ0 - 1)) / maxZ0_; - int d0 = track->d0() * (1 << (BITSD0 - 1)) / maxD0_; - //calculate pt - uint absCurv = curvature > 0 ? (curvature) : (-curvature); - uint pt = ptLUT[ptLookup(absCurv)]; - uint quality = generateQuality(track); - uint absTanL = tanLambda > 0 ? (tanLambda) : (-tanLambda); - uint absEta = etaLUT[etaLookup(absTanL)]; - int eta = tanLambda > 0 ? (absEta) : (-absEta); - - ap_int phiSec = ap_int(phi) - - ap_int((track->phiSector() * 40 * M_PI / 180.) * (1 << (BITSPHI - 1)) / (M_PI)); - ap_int phiCorrected = ap_int(phiSec + track->phiSector() * 910); - - wordtype word = 0; - int bstart = 0; - bstart = wordconcat(word, bstart, curvature, BITSTTCURV); - bstart = wordconcat(word, bstart, phiSec, BITSTTPHI); - bstart = wordconcat(word, bstart, tanLambda, BITSTTTANL); - bstart = wordconcat(word, bstart, z0, BITSZ0); - bstart = wordconcat(word, bstart, d0, BITSD0); - bstart = wordconcat(word, bstart, uint(track->chi2()), 4); - - ConvertedTTTrack convertedTrack(charge, curvature, absEta, pt, eta, phiCorrected.to_int(), z0, d0, quality, word); - convertedTrack.setOfflineQuantities(track->momentum().transverse(), track->eta(), track->phi()); - if (verbose_) - convertedTrack.print(); - convertedTrack.setTrkPtr(track); - return convertedTrack; - } - }; -} // namespace Phase2L1GMT - -#endif diff --git a/L1Trigger/Phase2L1GMT/plugins/TrackMuonMatchAlgorithm.h b/L1Trigger/Phase2L1GMT/plugins/TrackMuonMatchAlgorithm.h deleted file mode 100644 index 30f3ad6d8a3f5..0000000000000 --- a/L1Trigger/Phase2L1GMT/plugins/TrackMuonMatchAlgorithm.h +++ /dev/null @@ -1,626 +0,0 @@ -#ifndef PHASE2GMT_TRACKMUONMATCHALGO -#define PHASE2GMT_TRACKMUONMATCHALGO - -#include "DataFormats/L1TrackTrigger/interface/TTTrack.h" -#include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h" -#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" -#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" -#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" -#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" -#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h" -#include "DataFormats/L1Trigger/interface/L1TObjComparison.h" -#include "TrackConverter.h" -#include "PreTrackMatchedMuon.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "MuonROI.h" -#include "ConvertedTTTrack.h" -#include "Constants.h" -#include - -namespace Phase2L1GMT { - - const unsigned int PHIDIVIDER = 1 << (BITSPHI - BITSSTUBCOORD); - const unsigned int ETADIVIDER = 1 << (BITSETA - BITSSTUBETA); - - typedef struct { - ap_int coord1; - ap_uint sigma_coord1; - ap_int coord2; - ap_uint sigma_coord2; - ap_int eta; - ap_uint sigma_eta1; - ap_uint sigma_eta2; - ap_uint<1> valid; - ap_uint<1> is_barrel; - } propagation_t; - - typedef struct { - ap_uint quality; - ap_uint id; - ap_uint<1> valid; - bool isGlobal; - l1t::RegionalMuonCandRef muRef; - l1t::MuonStubRef stubRef; - - } match_t; - - class TrackMuonMatchAlgorithm { - public: - TrackMuonMatchAlgorithm(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter("verbose")) {} - - ~TrackMuonMatchAlgorithm() {} - - std::vector processNonant(const std::vector& convertedTracks, - const std::vector& rois) { - std::vector preMuons; - for (const auto& track : convertedTracks) { - PreTrackMatchedMuon mu = processTrack(track, rois); - if (mu.valid() && preMuons.size() < 16) - preMuons.push_back(mu); - } - std::vector cleanedMuons = clean(preMuons); - return cleanedMuons; - } - - std::vector cleanNeighbor(const std::vector& muons, - const std::vector& muonsPrevious, - const std::vector& muonsNext, - bool equality) { - std::vector out; - - if (muons.empty()) - return out; - - if (verbose_ == 1) { - printf("-----Cleaning Up Muons in the neighbours\n"); - printf("Before:\n"); - } - - for (uint i = 0; i < muons.size(); ++i) { - if (verbose_ == 1) { - muons[i].print(); - } - ap_uint<5> mask = 0x1f; - for (uint j = 0; j < muonsPrevious.size(); ++j) { - mask = mask & cleanMuon(muons[i], muonsPrevious[j], equality); - } - for (uint j = 0; j < muonsNext.size(); ++j) { - mask = mask & cleanMuon(muons[i], muonsNext[j], equality); - } - if (mask) { - if (verbose_ == 1) - printf("kept\n"); - out.push_back(muons[i]); - } else { - if (verbose_ == 1) - printf("discarded\n"); - } - } - return out; - } - - std::vector convert(std::vector& muons, uint maximum) { - std::vector out; - for (const auto& mu : muons) { - if (out.size() == maximum) - break; - l1t::TrackerMuon muon(mu.trkPtr(), mu.charge(), mu.pt(), mu.eta(), mu.phi(), mu.z0(), mu.d0(), mu.quality()); - muon.setMuonRef(mu.muonRef()); - for (const auto& stub : mu.stubs()) - muon.addStub(stub); - out.push_back(muon); - if (verbose_ == 1) { - printf("Final Muon:"); - muon.print(); - } - } - return out; - } - - bool outputGT(std::vector& muons) { - for (auto& mu : muons) { - wordtype word1 = 0; - wordtype word2 = 0; - - int bstart = 0; - bstart = wordconcat(word1, bstart, mu.hwPt(), BITSGTPT); - bstart = wordconcat(word1, bstart, mu.hwPhi(), BITSGTPHI); - bstart = wordconcat(word1, bstart, mu.hwEta(), BITSGTETA); - bstart = wordconcat(word1, bstart, mu.hwZ0(), BITSGTZ0); - bstart = wordconcat(word1, bstart, (mu.hwD0() >> 2), BITSGTD0); - - bstart = 0; - bstart = wordconcat(word2, bstart, mu.hwCharge(), 1); - bstart = wordconcat(word2, bstart, mu.hwQual(), BITSGTQUAL); - bstart = wordconcat(word2, bstart, mu.hwIso(), BITSGTISO); - bstart = wordconcat(word2, bstart, mu.hwBeta(), BITSGTBETA); - - std::array wordout = {{word1, word2}}; - mu.setWord(wordout); - } - return true; - } - - std::vector sort(std::vector& muons, uint maximum) { - if (muons.size() < 2) - return muons; - - std::sort(muons.begin(), muons.end(), [](l1t::TrackerMuon a, l1t::TrackerMuon b) { return a.hwPt() > b.hwPt(); }); - std::vector out; - for (unsigned int i = 0; i < muons.size(); ++i) { - out.push_back(muons[i]); - if (i == (maximum - 1)) - break; - } - - return out; - } - - private: - int verbose_; - - propagation_t propagate(const ConvertedTTTrack& track, uint layer) { - ap_uint prop_coord1 = 0; - ap_uint prop_coord2 = 0; - ap_uint res0_coord1 = 0; - ap_uint res1_coord1 = 0; - ap_uint res0_coord2 = 0; - ap_uint res1_coord2 = 0; - ap_uint res0_eta1 = 0; - ap_uint res1_eta = 0; - ap_uint res0_eta2 = 0; - ap_uint<1> is_barrel = 0; - - uint reducedAbsEta = track.abseta() / 8; - - if (layer == 0) { - prop_coord1 = lt_prop_coord1_0[reducedAbsEta]; - prop_coord2 = lt_prop_coord2_0[reducedAbsEta]; - res0_coord1 = lt_res0_coord1_0[reducedAbsEta]; - res1_coord1 = lt_res1_coord1_0[reducedAbsEta]; - res0_coord2 = lt_res0_coord2_0[reducedAbsEta]; - res1_coord2 = lt_res1_coord2_0[reducedAbsEta]; - res0_eta1 = lt_res0_eta1_0[reducedAbsEta]; - res1_eta = lt_res1_eta_0[reducedAbsEta]; - res0_eta2 = lt_res0_eta2_0[reducedAbsEta]; - is_barrel = reducedAbsEta < barrelLimit0_ ? 1 : 0; - } else if (layer == 1) { - prop_coord1 = lt_prop_coord1_1[reducedAbsEta]; - prop_coord2 = lt_prop_coord2_1[reducedAbsEta]; - res0_coord1 = lt_res0_coord1_1[reducedAbsEta]; - res1_coord1 = lt_res1_coord1_1[reducedAbsEta]; - res0_coord2 = lt_res0_coord2_1[reducedAbsEta]; - res1_coord2 = lt_res1_coord2_1[reducedAbsEta]; - res0_eta1 = lt_res0_eta1_1[reducedAbsEta]; - res1_eta = lt_res1_eta_1[reducedAbsEta]; - res0_eta2 = lt_res0_eta2_1[reducedAbsEta]; - is_barrel = reducedAbsEta < barrelLimit1_ ? 1 : 0; - - } else if (layer == 2) { - prop_coord1 = lt_prop_coord1_2[reducedAbsEta]; - prop_coord2 = lt_prop_coord2_2[reducedAbsEta]; - res0_coord1 = lt_res0_coord1_2[reducedAbsEta]; - res1_coord1 = lt_res1_coord1_2[reducedAbsEta]; - res0_coord2 = lt_res0_coord2_2[reducedAbsEta]; - res1_coord2 = lt_res1_coord2_2[reducedAbsEta]; - res0_eta1 = lt_res0_eta1_2[reducedAbsEta]; - res1_eta = lt_res1_eta_2[reducedAbsEta]; - res0_eta2 = lt_res0_eta2_2[reducedAbsEta]; - is_barrel = reducedAbsEta < barrelLimit2_ ? 1 : 0; - - } else if (layer == 3) { - prop_coord1 = lt_prop_coord1_3[reducedAbsEta]; - prop_coord2 = lt_prop_coord2_3[reducedAbsEta]; - res0_coord1 = lt_res0_coord1_3[reducedAbsEta]; - res1_coord1 = lt_res1_coord1_3[reducedAbsEta]; - res0_coord2 = lt_res0_coord2_3[reducedAbsEta]; - res1_coord2 = lt_res1_coord2_3[reducedAbsEta]; - res0_eta1 = lt_res0_eta1_3[reducedAbsEta]; - res1_eta = lt_res1_eta_3[reducedAbsEta]; - res0_eta2 = lt_res0_eta2_3[reducedAbsEta]; - is_barrel = reducedAbsEta < barrelLimit3_ ? 1 : 0; - - } else if (layer == 4) { - prop_coord1 = lt_prop_coord1_4[reducedAbsEta]; - prop_coord2 = lt_prop_coord2_4[reducedAbsEta]; - res0_coord1 = lt_res0_coord1_4[reducedAbsEta]; - res1_coord1 = lt_res1_coord1_4[reducedAbsEta]; - res0_coord2 = lt_res0_coord2_4[reducedAbsEta]; - res1_coord2 = lt_res1_coord2_4[reducedAbsEta]; - res0_eta1 = lt_res0_eta1_4[reducedAbsEta]; - res1_eta = lt_res1_eta_4[reducedAbsEta]; - res0_eta2 = lt_res0_eta2_4[reducedAbsEta]; - is_barrel = 0; - } - - propagation_t out; - ap_int curvature = track.curvature(); - ap_int phi = track.phi(); - ap_int c1kFull = prop_coord1 * curvature; - ap_int c1k = (c1kFull) / 1024; - ap_int coord1 = phi - c1k; - - out.coord1 = coord1 / PHIDIVIDER; - - ap_int c2kFull = prop_coord2 * curvature; - - ap_int c2k = (c2kFull) / 1024; - if (is_barrel) - out.coord2 = -c2k / PHIDIVIDER; - else - out.coord2 = (phi - c2k) / PHIDIVIDER; - - ap_int eta = track.eta(); - out.eta = eta / ETADIVIDER; - - ap_uint<2 * BITSTTCURV - 2> curvature2All = curvature * curvature; - ap_uint curvature2 = curvature2All / 2; - - //Remember to change emulator with new k2 - ap_uint rescoord1k = (res1_coord1 * curvature2) >> 23; - ap_ufixed sigma_coord1 = res0_coord1 + rescoord1k; - out.sigma_coord1 = ap_uint(sigma_coord1); - - ap_uint rescoord2k = (res1_coord2 * curvature2) >> 23; - ap_ufixed sigma_coord2 = res0_coord2 + rescoord2k; - out.sigma_coord2 = ap_uint(sigma_coord2); - - ap_uint resetak = (res1_eta * curvature2) >> 23; - ap_ufixed sigma_eta1 = res0_eta1 + resetak; - out.sigma_eta1 = ap_uint(sigma_eta1); - ap_ufixed sigma_eta2 = res0_eta2 + resetak; - out.sigma_eta2 = ap_uint(sigma_eta2); - out.valid = 1; - out.is_barrel = is_barrel; - - if (verbose_ == 1) - - printf("Propagating to layer %d:is barrel=%d coords=%d+-%d , %d +-%d etas = %d +- %d +-%d\n", - int(layer), - out.is_barrel.to_int(), - out.coord1.to_int(), - out.sigma_coord1.to_int(), - out.coord2.to_int(), - out.sigma_coord2.to_int(), - out.eta.to_int(), - out.sigma_eta1.to_int(), - out.sigma_eta2.to_int()); - - return out; - } - - ap_uint deltaEta(const ap_int& eta1, const ap_int& eta2) { - ap_fixed dEta = eta1 - eta2; - if (dEta < 0) - return ap_uint(-dEta); - else - return ap_uint(dEta); - } - - ap_uint deltaCoord(const ap_int& phi1, const ap_int& phi2) { - ap_int dPhiRoll = phi1 - phi2; - ap_ufixed dPhi; - if (dPhiRoll < 0) - dPhi = ap_ufixed(-dPhiRoll); - else - dPhi = ap_ufixed(dPhiRoll); - - return ap_uint(dPhi); - } - - match_t match(const propagation_t prop, const l1t::MuonStubRef& stub) { - if (verbose_ == 1) { - printf("Matching to "); - stub->print(); - } - //Matching of Coord1 - ap_uint<1> coord1Matched; - ap_uint deltaCoord1 = deltaCoord(prop.coord1, stub->coord1()); - if (deltaCoord1 <= prop.sigma_coord1 && (stub->quality() & 0x1)) { - coord1Matched = 1; - } else { - coord1Matched = 0; - } - if (verbose_ == 1) - printf("Coord1 matched=%d delta=%d res=%d\n", - coord1Matched.to_int(), - deltaCoord1.to_int(), - prop.sigma_coord1.to_int()); - - //Matching of Coord2 - ap_uint<1> coord2Matched; - ap_uint deltaCoord2 = deltaCoord(prop.coord2, stub->coord2()); - if (deltaCoord2 <= prop.sigma_coord2 && (stub->quality() & 0x2)) { - coord2Matched = 1; - } else { - coord2Matched = 0; - } - if (verbose_ == 1) - printf("Coord2 matched=%d delta=%d res=%d\n", - coord2Matched.to_int(), - deltaCoord2.to_int(), - prop.sigma_coord2.to_int()); - - //Matching of Eta1 - - ap_uint<1> eta1Matched; - - //if we have really bad quality[Barrel no eta] - //increase the resolution - ap_ufixed prop_sigma_eta1; - if (stub->etaQuality() == 0) - prop_sigma_eta1 = prop.sigma_eta1 + 6; - else - prop_sigma_eta1 = prop.sigma_eta1; - - ap_uint deltaEta1 = deltaEta(prop.eta, stub->eta1()); - if (deltaEta1 <= prop_sigma_eta1 && (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1))) - eta1Matched = 1; - else - eta1Matched = 0; - - if (verbose_ == 1) - printf("eta1 matched=%d delta=%d res=%d\n", eta1Matched.to_int(), deltaEta1.to_int(), prop_sigma_eta1.to_int()); - - //Matching of Eta2 - - ap_uint<1> eta2Matched; - - ap_uint deltaEta2 = deltaEta(prop.eta, stub->eta2()); - if (deltaEta2 <= prop.sigma_eta2 && (stub->etaQuality() & 0x2)) - eta2Matched = 1; - else - eta2Matched = 0; - match_t out; - out.id = stub->id(); - - if (verbose_ == 1) - printf("eta2 matched=%d delta=%d res=%d\n", eta2Matched.to_int(), deltaEta2.to_int(), prop.sigma_eta2.to_int()); - - //if barrel, coord1 has to always be matched, coord2 maybe and eta1 is needed if etaQ=0 or then the one that depends on eta quality - if (prop.is_barrel) { - out.valid = (coord1Matched == 1 && (eta1Matched == 1 || eta2Matched == 1)); - if (out.valid == 0) { - out.quality = 0; - } else { - out.quality = 32 - deltaCoord1; - if (coord2Matched == 1) - out.quality += 32 - deltaCoord2; - } - } - //if endcap each coordinate is independent except the case where phiQuality=1 and etaQuality==3 - else { - bool match1 = (coord1Matched == 1 && eta1Matched == 1); - bool match2 = (coord2Matched == 1 && eta2Matched == 1); - bool match3 = - (coord1Matched == 1 && (eta1Matched || eta2Matched) && stub->etaQuality() == 3 && stub->quality() == 1); - out.valid = match1 || match2 || match3; - if (out.valid == 0) - out.quality = 0; - else { - out.quality = 0; - if (match1 || match3) - out.quality += 32 - deltaCoord1; - if (match2) - out.quality += 32 - deltaCoord2; - } - } - if (verbose_ == 1) - printf("GlobalMatchQuality = %d\n", out.quality.to_int()); - out.stubRef = stub; - return out; - } - - match_t propagateAndMatch(const ConvertedTTTrack& track, const l1t::MuonStubRef& stub) { - propagation_t prop = propagate(track, stub->tfLayer()); - return match(prop, stub); - } - - match_t getBest(const std::vector matches) { - match_t best = matches[0]; - for (const auto& m : matches) { - if (m.quality > best.quality) - best = m; - } - - return best; - } - - PreTrackMatchedMuon processTrack(const ConvertedTTTrack& track, const std::vector& rois) { - std::vector matchInfo0; - std::vector matchInfo1; - std::vector matchInfo2; - std::vector matchInfo3; - std::vector matchInfo4; - - if (verbose_ == 1 && !rois.empty()) { - printf("-----------processing new track----------"); - track.print(); - } - for (const auto& roi : rois) { - if (verbose_ == 1) { - printf("New ROI with %d stubs \n", int(roi.stubs().size())); - } - for (const auto& stub : roi.stubs()) { - match_t m = propagateAndMatch(track, stub); - if (m.valid == 1) { - if (roi.isGlobalMuon() && roi.muonRef().isNonnull()) { - m.isGlobal = true; - m.muRef = roi.muonRef(); - } - - if (stub->tfLayer() == 0) - matchInfo0.push_back(m); - else if (stub->tfLayer() == 1) - matchInfo1.push_back(m); - else if (stub->tfLayer() == 2) - matchInfo2.push_back(m); - else if (stub->tfLayer() == 3) - matchInfo3.push_back(m); - else if (stub->tfLayer() == 4) - matchInfo4.push_back(m); - } - } - } - - ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM> ptPenalty = ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM>(track.pt() / 32); - - ap_uint quality = 0; - PreTrackMatchedMuon muon(track.charge(), track.pt(), track.eta(), track.phi(), track.z0(), track.d0()); - - if (!matchInfo0.empty()) { - match_t b = getBest(matchInfo0); - if (b.valid) { - muon.addStub(b.stubRef); - if (b.isGlobal) - muon.addMuonRef(b.muRef); - quality += b.quality; - } - } - if (!matchInfo1.empty()) { - match_t b = getBest(matchInfo1); - if (b.valid) { - muon.addStub(b.stubRef); - if (b.isGlobal) - muon.addMuonRef(b.muRef); - quality += b.quality; - } - } - if (!matchInfo2.empty()) { - match_t b = getBest(matchInfo2); - if (b.valid) { - muon.addStub(b.stubRef); - if (b.isGlobal) - muon.addMuonRef(b.muRef); - quality += b.quality; - } - } - if (!matchInfo3.empty()) { - match_t b = getBest(matchInfo3); - if (b.valid) { - muon.addStub(b.stubRef); - if (b.isGlobal) - muon.addMuonRef(b.muRef); - quality += b.quality; - } - } - if (!matchInfo4.empty()) { - match_t b = getBest(matchInfo4); - if (b.valid) { - muon.addStub(b.stubRef); - if (b.isGlobal) - muon.addMuonRef(b.muRef); - quality += b.quality; - } - } - - muon.setOfflineQuantities(track.offline_pt(), track.offline_eta(), track.offline_phi()); - muon.setTrkPtr(track.trkPtr()); - - ap_uint<8> etaAddr = muon.eta() < 0 ? ap_uint<8>(-muon.eta() / 256) : ap_uint<8>((muon.eta()) / 256); - ap_uint<8> ptAddr = muon.pt() > 4095 ? ap_uint<8>(15) : ap_uint<8>(muon.pt() / 256); - ap_uint<8> addr = ptAddr | (etaAddr << 4); - ap_uint<8> qualityCut = lt_tpsID[addr]; - - if (quality >= qualityCut) { - muon.setValid(true); - muon.setQuality(quality + ptPenalty); - } else { - muon.setValid(false); - muon.setQuality(0); - muon.resetGlobal(); - } - if (verbose_ == 1) - muon.print(); - - if (verbose_ == 1 && !rois.empty()) { //patterns for HLS - - printf("TPS %d", track.trkPtr()->phiSector()); - track.printWord(); - - for (uint i = 0; i < 16; ++i) { - if (rois.size() > i) { - rois[i].printROILine(); - } else { - printf("%08x", 0); - printf("%016lx", 0x1ff000000000000); - printf("%016lx", 0x1ff000000000000); - printf("%016lx", 0x1ff000000000000); - printf("%016lx", 0x1ff000000000000); - printf("%016lx", 0x1ff000000000000); - } - } - muon.printWord(); - printf("\n"); - } - return muon; - } - - ap_uint<5> cleanMuon(const PreTrackMatchedMuon& mu, const PreTrackMatchedMuon& other, bool eq) { - ap_uint<5> valid = 0; - ap_uint<5> overlap = 0; - if (mu.stubID0() != 511) { - valid = valid | 0x1; - if (mu.stubID0() == other.stubID0()) - overlap = overlap | 0x1; - } - if (mu.stubID1() != 511) { - valid = valid | 0x2; - if (mu.stubID1() == other.stubID1()) - overlap = overlap | 0x2; - } - if (mu.stubID2() != 511) { - valid = valid | 0x4; - if (mu.stubID2() == other.stubID2()) - overlap = overlap | 0x4; - } - if (mu.stubID3() != 511) { - valid = valid | 0x8; - if (mu.stubID3() == other.stubID3()) - overlap = overlap | 0x8; - } - if (mu.stubID4() != 511) { - valid = valid | 0x10; - if (mu.stubID4() == other.stubID4()) - overlap = overlap | 0x10; - } - - if (((mu.quality() < other.quality()) && (!eq)) || ((mu.quality() <= other.quality()) && (eq))) - return valid & (~overlap); - else - return valid; - } - - std::vector clean(std::vector& muons) { - std::vector out; - if (muons.empty()) - return out; - if (verbose_ == 1) { - printf("-----Cleaning Up Muons in the same Nonant\n"); - printf("Before:\n"); - } - for (uint i = 0; i < muons.size(); ++i) { - if (verbose_ == 1) - muons[i].print(); - - ap_uint<5> mask = 0x1f; - for (uint j = 0; j < muons.size(); ++j) { - if (i == j) - continue; - mask = mask & cleanMuon(muons[i], muons[j], false); - } - if (mask) { - if (verbose_ == 1) - printf("kept\n"); - out.push_back(muons[i]); - } else { - if (verbose_ == 1) - printf("discarded\n"); - } - } - return out; - } - }; -} // namespace Phase2L1GMT - -#endif diff --git a/L1Trigger/Phase2L1GMT/python/gmtFwdMuons_cfi.py b/L1Trigger/Phase2L1GMT/python/gmtFwdMuons_cfi.py new file mode 100644 index 0000000000000..29edd9d6ffcbe --- /dev/null +++ b/L1Trigger/Phase2L1GMT/python/gmtFwdMuons_cfi.py @@ -0,0 +1,9 @@ +import FWCore.ParameterSet.Config as cms + +gmtFwdMuons = cms.EDProducer( + 'Phase2L1TGMTFwdMuonTranslator', + stubs = cms.InputTag('gmtStubs','tps'), + omtfTracks = cms.InputTag('simOmtfPhase2Digis', 'OMTF'), + emtfTracks = cms.InputTag('simEmtfDigisPhase2'), + +) diff --git a/L1Trigger/Phase2L1GMT/python/gmtKMTFMuons_cfi.py b/L1Trigger/Phase2L1GMT/python/gmtKMTFMuons_cfi.py new file mode 100644 index 0000000000000..b328e18adac84 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/python/gmtKMTFMuons_cfi.py @@ -0,0 +1,73 @@ +import FWCore.ParameterSet.Config as cms + + +gmtKMTFMuons = cms.EDProducer('Phase2L1TGMTKMTFProducer', + stubs = cms.InputTag('gmtStubs','kmtf'), + verbose = cms.int32(0), + algo = cms.PSet( + verbose = cms.bool(False), + lutFile = cms.string("L1Trigger/Phase2L1GMT/data/packedGainLUTs.root"), + initialK = cms.vdouble(-0.4576229536749278, -0.6364802777566145, -1.0305030909883524, -1.7272067322624118), + initialK2 = cms.vdouble(-6.442002637356136e-05, -9.582709649965545e-05, -0.0002741064246218815, -0.0014910074450869175), + eLoss = cms.vdouble(6.77765e-05,0,0,0), + + aPhi = cms.vdouble(5.6533349391874275, 0.03477876333443834, 0.032506522838098864, 0.024752809174909053), + aPhiB = cms.vdouble(-2.02, -0.2994087741381382, -0.4033668521165302, -0.3592231728688621), + aPhiBNLO = cms.vdouble(9.04133e-05,0,0,0), + + bPhi = cms.vdouble(-1,.18245,.20898,.17286), + bPhiB = cms.vdouble(-1,1.18245,1.20898,1.17286), + phiAt2 = cms.double(0.17917991867483288), + etaLUT0 = cms.vdouble(8.946,7.508,6.279,6.399), + etaLUT1 = cms.vdouble(0.159,0.116,0.088,0.128), + + #Chi2 Calculation coefficients + + chiSquareDisp1 = cms.vdouble(0.241,0.575,0.892), + chiSquareDisp2 = cms.vdouble(0.347,0.707), + chiSquareDisp3 = cms.vdouble(0.336), + + chiSquareErrADisp1 = cms.vint32(21,23,45), + chiSquareErrADisp2 = cms.vint32(14,28), + chiSquareErrADisp3 = cms.vint32(29), + chiSquareErrBDisp1 = cms.vdouble(5*0.108,5*0.161,5*0.148), + chiSquareErrBDisp2 = cms.vdouble(5*0.146,5*0.189), + chiSquareErrBDisp3 = cms.vdouble(5*0.100), + + chiSquarePrompt1 = cms.vdouble(-0.323,-0.508,-0.578), + chiSquarePrompt2 = cms.vdouble(-0.228,-0.343), + chiSquarePrompt3 = cms.vdouble(-0.100), + + chiSquareErrAPrompt1 = cms.vint32(21,24,33), + chiSquareErrAPrompt2 = cms.vint32(18,14), + chiSquareErrAPrompt3 = cms.vint32(21), + chiSquareErrBPrompt1 = cms.vdouble(5*0.009,5*0.016,5*0.012), + chiSquareErrBPrompt2 = cms.vdouble(5*0.013,5*0.055), + chiSquareErrBPrompt3 = cms.vdouble(5*0.01), + chiSquareCutDispPattern = cms.vint32(), + chiSquareCutOffDisp = cms.vint32(), + chiSquareCutDisp = cms.vint32(), + chiSquareCutPromptPattern = cms.vint32(), + chiSquareCutOffPrompt = cms.vint32(), + chiSquareCutPrompt = cms.vint32(), + combos4=cms.vint32(9,10,11,12,13,14,15), + combos3=cms.vint32(5,6,7), + combos2=cms.vint32(3), + combos1=cms.vint32(), #for future possible usage + useOfflineAlgo = cms.bool(False), + ###Only for the offline algo -not in firmware -------------------- + mScatteringPhi = cms.vdouble(0.1169021113298598, 0.00016777763395543814, 0.0004322078772344548, 0.00024985881710722107), + mScatteringPhiB = cms.vdouble(.0522762, 0.01762000062188365, 0.03508319015441297, 0.03126825551530328), + pointResolutionPhi = cms.double(1.), + pointResolutionPhiB = cms.double(12493.7429036), + pointResolutionPhiBH = cms.vdouble(19925.62953113343, 15583.06791339368, 10258.11768352221, 15462.112839170433), + pointResolutionPhiBL = cms.vdouble(161519.85395846734, 155051.58394241595, 149693.88179343447, 174896.46766622085), + pointResolutionVertex = cms.double(1.), + curvResolution1 = cms.vdouble(1, 2.36097e+03, 8.73003e+02, 2.58138e5), + curvResolution2 = cms.vdouble(1, 4.903692e+00, 4.87941e+01, 0)), + Nprompt = cms.uint32(12), + Ndisplaced = cms.uint32(12) +) + + + diff --git a/L1Trigger/Phase2L1GMT/python/gmtSAMuons_cfi.py b/L1Trigger/Phase2L1GMT/python/gmtSAMuons_cfi.py new file mode 100644 index 0000000000000..ca4559d026428 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/python/gmtSAMuons_cfi.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms +gmtSAMuons = cms.EDProducer('Phase2L1TGMTSAMuonGhostCleaner', + barrelPrompt = cms.InputTag('gmtKMTFMuons:prompt'), + barrelDisp = cms.InputTag('gmtKMTFMuons:displaced'), + forwardPrompt = cms.InputTag('gmtFwdMuons:prompt'), + forwardDisp = cms.InputTag('gmtFwdMuons:displaced') +) + diff --git a/L1Trigger/Phase2L1GMT/python/gmtStubs_cfi.py b/L1Trigger/Phase2L1GMT/python/gmtStubs_cfi.py new file mode 100644 index 0000000000000..94fc3c49e5d5e --- /dev/null +++ b/L1Trigger/Phase2L1GMT/python/gmtStubs_cfi.py @@ -0,0 +1,40 @@ +import FWCore.ParameterSet.Config as cms + +gmtStubs = cms.EDProducer("Phase2L1TGMTStubProducer", + verbose = cms.int32(0), + srcCSC = cms.InputTag("simCscTriggerPrimitiveDigis"), + srcDT = cms.InputTag("dtTriggerPhase2PrimitiveDigis"), + srcDTTheta = cms.InputTag("simDtTriggerPrimitiveDigis"), + srcRPC = cms.InputTag("simMuonRPCDigis"), + Endcap =cms.PSet( + verbose = cms.uint32(0), + minBX = cms.int32(0), + maxBX = cms.int32(0), + coord1LSB = cms.double(0.00076660156*8),#was 32 + eta1LSB = cms.double(7.68334e-04*32), + coord2LSB = cms.double(0.00076660156*8),# was 32 + eta2LSB = cms.double(7.68334e-04*32), + phiMatch = cms.double(0.05), + etaMatch = cms.double(0.1) + ), + Barrel = cms.PSet( + verbose = cms.int32(0),#2 for patterns + minPhiQuality = cms.int32(0),#was 0!!! + minThetaQuality = cms.int32(0), + minBX = cms.int32(0), + maxBX = cms.int32(0), + phiLSB = cms.double(2.3968450e-05), + phiBDivider = cms.int32(1), + etaLSB = cms.double(7.68334e-04*32), + eta_1 = cms.vint32(int(-1503/32),int(-1446/32),int(-1387/32),int(-1327/32),int(-1266/32),int(-1194/32),int(-1125/32),int(-985/32),int(-916/32),int(-839/32),int(-752/32),int(-670/32),int(-582/32),int(-489/32),int(-315/32),int(-213/32),int(-115/32),int(-49/32),int(49/32),int(115/32),int(213/32),int(315/32),int(489/32),int(582/32),int(670/32),int(752/32),int(839/32),int(916/32),int(985/32),int(1125/32),int(1194/32),int(1266/32),int(1327/32),int(1387/32),int(1446/32), 1503), + eta_2 = cms.vint32(int(-1334/32),int(-1279/32),int(-1227/32),int(-1168/32),int(-1109/32),int(-1044/32),int(-982/32),int(-861/32),int(-793/32),int(-720/32),int(-648/32),int(-577/32),int(-496/32),int(-425/32),int(-268/32),int(-185/32),int(-97/32),int(-51/32),int(51/32),int(97/32),int(185/32),int(268/32),int(425/32),int(496/32),int(577/32),int(648/32),int(720/32),int(793/32),int(861/32),int(982/32),int(1044/32),int(1109/32),int(1168/32),int(1227/32),int(1279/32),1334), + eta_3 = cms.vint32(int(-1148/32),int(-1110/32),int(-1051/32),int(-1004/32),int(-947/32),int(-895/32),int(-839/32),int(-728/32),int(-668/32),int(-608/32),int(-546/32),int(-485/32),int(-425/32),int(-366/32),int(-222/32),int(-155/32),int(-87/32),int(-40/32),int(40/32),int(87/32),int(155/32),int(222/32),int(366/32),int(425/32),int(485/32),int(546/32),int(608/32),int(668/32),int(728/32),int(839/32),int(895/32),int(947/32),int(1004/32),int(1051/32),int(1110/32), 1148), + + coarseEta_1 = cms.vint32(int(0/32),int(758/32),int(1336/32)), + coarseEta_2 = cms.vint32(int(0/32),int(653/32),int(1168/32)), + coarseEta_3 = cms.vint32(int(0/32),int(552/32),int(1001/32)), + coarseEta_4 = cms.vint32(int(0/32),int(478/32),int(878/32)), + phiOffset = cms.vint32(0,0,0,0) + ) +) + diff --git a/L1Trigger/Phase2L1GMT/python/gmtTkMuons_cfi.py b/L1Trigger/Phase2L1GMT/python/gmtTkMuons_cfi.py new file mode 100644 index 0000000000000..1a0704a5e2a85 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/python/gmtTkMuons_cfi.py @@ -0,0 +1,32 @@ +import FWCore.ParameterSet.Config as cms +gmtTkMuons = cms.EDProducer('Phase2L1TGMTTkMuonProducer', + srcTracks = cms.InputTag("l1tTTTracksFromTrackletEmulation:Level1TTTracks"), + srcStubs = cms.InputTag('gmtStubs:tps'), + minTrackStubs = cms.int32(4), + muonBXMin = cms.int32(0), + muonBXMax = cms.int32(0), + verbose = cms.int32(0), + trackConverter = cms.PSet( + verbose = cms.int32(0) + ), + trackMatching = cms.PSet( + verbose=cms.int32(0) + ), + isolation = cms.PSet( + AbsIsoThresholdL = cms.int32(160), + AbsIsoThresholdM = cms.int32(120), + AbsIsoThresholdT = cms.int32(80), + RelIsoThresholdL = cms.double(0.1), + RelIsoThresholdM = cms.double(0.05), + RelIsoThresholdT = cms.double(0.01), + verbose = cms.int32(0), + IsodumpForHLS = cms.int32(0), + ), + tauto3mu = cms.PSet() + +) + + + + + diff --git a/L1Trigger/Phase2L1GMT/python/gmt_cfi.py b/L1Trigger/Phase2L1GMT/python/gmt_cfi.py index 0c2008095889a..f5f924f562d61 100644 --- a/L1Trigger/Phase2L1GMT/python/gmt_cfi.py +++ b/L1Trigger/Phase2L1GMT/python/gmt_cfi.py @@ -1,81 +1,10 @@ -import FWCore.ParameterSet.Config as cms - -l1tGMTStubs = cms.EDProducer("Phase2L1TGMTStubProducer", - verbose = cms.int32(0), - srcCSC = cms.InputTag("simCscTriggerPrimitiveDigis"), - srcDT = cms.InputTag("dtTriggerPhase2PrimitiveDigis"), - srcDTTheta = cms.InputTag("simDtTriggerPrimitiveDigis"), - srcRPC = cms.InputTag("simMuonRPCDigis"), - Endcap =cms.PSet( - verbose = cms.uint32(0), - minBX = cms.int32(0), - maxBX = cms.int32(0), - coord1LSB = cms.double(0.00076660156*32), - eta1LSB = cms.double(7.68334e-04*32), - coord2LSB = cms.double(0.00076660156*32), - eta2LSB = cms.double(7.68334e-04*32), - phiMatch = cms.double(0.05), - etaMatch = cms.double(0.1) - ), - Barrel = cms.PSet( - verbose = cms.int32(0), - minPhiQuality = cms.int32(0),#was 5 - minThetaQuality = cms.int32(0), - minBX = cms.int32(0), - maxBX = cms.int32(0), - phiLSB = cms.double(0.00076660156*32), - phiBDivider = cms.int32(16), - etaLSB = cms.double(7.68334e-04*32), - eta_1 = cms.vint32(int(-1503/32),int(-1446/32),int(-1387/32),int(-1327/32),int(-1266/32),int(-1194/32),int(-1125/32),int(-985/32),int(-916/32),int(-839/32),int(-752/32),int(-670/32),int(-582/32),int(-489/32),int(-315/32),int(-213/32),int(-115/32),int(-49/32),int(49/32),int(115/32),int(213/32),int(315/32),int(489/32),int(582/32),int(670/32),int(752/32),int(839/32),int(916/32),int(985/32),int(1125/32),int(1194/32),int(1266/32),int(1327/32),int(1387/32),int(1446/32), 1503), - eta_2 = cms.vint32(int(-1334/32),int(-1279/32),int(-1227/32),int(-1168/32),int(-1109/32),int(-1044/32),int(-982/32),int(-861/32),int(-793/32),int(-720/32),int(-648/32),int(-577/32),int(-496/32),int(-425/32),int(-268/32),int(-185/32),int(-97/32),int(-51/32),int(51/32),int(97/32),int(185/32),int(268/32),int(425/32),int(496/32),int(577/32),int(648/32),int(720/32),int(793/32),int(861/32),int(982/32),int(1044/32),int(1109/32),int(1168/32),int(1227/32),int(1279/32),1334), - eta_3 = cms.vint32(int(-1148/32),int(-1110/32),int(-1051/32),int(-1004/32),int(-947/32),int(-895/32),int(-839/32),int(-728/32),int(-668/32),int(-608/32),int(-546/32),int(-485/32),int(-425/32),int(-366/32),int(-222/32),int(-155/32),int(-87/32),int(-40/32),int(40/32),int(87/32),int(155/32),int(222/32),int(366/32),int(425/32),int(485/32),int(546/32),int(608/32),int(668/32),int(728/32),int(839/32),int(895/32),int(947/32),int(1004/32),int(1051/32),int(1110/32), 1148), - - coarseEta_1 = cms.vint32(int(0/32),int(758/32),int(1336/32)), - coarseEta_2 = cms.vint32(int(0/32),int(653/32),int(1168/32)), - coarseEta_3 = cms.vint32(int(0/32),int(552/32),int(1001/32)), - coarseEta_4 = cms.vint32(int(0/32),int(478/32),int(878/32)), - phiOffset = cms.vint32(int(33/32),int(-8/32),int(+14/32),0) - ) - -) - - - - - -l1tGMTMuons = cms.EDProducer('Phase2L1TGMTProducer', - srcTracks = cms.InputTag("l1tTTTracksFromTrackletEmulation:Level1TTTracks"), - srcStubs = cms.InputTag('l1tGMTStubs'), - srcBMTF = cms.InputTag('simBmtfDigis','BMTF'), - srcEMTF = cms.InputTag('simEmtfDigis','EMTF'), - srcOMTF = cms.InputTag('simOmtfDigis','OMTF'), - minTrackStubs = cms.int32(4), - muonBXMin = cms.int32(0), - muonBXMax = cms.int32(0), - verbose = cms.int32(0), - trackConverter = cms.PSet( - verbose = cms.int32(0) - ), - roiTrackAssociator = cms.PSet( - verbose=cms.int32(0) - ), - trackMatching = cms.PSet( - verbose=cms.int32(0) - ), - isolation = cms.PSet( - AbsIsoThresholdL = cms.int32(160), - AbsIsoThresholdM = cms.int32(120), - AbsIsoThresholdT = cms.int32(80), - RelIsoThresholdL = cms.double(0.1), - RelIsoThresholdM = cms.double(0.05), - RelIsoThresholdT = cms.double(0.01), - verbose = cms.int32(0), - IsodumpForHLS = cms.int32(0), - ), - tauto3mu = cms.PSet() - -) - +from L1Trigger.Phase2L1GMT.gmtStubs_cfi import * +from L1Trigger.Phase2L1GMT.gmtKMTFMuons_cfi import * +from L1Trigger.Phase2L1GMT.gmtFwdMuons_cfi import * +from L1Trigger.Phase2L1GMT.gmtSAMuons_cfi import * +from L1Trigger.Phase2L1GMT.gmtTkMuons_cfi import * +l1tGMTStubs = cms.Sequence(gmtStubs) +l1tGMTMuons = cms.Sequence(gmtKMTFMuons*gmtFwdMuons*gmtSAMuons*gmtTkMuons) l1tGMTFilteredMuons = cms.EDProducer('Phase2L1TGMTFilter', srcMuons = cms.InputTag("l1tTkMuonsGmt",""), @@ -83,12 +12,5 @@ ptBarrelMin = cms.int32(8), ptEndcapMin = cms.int32(8), etaBE = cms.double(0.9) - -) - -l1tStandaloneMuons = cms.EDProducer('Phase2L1TGMTSAMuonProducer', - muonToken = cms.InputTag('simGmtStage2Digis'), - Nprompt = cms.uint32(12), - Ndisplaced = cms.uint32(12) - ) +) diff --git a/L1Trigger/Phase2L1GMT/src/KMTF.cc b/L1Trigger/Phase2L1GMT/src/KMTF.cc new file mode 100644 index 0000000000000..918554895b131 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/src/KMTF.cc @@ -0,0 +1,464 @@ +#include "L1Trigger/Phase2L1GMT/interface/KMTF.h" +using namespace Phase2L1GMT; + +KMTF::KMTF(int verbose, const edm::ParameterSet& iConfig) + : verbose_(verbose), trackMaker_(std::make_unique(iConfig)) {} + +KMTF::~KMTF() = default; + +std::pair, std::vector > KMTF::process( + const l1t::MuonStubRefVector& stubsAll, int bx, unsigned int MAXN) { + std::vector pretracksP2; + std::vector pretracksP3; + std::vector pretracksP4; + std::vector pretracksD2; + std::vector pretracksD3; + std::vector pretracksD4; + uint Nstubs4 = 0; + uint Nstubs3 = 0; + uint Nstubs2 = 0; + uint Nstubs1 = 0; + + l1t::MuonStubRefVector stubs4; + l1t::MuonStubRefVector stubs3; + l1t::MuonStubRefVector stubs2; + l1t::MuonStubRefVector stubs1; + + for (const auto& stub : stubsAll) { + if (stub->bxNum() != bx || stub->id() > 3) + continue; + if (!stub->isBarrel()) + continue; + + if (stub->depthRegion() == 4) { + if (Nstubs4 < MAXN) { + stubs4.push_back(stub); + Nstubs4++; + } + } + if (stub->depthRegion() == 3) { + if (Nstubs3 < MAXN) { + stubs3.push_back(stub); + Nstubs3++; + } + } + if (stub->depthRegion() == 2) { + if (Nstubs2 < MAXN) { + stubs2.push_back(stub); + Nstubs2++; + } + } + if (stub->depthRegion() == 1) { + if (Nstubs1 < MAXN) { + stubs1.push_back(stub); + Nstubs1++; + } + } + } + + //Sort the seeds by tag so that the emulator is aligned like the firmware + SeedSorter sorter; + if (stubs4.size() > 1) { + std::sort(stubs4.begin(), stubs4.end(), sorter); + } + if (stubs3.size() > 1) { + std::sort(stubs3.begin(), stubs3.end(), sorter); + } + if (stubs2.size() > 1) { + std::sort(stubs2.begin(), stubs2.end(), sorter); + } + if (stubs1.size() > 1) { + std::sort(stubs1.begin(), stubs1.end(), sorter); + } + + bool pre_patterns = (verbose_ > 1) && ((Nstubs4 + Nstubs3 + Nstubs2 + Nstubs1) > 2); + + //OK now process the data almost as in hardware + for (unsigned int i = 0; i < 32; ++i) { + //print the stubs taking into account + + bool patterns = pre_patterns && ((i < Nstubs4) || (i < Nstubs3) || (i << Nstubs2)); + + if (patterns) { + edm::LogInfo("KMTF") << "KMTFPattern " << std::flush; + if (i < Nstubs4) + edm::LogInfo("KMTF") << stubs4[0]->coord1() << " " << stubs4[0]->coord2() << " " << stubs4[0]->quality() << " " + << " 1 " << stubs4[0]->kmtf_address() << " 0 " << std::flush; + else + edm::LogInfo("KMTF") << "0 0 0 0 511 0 " << std::flush; + + if (i < Nstubs3) { + for (const auto& s : stubs3) { + edm::LogInfo("KMTF") << "" << s->coord1() << " " << s->coord2() << " " << s->quality() << " 1 " + << s->kmtf_address() << " 0 " << std::flush; + } + //pad with zeros + for (unsigned int j = stubs3.size(); j < 32; ++j) { + edm::LogInfo("KMTF") << "0 0 0 0 511 0 " << std::flush; + } + } else { + for (unsigned int j = stubs3.size(); j < 32; ++j) { + edm::LogInfo("KMTF") << "0 0 0 0 511 0 " << std::flush; + } + for (const auto& s : stubs3) { + edm::LogInfo("KMTF") << "" << s->coord1() << " " << s->coord2() << " " << s->quality() << " 1 " + << s->kmtf_address() << " 0 " << std::flush; + } + } + + if (i < Nstubs2) { + for (const auto& s : stubs2) { + edm::LogInfo("KMTF") << "" << s->coord1() << " " << s->coord2() << " " << s->quality() << " 1 " + << s->kmtf_address() << " 0 " << std::flush; + } + //pad with zeros + for (unsigned int j = stubs2.size(); j < 32; ++j) { + edm::LogInfo("KMTF") << "0 0 0 0 511 0 " << std::flush; + } + } else { + for (unsigned int j = stubs2.size(); j < 32; ++j) { + edm::LogInfo("KMTF") << "0 0 0 0 511 0 " << std::flush; + } + for (const auto& s : stubs2) { + edm::LogInfo("KMTF") << s->coord1() << " " << s->coord2() << " " << s->quality() << " 1 " << s->kmtf_address() + << " 0 " << std::flush; + } + } + if (i < Nstubs1) { + for (const auto& s : stubs1) { + edm::LogInfo("KMTF") << s->coord1() << " " << s->coord2() << " " << s->quality() << " 1 " << s->kmtf_address() + << " 0 " << std::flush; + } + //pad with zeros + for (unsigned int j = stubs1.size(); j < 32; ++j) { + edm::LogInfo("KMTF") << "0 0 0 0 511 0 " << std::flush; + } + } else { + for (unsigned int j = stubs1.size(); j < 32; ++j) { + edm::LogInfo("KMTF") << "0 0 0 0 511 0 " << std::flush; + } + for (const auto& s : stubs1) { + edm::LogInfo("KMTF") << s->coord1() << " " << s->coord2() << " " << s->quality() << " 1 " << s->kmtf_address() + << " 0 " << std::flush; + } + } + } + + //seed is 4 + if (i < Nstubs4) { + l1t::MuonStubRefVector stubs_proc; + if (Nstubs3 > 0) + stubs_proc.insert(stubs_proc.end(), stubs3.begin(), stubs3.end()); + if (Nstubs2 > 0) + stubs_proc.insert(stubs_proc.end(), stubs2.begin(), stubs2.end()); + if (Nstubs1 > 0) + stubs_proc.insert(stubs_proc.end(), stubs1.begin(), stubs1.end()); + std::pair tracks = trackMaker_->chain(stubs4[0], stubs_proc); + if (tracks.first.id() & 0x1) + pretracksP4.push_back(tracks.first); + if (tracks.second.id() & 0x2) + pretracksD4.push_back(tracks.second); + if (patterns) { + if (tracks.first.id() & 0x1) + edm::LogInfo("KMTF") << "1 " << (tracks.first.curvatureAtVertex() < 0 ? 1 : 0) << " " + << tracks.first.ptPrompt() << " " << tracks.first.phiAtMuon() / (1 << 5) << " " + << tracks.first.coarseEta() << " " << int(tracks.first.dxy() * ap_ufixed<8, 1>(1.606)) + << " " << tracks.first.rankPrompt() << " " << std::flush; + + else + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + if (tracks.second.id() & 0x2) + edm::LogInfo("KMTF") << "1 " << (tracks.second.curvatureAtVertex() < 0 ? 1 : 0) << " " + << tracks.second.ptDisplaced() << " " << tracks.second.phiAtMuon() / (1 << 5) << " " + << tracks.second.coarseEta() << " " << int(tracks.second.dxy() * ap_ufixed<8, 1>(1.606)) + << " " << tracks.second.rankDisp() << " " << std::flush; + + else + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + } + } else if (patterns) { + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + } + + if (i < Nstubs3) { + l1t::MuonStubRefVector stubs_proc; + if (Nstubs2 > 0) + stubs_proc.insert(stubs_proc.end(), stubs2.begin(), stubs2.end()); + if (Nstubs1 > 0) + stubs_proc.insert(stubs_proc.end(), stubs1.begin(), stubs1.end()); + std::pair tracks = trackMaker_->chain(stubs3[0], stubs_proc); + if (tracks.first.id() & 0x1) + pretracksP3.push_back(tracks.first); + if (tracks.second.id() & 0x2) + pretracksD3.push_back(tracks.second); + if (patterns) { + if (tracks.first.id() & 0x1) + edm::LogInfo("KMTF") << "1 " << (tracks.first.curvatureAtVertex() < 0 ? 1 : 0) << " " + << tracks.first.ptPrompt() << " " << tracks.first.phiAtMuon() / (1 << 5) << " " + << tracks.first.coarseEta() << " " << int(tracks.first.dxy() * ap_ufixed<8, 1>(1.606)) + << " " << tracks.first.rankPrompt() << " " << std::flush; + + else + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + if (tracks.second.id() & 0x2) + edm::LogInfo("KMTF") << "1 " << (tracks.second.curvatureAtVertex() < 0 ? 1 : 0) << " " + << tracks.second.ptDisplaced() << " " << tracks.second.phiAtMuon() / (1 << 5) << " " + << tracks.second.coarseEta() << " " << int(tracks.second.dxy() * ap_ufixed<8, 1>(1.606)) + << " " << tracks.second.rankDisp() << " " << std::flush; + + else + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + } + } else if (patterns) { + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + } + if (i < Nstubs2) { + l1t::MuonStubRefVector stubs_proc; + if (Nstubs1 > 0) + stubs_proc.insert(stubs_proc.end(), stubs1.begin(), stubs1.end()); + std::pair tracks = trackMaker_->chain(stubs2[0], stubs_proc); + if (tracks.first.id() & 0x1) + pretracksP2.push_back(tracks.first); + if (tracks.second.id() & 0x2) + pretracksD2.push_back(tracks.second); + if (patterns) { + if (tracks.first.id() & 0x1) + edm::LogInfo("KMTF") << "1 " << (tracks.first.curvatureAtVertex() < 0 ? 1 : 0) << " " + << tracks.first.ptPrompt() << " " << tracks.first.phiAtMuon() / (1 << 5) << " " + << tracks.first.coarseEta() << " " << int(tracks.first.dxy() * ap_ufixed<8, 1>(1.606)) + << " " << tracks.first.rankPrompt() << " " << std::flush; + + else + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + if (tracks.second.id() & 0x2) + edm::LogInfo("KMTF") << "1 " << (tracks.second.curvatureAtVertex() < 0 ? 1 : 0) << " " + << tracks.second.ptDisplaced() << " " << tracks.second.phiAtMuon() / (1 << 5) << " " + << tracks.second.coarseEta() << " " << int(tracks.second.dxy() * ap_ufixed<8, 1>(1.606)) + << " " << tracks.second.rankDisp(); + else + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0" << std::flush; + } + } else if (patterns) { + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0 " << std::flush; + edm::LogInfo("KMTF") << "0 0 0 0 0 0 0"; + } + //Now the shift register emulation in C_++ + if (stubs4.size() > 1) { + l1t::MuonStubRef s4 = stubs4[0]; + stubs4.erase(stubs4.begin(), stubs4.begin() + 1); + stubs4.push_back(s4); + } + if (stubs3.size() > 1) { + l1t::MuonStubRef s3 = stubs3[0]; + stubs3.erase(stubs3.begin(), stubs3.begin() + 1); + stubs3.push_back(s3); + } + if (stubs2.size() > 1) { + l1t::MuonStubRef s2 = stubs2[0]; + stubs2.erase(stubs2.begin(), stubs2.begin() + 1); + stubs2.push_back(s2); + } + if (stubs1.size() > 1) { + l1t::MuonStubRef s1 = stubs1[0]; + stubs1.erase(stubs1.begin(), stubs1.begin() + 1); + stubs1.push_back(s1); + } + } + + std::vector cleanedPrompt = cleanRegion(pretracksP2, pretracksP3, pretracksP4, true); + std::vector cleanedDisp = cleanRegion(pretracksD2, pretracksD3, pretracksD4, false); + if (verbose_) { + edm::LogInfo("KMTF") << "Prompt pretracks 2=" << int(pretracksP2.size()) << " 3=" << int(pretracksP3.size()) + << " 4=" << int(pretracksP4.size()); + edm::LogInfo("KMTF") << "Cleaned Tracks Prompt=" << (int)cleanedPrompt.size() + << " Displaced=" << (int)cleanedDisp.size(); + } + + if (verbose_ && !cleanedPrompt.empty()) + for (const auto& t : cleanedPrompt) + if (t.id() != 0) + edm::LogInfo("KMTF") << "final cleaned sector track from all chains track pt=" << t.ptPrompt() + << " pattern=" << t.hitPattern() << " rank=" << t.rankPrompt(); + + sort(cleanedPrompt, true); + sort(cleanedDisp, false); + + if (verbose_ && !cleanedPrompt.empty()) + for (const auto& t : cleanedPrompt) + if (t.id() != 0) + edm::LogInfo("KMTF") << "final sorted sector track from all chains track pt=" << t.ptPrompt() + << " pattern=" << t.hitPattern() << " rank=" << t.rankPrompt(); + + return std::make_pair(cleanedPrompt, cleanedDisp); +} + +void KMTF::overlapCleanTrack(l1t::KMTFTrack& source, const l1t::KMTFTrack& other, bool eq, bool vertex) { + int rank1 = vertex ? source.rankPrompt() : source.rankDisp(); + int rank2 = vertex ? other.rankPrompt() : other.rankDisp(); + int id1 = vertex ? source.id() & 0x1 : source.id() & 0x2; + int id2 = vertex ? other.id() & 0x1 : other.id() & 0x2; + bool keep = true; + unsigned int pattern = 0; + if (id1 == 0) + keep = false; + else if (id1 != 0 && id2 != 0) { + if (eq && rank1 <= rank2) + keep = false; + if ((!eq) && rank1 < rank2) + keep = false; + } + + l1t::MuonStubRefVector stubs; + for (const auto& s1 : source.stubs()) { + bool ok = true; + for (const auto& s2 : other.stubs()) { + if ((*s1) == (*s2) && (!keep)) + ok = false; + } + if (ok) { + stubs.push_back(s1); + pattern = pattern | (1 << (s1->depthRegion() - 1)); + } + } + source.setStubs(stubs); + source.setHitPattern(pattern); +} + +std::vector KMTF::cleanRegion(const std::vector& tracks2, + const std::vector& tracks3, + const std::vector& tracks4, + bool vertex) { + std::vector cleaned2; + for (unsigned int i = 0; i < tracks2.size(); ++i) { + l1t::KMTFTrack source = tracks2[i]; + + for (unsigned int j = 0; j < tracks2.size(); ++j) { + if (i == j) + continue; + overlapCleanTrack(source, tracks2[j], false, vertex); + } + for (unsigned int j = 0; j < tracks3.size(); ++j) { + overlapCleanTrack(source, tracks3[j], true, vertex); + } + for (unsigned int j = 0; j < tracks4.size(); ++j) { + overlapCleanTrack(source, tracks4[j], true, vertex); + } + + if (source.stubs().size() > 1) + cleaned2.push_back(source); + } + + std::vector cleaned3; + for (unsigned int i = 0; i < tracks3.size(); ++i) { + l1t::KMTFTrack source = tracks3[i]; + + for (unsigned int j = 0; j < tracks3.size(); ++j) { + if (i == j) + continue; + overlapCleanTrack(source, tracks3[j], false, vertex); + } + for (unsigned int j = 0; j < tracks2.size(); ++j) { + overlapCleanTrack(source, tracks2[j], false, vertex); + } + for (unsigned int j = 0; j < tracks4.size(); ++j) { + overlapCleanTrack(source, tracks4[j], true, vertex); + } + + if (source.stubs().size() > 1) + cleaned3.push_back(source); + } + + std::vector cleaned4; + for (unsigned int i = 0; i < tracks4.size(); ++i) { + l1t::KMTFTrack source = tracks4[i]; + + for (unsigned int j = 0; j < tracks4.size(); ++j) { + if (i == j) + continue; + overlapCleanTrack(source, tracks4[j], false, vertex); + } + for (unsigned int j = 0; j < tracks3.size(); ++j) { + overlapCleanTrack(source, tracks3[j], false, vertex); + } + for (unsigned int j = 0; j < tracks2.size(); ++j) { + overlapCleanTrack(source, tracks2[j], false, vertex); + } + + if (source.stubs().size() > 1) + cleaned4.push_back(source); + } + uint max234 = std::max(cleaned2.size(), std::max(cleaned3.size(), cleaned4.size())); + + std::vector output; + + for (uint i = 0; i < max234; ++i) { + if (i < cleaned2.size()) + output.push_back(cleaned2[i]); + if (i < cleaned3.size()) + output.push_back(cleaned3[i]); + if (i < cleaned4.size()) + output.push_back(cleaned4[i]); + } + return output; +} + +void KMTF::swap(std::vector& list, int i, int j, bool vertex) { + const l1t::KMTFTrack& track1 = list[i]; + const l1t::KMTFTrack& track2 = list[j]; + int id1 = track1.id(); + int id2 = track2.id(); + int pt1 = vertex ? track1.ptPrompt() : track1.ptDisplaced(); + int pt2 = vertex ? track2.ptPrompt() : track2.ptDisplaced(); + bool swap = false; + if (vertex) { + id1 = id1 & 0x1; + id2 = id2 & 0x1; + } else { + id1 = id1 & 0x2; + id2 = id2 & 0x2; + } + if (id1 && (!id2)) + swap = false; + else if ((!id1) && id2) + swap = true; + else if (id1 && id2) { + if (pt1 > pt2) + swap = false; + else + swap = true; + } else { + swap = false; + } + if (swap) { + l1t::KMTFTrack tmp = list[i]; + list[i] = list[j]; + list[j] = tmp; + } +} + +void KMTF::sort(std::vector& in, bool vertex) { + l1t::KMTFTrack nullTrack; + nullTrack.setPtEtaPhi(0, 0, 0); + nullTrack.setIDFlag(false, false); + nullTrack.setRank(0, vertex); + while (in.size() < 32) + in.push_back(nullTrack); + + for (uint iteration = 0; iteration < 16; ++iteration) { + for (uint i = 0; i < 32; i = i + 2) { + swap(in, i, i + 1, vertex); + } + for (uint i = 1; i < 31; i = i + 2) { + swap(in, i, i + 1, vertex); + } + } + + std::vector out; + for (const auto& track : in) { + if ((vertex && (track.id() & 0x1)) || ((!vertex) && (track.id() & 0x2))) + out.push_back(track); + } + in = out; +} diff --git a/L1Trigger/Phase2L1GMT/src/KMTFCore.cc b/L1Trigger/Phase2L1GMT/src/KMTFCore.cc new file mode 100644 index 0000000000000..d58b84e1705fd --- /dev/null +++ b/L1Trigger/Phase2L1GMT/src/KMTFCore.cc @@ -0,0 +1,1167 @@ +#include "L1Trigger/Phase2L1GMT/interface/KMTFCore.h" +using namespace Phase2L1GMT; +KMTFCore::KMTFCore(const edm::ParameterSet& settings) + : lutService_(new KMTFLUTs(settings.getParameter("lutFile"))), + verbose_(settings.getParameter("verbose")), + initK_(settings.getParameter >("initialK")), + initK2_(settings.getParameter >("initialK2")), + eLoss_(settings.getParameter >("eLoss")), + aPhi_(settings.getParameter >("aPhi")), + aPhiB_(settings.getParameter >("aPhiB")), + aPhiBNLO_(settings.getParameter >("aPhiBNLO")), + bPhi_(settings.getParameter >("bPhi")), + bPhiB_(settings.getParameter >("bPhiB")), + phiAt2_(settings.getParameter("phiAt2")), + + chiSquareDisp1_(settings.getParameter >("chiSquareDisp1")), + chiSquareDisp2_(settings.getParameter >("chiSquareDisp2")), + chiSquareDisp3_(settings.getParameter >("chiSquareDisp3")), + chiSquareErrADisp1_(settings.getParameter >("chiSquareErrADisp1")), + chiSquareErrADisp2_(settings.getParameter >("chiSquareErrADisp2")), + chiSquareErrADisp3_(settings.getParameter >("chiSquareErrADisp3")), + chiSquareErrBDisp1_(settings.getParameter >("chiSquareErrBDisp1")), + chiSquareErrBDisp2_(settings.getParameter >("chiSquareErrBDisp2")), + chiSquareErrBDisp3_(settings.getParameter >("chiSquareErrBDisp3")), + + chiSquarePrompt1_(settings.getParameter >("chiSquarePrompt1")), + chiSquarePrompt2_(settings.getParameter >("chiSquarePrompt2")), + chiSquarePrompt3_(settings.getParameter >("chiSquarePrompt3")), + chiSquareErrAPrompt1_(settings.getParameter >("chiSquareErrAPrompt1")), + chiSquareErrAPrompt2_(settings.getParameter >("chiSquareErrAPrompt2")), + chiSquareErrAPrompt3_(settings.getParameter >("chiSquareErrAPrompt3")), + chiSquareErrBPrompt1_(settings.getParameter >("chiSquareErrBPrompt1")), + chiSquareErrBPrompt2_(settings.getParameter >("chiSquareErrBPrompt2")), + chiSquareErrBPrompt3_(settings.getParameter >("chiSquareErrBPrompt3")), + + chiSquareCutDispPattern_(settings.getParameter >("chiSquareCutDispPattern")), + chiSquareCutOffDisp_(settings.getParameter >("chiSquareCutOffDisp")), + chiSquareCutDisp_(settings.getParameter >("chiSquareCutDisp")), + + chiSquareCutPromptPattern_(settings.getParameter >("chiSquareCutPromptPattern")), + chiSquareCutOffPrompt_(settings.getParameter >("chiSquareCutOffPrompt")), + chiSquareCutPrompt_(settings.getParameter >("chiSquareCutPrompt")), + + combos4_(settings.getParameter >("combos4")), + combos3_(settings.getParameter >("combos3")), + combos2_(settings.getParameter >("combos2")), + combos1_(settings.getParameter >("combos1")), + + useOfflineAlgo_(settings.getParameter("useOfflineAlgo")), + mScatteringPhi_(settings.getParameter >("mScatteringPhi")), + mScatteringPhiB_(settings.getParameter >("mScatteringPhiB")), + pointResolutionPhi_(settings.getParameter("pointResolutionPhi")), + pointResolutionPhiB_(settings.getParameter("pointResolutionPhiB")), + pointResolutionPhiBH_(settings.getParameter >("pointResolutionPhiBH")), + pointResolutionPhiBL_(settings.getParameter >("pointResolutionPhiBL")), + pointResolutionVertex_(settings.getParameter("pointResolutionVertex")), + curvResolution1_(settings.getParameter >("curvResolution1")), + curvResolution2_(settings.getParameter >("curvResolution2")) {} + +std::pair KMTFCore::chain(const l1t::MuonStubRef& seed, + const l1t::MuonStubRefVector& stubs) { + std::vector pretracks; + std::vector combinatorics; + int seedQual; + switch (seed->depthRegion()) { + case 1: + combinatorics = combos1_; + break; + case 2: + combinatorics = combos2_; + break; + case 3: + combinatorics = combos3_; + break; + case 4: + combinatorics = combos4_; + break; + default: + throw cms::Exception("KMTFCore") << "Something really bad happend\n"; + } + + l1t::KMTFTrack nullTrack(seed, seed->coord1(), correctedPhiB(seed)); + seedQual = seed->quality(); + for (const auto& mask : combinatorics) { + l1t::KMTFTrack track(seed, seed->coord1(), correctedPhiB(seed)); + int phiB = correctedPhiB(seed); + int charge; + if (phiB == 0) + charge = 0; + else + charge = phiB / fabs(phiB); + + int address = phiB; + if (track.step() == 4 && (fabs(seed->coord2()) > 15)) + address = charge * 15 * ap_ufixed(28.5205658); + if (track.step() == 3 && (fabs(seed->coord2()) > 100)) + address = charge * 100 * ap_ufixed(28.5205658); + if (track.step() == 2 && (fabs(seed->coord2()) > 250)) + address = charge * 250 * ap_ufixed(28.5205658); + int initialK = + int(initK_[seed->depthRegion() - 1] * address / (1 + initK2_[seed->depthRegion() - 1] * charge * address)); + if (initialK >= pow(2, BITSCURV - 1)) + initialK = pow(2, BITSCURV - 1) - 1; + if (initialK <= -pow(2, BITSCURV - 1)) + initialK = -pow(2, BITSCURV - 1) + 1; + track.setCoordinates(seed->depthRegion(), initialK, seed->coord1(), phiB); + if (seed->quality() < 6) { + track.setCoordinates(seed->depthRegion(), initialK, seed->coord1(), 0); + } + if (verbose_) { + edm::LogInfo("KMTFCore") << "Initial state: phiB=" << phiB << " addr=" << address << " K=" << initialK; + } + track.setHitPattern(hitPattern(track)); + //set covariance + l1t::KMTFTrack::CovarianceMatrix covariance; + float DK = curvResolution1_[track.step() - 1] + curvResolution2_[track.step() - 1] * initialK * initialK; + if (seed->quality() < 6) + DK = pow(2, 22); + // DK = pow(2,24); + covariance(0, 0) = DK * 4; + covariance(0, 1) = 0; + covariance(0, 2) = 0; + covariance(1, 0) = 0; + covariance(1, 1) = float(pointResolutionPhi_); + covariance(1, 2) = 0; + covariance(2, 0) = 0; + covariance(2, 1) = 0; + if (!(mask == 1 || mask == 2 || mask == 3 || mask == 4 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || + mask == 12)) + covariance(2, 2) = float(pointResolutionPhiB_); + else { + if (seed->quality() < 6) + covariance(2, 2) = float(pointResolutionPhiBL_[seed->depthRegion() - 1]); + else + covariance(2, 2) = float(pointResolutionPhiBH_[seed->depthRegion() - 1]); + } + track.setCovariance(covariance); + + // + if (verbose_) { + edm::LogInfo("KMTFCore") << "New Kalman fit staring at step=" << track.step() << ", phi=" << track.positionAngle() + << ", phiB=" << track.bendingAngle() << ", with curvature=" << track.curvature(); + edm::LogInfo("KMTFCore") << "BITMASK:" << std::flush; + for (unsigned int i = 0; i < 4; ++i) + edm::LogInfo("KMTFCore") << getBit(mask, i) << std::flush; + edm::LogInfo("KMTFCore") << std::endl; + edm::LogInfo("KMTFCore") << "------------------------------------------------------"; + edm::LogInfo("KMTFCore") << "------------------------------------------------------"; + edm::LogInfo("KMTFCore") << "------------------------------------------------------"; + edm::LogInfo("KMTFCore") << "stubs:"; + for (const auto& stub : stubs) + edm::LogInfo("KMTFCore") << "station=" << stub->depthRegion() << " phi=" << stub->coord1() + << " phiB=" << correctedPhiB(stub) << " qual=" << stub->quality() + << " tag=" << stub->id() << " sector=" << stub->phiRegion() + << " wheel=" << stub->etaRegion() << " fineEta= " << stub->eta1() << " " + << stub->eta2(); + edm::LogInfo("KMTFCore") << "------------------------------------------------------"; + edm::LogInfo("KMTFCore") << "------------------------------------------------------"; + } + + bool passedU = false; + bool passedV = false; + while (track.step() > 0) { + // muon station 1 + if (track.step() == 1) { + track.setCoordinatesAtMuon(track.curvature(), track.positionAngle(), track.bendingAngle()); + passedU = estimateChiSquare(track, false); + setRank(track, false); + + if (verbose_) + edm::LogInfo("KMTFCore") << "Calculated Chi2 for displaced track =" << track.approxDispChi2() + << " Passed Cut=" << passedU; + calculateEta(track); + setFourVectors(track); + //calculate coarse eta + ////////////////////// + if (verbose_) + edm::LogInfo("KMTFCore") << "Unconstrained PT in Muon System: pt=" << track.displacedP4().pt(); + calculateEta(track); + } + + propagate(track); + if (verbose_) + edm::LogInfo("KMTFCore") << "propagated Coordinates step:" << track.step() << "phi=" << track.positionAngle() + << "phiB=" << track.bendingAngle() << "K=" << track.curvature(); + if (track.step() > 0) + if (getBit(mask, track.step() - 1)) { + std::pair bestStub = match(seed, stubs, track.step()); + if (verbose_) + edm::LogInfo("KMTFCore") << "Found match =" << bestStub.first << " index=" << bestStub.second + << " number of all stubs=" << stubs.size(); + + if ((!bestStub.first) || (!update(track, stubs[bestStub.second], mask, seedQual))) + break; + if (verbose_) { + edm::LogInfo("KMTFCore") << "updated Coordinates step:" << track.step() << " phi=" << track.positionAngle() + << " phiB=" << track.bendingAngle() << " K=" << track.curvature(); + } + } + + if (track.step() == 0) { + track.setCoordinatesAtVertex(track.curvature(), track.positionAngle(), track.bendingAngle()); + if (verbose_) + edm::LogInfo("KMTFCore") << " Coordinates before vertex constraint step:" << track.step() + << " phi=" << track.phiAtVertex() << " dxy=" << track.dxy() + << " K=" << track.curvatureAtVertex(); + + //apply vertex constraint for non single tracks + if (track.stubs().size() > 1) + vertexConstraint(track); + + passedV = estimateChiSquare(track, true); + setRank(track, true); + + if (verbose_) + edm::LogInfo("KMTFCore") << "Calculated Chi2 for prompt track =" << track.approxPromptChi2() + << " Passed Cut=" << passedV; + + if (verbose_) { + edm::LogInfo("KMTFCore") << " Coordinates after vertex constraint step:" << track.step() + << " phi=" << track.phiAtVertex() << " dxy=" << track.dxy() + << " K=" << track.curvatureAtVertex() + << " maximum local chi2=" << track.approxPromptChi2(); + edm::LogInfo("KMTFCore") << "------------------------------------------------------"; + edm::LogInfo("KMTFCore") << "------------------------------------------------------"; + } + setFourVectors(track); + //finally set the displaced or prompt ID + track.setIDFlag(passedV, passedU); + + if (verbose_) + edm::LogInfo("KMTFCore") << "Floating point coordinates at vertex: pt=" << track.pt() + << ", eta=" << track.eta() << " phi=" << track.phi(); + + pretracks.push_back(track); + } + } + } + if (verbose_) { + if (!pretracks.empty()) + edm::LogInfo("KMTFCore") << "-----Kalman Algo at station " << seed->depthRegion() << " (uncleaned)-----"; + for (const auto& track : pretracks) + edm::LogInfo("KMTFCore") << "Kalman Track charge=" << track.charge() << " pt=" << track.pt() + << " hit pattern = " << track.hitPattern() << " eta=" << track.eta() + << " phi=" << track.phi() << " curvature=" << track.curvatureAtVertex() + << " curvature STA =" << track.curvatureAtMuon() + << " stubs=" << int(track.stubs().size()) << " chi2=" << track.approxPromptChi2() << "," + << track.approxDispChi2() << " rank=" << track.rankPrompt() << "," << track.rankDisp() + << " pts=" << track.pt() << " " << track.displacedP4().pt() << " ID=" << track.id(); + } + //Now for all the pretracks we need only one vertex constrained and one vertex unconstrained + //so we clean twice + if (verbose_) + edm::LogInfo("KMTFCore") << "Chain Reconstructed " << pretracks.size() + << " pretracks, now cleaning them separately"; + + std::vector cleanedPrompt = clean(pretracks, seed->depthRegion(), true); + std::vector cleanedDisp = clean(pretracks, seed->depthRegion(), false); + if (verbose_) + edm::LogInfo("KMTFCore") << "Cleaned Chain tracks prompt=" << cleanedPrompt.size() + << " displaced=" << cleanedDisp.size(); + + if (cleanedPrompt.empty() && cleanedDisp.empty()) + return std::make_pair(nullTrack, nullTrack); + else if ((!cleanedPrompt.empty()) && cleanedDisp.empty()) + return std::make_pair(cleanedPrompt[0], nullTrack); + else if (cleanedPrompt.empty() && (!cleanedDisp.empty())) + return std::make_pair(nullTrack, cleanedDisp[0]); + else + return std::make_pair(cleanedPrompt[0], cleanedDisp[0]); +} + +std::vector KMTFCore::clean(const std::vector& tracks, uint seed, bool vertex) { + std::vector out; + + std::map infoRank; + std::map infoTrack; + for (uint i = 1; i <= 15; ++i) { + infoRank[i] = -1; + } + + for (const auto& track : tracks) { + if (vertex) { + if ((track.id() & 0x1) == 0) + continue; + if (verbose_) + edm::LogInfo("KMTFCore") << "Chain Cleaning : Pre Track = pattern = " << track.rankPrompt() + << " rank=" << track.hitPattern(); + infoRank[track.hitPattern()] = track.rankPrompt(); + infoTrack[track.hitPattern()] = track; + + } else { + if ((track.id() & 0x2) == 0) + continue; + infoRank[track.hitPattern()] = track.rankDisp(); + infoTrack[track.hitPattern()] = track; + } + } + + int selected = 15; + if (seed == 4) //station 4 seeded + { + int sel6 = infoRank[10] >= infoRank[12] ? 10 : 12; + int sel5 = infoRank[14] >= infoRank[9] ? 14 : 9; + int sel4 = infoRank[11] >= infoRank[13] ? 11 : 13; + int sel3 = infoRank[sel6] >= infoRank[sel5] ? sel6 : sel5; + int sel2 = infoRank[sel4] >= infoRank[sel3] ? sel4 : sel3; + int sel1 = infoRank[15] >= infoRank[sel2] ? 15 : sel2; + if (vertex) + selected = infoRank[sel1] > 0 ? sel1 : 8; + else + selected = sel1; + } + if (seed == 3) //station 3 seeded + { + int sel2 = infoRank[5] >= infoRank[6] ? 5 : 6; + int sel1 = infoRank[7] >= infoRank[sel2] ? 7 : sel2; + if (vertex) + selected = infoRank[sel1] > 0 ? sel1 : 4; + else + selected = sel1; + } + if (seed == 2) //station 2 seeded + { + if (vertex) + selected = infoRank[3] > 0 ? 3 : 2; + else + selected = 3; + } + if (seed == 1) //station 1 seeded + selected = 1; + + auto search = infoTrack.find(selected); + if (search != infoTrack.end()) + out.push_back(search->second); + + return out; +} + +std::pair KMTFCore::match(const l1t::MuonStubRef& seed, const l1t::MuonStubRefVector& stubs, int step) { + l1t::MuonStubRefVector selected; + std::map diffInfo; + for (uint i = 0; i < 32; ++i) { + diffInfo[i] = 60000; + } + + int wheel = seed->etaRegion(); + int innerWheel = 0; + if (wheel == -2) + innerWheel = -1; + if (wheel == -1) + innerWheel = 0; + if (wheel == 0) + innerWheel = 1982; + if (wheel == 1) + innerWheel = 0; + if (wheel == 2) + innerWheel = 1; + //calculate the distance of all stubs + + for (unsigned int N = 0; N < stubs.size(); ++N) { + const l1t::MuonStubRef& stub = stubs[N]; + //Should not be stubs with tag=4 but there are, so skip those + if (verbose_) + edm::LogInfo("KMTFCore") << "testing stub on depth=" << stub->depthRegion() << " for step=" << step; + + if (stub->depthRegion() != step) + continue; + if (verbose_) + edm::LogInfo("KMTFCore") << "Passed"; + + uint distance = fabs(wrapAround((seed->coord1() - stub->coord1()) >> 3, 32768)); + //if the wheels are not adjacent make this huge + if (!((stub->etaRegion() == wheel) || (stub->etaRegion() == innerWheel))) + distance = 60000; + + diffInfo[N] = distance; + } + + uint s1_1 = matchAbs(diffInfo, 0, 1); + uint s1_2 = matchAbs(diffInfo, 2, 3); + uint s1_3 = matchAbs(diffInfo, 4, 5); + uint s1_4 = matchAbs(diffInfo, 6, 7); + uint s1_5 = matchAbs(diffInfo, 8, 9); + uint s1_6 = matchAbs(diffInfo, 10, 11); + uint s1_7 = matchAbs(diffInfo, 12, 13); + uint s1_8 = matchAbs(diffInfo, 14, 15); + uint s1_9 = matchAbs(diffInfo, 16, 17); + uint s1_10 = matchAbs(diffInfo, 18, 19); + uint s1_11 = matchAbs(diffInfo, 20, 21); + uint s1_12 = matchAbs(diffInfo, 22, 23); + uint s1_13 = matchAbs(diffInfo, 24, 25); + uint s1_14 = matchAbs(diffInfo, 26, 27); + uint s1_15 = matchAbs(diffInfo, 28, 29); + uint s1_16 = matchAbs(diffInfo, 30, 31); + + uint s2_1 = matchAbs(diffInfo, s1_1, s1_2); + uint s2_2 = matchAbs(diffInfo, s1_3, s1_4); + uint s2_3 = matchAbs(diffInfo, s1_5, s1_6); + uint s2_4 = matchAbs(diffInfo, s1_7, s1_8); + uint s2_5 = matchAbs(diffInfo, s1_9, s1_10); + uint s2_6 = matchAbs(diffInfo, s1_11, s1_12); + uint s2_7 = matchAbs(diffInfo, s1_13, s1_14); + uint s2_8 = matchAbs(diffInfo, s1_15, s1_16); + + uint s3_1 = matchAbs(diffInfo, s2_1, s2_2); + uint s3_2 = matchAbs(diffInfo, s2_3, s2_4); + uint s3_3 = matchAbs(diffInfo, s2_5, s2_6); + uint s3_4 = matchAbs(diffInfo, s2_7, s2_8); + + uint s4_1 = matchAbs(diffInfo, s3_1, s3_2); + uint s4_2 = matchAbs(diffInfo, s3_3, s3_4); + + uint s5 = matchAbs(diffInfo, s4_1, s4_2); + + if (diffInfo[s5] != 60000) + return std::make_pair(true, s5); + else + return std::make_pair(false, 0); +} + +int KMTFCore::correctedPhiB(const l1t::MuonStubRef& stub) { + return ap_fixed(ap_ufixed(28.5205658) * + stub->coord2()); +} + +void KMTFCore::propagate(l1t::KMTFTrack& track) { + int K = track.curvature(); + int phi = track.positionAngle(); + int phiB = track.bendingAngle(); + unsigned int step = track.step(); + + int charge = 1; + if (K != 0) + charge = K / fabs(K); + + int KBound = K; + if (KBound > pow(2, BITSCURV - 3) - 1) + KBound = pow(2, BITSCURV - 3) - 1; + if (KBound < -(pow(2, BITSCURV - 3) - 1)) + KBound = -(pow(2, BITSCURV - 3) - 1); + + int deltaK = 0; + int KNew = K; + if (step == 1) { + ap_ufixed<17, 0> eLoss = ap_ufixed<17, 0>(eLoss_[step - 1]); + ap_fixed Kint = ap_fixed(KBound); + ap_fixed<16, 5> eK = eLoss * Kint; + if (charge < 0) + eK = -eK; + ap_fixed KnewInt = ap_fixed(K) - eK * Kint; + KNew = KnewInt; + if (verbose_) + edm::LogInfo("KMTFCore") << "propagate to vertex Kint=" << Kint.to_int() << " ek=" << eK.to_float() + << " Knew=" << KNew; + } + + //phi propagation + ap_fixed phi11 = ap_fixed(aPhi_[step - 1]) * ap_fixed(K); + ap_fixed phi12 = + ap_fixed(-bPhi_[step - 1]) * ap_fixed(phiB); + + if (verbose_) { + edm::LogInfo("KMTFCore") << "phi prop = " << K << " * " << ap_fixed(aPhi_[step - 1]).to_float() + << " = " << phi11.to_int() << ", " << phiB << " * " + << ap_fixed(-bPhi_[step - 1]).to_float() << " = " << phi12.to_int(); + } + int phiNew = ap_fixed(phi + phi11 + phi12); + + //phiB propagation + ap_fixed phiB11 = ap_fixed(aPhiB_[step - 1]) * ap_fixed(K); + ap_fixed phiB12 = + ap_ufixed(bPhiB_[step - 1]) * ap_fixed(phiB); + int phiBNew = ap_fixed(phiB11 + phiB12); + if (verbose_) { + edm::LogInfo("KMTFCore") << "phiB prop = " << K << " * " << ap_fixed(aPhiB_[step - 1]).to_float() + << " = " << phiB11.to_int() << ", " << phiB << " * " + << ap_ufixed(bPhiB_[step - 1]).to_float() << " = " << phiB12.to_int(); + } + + //Only for the propagation to vertex we use second order; + if (step == 1) { + ap_fixed<10, 4> aPhiB = aPhiB_[step - 1]; + ap_ufixed<16, 0> aPhiBNLO = aPhiBNLO_[step - 1]; + + ap_fixed Kint = ap_fixed(KBound); + ap_fixed aK = aPhiB * Kint; + ap_fixed<16, 5> eK = aPhiBNLO * Kint; + if (charge < 0) + eK = -eK; + ap_fixed DXY = aK + eK * Kint; + //ap_fixed diff = DXY - ap_fixed(phiB); + + ap_fixed diff = DXY - ap_fixed(phiB); + + phiBNew = ap_fixed(diff); + if (verbose_) { + edm::LogInfo("KMTFCore") << "Vertex phiB prop = " << DXY.to_int() << "(=" << aK.to_int() << " +" + << (eK * Kint).to_int() << ") - " << ap_fixed(phiB).to_int() << " = " + << phiBNew; + } + } + /////////////////////////////////////////////////////// + //Rest of the stuff is for the offline version only + //where we want to check what is happening in the covariance matrix + + //Create the transformation matrix + double a[9]; + a[0] = 1.; + a[1] = 0.0; + a[2] = 0.0; + a[3] = aPhi_[step - 1]; + // a[3] = 0.0; + a[4] = 1.0; + a[5] = -bPhi_[step - 1]; + //a[6]=0.0; + a[6] = aPhiB_[step - 1]; + if (step == 1) + a[6] = aPhiB_[step - 1] / 2.0; + + a[7] = 0.0; + a[8] = bPhiB_[step - 1]; + + ROOT::Math::SMatrix P(a, 9); + + const std::vector& covLine = track.covariance(); + l1t::KMTFTrack::CovarianceMatrix cov(covLine.begin(), covLine.end()); + cov = ROOT::Math::Similarity(P, cov); + + //Add the multiple scattering + double phiRMS = mScatteringPhi_[step - 1] * K * K; + double phiBRMS = mScatteringPhiB_[step - 1] * K * K; + + std::vector b(6); + b[0] = 0; + b[1] = 0; + b[2] = phiRMS; + b[3] = 0; + b[4] = 0; + b[5] = phiBRMS; + + reco::Candidate::CovarianceMatrix MS(b.begin(), b.end()); + + cov = cov + MS; + + if (verbose_) { + edm::LogInfo("KMTFCore") << "Covariance term for phiB = " << cov(2, 2); + edm::LogInfo("KMTFCore") << "Multiple scattering term for phiB = " << MS(2, 2); + } + + track.setCovariance(cov); + track.setCoordinates(step - 1, KNew, phiNew, phiBNew); +} + +bool KMTFCore::update(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub, int mask, int seedQual) { + // updateEta(track, stub); + if (useOfflineAlgo_) { + if (mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12) + return updateOffline(track, stub); + else + return updateOffline1D(track, stub); + + } else + return updateLUT(track, stub, mask, seedQual); +} + +bool KMTFCore::updateOffline(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub) { + int trackK = track.curvature(); + int trackPhi = track.positionAngle(); + int trackPhiB = track.bendingAngle(); + + int phi = stub->coord1(); + int phiB = correctedPhiB(stub); + + Vector2 residual; + residual[0] = ap_fixed(phi - trackPhi); + residual[1] = phiB - trackPhiB; + + Matrix23 H; + H(0, 0) = 0.0; + H(0, 1) = 1.0; + H(0, 2) = 0.0; + H(1, 0) = 0.0; + H(1, 1) = 0.0; + H(1, 2) = 1.0; + + CovarianceMatrix2 R; + R(0, 0) = pointResolutionPhi_; + R(0, 1) = 0.0; + R(1, 0) = 0.0; + if (stub->quality() < 6) + R(1, 1) = pointResolutionPhiBL_[track.step() - 1]; + else + R(1, 1) = pointResolutionPhiBH_[track.step() - 1]; + + const std::vector& covLine = track.covariance(); + l1t::KMTFTrack::CovarianceMatrix cov(covLine.begin(), covLine.end()); + CovarianceMatrix2 S = ROOT::Math::Similarity(H, cov) + R; + if (!S.Invert()) + return false; + Matrix32 Gain = cov * ROOT::Math::Transpose(H) * S; + + track.setKalmanGain( + track.step(), fabs(trackK), Gain(0, 0), Gain(0, 1), Gain(1, 0), Gain(1, 1), Gain(2, 0), Gain(2, 1)); + + int KNew = (trackK + int(Gain(0, 0) * residual(0) + Gain(0, 1) * residual(1))); + if (fabs(KNew) > pow(2, BITSCURV - 1)) + return false; + + int phiNew = wrapAround(trackPhi + residual(0), pow(2, BITSPHI - 1)); + int phiBNew = wrapAround(trackPhiB + int(Gain(2, 0) * residual(0) + Gain(2, 1) * residual(1)), pow(2, BITSPHIB - 1)); + + track.setResidual(stub->depthRegion() - 1, fabs(phi - phiNew) + fabs(phiB - phiBNew)); + + if (verbose_) { + edm::LogInfo("KMTFCore") << "residual " << phi << " - " << trackPhi << " = " << int(residual[0]) << " " << phiB + << " - " << trackPhiB << " = " << int(residual[1]); + edm::LogInfo("KMTFCore") << "Gains offline: " << Gain(0, 0) << " " << Gain(0, 1) << " " << Gain(2, 0) << " " + << Gain(2, 1); + edm::LogInfo("KMTFCore") << " K = " << trackK << " + " << Gain(0, 0) << " * " << residual(0) << " + " << Gain(0, 1) + << " * " << residual(1); + edm::LogInfo("KMTFCore") << " phiB = " << trackPhiB << " + " << Gain(2, 0) << " * " << residual(0) << " + " + << Gain(2, 1) << " * " << residual(1); + } + + track.setCoordinates(track.step(), KNew, phiNew, phiBNew); + Matrix33 covNew = cov - Gain * (H * cov); + l1t::KMTFTrack::CovarianceMatrix c; + + c(0, 0) = covNew(0, 0); + c(0, 1) = covNew(0, 1); + c(0, 2) = covNew(0, 2); + c(1, 0) = covNew(1, 0); + c(1, 1) = covNew(1, 1); + c(1, 2) = covNew(1, 2); + c(2, 0) = covNew(2, 0); + c(2, 1) = covNew(2, 1); + c(2, 2) = covNew(2, 2); + if (verbose_) { + edm::LogInfo("KMTFCore") << "Post Fit Covariance Matrix " << cov(0, 0) << " " << cov(1, 1) << " " << cov(2, 2); + } + + track.setCovariance(c); + track.addStub(stub); + track.setHitPattern(hitPattern(track)); + + return true; +} + +bool KMTFCore::updateOffline1D(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub) { + int trackK = track.curvature(); + int trackPhi = track.positionAngle(); + int trackPhiB = track.bendingAngle(); + + int phi = stub->coord1(); + + double residual = ap_fixed(phi - trackPhi); + + if (verbose_) + edm::LogInfo("KMTFCore") << "residuals " << phi << " - " << trackPhi << " = " << int(residual); + + Matrix13 H; + H(0, 0) = 0.0; + H(0, 1) = 1.0; + H(0, 2) = 0.0; + + const std::vector& covLine = track.covariance(); + l1t::KMTFTrack::CovarianceMatrix cov(covLine.begin(), covLine.end()); + + double S = ROOT::Math::Similarity(H, cov)(0, 0) + pointResolutionPhi_; + if (S == 0.0) + return false; + Matrix31 Gain = cov * ROOT::Math::Transpose(H) / S; + + track.setKalmanGain(track.step(), fabs(trackK), Gain(0, 0), 0.0, Gain(1, 0), 0.0, Gain(2, 0), 0.0); + + int KNew = wrapAround(trackK + int(Gain(0, 0) * residual), pow(2, BITSCURV - 1)); + int phiNew = wrapAround(trackPhi + residual, pow(2, BITSPHI - 1)); + int phiBNew = wrapAround(trackPhiB + int(Gain(2, 0) * residual), pow(2, BITSPHIB - 1)); + track.setCoordinates(track.step(), KNew, phiNew, phiBNew); + Matrix33 covNew = cov - Gain * (H * cov); + l1t::KMTFTrack::CovarianceMatrix c; + + if (verbose_) { + edm::LogInfo("KMTFCore") << "phiUpdate: " << int(Gain(0, 0) * residual) << " " << int(Gain(2, 0) * residual); + edm::LogInfo("KMTFCore") << " K = " << trackK << " + " << Gain(0, 0) << " * " << residual; + edm::LogInfo("KMTFCore") << " phiBNew = " << trackPhiB << " + " << Gain(2, 0) << " * " << residual; + } + + c(0, 0) = covNew(0, 0); + c(0, 1) = covNew(0, 1); + c(0, 2) = covNew(0, 2); + c(1, 0) = covNew(1, 0); + c(1, 1) = covNew(1, 1); + c(1, 2) = covNew(1, 2); + c(2, 0) = covNew(2, 0); + c(2, 1) = covNew(2, 1); + c(2, 2) = covNew(2, 2); + track.setCovariance(c); + track.addStub(stub); + track.setHitPattern(hitPattern(track)); + + return true; +} + +bool KMTFCore::updateLUT(l1t::KMTFTrack& track, const l1t::MuonStubRef& stub, int mask, int seedQual) { + int trackK = track.curvature(); + int trackPhi = track.positionAngle(); + int trackPhiB = track.bendingAngle(); + + int phi = stub->coord1(); + int phiB = correctedPhiB(stub); + + Vector2 residual; + ap_fixed residualPhi = phi - trackPhi; + ap_fixed residualPhiB = phiB - trackPhiB; + + if (verbose_) + edm::LogInfo("KMTFCore") << "residual " << phi << " - " << trackPhi << " = " << residualPhi.to_int() << " " << phiB + << " - " << trackPhiB << " = " << residualPhiB.to_int(); + + uint absK = fabs(trackK); + if (absK > pow(2, BITSCURV - 2) - 1) + absK = pow(2, BITSCURV - 2) - 1; + + std::vector GAIN; + if (verbose_) { + edm::LogInfo("KMTFCore") << "Looking up LUTs for mask=" << mask << " with hit pattern=" << track.hitPattern(); + } + //For the three stub stuff use only gains 0 and 4 + if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) { + GAIN = lutService_->trackGain(track.step(), track.hitPattern(), absK / 16); + GAIN[1] = 0.0; + GAIN[3] = 0.0; + + } else { + GAIN = lutService_->trackGain2(track.step(), track.hitPattern(), absK / 32, seedQual, stub->quality()); + } + if (verbose_) { + edm::LogInfo("KMTFCore") << "Gains (fp): " << GAIN[0] << " " << GAIN[1] << " " << GAIN[2] << " " << GAIN[3]; + + if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) + edm::LogInfo("KMTFCore") << "Addr=" << absK / 16 + << " gain0=" << ap_ufixed(GAIN[0]).to_float() << " gain4=-" + << ap_ufixed(GAIN[2]).to_float(); + else + edm::LogInfo("KMTFCore") << "Addr=" << absK / 32 << " " << ap_ufixed(GAIN[0]).to_float() + << " -" << ap_ufixed(GAIN[1]).to_float() << " " + << ap_ufixed(GAIN[2]).to_float() << " " + << ap_ufixed(GAIN[3]).to_float(); + } + + track.setKalmanGain(track.step(), fabs(trackK), GAIN[0], GAIN[1], 1, 0, GAIN[2], GAIN[3]); + + int KNew; + if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) { + KNew = ap_fixed(ap_fixed(trackK) + + ap_ufixed(GAIN[0]) * residualPhi); + if (verbose_) { + edm::LogInfo("KMTFCore") << "K = " << KNew << " = " << ap_fixed(trackK).to_int() << " + " + << ap_ufixed(GAIN[0]).to_float() << "*" << residualPhi.to_int(); + } + } else { + ap_fixed k11 = ap_ufixed(GAIN[0]) * residualPhi; + ap_fixed k12 = ap_ufixed(GAIN[1]) * residualPhiB; + + KNew = ap_fixed(ap_fixed(trackK) + k11 - k12); + if (verbose_) { + edm::LogInfo("KMTFCore") << "K = " << KNew << " = " << ap_fixed(trackK).to_int() << " + " + << k11.to_int() << " + " << k12.to_int(); + } + } + if ((KNew > (pow(2, BITSCURV - 1) - 1)) || (KNew < -(pow(2, BITSCURV - 1)))) { + if (verbose_) + edm::LogInfo("KMTFCore") << "K has saturated, track has extremely low energy"; + return false; + } + KNew = wrapAround(KNew, pow(2, BITSCURV - 1)); + int phiNew = phi; + + //different products for different firmware logic + ap_fixed pbdouble_0 = ap_ufixed(GAIN[2]) * residualPhi; + ap_fixed pb_1 = ap_ufixed(GAIN[3]) * residualPhiB; + ap_fixed pb_0 = ap_ufixed(GAIN[2]) * residualPhi; + + if (verbose_) { + edm::LogInfo("KMTFCore") << "phiupdate " << pb_0.to_float() << " " << pb_1.to_float() << " " + << pbdouble_0.to_float(); + } + + int phiBNew; + if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) { + phiBNew = ap_fixed(ap_fixed(trackPhiB) - + ap_ufixed(GAIN[2]) * residualPhi); + } else { + phiBNew = ap_fixed(ap_fixed(trackPhiB) + pb_1 - pbdouble_0); + } + + if ((phiBNew > (pow(2, BITSPHIB - 1) - 1)) || (phiBNew < (-pow(2, BITSPHIB - 1)))) + return false; + + track.setCoordinates(track.step(), KNew, phiNew, phiBNew); + track.addStub(stub); + track.setHitPattern(hitPattern(track)); + if (verbose_) { + edm::LogInfo("KMTFCore") << "Stub station =" << stub->depthRegion(); + + edm::LogInfo("KMTFCore") << "Updated Hit Pattern =" << track.hitPattern(); + } + + return true; +} + +void KMTFCore::vertexConstraint(l1t::KMTFTrack& track) { + if (useOfflineAlgo_) + vertexConstraintOffline(track); + else + vertexConstraintLUT(track); +} + +void KMTFCore::vertexConstraintOffline(l1t::KMTFTrack& track) { + double residual = -track.dxy(); + Matrix13 H; + H(0, 0) = 0; + H(0, 1) = 0; + H(0, 2) = 1; + + const std::vector& covLine = track.covariance(); + l1t::KMTFTrack::CovarianceMatrix cov(covLine.begin(), covLine.end()); + + double S = (ROOT::Math::Similarity(H, cov))(0, 0) + pointResolutionVertex_; + S = 1.0 / S; + Matrix31 Gain = cov * (ROOT::Math::Transpose(H)) * S; + track.setKalmanGain(track.step(), fabs(track.curvature()), Gain(0, 0), Gain(1, 0), Gain(2, 0)); + + if (verbose_) { + edm::LogInfo("KMTFCore") << "sigma3=" << cov(0, 3) << " sigma6=" << cov(3, 3); + edm::LogInfo("KMTFCore") << " K = " << track.curvature() << " + " << Gain(0, 0) << " * " << residual; + } + + int KNew = wrapAround(int(track.curvature() + Gain(0, 0) * residual), pow(2, BITSCURV - 1)); + int phiNew = wrapAround(int(track.positionAngle() + Gain(1, 0) * residual), pow(2, BITSPHI)); + int dxyNew = wrapAround(int(track.dxy() + Gain(2, 0) * residual), pow(2, BITSPHIB)); + if (verbose_) + edm::LogInfo("KMTFCore") << "Post fit impact parameter=" << dxyNew; + track.setCoordinatesAtVertex(KNew, phiNew, -residual); + Matrix33 covNew = cov - Gain * (H * cov); + l1t::KMTFTrack::CovarianceMatrix c; + c(0, 0) = covNew(0, 0); + c(0, 1) = covNew(0, 1); + c(0, 2) = covNew(0, 2); + c(1, 0) = covNew(1, 0); + c(1, 1) = covNew(1, 1); + c(1, 2) = covNew(1, 2); + c(2, 0) = covNew(2, 0); + c(2, 1) = covNew(2, 1); + c(2, 2) = covNew(2, 2); + track.setCovariance(c); + // track.covariance = track.covariance - Gain*H*track.covariance; +} + +void KMTFCore::vertexConstraintLUT(l1t::KMTFTrack& track) { + double residual = -track.dxy(); + uint absK = fabs(track.curvature()); + if (absK > pow(2, BITSCURV - 4) - 1) + absK = pow(2, BITSCURV - 4) - 1; + + std::pair GAIN = lutService_->vertexGain(track.hitPattern(), absK / 4); + track.setKalmanGain(track.step(), fabs(track.curvature()), GAIN.first, GAIN.second, -1); + + ap_fixed k_0 = + -(ap_ufixed(fabs(GAIN.first))) * ap_fixed(residual); + int KNew = ap_fixed(k_0 + ap_fixed(track.curvature())); + + if (verbose_) { + edm::LogInfo("KMTFCore") << "VERTEX GAIN(" << absK / 4 << ")= -" + << ap_ufixed(fabs(GAIN.first)).to_float() << " * " + << ap_fixed(residual).to_int() << " = " << k_0.to_int(); + } + + //int p_0 = fp_product(GAIN.second, int(residual), 7); + int p_0 = GAIN.second * int(residual); + int phiNew = wrapAround(track.positionAngle() + p_0, pow(2, BITSPHI - 1)); + track.setCoordinatesAtVertex(KNew, phiNew, -residual); +} + +int KMTFCore::hitPattern(const l1t::KMTFTrack& track) { + unsigned int mask = 0; + for (const auto& stub : track.stubs()) { + mask = mask + round(pow(2, stub->depthRegion() - 1)); + } + return mask; +} + +int KMTFCore::customBitmask(unsigned int bit1, unsigned int bit2, unsigned int bit3, unsigned int bit4) { + return bit1 * 1 + bit2 * 2 + bit3 * 4 + bit4 * 8; +} + +bool KMTFCore::getBit(int bitmask, int pos) { return (bitmask & (1 << pos)) >> pos; } + +void KMTFCore::setFourVectors(l1t::KMTFTrack& track) { + int etaINT = track.coarseEta(); + double lsbEta = M_PI / pow(2, 12); + + int charge = 1; + if (track.curvatureAtVertex() < 0) + charge = -1; + + int ptC = ptLUT(track.curvatureAtVertex()); + int ptU = ptLUT(track.curvatureAtMuon()); + + //if only one stub return the phi of the stub. + //Also set PT =0 and dxy=0 + if (track.stubs().size() == 1) { + ptC = 0; + track.setCoordinatesAtMuon(track.curvatureAtMuon(), track.stubs()[0]->coord1(), track.phiBAtMuon()); + track.setCoordinatesAtVertex(track.curvatureAtVertex(), track.phiAtVertex(), 0); + } + track.setPt(ptC, ptU); + //shift the dxy by 10 bits + track.setCoordinatesAtVertex(track.curvatureAtVertex(), track.phiAtVertex(), track.dxy() / 1024); + + //vertex + double pt = ptC * 0.03125; + double phi = (track.phiAtMuon() / 32) * M_PI / pow(2, 12); + double eta = etaINT * lsbEta; + track.setPtEtaPhi(pt, eta, phi); + track.setCharge(charge); + pt = double(ptLUT(track.curvatureAtMuon())) * 0.03125; + track.setPtEtaPhiDisplaced(pt, eta, phi); +} + +bool KMTFCore::estimateChiSquare(l1t::KMTFTrack& track, bool vertex) { + int K; + uint chi = 0; + uint chiErr = 0; + + //exception for 1 stub tracks and vertex constraint + //displaced track not allowed / prompt are allowed + if (track.stubs().size() == 1) { + if (!vertex) + return false; + else { + track.setApproxChi2(127, chiErr, vertex); + return true; + } + } + + std::vector prop; + std::vector propErrB; + std::vector propErrA; + std::vector cut; + + const l1t::MuonStubRef& innerStub = track.stubs()[track.stubs().size() - 1]; + + if (vertex) { + K = track.curvatureAtVertex(); + if (innerStub->depthRegion() == 1) { + prop = chiSquarePrompt1_; + propErrA = chiSquareErrAPrompt1_; + propErrB = chiSquareErrBPrompt1_; + } else if (innerStub->depthRegion() == 2) { + prop = chiSquarePrompt2_; + propErrA = chiSquareErrAPrompt2_; + propErrB = chiSquareErrBPrompt2_; + + } else if (innerStub->depthRegion() == 3) { + prop = chiSquarePrompt3_; + propErrA = chiSquareErrAPrompt3_; + propErrB = chiSquareErrBPrompt3_; + } + } else { + K = track.curvatureAtMuon(); + if (innerStub->depthRegion() == 1) { + prop = chiSquareDisp1_; + propErrA = chiSquareErrADisp1_; + propErrB = chiSquareErrBDisp1_; + + } else if (innerStub->depthRegion() == 2) { + prop = chiSquareDisp2_; + propErrA = chiSquareErrADisp2_; + propErrB = chiSquareErrBDisp2_; + + } else if (innerStub->depthRegion() == 3) { + prop = chiSquareDisp3_; + propErrA = chiSquareErrADisp3_; + propErrB = chiSquareErrBDisp3_; + } + } + + ap_fixed Kdig = K; + ap_fixed Kshifted = Kdig >> 4; + ap_ufixed absK = 0; + + if (Kshifted < 0) + absK = (-Kshifted); + else + absK = (Kshifted); + + for (unsigned int i = 0; i < (track.stubs().size() - 1); i++) { + const l1t::MuonStubRef& stub = track.stubs()[i]; + + int diffPhi = ap_fixed(stub->coord1() - innerStub->coord1()) >> 4; + int diffPhiB = ap_fixed(correctedPhiB(stub) - correctedPhiB(innerStub)) >> 4; + if (vertex) + diffPhiB = 0; + + if (verbose_) + edm::LogInfo("KMTFCore") << "Error propagation coefficients A=" + << propErrA[stub->depthRegion() - innerStub->depthRegion() - 1] + << " B=" << propErrB[stub->depthRegion() - innerStub->depthRegion() - 1] << " BK = " + << uint(ap_fixed<8, 2>(propErrB[stub->depthRegion() - innerStub->depthRegion() - 1]) * + (absK >> 4)); + uint positionError = propErrA[stub->depthRegion() - innerStub->depthRegion() - 1]; + if (stub->quality() < 6 || innerStub->quality() < 6) + positionError = positionError * 2; + + uint err = + positionError + uint(ap_fixed<8, 2>(propErrB[stub->depthRegion() - innerStub->depthRegion() - 1]) * absK); + ap_fixed<8, 2> propC = ap_fixed<8, 2>(prop[stub->depthRegion() - innerStub->depthRegion() - 1]); + ap_fixed AK = -propC * Kshifted; + int delta = diffPhi + diffPhiB + AK; + uint absDelta = delta < 0 ? -delta : delta; + chi = chi + absDelta; + chiErr = chiErr + err; + if (verbose_) { + edm::LogInfo("KMTFCore") << "Chi Square stub for track with pattern=" << track.hitPattern() + << " inner stub depth=" << innerStub->depthRegion() << "-> AK=" << int(AK) + << " stubDepth=" << stub->depthRegion() << " diff1=" << diffPhi << " diff2=" << diffPhiB + << " delta=" << absDelta << " absK=" << uint(absK) << " err=" << err; + } + } + if (verbose_) { + edm::LogInfo("KMTFCore") << "Chi Square =" << chi << " ChiSquare Error = " << chiErr; + } + + track.setApproxChi2(chi, chiErr, vertex); + if (chi > chiErr) + return false; + return true; +} + +void KMTFCore::setRank(l1t::KMTFTrack& track, bool vertex) { + uint chi = 0; + if (vertex) + chi = track.approxPromptChi2() > 127 ? 127 : track.approxPromptChi2(); + else + chi = track.approxDispChi2() > 127 ? 127 : track.approxDispChi2(); + + uint Q = 0; + for (const auto& stub : track.stubs()) { + if (stub->quality() > 2) + Q = Q + 2; + else + Q = Q + 1; + } + uint rank = Q * 4 - chi + 125; + + //exception for track 1100 + if (hitPattern(track) == customBitmask(0, 0, 1, 1)) { + rank = 1; + } + + //Exception for one stub tracks. + if (track.stubs().size() == 1) + rank = 0; + + if (verbose_) + edm::LogInfo("KMTFCore") << "Rank Calculated for vertex=" << vertex << " = " << rank; + track.setRank(rank, vertex); +} + +int KMTFCore::wrapAround(int value, int maximum) { + if (value > maximum - 1) + return wrapAround(value - 2 * maximum, maximum); + if (value < -maximum) + return wrapAround(value + 2 * maximum, maximum); + return value; +} + +int KMTFCore::encode(bool ownwheel, int sector, int tag) { + int wheel = ownwheel ? 1 : 0; + int phi = 0; + if (sector == 1) + phi = 1; + if (sector == -1) + phi = 2; + int addr = (wheel << 4) + (phi << 2) + tag; + return addr; +} + +std::pair KMTFCore::getByCode(const std::vector& tracks, int mask) { + for (uint i = 0; i < tracks.size(); ++i) { + edm::LogInfo("KMTFCore") << "Code=" << tracks[i].hitPattern() << ", track=" << mask; + if (tracks[i].hitPattern() == mask) + return std::make_pair(true, i); + } + return std::make_pair(false, 0); +} + +uint KMTFCore::twosCompToBits(int q) { + if (q >= 0) + return q; + else + return (~q) + 1; +} + +uint KMTFCore::etaStubRank(const l1t::MuonStubRef& stub) { + if (stub->etaQuality() == 3) + return 0; + if (stub->etaQuality() == 0) + return 0; + return (stub->etaQuality()); +} + +void KMTFCore::calculateEta(l1t::KMTFTrack& track) { + uint pattern = track.hitPattern(); + int wheel = track.stubs()[0]->etaRegion(); + uint awheel = fabs(wheel); + int sign = 1; + if (wheel < 0) + sign = -1; + uint nstubs = track.stubs().size(); + if (nstubs <= 1) { + track.setCoarseEta(0); + return; + } + uint mask = 0; + + for (unsigned int i = 0; i < track.stubs().size(); ++i) { + mask = mask | ((uint(fabs(track.stubs()[i]->etaRegion()) + 1) << (2 * (track.stubs()[i]->depthRegion() - 1)))); + } + if (verbose_) + edm::LogInfo("KMTFCore") << "Mask = " << mask; + + track.setCoarseEta(sign * lutService_->coarseEta(mask)); + if (verbose_) + edm::LogInfo("KMTFCore") << "Coarse Eta mask=" << mask << " set = " << sign * lutService_->coarseEta(mask); + track.setFineEta(0); +} + +uint KMTFCore::matchAbs(std::map& info, uint i, uint j) { + if (info[i] < info[j]) + return i; + else + return j; +} + +int KMTFCore::ptLUT(int K) { + int charge = (K >= 0) ? +1 : -1; + float lsb = 1.25 / float(1 << (BITSCURV - 1)); + float FK = fabs(K); + int pt = 0; + if (FK > 8191) + FK = 8191; + if (FK < 103) + FK = 103; + FK = FK * lsb; + if (FK == 0) { + pt = 8191; + } else { + float ptF = 1.0 / FK; //ct + pt = int(ptF / 0.03125); + } + + return pt; +} diff --git a/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTBarrelStubProcessor.cc b/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTBarrelStubProcessor.cc index 6e29a5440c4c2..80f565827c9ca 100644 --- a/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTBarrelStubProcessor.cc +++ b/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTBarrelStubProcessor.cc @@ -3,6 +3,8 @@ #include #include #include +#include +#include L1TPhase2GMTBarrelStubProcessor::L1TPhase2GMTBarrelStubProcessor() : minPhiQuality_(0), minBX_(-3), maxBX_(3) {} @@ -74,17 +76,18 @@ l1t::MuonStub L1TPhase2GMTBarrelStubProcessor::buildStubNoEta(const L1Phase2MuDT int sign = wheel > 0 ? 1 : -1; int sector = phiS.scNum(); int station = phiS.stNum(); - double globalPhi = (sector * 30) + phiS.phi() * 30. / 65535.; - if (globalPhi < -180) - globalPhi += 360; - if (globalPhi > 180) - globalPhi -= 360; - globalPhi = globalPhi * M_PI / 180.; - int phi = int(globalPhi / phiLSB_) + phiOffset_[station - 1]; - int phiB = phiS.phiBend() / phiBFactor_; - uint tag = phiS.index(); + + ap_uint<18> normalization0 = sector * ap_uint<15>(21845); + ap_int<18> normalization1 = ap_int<18>(ap_int<17>(phiS.phi()) * ap_ufixed<8, 0>(0.3183)); + ap_int<18> kmtf_phi = ap_int<18>(normalization0 + normalization1); + int phi = int(kmtf_phi); + float globalPhi = phi * M_PI / (1 << 17); + + // double globalPhi = (sector * 30) + phiS.phi() * 30. / 65535.; + int tag = phiS.index(); + int bx = phiS.bxNum() - 20; - int quality = 3; + int quality = phiS.quality(); uint tfLayer = phiS.stNum() - 1; int eta = -16384; if (station == 1) { @@ -103,8 +106,9 @@ l1t::MuonStub L1TPhase2GMTBarrelStubProcessor::buildStubNoEta(const L1Phase2MuDT //Now full eta eta = eta * sign; - l1t::MuonStub stub(wheel, sector, station, tfLayer, phi, phiB, tag, bx, quality, eta, 0, 0, 1); - stub.setOfflineQuantities(globalPhi, float(phiB), eta * etaLSB_, 0.0); + l1t::MuonStub stub(wheel, sector, station, tfLayer, phi, phiS.phiBend(), tag, bx, quality, eta, 0, 0, 1); + + stub.setOfflineQuantities(globalPhi, float(phiS.phiBend() * 0.49e-3), eta * etaLSB_, 0.0); return stub; } @@ -112,6 +116,9 @@ l1t::MuonStubCollection L1TPhase2GMTBarrelStubProcessor::makeStubs(const L1Phase const L1MuDTChambThContainer* etaContainer) { l1t::MuonStubCollection out; for (int bx = minBX_; bx <= maxBX_; bx++) { + ostringstream os; + if (verbose_ == 2) + os << "PATTERN "; for (int wheel = -2; wheel <= 2; wheel++) { for (int sector = 0; sector < 12; sector++) { for (int station = 1; station < 5; station++) { @@ -127,6 +134,24 @@ l1t::MuonStubCollection L1TPhase2GMTBarrelStubProcessor::makeStubs(const L1Phase continue; if (phiDigi.quality() < minPhiQuality_) continue; + + if (verbose_ == 2) { + ap_uint<64> wphi = ap_uint<17>(phiDigi.phi()); + ap_uint<64> wphib = ap_uint<13>(phiDigi.phiBend()); + ap_uint<64> wr1 = ap_uint<21>(0); + ap_uint<64> wq = ap_uint<4>(phiDigi.quality()); + ap_uint<64> wr2 = ap_uint<9>(0); + ap_uint<64> sN = 0; + sN = sN | wphi; + sN = sN | (wphib << 17); + sN = sN | (wr1 << 30); + sN = sN | (wq << 51); + sN = sN | (wr2 << 55); + unsigned int index = (station - 1) * 4 + phiDigi.index(); + os << std::setw(0) << std::dec << sector << " " << wheel << " " << station << " "; + os << std::uppercase << std::setfill('0') << std::setw(16) << std::hex << uint64_t(sN) << " "; + } + if (hasEta) { out.push_back(buildStub(phiDigi, tseta)); } else { @@ -136,29 +161,20 @@ l1t::MuonStubCollection L1TPhase2GMTBarrelStubProcessor::makeStubs(const L1Phase } } } + if (verbose_ == 2) + edm::LogInfo("BarrelStub") << os.str() << std::endl; } if (verbose_) { - printf("Barrel Stubs\n"); + edm::LogInfo("BarrelStub") << "Barrel Stubs"; for (const auto& stub : out) - printf( - "Barrel Stub bx=%d TF=%d etaRegion=%d phiRegion=%d depthRegion=%d coord1=%f,%d coord2=%f,%d eta1=%f,%d " - "eta2=%f,%d quality=%d etaQuality=%d\n", - stub.bxNum(), - stub.tfLayer(), - stub.etaRegion(), - stub.phiRegion(), - stub.depthRegion(), - stub.offline_coord1(), - stub.coord1(), - stub.offline_coord2(), - stub.coord2(), - stub.offline_eta1(), - stub.eta1(), - stub.offline_eta2(), - stub.eta2(), - stub.quality(), - stub.etaQuality()); + edm::LogInfo("BarrelStub") << "Barrel Stub bx=" << stub.bxNum() << " TF=" << stub.tfLayer() + << " etaRegion=" << stub.etaRegion() << " phiRegion=" << stub.phiRegion() + << " depthRegion=" << stub.depthRegion() << " coord1=" << stub.offline_coord1() << "," + << stub.coord1() << " coord2=" << stub.offline_coord2() << "," << stub.coord2() + << " eta1=" << stub.offline_eta1() << "," << stub.eta1() + << " eta2=" << stub.offline_eta2() << "," << stub.eta2() + << " quality=" << stub.quality() << " etaQuality=" << stub.etaQuality(); } return out; diff --git a/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTEndcapStubProcessor.cc b/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTEndcapStubProcessor.cc index 4287ed0401bf9..d9aa58ce1aeeb 100644 --- a/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTEndcapStubProcessor.cc +++ b/L1Trigger/Phase2L1GMT/src/L1TPhase2GMTEndcapStubProcessor.cc @@ -22,7 +22,8 @@ L1TPhase2GMTEndcapStubProcessor::~L1TPhase2GMTEndcapStubProcessor() {} l1t::MuonStub L1TPhase2GMTEndcapStubProcessor::buildCSCOnlyStub(const CSCDetId& detid, const CSCCorrelatedLCTDigi& digi, - const L1TMuon::GeometryTranslator* translator) { + const L1TMuon::GeometryTranslator* translator, + unsigned int tag) { int endcap = detid.endcap(); int station = detid.station(); int chamber = detid.chamber(); @@ -62,7 +63,7 @@ l1t::MuonStub L1TPhase2GMTEndcapStubProcessor::buildCSCOnlyStub(const CSCDetId& else if (station == 4) //ME4/2 tfLayer = 3; - l1t::MuonStub stub(wheel, sector, station, tfLayer, phi, 0, 0, bx, quality, eta1, 0, 1, 0); + l1t::MuonStub stub(wheel, sector, station, tfLayer, phi, 0, tag, bx, quality, eta1, 0, 1, 0); stub.setOfflineQuantities(gp.phi().value(), 0.0, gp.eta(), 0.0); return stub; @@ -250,8 +251,10 @@ l1t::MuonStubCollection L1TPhase2GMTEndcapStubProcessor::makeStubs( for (; chamber != chend; ++chamber) { auto digi = (*chamber).second.first; auto dend = (*chamber).second.second; + unsigned int tag = 0; for (; digi != dend; ++digi) { - l1t::MuonStub stub = buildCSCOnlyStub((*chamber).first, *digi, t); + l1t::MuonStub stub = buildCSCOnlyStub((*chamber).first, *digi, t, tag); + tag = tag + 1; if (stub.bxNum() >= minBX_ && stub.bxNum() <= maxBX_) cscStubs.push_back(stub); } @@ -276,65 +279,34 @@ l1t::MuonStubCollection L1TPhase2GMTEndcapStubProcessor::makeStubs( l1t::MuonStubCollection combinedStubs = combineStubs(cscStubs, rpcStubs); if (verbose_) { - printf("CSC Stubs\n"); + edm::LogInfo("EndcapStub") << "CSC Stubs"; for (const auto& stub : cscStubs) - printf( - "CSC Stub bx=%d TF=%d etaRegion=%d phiRegion=%d depthRegion=%d coord1=%f,%d coord2=%f,%d eta1=%f,%d " - "eta2=%f,%d quality=%d etaQuality=%d\n", - stub.bxNum(), - stub.tfLayer(), - stub.etaRegion(), - stub.phiRegion(), - stub.depthRegion(), - stub.offline_coord1(), - stub.coord1(), - stub.offline_coord2(), - stub.coord2(), - stub.offline_eta1(), - stub.eta1(), - stub.offline_eta2(), - stub.eta2(), - stub.quality(), - stub.etaQuality()); - printf("RPC Stubs\n"); + edm::LogInfo("EndcapStub") << "CSC Stub bx=" << stub.bxNum() << " TF=" << stub.tfLayer() + << " etaRegion=" << stub.etaRegion() << " phiRegion=" << stub.phiRegion() + << " depthRegion=" << stub.depthRegion() << " coord1=" << stub.offline_coord1() << "," + << stub.coord1() << " coord2=" << stub.offline_coord2() << "," << stub.coord2() + << " eta1=" << stub.offline_eta1() << "," << stub.eta1() + << " eta2=" << stub.offline_eta2() << "," << stub.eta2() + << " quality=" << stub.quality() << " etaQuality=" << stub.etaQuality(); + + edm::LogInfo("EndcapStub") << "RPC Stubs"; for (const auto& stub : rpcStubs) - printf( - "RPC Stub bx=%d TF=%d etaRegion=%d phiRegion=%d depthRegion=%d coord1=%f,%d coord2=%f,%d eta1=%f,%d " - "eta2=%f,%d quality=%d etaQuality=%d\n", - stub.bxNum(), - stub.tfLayer(), - stub.etaRegion(), - stub.phiRegion(), - stub.depthRegion(), - stub.offline_coord1(), - stub.coord1(), - stub.offline_coord2(), - stub.coord2(), - stub.offline_eta1(), - stub.eta1(), - stub.offline_eta2(), - stub.eta2(), - stub.quality(), - stub.etaQuality()); + edm::LogInfo("EndcapStub") << "RPC Stub bx=" << stub.bxNum() << " TF=" << stub.tfLayer() + << " etaRegion=" << stub.etaRegion() << " phiRegion=" << stub.phiRegion() + << " depthRegion=" << stub.depthRegion() << " coord1=" << stub.offline_coord1() << "," + << stub.coord1() << " coord2=" << stub.offline_coord2() << "," << stub.coord2() + << " eta1=" << stub.offline_eta1() << "," << stub.eta1() + << " eta2=" << stub.offline_eta2() << "," << stub.eta2() + << " quality=" << stub.quality() << " etaQuality=" << stub.etaQuality(); + for (const auto& stub : combinedStubs) - printf( - "Combined Stub bx=%d TF=%d etaRegion=%d phiRegion=%d depthRegion=%d coord1=%f,%d coord2=%f,%d eta1=%f,%d " - "eta2=%f,%d quality=%d etaQuality=%d\n", - stub.bxNum(), - stub.tfLayer(), - stub.etaRegion(), - stub.phiRegion(), - stub.depthRegion(), - stub.offline_coord1(), - stub.coord1(), - stub.offline_coord2(), - stub.coord2(), - stub.offline_eta1(), - stub.eta1(), - stub.offline_eta2(), - stub.eta2(), - stub.quality(), - stub.etaQuality()); + edm::LogInfo("EndcapStub") << "Combined Stub bx=" << stub.bxNum() << " TF=" << stub.tfLayer() + << " etaRegion=" << stub.etaRegion() << " phiRegion=" << stub.phiRegion() + << " depthRegion=" << stub.depthRegion() << " coord1=" << stub.offline_coord1() << "," + << stub.coord1() << " coord2=" << stub.offline_coord2() << "," << stub.coord2() + << " eta1=" << stub.offline_eta1() << "," << stub.eta1() + << " eta2=" << stub.offline_eta2() << "," << stub.eta2() + << " quality=" << stub.quality() << " etaQuality=" << stub.etaQuality(); } return combinedStubs; diff --git a/L1Trigger/Phase2L1GMT/src/SAMuonCleaner.cc b/L1Trigger/Phase2L1GMT/src/SAMuonCleaner.cc new file mode 100644 index 0000000000000..acb733be263f8 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/src/SAMuonCleaner.cc @@ -0,0 +1,156 @@ +#include "L1Trigger/Phase2L1GMT/interface/SAMuonCleaner.h" + +void SAMuonCleaner::overlapCleanTrack(l1t::SAMuon& source, const l1t::SAMuon& other, bool eq) { + int rank1 = source.hwQual(); + int rank2 = other.hwQual(); + bool keep = true; + if ((eq && rank1 <= rank2) || ((!eq) && rank1 < rank2)) + keep = false; + l1t::MuonStubRefVector stubs; + for (const auto& s1 : source.stubs()) { + bool ok = true; + for (const auto& s2 : other.stubs()) { + if ((*s1) == (*s2) && (!keep)) + ok = false; + } + if (ok) { + stubs.push_back(s1); + } + } + source.setStubs(stubs); +} + +void SAMuonCleaner::overlapCleanTrackInter(l1t::SAMuon& source, const l1t::SAMuon& other) { + bool keep = false; + l1t::MuonStubRefVector stubs; + for (const auto& s1 : source.stubs()) { + bool ok = true; + for (const auto& s2 : other.stubs()) { + if ((*s1) == (*s2) && (!keep)) + ok = false; + } + if (ok) { + stubs.push_back(s1); + } + } + source.setStubs(stubs); +} + +std::vector SAMuonCleaner::cleanTF(const std::vector& tfMuons) { + std::vector out; + for (unsigned int i = 0; i < tfMuons.size(); ++i) { + l1t::SAMuon source = tfMuons[i]; + for (unsigned int j = 0; j < tfMuons.size(); ++j) { + if (i == j) + continue; + overlapCleanTrack(source, tfMuons[j], false); + } + if (source.stubs().size() > 1) + out.push_back(source); + } + return out; +} + +std::vector SAMuonCleaner::interTFClean(const std::vector& bmtf, + const std::vector& omtf, + const std::vector& emtf) { + std::vector out = emtf; + for (unsigned int i = 0; i < omtf.size(); ++i) { + l1t::SAMuon source = omtf[i]; + for (const auto& other : emtf) { + overlapCleanTrackInter(source, other); + } + if (source.stubs().size() > 1) + out.push_back(source); + } + for (unsigned int i = 0; i < bmtf.size(); ++i) { + l1t::SAMuon source = bmtf[i]; + for (const auto& other : omtf) { + overlapCleanTrackInter(source, other); + } + if (source.stubs().size() > 1) + out.push_back(source); + } + return out; +} + +void SAMuonCleaner::swap(std::vector& list, int i, int j) { + const l1t::SAMuon& track1 = list[i]; + const l1t::SAMuon& track2 = list[j]; + + int pt1 = track1.pt(); + int pt2 = track2.pt(); + bool swap = false; + if (pt1 > pt2) + swap = false; + else + swap = true; + + if (swap) { + l1t::SAMuon tmp = list[i]; + list[i] = list[j]; + list[j] = tmp; + } +} + +void SAMuonCleaner::sort(std::vector& in) { + l1t::SAMuon nullTrack; + nullTrack.setP4(reco::Candidate::LorentzVector(0, 0, 0, 0.000001)); + while (in.size() < 32) + in.push_back(nullTrack); + + for (uint iteration = 0; iteration < 16; ++iteration) { + for (uint i = 0; i < 32; i = i + 2) { + swap(in, i, i + 1); + } + for (uint i = 1; i < 31; i = i + 2) { + swap(in, i, i + 1); + } + } + + std::vector out; + for (const auto& track : in) { + if (!track.stubs().empty() && out.size() < 12) + out.push_back(track); + } + in = out; +} + +std::vector SAMuonCleaner::cleanTFMuons(const std::vector& muons) { + std::vector out; + + //split into collections + std::vector bmtf; + std::vector omtf_pos; + std::vector emtf_pos; + std::vector omtf_neg; + std::vector emtf_neg; + + for (const auto& mu : muons) { + if (mu.tfType() == l1t::tftype::bmtf) { + bmtf.push_back(mu); + } else if (mu.tfType() == l1t::tftype::omtf_pos) { + omtf_pos.push_back(mu); + } else if (mu.tfType() == l1t::tftype::emtf_pos) { + emtf_pos.push_back(mu); + } else if (mu.tfType() == l1t::tftype::omtf_neg) { + omtf_neg.push_back(mu); + } else if (mu.tfType() == l1t::tftype::emtf_neg) { + emtf_neg.push_back(mu); + } + } + + std::vector omtf_cleaned = cleanTF(omtf_pos); + std::vector omtf_neg_cleaned = cleanTF(omtf_neg); + omtf_cleaned.insert(omtf_cleaned.end(), omtf_neg_cleaned.begin(), omtf_neg_cleaned.end()); + sort(omtf_cleaned); + + std::vector emtf_cleaned = cleanTF(emtf_pos); + std::vector emtf_neg_cleaned = cleanTF(emtf_neg); + emtf_cleaned.insert(emtf_cleaned.end(), emtf_neg_cleaned.begin(), emtf_neg_cleaned.end()); + sort(emtf_cleaned); + + std::vector cleaned = interTFClean(bmtf, omtf_cleaned, emtf_cleaned); + sort(cleaned); + return cleaned; +} diff --git a/L1Trigger/Phase2L1GMT/src/TPS.cc b/L1Trigger/Phase2L1GMT/src/TPS.cc new file mode 100644 index 0000000000000..773cad5d64150 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/src/TPS.cc @@ -0,0 +1,122 @@ +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" +#include "L1Trigger/Phase2L1GMT/interface/TPS.h" + +using namespace Phase2L1GMT; + +TPS::TPS(const edm::ParameterSet& iConfig) + : verbose_(iConfig.getParameter("verbose")), + tt_track_converter_(new TrackConverter(iConfig.getParameter("trackConverter"))), + tps_(new TPSAlgorithm(iConfig.getParameter("trackMatching"))), + isolation_(new Isolation(iConfig.getParameter("isolation"))) {} + +std::vector TPS::processEvent(const std::vector >& tracks, + const l1t::MuonStubRefVector& muonStubs) { + //Split tracks to the links as they come + std::array >, 9> loctracks; + for (unsigned i = 0; i < 9; ++i) + loctracks[i] = associateTracksWithNonant(tracks, i); + + //Convert TT tracks to our internal tracking format + std::array, 9> convertedTracks; + for (unsigned i = 0; i < 9; ++i) + convertedTracks[i] = tt_track_converter_->convertTracks(loctracks.at(i)); + + //Transition stubs to different nonants with overlap + std::array stubs; + for (int i = 0; i < 9; ++i) + stubs[i] = associateStubsWithNonant(muonStubs, i); + + //run track - muon matching per nonant + std::array, 9> mus; + for (int i = 0; i < 9; ++i) + mus[i] = tps_->processNonant(convertedTracks.at(i), stubs.at(i)); + + //clean neighboring nonants + std::vector > muCleaneds; + muCleaneds.push_back(tps_->cleanNeighbor(mus[0], mus[8], mus[1], true)); + muCleaneds.push_back(tps_->cleanNeighbor(mus[1], mus[0], mus[2], false)); + muCleaneds.push_back(tps_->cleanNeighbor(mus[2], mus[1], mus[3], true)); + muCleaneds.push_back(tps_->cleanNeighbor(mus[3], mus[2], mus[4], false)); + muCleaneds.push_back(tps_->cleanNeighbor(mus[4], mus[3], mus[5], true)); + muCleaneds.push_back(tps_->cleanNeighbor(mus[5], mus[4], mus[6], false)); + muCleaneds.push_back(tps_->cleanNeighbor(mus[6], mus[5], mus[7], true)); + muCleaneds.push_back(tps_->cleanNeighbor(mus[7], mus[6], mus[8], false)); + //ARGH! 9 sectors - so some duplicates very rarely + muCleaneds.push_back(tps_->cleanNeighbor(mus[8], mus[7], mus[0], false)); + + //merge all the collections + std::vector mergedCleaned; + for (auto&& v : muCleaneds) { + mergedCleaned.insert(mergedCleaned.end(), v.begin(), v.end()); + } + + std::vector trackMatchedMuonsNoIso = tps_->convert(mergedCleaned, 32); + + //sorter here: + std::vector sortedTrackMuonsNoIso = tps_->sort(trackMatchedMuonsNoIso, 12); + + tps_->SetQualityBits(sortedTrackMuonsNoIso); + + //Isolation and tau3mu will read those muons and all 9 collections of convertedTracks* + std::vector mergedconvertedTracks; + for (auto&& v : convertedTracks) { + mergedconvertedTracks.insert(mergedconvertedTracks.end(), v.begin(), v.end()); + } + + isolation_->isolation_allmu_alltrk(sortedTrackMuonsNoIso, mergedconvertedTracks); + + // To be enable when tau->3mu rate study is ready + //tauto3mu_->GetTau3Mu(sortedTrackMuonsNoIso, mergedconvertedTracks); + + tps_->outputGT(sortedTrackMuonsNoIso); + + return sortedTrackMuonsNoIso; //when we add more collections like tau3mu etc we change that +} + +std::vector > TPS::associateTracksWithNonant( + const std::vector >& tracks, uint processor) { + std::vector > out; + for (const auto& track : tracks) { + if (track->phiSector() == processor) { + out.push_back(track); + } + } + return out; +} + +l1t::SAMuonRefVector TPS::associateMuonsWithNonant(const l1t::SAMuonRefVector& muons, uint processor) { + l1t::SAMuonRefVector out; + + ap_int center = ap_int(processor * 910); + + for (const auto& s : muons) { + ap_int deltaPhi = s->hwPhi() - center; + ap_uint absDeltaPhi = + (deltaPhi < 0) ? ap_uint(-deltaPhi) : ap_uint(deltaPhi); + if (absDeltaPhi < 683) + out.push_back(s); + } + return out; +} + +l1t::MuonStubRefVector TPS::associateStubsWithNonant(const l1t::MuonStubRefVector& allStubs, uint processor) { + l1t::MuonStubRefVector out; + + ap_int center = ap_int((processor * 910) / 8); //was 32 + + for (const auto& s : allStubs) { + ap_int phi = 0; + if (s->quality() & 0x1) + phi = s->coord1(); + else + phi = s->coord2(); + + ap_int deltaPhi = phi - center; + ap_uint absDeltaPhi = + (deltaPhi < 0) ? ap_uint(-deltaPhi) : ap_uint(deltaPhi); + if (absDeltaPhi < 168) //was 42 + out.push_back(s); + } + return out; +} diff --git a/L1Trigger/Phase2L1GMT/src/TPSAlgorithm.cc b/L1Trigger/Phase2L1GMT/src/TPSAlgorithm.cc new file mode 100644 index 0000000000000..95a7503b22c0c --- /dev/null +++ b/L1Trigger/Phase2L1GMT/src/TPSAlgorithm.cc @@ -0,0 +1,544 @@ +#include "L1Trigger/Phase2L1GMT/interface/TPSAlgorithm.h" + +using namespace Phase2L1GMT; + +TPSAlgorithm::TPSAlgorithm(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter("verbose")) {} + +TPSAlgorithm::~TPSAlgorithm() {} + +std::vector TPSAlgorithm::processNonant(const std::vector& convertedTracks, + const l1t::MuonStubRefVector& stubs) { + std::vector preMuons; + for (const auto& track : convertedTracks) { + PreTrackMatchedMuon mu = processTrack(track, stubs); + if (mu.valid() && preMuons.size() < 16) + preMuons.push_back(mu); + } + std::vector cleanedMuons = clean(preMuons); + return cleanedMuons; +} + +std::vector TPSAlgorithm::cleanNeighbor(const std::vector& muons, + const std::vector& muonsPrevious, + const std::vector& muonsNext, + bool equality) { + std::vector out; + + if (muons.empty()) + return out; + + if (verbose_ == 1) { + edm::LogInfo("TPSAlgo") << "-----Cleaning Up Muons in the neighbours"; + edm::LogInfo("TPSAlgo") << "Before:"; + } + + for (uint i = 0; i < muons.size(); ++i) { + if (verbose_ == 1) { + muons[i].print(); + } + ap_uint<5> mask = 0x1f; + for (uint j = 0; j < muonsPrevious.size(); ++j) { + mask = mask & cleanMuon(muons[i], muonsPrevious[j], equality); + } + for (uint j = 0; j < muonsNext.size(); ++j) { + mask = mask & cleanMuon(muons[i], muonsNext[j], equality); + } + if (mask) { + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "kept"; + out.push_back(muons[i]); + } else { + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "discarded"; + } + } + return out; +} + +std::vector TPSAlgorithm::convert(std::vector& muons, uint maximum) { + std::vector out; + for (const auto& mu : muons) { + if (out.size() == maximum) + break; + l1t::TrackerMuon muon(mu.trkPtr(), mu.charge(), mu.pt(), mu.eta(), mu.phi(), mu.z0(), mu.d0(), mu.quality()); + muon.setMuonRef(mu.muonRef()); + for (const auto& stub : mu.stubs()) + muon.addStub(stub); + + uint matches = 0; + uint mask = mu.matchMask(); + + for (uint i = 0; i < 10; i = i + 1) { + if (mask & (1 << i)) + matches++; + } + muon.setNumberOfMatches(matches); + out.push_back(muon); + + if (verbose_ == 1) { + edm::LogInfo("TPSAlgo") << "Final Muon:" << std::flush; + muon.print(); + } + } + return out; +} + +void TPSAlgorithm::SetQualityBits(std::vector& muons) { + for (auto& mu : muons) { + // A preliminary suggestion. Need feedback from the menu group + bool veryloose = mu.numberOfMatches() > 0; + bool loose = mu.numberOfMatches() > 1; + bool medium = mu.stubs().size() > 1; + bool tight = mu.numberOfMatches() > 2; + int qualbit = 0; + qualbit = (veryloose << 0) | (loose << 1) | (medium << 2) | (tight << 3); + mu.setHwQual(qualbit); + } +} + +bool TPSAlgorithm::outputGT(std::vector& muons) { + for (auto& mu : muons) { + wordtype word1 = 0; + wordtype word2 = 0; + + int bstart = 0; + bstart = wordconcat(word1, bstart, mu.hwPt(), BITSGTPT); + bstart = wordconcat(word1, bstart, mu.hwPhi(), BITSGTPHI); + bstart = wordconcat(word1, bstart, mu.hwEta(), BITSGTETA); + bstart = wordconcat(word1, bstart, mu.hwZ0(), BITSGTZ0); + bstart = wordconcat(word1, bstart, (mu.hwD0() >> 2), BITSGTD0); + + bstart = 0; + bstart = wordconcat(word2, bstart, mu.hwCharge(), 1); + bstart = wordconcat(word2, bstart, mu.hwQual(), BITSGTQUAL); + bstart = wordconcat(word2, bstart, mu.hwIso(), BITSGTISO); + bstart = wordconcat(word2, bstart, mu.hwBeta(), BITSGTBETA); + + std::array wordout = {{word1, word2}}; + mu.setWord(wordout); + } + return true; +} + +std::vector TPSAlgorithm::sort(std::vector& muons, uint maximum) { + if (muons.size() < 2) + return muons; + + std::sort(muons.begin(), muons.end(), [](l1t::TrackerMuon a, l1t::TrackerMuon b) { return a.hwPt() > b.hwPt(); }); + std::vector out; + for (unsigned int i = 0; i < muons.size(); ++i) { + out.push_back(muons[i]); + if (i == (maximum - 1)) + break; + } + + return out; +} + +propagation_t TPSAlgorithm::propagate(const ConvertedTTTrack& track, uint layer) { + static const std::array*, 5> lt_prop_coord1 = { + {lt_prop_coord1_0, lt_prop_coord1_1, lt_prop_coord1_2, lt_prop_coord1_3, lt_prop_coord1_4}}; + static const std::array*, 5> lt_prop_coord2 = { + {lt_prop_coord2_0, lt_prop_coord2_1, lt_prop_coord2_2, lt_prop_coord2_3, lt_prop_coord2_4}}; + + static const std::array*, 5> lt_res0_coord1 = { + {lt_res0_coord1_0, lt_res0_coord1_1, lt_res0_coord1_2, lt_res0_coord1_3, lt_res0_coord1_4}}; + static const std::array*, 5> lt_res1_coord1 = { + {lt_res1_coord1_0, lt_res1_coord1_1, lt_res1_coord1_2, lt_res1_coord1_3, lt_res1_coord1_4}}; + static const std::array*, 5> lt_res0_coord2 = { + {lt_res0_coord2_0, lt_res0_coord2_1, lt_res0_coord2_2, lt_res0_coord2_3, lt_res0_coord2_4}}; + static const std::array*, 5> lt_res1_coord2 = { + {lt_res1_coord2_0, lt_res1_coord2_1, lt_res1_coord2_2, lt_res1_coord2_3, lt_res1_coord2_4}}; + + static const std::array*, 5> lt_res0_eta1 = { + {lt_res0_eta1_0, lt_res0_eta1_1, lt_res0_eta1_2, lt_res0_eta1_3, lt_res0_eta1_4}}; + static const std::array*, 5> lt_res1_eta1 = { + {lt_res1_eta_0, lt_res1_eta_1, lt_res1_eta_2, lt_res1_eta_3, lt_res1_eta_4}}; + + static const std::array*, 5> lt_res0_eta2 = { + {lt_res0_eta2_0, lt_res0_eta2_1, lt_res0_eta2_2, lt_res0_eta2_3, lt_res0_eta2_4}}; + + static const uint barrellimit[5] = {barrelLimit0_, barrelLimit1_, barrelLimit2_, barrelLimit3_, barrelLimit4_}; + + ap_uint prop_coord1 = 0; + ap_uint prop_coord2 = 0; + ap_uint res0_coord1 = 0; + ap_uint res1_coord1 = 0; + ap_uint res0_coord2 = 0; + ap_uint res1_coord2 = 0; + ap_uint res0_eta1 = 0; + ap_uint res1_eta = 0; + ap_uint res0_eta2 = 0; + ap_uint<1> is_barrel = 0; + + uint reducedAbsEta = track.abseta() / 8; + + //Propagate to layers + assert(layer < 5); + prop_coord1 = lt_prop_coord1[layer][reducedAbsEta]; + prop_coord2 = lt_prop_coord2[layer][reducedAbsEta]; + res0_coord1 = lt_res0_coord1[layer][reducedAbsEta]; + res1_coord1 = lt_res1_coord1[layer][reducedAbsEta]; + res0_coord2 = lt_res0_coord2[layer][reducedAbsEta]; + res1_coord2 = lt_res1_coord2[layer][reducedAbsEta]; + res0_eta1 = lt_res0_eta1[layer][reducedAbsEta]; + res1_eta = lt_res1_eta1[layer][reducedAbsEta]; + res0_eta2 = lt_res0_eta2[layer][reducedAbsEta]; + is_barrel = reducedAbsEta < barrellimit[layer] ? 1 : 0; + + propagation_t out; + ap_int curvature = track.curvature(); + ap_int phi = track.phi(); + ap_int c1kFull = prop_coord1 * curvature; + ap_int c1k = (c1kFull) / 1024; + ap_int coord1 = phi - c1k; + + out.coord1 = coord1 / PHIDIVIDER; + + ap_int c2kFull = prop_coord2 * curvature; + + ap_int c2k = (c2kFull) / 1024; + if (is_barrel) + out.coord2 = -c2k / PHIDIVIDER; + else + out.coord2 = (phi - c2k) / PHIDIVIDER; + + ap_int eta = track.eta(); + out.eta = eta / ETADIVIDER; + + ap_uint<2 * BITSTTCURV - 2> curvature2All = curvature * curvature; + ap_uint curvature2 = curvature2All / 2; + + /////New propagation for sigma + ap_uint absK = 0; + if (track.curvature() < 0) + absK = ap_uint(-track.curvature()); + else + absK = ap_uint(track.curvature()); + + //bound the resolution propagation + if (absK > 4095) + absK = 4095; + + ap_uint s1kFull = res1_coord1 * absK; + ap_uint s1k = s1kFull / 1024; + ap_uint sigma1 = res0_coord1 + s1k; + out.sigma_coord1 = ap_uint(sigma1 / PHIDIVIDER); + + ap_uint s2kFull = res1_coord2 * absK; + ap_uint s2k = s2kFull / 1024; + ap_uint sigma2 = res0_coord2 + s2k; + out.sigma_coord2 = ap_uint(sigma2 / PHIDIVIDER); + + ap_uint resetak = (res1_eta * curvature2) >> 23; + ap_ufixed sigma_eta1 = res0_eta1 + resetak; + out.sigma_eta1 = ap_uint(sigma_eta1); + ap_ufixed sigma_eta2 = res0_eta2 + resetak; + out.sigma_eta2 = ap_uint(sigma_eta2); + out.valid = 1; + out.is_barrel = is_barrel; + + if (verbose_ == 1) { + edm::LogInfo("TPSAlgo") << "Propagating to layer " << int(layer) << ":is barrel=" << out.is_barrel.to_int() + << " coords=" << out.coord1.to_int() << "+-" << out.sigma_coord1.to_int() << " , " + << out.coord2.to_int() << " +-" << out.sigma_coord2.to_int() + << " etas = " << out.eta.to_int() << " +- " << out.sigma_eta1.to_int() << " +-" + << out.sigma_eta2.to_int(); + + edm::LogInfo("TPSAlgo") << "----- breakout of sigma 1 : constant=" << res0_coord1.to_int() + << " slope=" << res1_coord1.to_int() << " before division=" << s1k.to_int(); + + edm::LogInfo("TPSAlgo") << "----- breakout of sigma 2 : constant=" << res0_coord2.to_int() + << " slope=" << res1_coord2.to_int() << " before division=" << s2k.to_int(); + } + return out; +} + +ap_uint TPSAlgorithm::deltaEta(const ap_int& eta1, const ap_int& eta2) { + ap_fixed dEta = eta1 - eta2; + if (dEta < 0) + return ap_uint(-dEta); + else + return ap_uint(dEta); +} + +ap_uint TPSAlgorithm::deltaCoord(const ap_int& phi1, + const ap_int& phi2) { + ap_int dPhiRoll = phi1 - phi2; + ap_ufixed dPhi; + if (dPhiRoll < 0) + dPhi = ap_ufixed(-dPhiRoll); + else + dPhi = ap_ufixed(dPhiRoll); + + return ap_uint(dPhi); +} + +match_t TPSAlgorithm::match(const propagation_t prop, const l1t::MuonStubRef& stub, uint trackID) { + if (verbose_ == 1) { + edm::LogInfo("TPSAlgo") << "Matching to coord1=" << stub->coord1() << " coord2=" << stub->coord2() + << " eta1=" << stub->eta1() << " eta2=" << stub->eta2(); + + stub->print(); + } + //Matching of Coord1 + ap_uint<1> coord1Matched; + ap_uint deltaCoord1 = deltaCoord(prop.coord1, stub->coord1()); + if (deltaCoord1 <= prop.sigma_coord1 && (stub->quality() & 0x1)) { + coord1Matched = 1; + } else { + coord1Matched = 0; + } + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "Coord1 matched=" << coord1Matched.to_int() << " delta=" << deltaCoord1.to_int() + << " res=" << prop.sigma_coord1.to_int(); + + //Matching of Coord2 + ap_uint<1> coord2Matched; + ap_uint deltaCoord2 = deltaCoord(prop.coord2, stub->coord2()); + if (deltaCoord2 <= prop.sigma_coord2 && (stub->quality() & 0x2)) { + coord2Matched = 1; + } else { + coord2Matched = 0; + } + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "Coord2 matched=" << coord2Matched.to_int() << " delta=" << deltaCoord2.to_int() + << " res=" << prop.sigma_coord2.to_int(); + + //Matching of Eta1 + + ap_uint<1> eta1Matched; + + //if we have really bad quality[Barrel no eta] + //increase the resolution + ap_ufixed prop_sigma_eta1; + if (stub->etaQuality() == 0) + prop_sigma_eta1 = prop.sigma_eta1 + 6; + else + prop_sigma_eta1 = prop.sigma_eta1; + + ap_uint deltaEta1 = deltaEta(prop.eta, stub->eta1()); + if (deltaEta1 <= prop_sigma_eta1 && (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1))) + eta1Matched = 1; + else + eta1Matched = 0; + + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "eta1 matched=" << eta1Matched.to_int() << " delta=" << deltaEta1.to_int() + << " res=" << prop_sigma_eta1.to_int(); + + //Matching of Eta2 + + ap_uint<1> eta2Matched; + + ap_uint deltaEta2 = deltaEta(prop.eta, stub->eta2()); + if (deltaEta2 <= prop.sigma_eta2 && (stub->etaQuality() & 0x2)) + eta2Matched = 1; + else + eta2Matched = 0; + match_t out; + out.id = trackID; + + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "eta2 matched=" << eta2Matched.to_int() << " delta=" << deltaEta2.to_int() + << " res=" << prop.sigma_eta2.to_int(); + + //Note I divided by 4 because of the new coordinate. Make it automatic + + //if barrel, coord1 has to always be matched, coord2 maybe and eta1 is needed if etaQ=0 or then the one that depends on eta quality + if (prop.is_barrel) { + out.valid = (coord1Matched == 1 && (eta1Matched == 1 || eta2Matched == 1)) ? 1 : 0; + if (out.valid == 0) { + out.quality = 0; + } else { + out.quality = 32 - deltaCoord1 / 4; + if (coord2Matched == 1) { + out.quality += 32 - deltaCoord2 / 4; + out.valid = 3; + } + } + } + //if endcap each coordinate is independent except the case where phiQuality=1 and etaQuality==3 + else { + bool match1 = (coord1Matched == 1 && eta1Matched == 1); + bool match2 = (coord2Matched == 1 && eta2Matched == 1); + bool match3 = + (coord1Matched == 1 && (eta1Matched || eta2Matched) && stub->etaQuality() == 3 && stub->quality() == 1); + out.valid = (match1 || match2 || match3) ? 1 : 0; + if (out.valid == 0) + out.quality = 0; + else { + out.quality = 0; + if (match1 || match3) + out.quality += 32 - deltaCoord1 / 4; + if (match2) { + out.quality += 32 - deltaCoord2 / 4; + if (match1 || match3) + out.valid = 3; + } + } + } + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "GlobalMatchQuality = " << out.quality.to_int(); + out.stubRef = stub; + return out; +} + +match_t TPSAlgorithm::propagateAndMatch(const ConvertedTTTrack& track, const l1t::MuonStubRef& stub, uint trackID) { + propagation_t prop = propagate(track, stub->tfLayer()); + return match(prop, stub, trackID); +} + +match_t TPSAlgorithm::getBest(const std::vector matches) { + match_t best = matches[0]; + for (const auto& m : matches) { + if (m.quality > best.quality) + best = m; + } + + return best; +} + +void TPSAlgorithm::matchingInfos(std::vector matchInfo, + PreTrackMatchedMuon& muon, + ap_uint& quality) { + if (!matchInfo.empty()) { + match_t b = getBest(matchInfo); + if (b.valid != 0) { + muon.addStub(b.stubRef, b.valid); + if (b.isGlobal) + muon.addMuonRef(b.muRef); + quality += b.quality; + } + } +} + +PreTrackMatchedMuon TPSAlgorithm::processTrack(const ConvertedTTTrack& track, const l1t::MuonStubRefVector& stubs) { + std::array, 6> matchInfos; + + if (verbose_ == 1 && !stubs.empty()) { + edm::LogInfo("TPSAlgo") << "-----------processing new track----------"; + track.print(); + } + for (const auto& stub : stubs) { + match_t m = propagateAndMatch(track, stub, 0); + if (m.valid != 0 && stub->tfLayer() < 6) { + matchInfos[stub->tfLayer()].push_back(m); + } + } + + ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM> ptPenalty = ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM>(track.pt() / 32); + + ap_uint quality = 0; + PreTrackMatchedMuon muon(track.charge(), track.pt(), track.eta(), track.phi(), track.z0(), track.d0()); + + for (auto&& m : matchInfos) + matchingInfos(m, muon, quality); + + muon.setOfflineQuantities(track.offline_pt(), track.offline_eta(), track.offline_phi()); + muon.setTrkPtr(track.trkPtr()); + + ap_uint<8> etaAddr = muon.eta() < 0 ? ap_uint<8>(-muon.eta() / 256) : ap_uint<8>((muon.eta()) / 256); + ap_uint<8> ptAddr = muon.pt() > 4095 ? ap_uint<8>(15) : ap_uint<8>(muon.pt() / 256); + ap_uint<8> addr = ptAddr | (etaAddr << 4); + ap_uint<8> qualityCut = lt_tpsID[addr]; + + if (!muon.stubs().empty()) { //change the ID for now + muon.setValid(true); + muon.setQuality(quality + ptPenalty); + } else { + muon.setValid(false); + muon.setQuality(0); + muon.resetGlobal(); + } + if (verbose_ == 1) + muon.print(); + + if (verbose_ == 1 && !stubs.empty()) { //patterns for HLS + + edm::LogInfo("TPSAlgo") << "TPS " << track.trkPtr()->phiSector() << std::flush; + track.printWord(); + + for (uint i = 0; i < 16; ++i) { + if (stubs.size() > i) { + edm::LogInfo("TPSAlgo") << "remember to implement printout of muon"; + } else { + edm::LogInfo("TPSAlgo") << std::hex << std::setw(8) << 0 << std::flush; + edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush; + edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush; + edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush; + edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush; + edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush; + } + } + muon.printWord(); + edm::LogInfo("TPSAlgo") << std::endl; + } + return muon; +} + +ap_uint<5> TPSAlgorithm::cleanMuon(const PreTrackMatchedMuon& mu, const PreTrackMatchedMuon& other, bool eq) { + ap_uint<5> valid = 0; + ap_uint<5> overlap = 0; + constexpr int bittest = 0xfff; // 4095, corresponding to 11bits + if (mu.stubID0() != bittest) { + valid = valid | 0x1; + if (mu.stubID0() == other.stubID0()) + overlap = overlap | 0x1; + } + if (mu.stubID1() != bittest) { + valid = valid | 0x2; + if (mu.stubID1() == other.stubID1()) + overlap = overlap | 0x2; + } + if (mu.stubID2() != bittest) { + valid = valid | 0x4; + if (mu.stubID2() == other.stubID2()) + overlap = overlap | 0x4; + } + if (mu.stubID3() != bittest) { + valid = valid | 0x8; + if (mu.stubID3() == other.stubID3()) + overlap = overlap | 0x8; + } + if (mu.stubID4() != bittest) { + valid = valid | 0x10; + if (mu.stubID4() == other.stubID4()) + overlap = overlap | 0x10; + } + + if (((mu.quality() < other.quality()) && (!eq)) || ((mu.quality() <= other.quality()) && (eq))) + return valid & (~overlap); + else + return valid; +} + +std::vector TPSAlgorithm::clean(std::vector& muons) { + std::vector out; + if (muons.empty()) + return out; + if (verbose_ == 1) { + edm::LogInfo("TPSAlgo") << "-----Cleaning Up Muons in the same Nonant"; + edm::LogInfo("TPSAlgo") << "Before:"; + } + for (uint i = 0; i < muons.size(); ++i) { + if (verbose_ == 1) + muons[i].print(); + + ap_uint<5> mask = 0x1f; + for (uint j = 0; j < muons.size(); ++j) { + if (i == j) + continue; + mask = mask & cleanMuon(muons[i], muons[j], false); + } + if (mask) { + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "kept"; + out.push_back(muons[i]); + } else { + if (verbose_ == 1) + edm::LogInfo("TPSAlgo") << "discarded"; + } + } + return out; +} diff --git a/L1Trigger/Phase2L1GMT/src/TrackConverter.cc b/L1Trigger/Phase2L1GMT/src/TrackConverter.cc new file mode 100644 index 0000000000000..414ee8b69ced0 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/src/TrackConverter.cc @@ -0,0 +1,50 @@ +#include "L1Trigger/Phase2L1GMT/interface/TrackConverter.h" + +using namespace Phase2L1GMT; + +TrackConverter::TrackConverter(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter("verbose")) {} + +std::vector TrackConverter::convertTracks( + const std::vector >& tracks) { + std::vector out; + out.reserve(tracks.size()); + for (const auto& t : tracks) + out.push_back(convert(t)); + return out; +} + +ConvertedTTTrack TrackConverter::convert(const edm::Ptr >& track) { + uint charge = (track->rInv() < 0) ? 1 : 0; + ap_int curvature = ap_int(track->getRinvBits()); + ap_int phisec = ap_int(ap_int(track->getPhiBits()) / 2); + ap_int tanLambda = ap_int(track->getTanlBits()); + ap_int z0 = ap_int(ap_int(track->getZ0Bits()) / (1 << (BITSTTZ0 - BITSZ0))); + ap_int d0 = ap_int(ap_int(track->getD0Bits()) / (1 << (BITSTTD0 - BITSD0))); + //calculate pt + ap_uint absCurv = + curvature > 0 ? ap_uint(curvature) : ap_uint(-curvature); + ap_uint pt = ptLUT[ptLookup(absCurv)]; + ap_uint<1> quality = generateQuality(track); + ap_uint absTanL = + tanLambda > 0 ? ap_uint(tanLambda) : ap_uint(-tanLambda); + ap_uint absEta = etaLUT[etaLookup(absTanL)]; + ap_int eta = tanLambda > 0 ? ap_int(absEta) : ap_int(-absEta); + + ap_int phi = ap_int(phisec + track->phiSector() * 910); + + wordtype word = 0; + int bstart = 0; + bstart = wordconcat(word, bstart, curvature, BITSTTCURV); + bstart = wordconcat(word, bstart, phi, BITSPHI); //was phiSec + bstart = wordconcat(word, bstart, tanLambda, BITSTTTANL); + bstart = wordconcat(word, bstart, z0, BITSZ0); + bstart = wordconcat(word, bstart, d0, BITSD0); + bstart = wordconcat(word, bstart, uint(track->chi2()), 4); + + ConvertedTTTrack convertedTrack(charge, curvature, absEta, pt, eta, phi, z0, d0, quality, word); + convertedTrack.setOfflineQuantities(LSBpt * pt, LSBeta * eta, LSBphi * phi); + if (verbose_) + convertedTrack.print(); + convertedTrack.setTrkPtr(track); + return convertedTrack; +} diff --git a/L1Trigger/Phase2L1GMT/test/gmtStudy.py b/L1Trigger/Phase2L1GMT/test/gmtStudy.py index f80fac6b05a58..629cf94d927a8 100644 --- a/L1Trigger/Phase2L1GMT/test/gmtStudy.py +++ b/L1Trigger/Phase2L1GMT/test/gmtStudy.py @@ -1,255 +1,372 @@ import ROOT,itertools,math +import argparse from array import array from DataFormats.FWLite import Events, Handle +import subprocess ROOT.FWLiteEnabler.enable() -# - -#0.005 -#idCut=[ -#20, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 48, 44, 44, 44, 60, 20, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 48, 20, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 60, 20, 24, 20, 44, 44, 44, 44, 44, 44, 44, 44, 20, 44, 44, 44, 60, 20, 24, 24, 24, 24, 44, 24, 24, 24, 20, 44, 40, 44, 44, 48, 44, 20, 44, 44, 48, 48, 48, 48, 60, 48, 48, 60, 60, 48, 60, 60, 60, 20, 44, 60, 60, 60, 60, 60, 60, 60, 48, 60, 60, 44, 60, 60, 60, 20, 40, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 16, 20, 60, 60, 60, 60, 60, 60, 60, 60, 48, 60, 44, 60, 60, 60, 16, 20, 44, 60, 60, 60, 60, 60, 48, 60, 60, 60, 60, 60, 60, 60, 20, 20, 40, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 48, 60, 20, 16, 20, 44, 48, 44, 44, 44, 60, 60, 60, 60, 48, 48, 48, 60, 20, 20, 20, 60, 44, 60, 60, 60, 60, 44, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60] - -#0.006 - -idCut=[ -36, 56, 64, 64, 32, 32, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, #0 -28, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 28, 28, 28, 28, #16 -28, 52, 56, 52, 52, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, #32 -28, 52, 52, 52, 56, 56, 56, 56, 56, 56, 56, 28, 56, 56, 56, 56, #48 -28, 36, 36, 36, 36, 36, 36, 36, 36, 36, 56, 56, 36, 56, 36, 36, #64 -28, 56, 60, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, #80 -28, 92, 120, 120, 92, 92, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, #96 -28, 120, 152, 128, 100, 124, 80, 80, 64, 64, 64, 64, 64, 64, 64,64, #112 -28, 88, 92, 64, 92, 60, 60, 60, 92, 60, 60, 60, 60, 60, 60, 60, #128 -36, 88, 88, 64, 64, 60, 60, 60, 60, 60, 60, 60, 92, 92, 92,92, #144 -28, 64, 92, 88, 88, 88, 88, 88, 88, 88, 88, 88, 120, 120, 120,120, #160 -28, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,92, #176 -28, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,92, #192 -64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,64, #208 -64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,64, #224 -64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64] #240 - -idCut=[ -40, 56, 64, 88, 64, 32, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, #0 -28, 56, 56, 54, 36, 36, 36, 36, 36, 36, 36, 36, 32, 28, 28, 28, #16 -28, 52, 56, 52, 52, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, #32 -28, 56, 52, 52, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, #48 -28, 52, 36, 36, 36, 36, 36, 36, 36, 36, 56, 56, 36, 56, 36, 36, #64 -28, 60, 60, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, #80 -28, 120, 120, 120, 92, 92, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, #96 -28, 120, 152, 128, 100, 124, 80, 80, 64, 100, 64, 64, 64, 64, 64,64, #112 -28, 88, 92, 64, 92, 60, 60, 60, 92, 60, 60, 60, 60, 60, 60, 60, #128 -36, 88, 88, 64, 64, 60, 60, 60, 60, 60, 60, 60, 92, 92, 92,92, #144 -28, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,88, #160 -28, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,92, #176 -28, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,92, #192 -64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,64, #208 -64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,64, #224 -64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64] #240 - - -def ID(eta,pt,quality): - p=pt - if p>4095: - p=4095 - p=p/256 - e=int(abs(eta)) - e=e/256 - addr=(e<<4) | p - if (quality-min(64,pt/32))>=(idCut[addr]): - return True - else: - return False - -#verbose=False -#tag='singleMuonOfficial' -#isData=False -#tag='signal' -def strAppend(s): - return "root://cmsxrootd.fnal.gov/"+s -from dy200 import * -from jpsi import * -from minbias import * -tag='/uscmst1b_scratch/lpc1/3DayLifetime/bachtis/DY200' -#events=Events(['/uscmst1b_scratch/lpc1/3DayLifetime/bachtis/MinBias.root' -# ]) -events=Events(map(strAppend,dy200)) +class muon_trigger_analyzer(object): + def __init__(self,prefix,thresholds=[0,3,5,10,15,20,30]): + self.bunchfactor = 40000*2760.0/3564.0 + self.prefix=prefix + self.thresholds = thresholds + self.histoData={'effpt':{}, 'effeta':{},'geneta':{},'genphi':{},'genlxy':{},'efflxy':{},'effphi':{},'effptB':{},'effptO':{},'effptE':{},'rateeta':{}} + self.histoData['genpt'] = ROOT.TH1D(prefix+"_genpt","genpt",50,0,100) + self.histoData['genptB'] = ROOT.TH1D(prefix+"_genptB","genptB",50,0,100) + self.histoData['genptO'] = ROOT.TH1D(prefix+"_genptO","genptO",50,0,100) + self.histoData['genptE'] = ROOT.TH1D(prefix+"_genptE","genptE",50,0,100) + self.histoData['rate'] = ROOT.TH1D(prefix+"_rate","rate",20,0,100) + self.histoData['resolution'] = ROOT.TH2D(prefix+"_resolution","resolution",20,0,100,100,-2,2) + self.histoData['rateBarrel'] = ROOT.TH1D(prefix+"_rateBarrel","rate",20,0,100) + self.histoData['rateOverlap'] = ROOT.TH1D(prefix+"_rateOverlap","rate",20,0,100) + self.histoData['rateEndcap'] = ROOT.TH1D(prefix+"_rateEndcap","rate",20,0,100) + for t in thresholds: + self.histoData['effpt'][t] = ROOT.TH1D(prefix+"_effpt_"+str(t),"effpt_"+str(t),50,0,100) + self.histoData['effptB'][t] = ROOT.TH1D(prefix+"_effptB_"+str(t),"effpt_"+str(t),50,0,100) + self.histoData['effptO'][t] = ROOT.TH1D(prefix+"_effptO_"+str(t),"effpt_"+str(t),50,0,100) + self.histoData['effptE'][t] = ROOT.TH1D(prefix+"_effptE_"+str(t),"effpt_"+str(t),50,0,100) + self.histoData['effeta'][t] = ROOT.TH1D(prefix+"_effeta_"+str(t),"effeta_"+str(t),48,-2.4,2.4) + self.histoData['effphi'][t] = ROOT.TH1D(prefix+"_effphi_"+str(t),"effphi_"+str(t),32,-math.pi,math.pi) + self.histoData['efflxy'][t] = ROOT.TH1D(prefix+"_efflxy_"+str(t),"efflxy_"+str(t),50,0,200) + self.histoData['geneta'][t] = ROOT.TH1D(prefix+"_geneta_"+str(t),"effeta_"+str(t),48,-2.4,2.4) + self.histoData['genphi'][t] = ROOT.TH1D(prefix+"_genphi_"+str(t),"genphi_"+str(t),32,-math.pi,math.pi) + self.histoData['genlxy'][t] = ROOT.TH1D(prefix+"_genlxy_"+str(t),"genlxy_"+str(t),50,0,200) + self.histoData['rateeta'][t] = ROOT.TH1D(prefix+"_rateeta_"+str(t),"rateeta_"+str(t),24,-2.4,2.4) + + def deltaPhi(self, p1, p2): + '''Computes delta phi, handling periodic limit conditions.''' + res = p1 - p2 + while res > math.pi: + res -= 2*math.pi + while res < -math.pi: + res += 2*math.pi + return res + + def deltaR(self, *args ): + return math.sqrt( self.deltaR2(*args) ) + + def deltaR2(self, e1, p1, e2, p2): + de = e1 - e2 + dp = self.deltaPhi(p1, p2) + return de*de + dp*dp + def getLxy(self,muon): + return abs(math.sqrt(muon.vx()*muon.vx()+muon.vy()*muon.vy())) + + def getDxy(self,muon): + tanphi = math.tan(m.phi()) + x=(tanphi*tanphi*muon.vx()-muon.vy()*tanphi)/(1+tanphi*tanphi) + y=muon.vy()+tanphi*(x-muon.vx()) + return abs(math.sqrt(x*x+y*y)) + + def getEta1(self,muon): + lxy = self.getLxy(muon) + vz = muon.vz() + theta1 = math.atan((700.-lxy)/(650.-vz)) + + if (theta1 < 0): + theta1 = math.pi+theta1 + eta1 = -math.log(math.tan(theta1/2.0)) + return eta1 + + def getEta2(self,muon): + lxy = self.getLxy(muon) + vz = muon.vz() + theta2 = math.pi-math.atan((700.-lxy)/(650.+vz)) + if theta2 > math.pi: + theta2 = theta2-math.pi + eta2 = -math.log(math.tan(theta2/2.0)) + return eta2 + + def getAcceptance(self,muon): + eta1 = self.getEta1(muon) + eta2 = self.getEta2(muon) + if muon.eta() < eta1 and muon.eta() > eta2: + return True #Muon is within barrel acceptance + else: + return False #Muon is outside of barrel + + def getSt2Eta(self,muon): + lxy = self.getLxy(muon) + vz = muon.vz() + theta_mu = 2*math.atan(math.exp(-muon.eta())) + st1_z = (512.-lxy)/math.tan(theta_mu)+vz + st1_r = 512. + theta_st1 = math.atan2(st1_r,st1_z) + eta_st1 = -math.log(math.tan(theta_st1/2.)) + return eta_st1 + + def getSt2Phi(self,muon): + # calculate intersection of line and circle + x1 = muon.vx() + y1 = muon.vy() + x2 = muon.vx() + muon.px()/(muon.px()**2+muon.py()**2) + y2 = muon.vy() + muon.py()/(muon.px()**2+muon.py()**2) + r = 512. + dx = x2-x1 + dy = y2-y1 + dr = math.sqrt(dx**2+dy**2) + D = x1*y2-x2*y1 + delta = (r**2)*(dr**2)-D**2 + if delta < 0: + return math.atan2(y1, x1) + # Two possible intersections = two possible phi values + xP = (D*dy+math.copysign(1,dy)*dx*math.sqrt(delta))/dr**2 + xM = (D*dy-math.copysign(1,dy)*dx*math.sqrt(delta))/dr**2 + yP = (-D*dx+abs(dy)*math.sqrt(delta))/dr**2 + yM = (-D*dx-abs(dy)*math.sqrt(delta))/dr**2 + + p1 = (xP, yP) + p2 = (xM, yM) + phi1 = math.atan2(yP,xP) + phi2 = math.atan2(yM,xM) + + phi = min([phi1, phi2], key = lambda x: abs(self.deltaPhi(x, muon.phi()))) #probably a better way to select which intersection + return phi + + + def process(self,gen,l1,dr=0.3,verbose=0): + #first efficiency + for g in gen: + if verbose: + print("Gen Muon pt={pt} eta={eta} phi={phi} vxy={dxy}".format(pt=g.pt(),eta=g.eta(),phi=g.phi(),dxy=math.sqrt(g.vx()*g.vx()+g.vy()*g.vy()))) + self.histoData['genpt'].Fill(g.pt()) + if abs(g.eta())<0.83: + self.histoData['genptB'].Fill(g.pt()) + elif abs(g.eta())>0.83 and abs(g.eta())<1.2: + self.histoData['genptO'].Fill(g.pt()) + else: + self.histoData['genptE'].Fill(g.pt()) + #Now let's process every threshold + for t in self.thresholds: + if g.pt()>(t+10): + self.histoData['geneta'][t].Fill(g.eta()) + self.histoData['genphi'][t].Fill(g.phi()) + if self.getAcceptance(g): + self.histoData['genlxy'][t].Fill(self.getLxy(g)) + + matched=[] + matchedDisplaced=[] + for mu in l1: + if mu.pt()20 and self.prefix=='tk' and t==15: +# import pdb;pdb.set_trace() + if len(matched)>0: + self.histoData['effpt'][t].Fill(g.pt()) + if abs(g.eta())<0.83: + self.histoData['effptB'][t].Fill(g.pt()) + elif abs(g.eta())>0.83 and abs(g.eta())<1.2: + self.histoData['effptO'][t].Fill(g.pt()) + else: + self.histoData['effptE'][t].Fill(g.pt()) + if g.pt()>(t+10): + self.histoData['effeta'][t].Fill(g.eta()) + self.histoData['effphi'][t].Fill(g.phi()) + deltaPt=10000 + best=None + for match in matched: + delta=abs(match.pt()-g.pt()) + if delta0: + if g.pt()>(t+10) and self.getAcceptance(g): + self.histoData['efflxy'][t].Fill(self.getLxy(g)) + + + #now rate + maxElement=None + maxPt=0 + for l in l1: + if verbose: + print("{prefix} Muon pt={pt} eta={eta} phi={phi} stubs={stubs}".format(prefix=self.prefix,pt=l.pt(),eta=l.eta(),phi=l.phi(),stubs=len(l.stubs()))) + for s in l.stubs(): + print("-----> Associated Stub etaR={eta} phiR={phi} depthR={depth} coord1={coord1} coord2={coord2} q={q} ".format(eta=s.etaRegion(),phi=s.phiRegion(),depth=s.depthRegion(),coord1=s.offline_coord1(),coord2=s.offline_coord2(),q=s.quality())) + if l.pt()>maxPt: + maxPt=l.pt() + maxElement=l + if maxElement!=None: + self.histoData['rate'].Fill(maxPt) + if abs(maxElement.eta())<0.83: + self.histoData['rateBarrel'].Fill(maxPt) + elif abs(maxElement.eta())>0.83 and abs(maxElement.eta())<1.2: + self.histoData['rateOverlap'].Fill(maxPt) + else: + self.histoData['rateEndcap'].Fill(maxPt) + for t in self.thresholds: + if maxPt>t: + self.histoData['rateeta'][t].Fill(maxElement.eta()) + + def write(self,f): + f.cd() + self.histoData['genpt'].Write() + self.histoData['genptB'].Write() + self.histoData['genptO'].Write() + self.histoData['genptE'].Write() + self.histoData['resolution'].Write() + c =self.histoData['rate'].GetCumulative(False) + c.Scale(float(self.bunchfactor)/float(counter)) + c.Write(self.prefix+"_rate") + c =self.histoData['rateBarrel'].GetCumulative(False) + c.Scale(float(self.bunchfactor)/float(counter)) + c.Write(self.prefix+"_rateBarrel") + c =self.histoData['rateOverlap'].GetCumulative(False) + c.Scale(float(self.bunchfactor)/float(counter)) + c.Write(self.prefix+"_rateOverlap") + c =self.histoData['rateEndcap'].GetCumulative(False) + c.Scale(float(self.bunchfactor)/float(counter)) + c.Write(self.prefix+"_rateEndcap") + for t in self.thresholds: + c =self.histoData['rateeta'][t] + c.Scale(float(self.bunchfactor)/float(counter)) + c.Write(self.prefix+"_rateeta_"+str(t)) + g = ROOT.TGraphAsymmErrors(self.histoData['effpt'][t],self.histoData['genpt']) + g.Write(self.prefix+"_eff_"+str(t)) + g = ROOT.TGraphAsymmErrors(self.histoData['effptB'][t],self.histoData['genptB']) + g.Write(self.prefix+"_effB_"+str(t)) + g = ROOT.TGraphAsymmErrors(self.histoData['effptO'][t],self.histoData['genptO']) + g.Write(self.prefix+"_effO_"+str(t)) + g = ROOT.TGraphAsymmErrors(self.histoData['effptE'][t],self.histoData['genptE']) + g.Write(self.prefix+"_effE_"+str(t)) + g = ROOT.TGraphAsymmErrors(self.histoData['effeta'][t],self.histoData['geneta'][t]) + g.Write(self.prefix+"_effeta_"+str(t)) + g = ROOT.TGraphAsymmErrors(self.histoData['effphi'][t],self.histoData['genphi'][t]) + g.Write(self.prefix+"_effphi_"+str(t)) + g = ROOT.TGraphAsymmErrors(self.histoData['efflxy'][t],self.histoData['genlxy'][t]) + g.Write(self.prefix+"_efflxy_"+str(t)) + + -#events=Events(minbias) -#events=Events(['reprocess.root']) -def fetchTracks(event): - trackHandle = Handle('vector,Phase2TrackerDigi,edm::refhelper::FindForDetSetVector > > >') - event.getByLabel("l1tTTTracksFromTrackletEmulation:Level1TTTracks",trackHandle) - return trackHandle.product() - +#HELPERS +def strAppend(s): + return "root://cmsxrootd.fnal.gov/"+s +def fetchSTA(event,tag,etamax=3.0): + phiSeg2 = Handle ('vector') + event.getByLabel(tag,phiSeg2) + return list(filter(lambda x: abs(x.eta())') event.getByLabel(tag,phiSeg2) - return filter(lambda x: abs(x.eta())') event.getByLabel(tag,phiSeg2) return phiSeg2.product() - def fetchGEN(event,etaMax=3.0): genH = Handle ('vector') event.getByLabel('genParticles',genH) - genMuons=filter(lambda x: abs(x.pdgId())==13 and x.status()==1 and abs(x.eta()) math.pi: - res -= 2*math.pi - while res < -math.pi: - res += 2*math.pi - return res - -def deltaR( *args ): - return math.sqrt( deltaR2(*args) ) - -def deltaR2( e1, p1, e2, p2): - de = e1 - e2 - dp = deltaPhi(p1, p2) - return de*de + dp*dp - - - - -quality = ROOT.TH3D("quality","",16,0,4096,16,0,4096,128,0,512) -qualityAll = ROOT.TH3D("qualityAll","",16,0,4096,16,0,4096,128,0,512) -histoData={'effpt':{}, 'effeta':{},'geneta':{},'genphi':{},'effphi':{}} -histoData['genpt'] = ROOT.TH1D("genpt","genpt",50,0,50) - -thresholds=[1,3,5,15,20] -for t in thresholds: - histoData['effpt'][t] = ROOT.TH1D("effpt_"+str(t),"effpt_"+str(t),50,0,50) - histoData['effeta'][t] = ROOT.TH1D("effeta_"+str(t),"effeta_"+str(t),48,-2.4,2.4) - histoData['effphi'][t] = ROOT.TH1D("effphi_"+str(t),"effphi_"+str(t),32,-math.pi,math.pi) - histoData['geneta'][t] = ROOT.TH1D("geneta_"+str(t),"effeta_"+str(t),48,-2.4,2.4) - histoData['genphi'][t] = ROOT.TH1D("genphi_"+str(t),"genphi_"+str(t),32,-math.pi,math.pi) - - - - -histoData['rate']= ROOT.TH1D("rate","rate",50,0,100) -histoData['rate20eta']= ROOT.TH1D("rate20eta","rate",8,0,8) - - -BUNCHFACTOR=40000*2760.0/3564.0 - -QUALITYCUT=0 +def EOSls(path): + print('eos root://cmseos.fnal.gov/ find -name "*root" %s' % path ) + p = subprocess.Popen('eos root://cmseos.fnal.gov/ find -name "*root" %s' % path, + stdout = subprocess.PIPE, stderr = subprocess.PIPE, + shell=True) + stdout, stderr = p.communicate() + out = ["root://cmseos.fnal.gov/"+i.decode('UTF-8') for i in stdout.split()] + return out +#DATASET +# from samples200 import * +# toProcess = dy200 +# files=[] +# for p in toProcess: + # files.append(strAppend(p)) +# events=Events(files) +# tag='DY_v1' +# tag='disp200' + +parser = argparse.ArgumentParser(description='Process some integers.') +parser.add_argument('--tag', default="Tau", help="fdf") +parser.add_argument('--prod', default="gmtMuons", help="fdf") +args = parser.parse_args() +tag = args.tag +samples = { + "MB_org" : "/eos/uscms//store/group/lpctrig/benwu/GMT_Ntupler/Spring22_GMToriginal_v2/MinBias_TuneCP5_14TeV-pythia8/PHASEII_MinBias/", + "DY_org" : "/eos/uscms//store/group/lpctrig/benwu/GMT_Ntupler/Spring22_GMToriginal_v2/DYToLL_M-50_TuneCP5_14TeV-pythia8/PHASEII_DYToLL/", + "MB_v1" : "/eos/uscms//store/group/lpctrig/benwu/GMT_Ntupler/Spring22_GMT_v3/MinBias_TuneCP5_14TeV-pythia8/PHASEII_MinBias/", + "DY_v1" : "/eos/uscms//store/group/lpctrig/benwu/GMT_Ntupler/Spring22_GMT_v3/DYToLL_M-50_TuneCP5_14TeV-pythia8/PHASEII_DYToLL/", +} +flist = EOSls(samples[tag]) +events= Events(flist) +# events=Events(['file:/uscmst1b_scratch/lpc1/3DayLifetime/bachtis/gmt.root']) +#events=Events(['file:gmt.root']) +# events=Events(['file:reprocess.root']) + + +#ANALYSIS SETUP verbose=0 -counter=-1 +saAnalyzer = muon_trigger_analyzer('sta_prompt') +kmtfAnalyzer_p = muon_trigger_analyzer('kmtf_prompt') +kmtfAnalyzer_d = muon_trigger_analyzer('kmtf_disp') +tkAnalyzer_1st = muon_trigger_analyzer('tk_1st') +tkAnalyzer_2st = muon_trigger_analyzer('tk_2st') +tkAnalyzer_2m = muon_trigger_analyzer('tk_2m') +tkAnalyzer_3m = muon_trigger_analyzer('tk_3m') +tkAnalyzer_4m = muon_trigger_analyzer('tk_4m') + +#EVENT LOOP + +counter=0; for event in events: - counter=counter+1 - if counter==100000: - break; - gen=fetchGEN(event,2.4) - stubs = fetchStubs(event,'l1tGMTStubs') - tps = filter(lambda x: ID(x.hwEta(),x.hwPt(),x.hwQual()),fetchTPS(event,'l1tGMTMuons')) -# tps = fetchTPS(event,'gmtMuons') - tracks=fetchTracks(event) - - if verbose: - for t in sorted(tracks,key=lambda x: x.momentum().transverse(),reverse=True): - print("Track ",t.eta(),t.phi(),t.momentum().transverse(),t.getStubRefs().size()) - for t in sorted(tps,key=lambda x: x.pt(),reverse=True): - print("Tracker Muon pt={pt} eta={eta} phi={phi} qual={qual}".format(pt=t.pt(),eta=t.eta(),phi=t.phi(),qual=t.hwQual)) - - # import pdb;pdb.set_trace() - for s in stubs: - print(" All Stub depth={depth} eta={eta1},{eta1I},{eta2},{eta2I} phi={phi1},{phi1I},{phi2},{phi2I} qualities={etaQ},{phiQ}".format(depth=s.depthRegion(),eta1=s.offline_eta1(),eta1I=s.eta1(),eta2=s.offline_eta2(),eta2I=s.eta2(),phi1=s.offline_coord1(),phi1I=s.coord1(),phi2=s.offline_coord2(),phi2I=s.coord2(),etaQ=s.etaQuality(),phiQ=s.quality())) - - - if len(tps)>0: - tpsInEta =filter(lambda x: abs(x.eta())<2.4,tps) - if len(tpsInEta)>0: - best=max(tpsInEta,key=lambda x: x.pt()) - qualityAll.Fill(abs(best.hwEta()),best.hwPt(),best.hwQual()-min(63,best.hwPt()/32)) - pt=best.pt() - if pt>99.9: - pt=99.9 - histoData['rate'].Fill(pt) - if pt>20: - histoData['rate20eta'].Fill(abs(best.hwEta())/512) -# import pdb;pdb.set_trace() - - - if counter %1000==0: - print(counter) - if verbose: - print ("EVENT:",counter) - - #efficiencies -loop on gen - for g in gen: - histoData['genpt'].Fill(g.pt()) - for thres in thresholds: - if g.pt()>(thres+2.0): - histoData['geneta'][thres].Fill(g.eta()) - histoData['genphi'][thres].Fill(g.phi()) - - if verbose: - print("Gen Muon pt={pt} eta={eta} phi={phi} charge={charge}".format(pt=g.pt(),eta=g.eta(),phi=g.phi(),charge=g.charge())) - - foundMatch=False - tpsMatched = sorted(filter(lambda x: deltaR(g.eta(),g.phi(),x.eta(),x.phi())<0.3, tps),key=lambda x:x.pt(),reverse=True) -# if len(tpsMatched)==0 and g.pt()>10: -# print("Not Matched ",g.pt(),g.eta(),len(tps)) -# import pdb;pdb.set_trace() - if len(tpsMatched)>0: - foundMatch=True - - if verbose: - for t in tpsMatched: - print(" -> matched track ->Tracker Muon pt={pt} eta={eta} phi={phi} qual={qual}".format(pt=t.pt(),eta=t.eta(),phi=t.phi(),qual=t.hwQual())) - best=tpsMatched[0] - quality.Fill(abs(best.hwEta()),best.hwPt(),best.hwQual()-min(63,best.hwPt()/32)) - for thres in thresholds: - overThreshold = filter(lambda x: x.pt()>thres,tpsMatched) - if len(overThreshold)>0: - histoData['effpt'][thres].Fill(g.pt()) - if g.pt()>(thres+2.0): - histoData['effeta'][thres].Fill(g.eta()) - histoData['effphi'][thres].Fill(g.phi()) - - - - - - - - stubsMatched = filter(lambda x: deltaR(g.eta(),g.phi(),x.offline_eta1(),x.offline_coord1())<0.3, stubs) - if verbose: - for s in stubsMatched: - print(" -> matched stub -> Muon Stub eta={eta1},{eta2} phi={phi1},{phi2} qualities={etaQ},{phiQ}".format(eta1=s.offline_eta1(),eta2=s.offline_eta2(),phi1=s.offline_coord1(),phi2=s.offline_coord2(),etaQ=s.etaQuality(),phiQ=s.quality())) - - - -f=ROOT.TFile("tpsResults_output.root","RECREATE") + if verbose: + print('EVENT {}'.format(counter)) + gen=fetchGEN(event,2.4) + genKMTF=fetchGEN(event,0.83) + sa=fetchSTA(event,'gmtSAMuons:prompt',2.5) + kmtf_p=fetchSTA(event,'gmtKMTFMuons:prompt',2.5) + kmtf_d=fetchSTA(event,'gmtKMTFMuons:displaced',2.5) + tps=fetchTPS(event,'gmtTkMuons',2.5) + # sa=fetchSTA(event,'l1tSAMuonsGmt:prompt',2.5) + # kmtf_p=fetchSTA(event,'l1tKMTFMuonsGmt:prompt',2.5) + # kmtf_d=fetchSTA(event,'l1tKMTFMuonsGmt:displaced',2.5) + # tps=fetchTPS(event,'l1tTkMuonsGmt',2.5) + tps_2st=list(filter(lambda x: x.stubs().size()>1,tps)) + tps_2m=list(filter(lambda x: x.numberOfMatches()>1,tps)) + tps_3m=list(filter(lambda x: x.numberOfMatches()>2,tps)) + tps_4m=list(filter(lambda x: x.numberOfMatches()>3,tps)) + #analyze + saAnalyzer.process(gen,sa,0.6,verbose) + kmtfAnalyzer_p.process(genKMTF,kmtf_p,0.6,verbose) + kmtfAnalyzer_d.process(genKMTF,kmtf_d,0.6,verbose) + tkAnalyzer_1st.process(gen,tps,0.2,verbose) + tkAnalyzer_2st.process(gen,tps_2st,0.2,0) + tkAnalyzer_2m.process(gen,tps_2m,0.2,0) + tkAnalyzer_3m.process(gen,tps_3m,0.2,0) + tkAnalyzer_4m.process(gen,tps_4m,0.2,0) + + + +# if verbose==1 and counter==69: +# import pdb;pdb.set_trace() + #counter +# if counter==100000: +# break + + if (counter %10000 ==0): + print(counter) + counter=counter+1 + +f=ROOT.TFile("gmtAnalysis_{tag}.root".format(tag=tag),"RECREATE") f.cd() -quality.Write() -qualityAll.Write() - -c = histoData['rate'].GetCumulative(False) -c.Scale(float(BUNCHFACTOR)/float(counter)) -c.Write("rate") - -for t in thresholds: - g = ROOT.TGraphAsymmErrors(histoData['effpt'][t],histoData['genpt']) - g.Write("eff_"+str(t)) - g = ROOT.TGraphAsymmErrors(histoData['effeta'][t],histoData['geneta'][t]) - g.Write("effeta_"+str(t)) - g = ROOT.TGraphAsymmErrors(histoData['effphi'][t],histoData['genphi'][t]) - g.Write("effphi_"+str(t)) - +saAnalyzer.write(f) +kmtfAnalyzer_p.write(f) +kmtfAnalyzer_d.write(f) +tkAnalyzer_1st.write(f) +tkAnalyzer_2st.write(f) +tkAnalyzer_2m.write(f) +tkAnalyzer_3m.write(f) +tkAnalyzer_4m.write(f) f.Close() - diff --git a/L1Trigger/Phase2L1GMT/test/makeKMTFCoarsseEtaLUT.py b/L1Trigger/Phase2L1GMT/test/makeKMTFCoarsseEtaLUT.py new file mode 100644 index 0000000000000..c2f8b21e5bf32 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/test/makeKMTFCoarsseEtaLUT.py @@ -0,0 +1,13 @@ +import ROOT +from math import pi +f=ROOT.TFile("../data/packedGainLUTs.root") +lut=f.Get("coarseETALUT") +l=[] +for i in range(0,256): + b = lut.GetXaxis().FindBin(i) + c=lut.GetBinContent(b) + l.append(str(int((1<<12)*c/pi))) + +print("const ap_uint coarseEtaLUT[256] ={"+','.join(l)+'};') + +f.Close() diff --git a/L1Trigger/Phase2L1GMT/test/makeKMTFPTLUT.py b/L1Trigger/Phase2L1GMT/test/makeKMTFPTLUT.py new file mode 100644 index 0000000000000..50301705ea5ac --- /dev/null +++ b/L1Trigger/Phase2L1GMT/test/makeKMTFPTLUT.py @@ -0,0 +1,17 @@ +lut=[] +for k in range(0,8192): + if k<103: + fk=103 + else: + fk=k + lsb = 1.25 /float(1 << 15); + fk=fk*lsb + if fk==0: + lut.append(str(8191)) + else: + ptF = 1.0/fk + pt =int(ptF/0.03125) + lut.append(str(pt)) + +print("const ap_uint ptLUT[8192] = {"+','.join(lut)+'};') + diff --git a/L1Trigger/Phase2L1GMT/test/runEMTFWithGMT.py b/L1Trigger/Phase2L1GMT/test/runEMTFWithGMT.py new file mode 100644 index 0000000000000..778e78c9a8ef0 --- /dev/null +++ b/L1Trigger/Phase2L1GMT/test/runEMTFWithGMT.py @@ -0,0 +1,192 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: EMTFTools/ParticleGuns/LLP_flatMass_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 8 --conditions auto:phase2_realistic --era Phase2C17I13M9 --geometry Extended2026D88 --fileout file:out.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --customise_commands=process.TFileService = cms.Service('TFileService', fileName = cms.string('out.root'))\nprocess.gemRecHits.gemDigiLabel = 'simMuonGEMDigis'\nprocess.emtfToolsNtupleMaker.EMTFP2SimInfoEnabled = cms.bool(False)\nprocess.emtfToolsNtupleMaker.L1TrackTriggerTracksEnabled = cms.bool(False)\nprocess.emtfToolsNtupleMaker.TrackingParticlesEnabled = cms.bool(True)\nprocess.emtfToolsNtupleMaker.GenParticlesEnabled = cms.bool(False) --python_filename test/phase2/pset_XTo2LongLivedTo4Mu.py --no_exec --mc +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 + +process = cms.Process('L1',Phase2C17I13M9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D88_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + TryToContinue = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + holdsReferencesToDeleteEarly = cms.untracked.VPSet(), + makeTriggerResults = cms.obsolete.untracked.bool, + modulesToCallForTryToContinue = cms.untracked.vstring(), + modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('EMTFTools/ParticleGuns/LLP_flatMass_cfi.py nevts:1000'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('FEVTDEBUGHLT'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('emtfwithgmt.root'), + outputCommands = cms.untracked.vstring( + "drop *_*_*_*", + 'keep *_l1tStubsGmt_*_*', + "keep *_l1tFwdMuonsGmt_*_*", + "keep *_genParticles_*_*", + "keep *_l1tTTTracksFromTrackletEmulation_Level1TTTracks_*", + "keep *_l1tTkMuons_*_*" + ), + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.generator = cms.EDProducer("FlatRandomLLPGunProducer2", + AddAntiParticle = cms.bool(False), + PGunParameters = cms.PSet( + LLPMassSpectrum = cms.string('flatMass'), + MaxCTauLLP = cms.double(5000), + MaxEta = cms.double(3.5), + MaxMassH = cms.double(1000), + MaxPhi = cms.double(3.141592653589793), + MaxPtH = cms.double(120), + MinCTauLLP = cms.double(10), + MinEta = cms.double(1e-06), + MinMassH = cms.double(20), + MinPhi = cms.double(-3.141592653589793), + MinPtH = cms.double(1), + PartID = cms.vint32(-13) + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('LLP decay with flat mass spectrum') +) + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# EMTF++ Step +process.load('L1Trigger.L1TMuonEndCapPhase2.simCscTriggerPrimitiveDigisForEMTF_cfi') +process.load('L1Trigger.L1TMuonEndCapPhase2.rpcRecHitsForEMTF_cfi') +process.load('L1Trigger.L1TMuonEndCapPhase2.simEmtfDigisPhase2_cfi') + +process.gemRecHits.gemDigiLabel = 'simMuonGEMDigis' +process.simEmtfDigisPhase2.Verbosity = cms.untracked.int32(1) + +process.L1TMuonEndCapPhase2Task = cms.Task( + process.simCscTriggerPrimitiveDigisForEMTF, + process.rpcRecHitsForEMTF, + process.simEmtfDigisPhase2 +) +process.L1TMuonEndCapPhase2Sequence = cms.Sequence(process.L1TMuonEndCapPhase2Task) +process.L1TMuonEndCapPhase2_step = cms.Path(process.L1TMuonEndCapPhase2Sequence) + + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.L1TMuonEndCapPhase2_step, process.endjob_step,process.FEVTDEBUGHLToutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads = 8 +process.options.numberOfStreams = 0 +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.generator) + +# customisation of the process. + +# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig +from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP + +#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig +process = higherPtTP(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging +from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 + +#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging +process = customise_aging_1000(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 +from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 + +#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 +process = customisePhase2TTOn110(process) + +# End of customisation functions + +# Customisation from command line + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/L1Trigger/Phase2L1GMT/test/runGMT.py b/L1Trigger/Phase2L1GMT/test/runGMT.py index 4268397646d3c..f8a99aab5dfea 100644 --- a/L1Trigger/Phase2L1GMT/test/runGMT.py +++ b/L1Trigger/Phase2L1GMT/test/runGMT.py @@ -1,13 +1,13 @@ # Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v # with command line options: step1 --conditions 111X_mcRun4_realistic_T15_v3 -n 2 --era Phase2C9 --eventcontent FEVTDEBUGHLT --runUnscheduled file:/eos/cms/store/relval/CMSSW_11_0_0/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v2/10000/01054EE2-1B51-C449-91A2-5202A60D16A3.root -s RAW2DIGI,L1TrackTrigger,L1 --datatier FEVTDEBUGHLT --customise SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTNoMC.customisePhase2TTNoMC,Configuration/DataProcessing/Utils.addMonitoring --geometry Extended2026D49 --fileout file:/tmp/step1_Reprocess_TrackTrigger_L1.root --no_exec --nThreads 8 --python step1_L1_ProdLike.py --filein das:/TT_TuneCP5_14TeV-powheg-pythia8/Phase2HLTTDRWinter20DIGI-PU200_110X_mcRun4_realistic_v3-v2/GEN-SIM-DIGI-RAW import FWCore.ParameterSet.Config as cms -from Configuration.Eras.Era_Phase2C9_cff import Phase2C9 +from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 -process = cms.Process('L1',Phase2C9) +process = cms.Process('L1',Phase2C17I13M9) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') @@ -15,32 +15,24 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') -process.load('Configuration.StandardSequences.RawToDigi_Data_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') process.load('Configuration.StandardSequences.L1TrackTrigger_cff') process.load('Configuration.StandardSequences.SimL1Emulator_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(18), + input = cms.untracked.int32(-1), output = cms.optional.untracked.allowed(cms.int32,cms.PSet), ) # Input source process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( ( -#'/store/mc/Phase2HLTTDRWinter20DIGI/JPsiToMuMu_Pt0to100-pythia8_TuneCP5-gun/GEN-SIM-DIGI-RAW/PU200_110X_mcRun4_realistic_v3-v2/20000/087AA768-91E6-124F-B226-DC00C45D967D.root', -'/store/mc/Phase2HLTTDRWinter20DIGI/DYToLL_M-50_TuneCP5_14TeV-pythia8/GEN-SIM-DIGI-RAW/PU200_pilot_110X_mcRun4_realistic_v3-v2/10000/0036F7A2-BADA-1E4E-8FE7-ABE1A9AEC350.root', -'/store/mc/Phase2HLTTDRWinter20DIGI/DYToLL_M-50_TuneCP5_14TeV-pythia8/GEN-SIM-DIGI-RAW/PU200_pilot_110X_mcRun4_realistic_v3-v2/10000/007C3CAA-5209-3B47-8755-4C6D0A3A5CD2.root', -'/store/mc/Phase2HLTTDRWinter20DIGI/DYToLL_M-50_TuneCP5_14TeV-pythia8/GEN-SIM-DIGI-RAW/PU200_pilot_110X_mcRun4_realistic_v3-v2/10000/00AECAEC-8DFE-8D49-AF78-A55FCEBB46B7.root', -'/store/mc/Phase2HLTTDRWinter20DIGI/DYToLL_M-50_TuneCP5_14TeV-pythia8/GEN-SIM-DIGI-RAW/PU200_pilot_110X_mcRun4_realistic_v3-v2/10000/00B04974-FAC3-5A4E-B5AE-9483D8FAD5B1.root', -'/store/mc/Phase2HLTTDRWinter20DIGI/DYToLL_M-50_TuneCP5_14TeV-pythia8/GEN-SIM-DIGI-RAW/PU200_pilot_110X_mcRun4_realistic_v3-v2/10000/00D64490-55F9-7E4E-B3CE-BE668F1A5938.root', -'/store/mc/Phase2HLTTDRWinter20DIGI/DYToLL_M-50_TuneCP5_14TeV-pythia8/GEN-SIM-DIGI-RAW/PU200_pilot_110X_mcRun4_realistic_v3-v2/10000/01708416-15F1-5B47-A8A0-B32D355622DB.root' ) ), secondaryFileNames = cms.untracked.vstring() -# skipEvents=cms.untracked.uint32(36) ) process.options = cms.untracked.PSet( @@ -49,6 +41,8 @@ TryToContinue = cms.untracked.vstring(), allowUnscheduled = cms.obsolete.untracked.bool, canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), emptyRunLumiMode = cms.obsolete.untracked.string, eventSetup = cms.untracked.PSet( forceNumberOfConcurrentIOVs = cms.untracked.PSet( @@ -88,6 +82,7 @@ "drop *_*_*_*", "keep *_l1tGMTMuons_*_*", "keep *_l1tGMTStubs_*_*", + "keep *_l1tFwdMuonsGmt_*_*", "keep *_genParticles_*_*", "keep *_l1tTTTracksFromTrackletEmulation_Level1TTTracks_*", "keep *_l1tTkMuons_*_*" @@ -99,12 +94,12 @@ # Other statements from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '111X_mcRun4_realistic_T15_v3', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') ## #Calibrate Digis process.load("L1Trigger.DTTriggerPhase2.CalibratedDigis_cfi") -process.CalibratedDigis.dtDigiTag = "simMuonDTDigis" +process.CalibratedDigis.dtDigiTag = "simMuonDTDigis" process.CalibratedDigis.scenario = 0 #DTTriggerPhase2 @@ -135,31 +130,28 @@ # customisation of the process. # Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging -from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 +from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 #call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging #process = customise_aging_1000(process) # Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTNoMC -from L1Trigger.Configuration.customisePhase2TTNoMC import customisePhase2TTNoMC +from L1Trigger.Configuration.customisePhase2TTNoMC import customisePhase2TTNoMC #call to customisation function customisePhase2TTNoMC imported from L1Trigger.Configuration.customisePhase2TTNoMC process = customisePhase2TTNoMC(process) # Automatic addition of the customisation function from Configuration.DataProcessing.Utils -from Configuration.DataProcessing.Utils import addMonitoring +from Configuration.DataProcessing.Utils import addMonitoring #call to customisation function addMonitoring imported from Configuration.DataProcessing.Utils process = addMonitoring(process) # End of customisation functions -#do not add changes to your config after this point (unless you know what you are doing) -from FWCore.ParameterSet.Utilities import convertToUnscheduled -process=convertToUnscheduled(process) - # Customisation from command line +process.source.inputCommands = cms.untracked.vstring("keep *", "drop l1tPFJets_*_*_*") # Add early deletion of temporary data products to reduce peak memory need from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete process = customiseEarlyDelete(process) diff --git a/L1Trigger/Phase2L1GMT/test/runMuonTrigger.py b/L1Trigger/Phase2L1GMT/test/runMuonTrigger.py new file mode 100644 index 0000000000000..10f844b9fc97f --- /dev/null +++ b/L1Trigger/Phase2L1GMT/test/runMuonTrigger.py @@ -0,0 +1,183 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step1 --conditions 125X_mcRun4_realistic_v2 -n 2 --era Phase2C17I13M9 --eventcontent FEVTDEBUGHLT -s RAW2DIGI,L1TrackTrigger,L1 --datatier GEN-SIM-DIGI-RAW-MINIAOD --fileout file:test.root --customise SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,Configuration/DataProcessing/Utils.addMonitoring,L1Trigger/Configuration/customisePhase2.addHcalTriggerPrimitives,L1Trigger/Configuration/customisePhase2FEVTDEBUGHLT.customisePhase2FEVTDEBUGHLT,L1Trigger/Configuration/customisePhase2TTNoMC.customisePhase2TTNoMC --geometry Extended2026D88 --nThreads 8 --filein /store/mc/Phase2Fall22DRMiniAOD/TT_TuneCP5_14TeV-powheg-pythia8/GEN-SIM-DIGI-RAW-MINIAOD/PU200_125X_mcRun4_realistic_v2_ext1-v1/30000/000c5e5f-78f7-44ee-95fe-7b2f2c2e2312.root --mc --customise_commands=process.source.inputCommands = cms.untracked.vstring("keep *", "drop l1tPFJets_*_*_*") +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 + +process = cms.Process('PHASE2MUONL1T',Phase2C17I13M9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + "file:/uscms_data/d2/lpctrig/benwu/GMTEmulator/TT2L2Nu_PU200_Spring23.root", +# '/store/user/bachtis/L1T/DYToLL_M-50_TuneCP5_14TeV-pythia8/PHASEII_DY200a/230803_231922/0000/skim_10.root' +#'/store/mc/Phase2Fall22DRMiniAOD/MinBias_TuneCP5_14TeV-pythia8/GEN-SIM-DIGI-RAW-MINIAOD/PU200_125X_mcRun4_realistic_v2-v1/30000/001ec7cf-71d4-4eb4-9002-078d21560b2f.root' + ), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + # FailPath = cms.untracked.vstring(), + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + # SkipEvent = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + makeTriggerResults = cms.obsolete.untracked.bool, + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step1 nevts:2'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition +process.FEVTDEBUGHLTEventContent.outputCommands = [ + 'drop *_*_*_*', + 'keep *_g4SimHits_Muon*_*', + 'keep *_CalibratedDigis_*_MUONL1T', + 'keep *_dtTriggerPhase2PrimitiveDigis_*_MUONL1T', + 'keep *_l1tStubsGmt_*_MUONL1T', + 'keep *_l1tSAMuonsGmt_*_MUONL1T', + 'keep *_l1tKMTFMuonsGmt_*_MUONL1T', + 'keep *_l1tFwdMuonsGmt_*_MUONL1T', + 'keep *_l1tTkMuonsGmt_*_MUONL1T', + 'keep *_genParticles_*_*', + 'keep *_simCscTriggerPrimitiveDigis_*_*', + 'keep *_simDtTriggerPrimitiveDigis_*_*', + 'keep *_simMuonRPCDigis_*_*', + 'keep *_simMuonDTDigis_*_*', + 'keep *_simBmtfDigis_*_*', + 'keep *_simEmtfDigis_*_*', + 'keep *_simGmtStage2Digis_*_*', + "keep *_gmt*Muons_*_*", + "keep *_gmtStubs_*_*", + "keep *_genParticles_*_*", + "keep *_l1tTTTracksFromTrackletEmulation_Level1TTTracks_*", + "keep *_l1tTkMuons_*_*", + 'keep *_simOmtfDigis_*_*', + 'keep *_l1tTTTracksFromTrackletEmulation_Level1TTTracks_*' +] + +#process.FEVTDEBUGHLTEventContent.outputCommands.append('drop l1tTrackerMuons_l1tTkMuonsGmt__HLT') + + + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW-MINIAOD'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('file:skim.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '125X_mcRun4_realistic_v2', '') + + +process.load("L1Trigger.Phase2L1GMT.gmt_cff") +process.L1simulation_step = cms.Path(process.CalibratedDigis*process.dtTriggerPhase2PrimitiveDigis*process.phase2GMT) + +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +#process.options.numberOfThreads = 8 +#process.options.numberOfStreams = 0 + +# customisation of the process. + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging +from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 + +#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging +process = customise_aging_1000(process) + +# Automatic addition of the customisation function from Configuration.DataProcessing.Utils +from Configuration.DataProcessing.Utils import addMonitoring + +#call to customisation function addMonitoring imported from Configuration.DataProcessing.Utils +process = addMonitoring(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2 +from L1Trigger.Configuration.customisePhase2 import addHcalTriggerPrimitives + +#call to customisation function addHcalTriggerPrimitives imported from L1Trigger.Configuration.customisePhase2 +process = addHcalTriggerPrimitives(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2FEVTDEBUGHLT +from L1Trigger.Configuration.customisePhase2FEVTDEBUGHLT import customisePhase2FEVTDEBUGHLT + +#call to customisation function customisePhase2FEVTDEBUGHLT imported from L1Trigger.Configuration.customisePhase2FEVTDEBUGHLT +process = customisePhase2FEVTDEBUGHLT(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTNoMC +from L1Trigger.Configuration.customisePhase2TTNoMC import customisePhase2TTNoMC + +#call to customisation function customisePhase2TTNoMC imported from L1Trigger.Configuration.customisePhase2TTNoMC +process = customisePhase2TTNoMC(process) + +# End of customisation functions + + +# Customisation from command line + +process.source.inputCommands = cms.untracked.vstring("keep *", "drop l1tPFJets_*_*_*") +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/L1Trigger/Phase2L1GMT/test/saStudy.py b/L1Trigger/Phase2L1GMT/test/saStudy.py new file mode 100644 index 0000000000000..bd1b42f89d96d --- /dev/null +++ b/L1Trigger/Phase2L1GMT/test/saStudy.py @@ -0,0 +1,240 @@ +import ROOT,itertools,math +from array import array +from DataFormats.FWLite import Events, Handle +ROOT.FWLiteEnabler.enable() + + + + +def strAppend(s): + return "root://cmsxrootd.fnal.gov/"+s + +def fetchKMTF(event,tag,etamax=3.0): + phiSeg2 = Handle ('vector') + event.getByLabel(tag,phiSeg2) + return list(filter(lambda x: abs(x.eta())') + event.getByLabel(tag,phiSeg2) + return phiSeg2.product() + + +def fetchGEN(event,etaMax=3.0): + genH = Handle ('vector') + event.getByLabel('genParticles',genH) + genMuons=list(filter(lambda x: abs(x.pdgId())==13 and x.status()==1 and abs(x.eta()) math.pi: + res -= 2*math.pi + while res < -math.pi: + res += 2*math.pi + return res + +def deltaR( *args ): + return math.sqrt( deltaR2(*args) ) + +def deltaR2( e1, p1, e2, p2): + de = e1 - e2 + dp = deltaPhi(p1, p2) + return de*de + dp*dp + + +histoData={'effpt':{}, 'effeta':{},'geneta':{},'genphi':{},'effphi':{},'effptB':{},'effptO':{},'effptE':{}} +histoData['genpt'] = ROOT.TH1D("genpt","genpt",20,0,100) +histoData['genptB'] = ROOT.TH1D("genptB","genptB",20,0,100) +histoData['genptO'] = ROOT.TH1D("genptO","genptO",20,0,100) +histoData['genptE'] = ROOT.TH1D("genptE","genptE",20,0,100) +rate = ROOT.TH1D("rate","rate",20,0,100) +rateB = ROOT.TH1D("rateB","rateB",20,0,100) +rateO = ROOT.TH1D("rateO","rateO",20,0,100) +rateE = ROOT.TH1D("rateE","rateE",20,0,100) + +thresholds=[0,1,3,5,15,20] +for t in thresholds: + histoData['effpt'][t] = ROOT.TH1D("effpt_"+str(t),"effpt_"+str(t),20,0,100) + histoData['effptB'][t] = ROOT.TH1D("effptB_"+str(t),"effpt_"+str(t),20,0,100) + histoData['effptO'][t] = ROOT.TH1D("effptO_"+str(t),"effpt_"+str(t),20,0,100) + histoData['effptE'][t] = ROOT.TH1D("effptE_"+str(t),"effpt_"+str(t),20,0,100) + histoData['effeta'][t] = ROOT.TH1D("effeta_"+str(t),"effeta_"+str(t),48,-2.4,2.4) + histoData['effphi'][t] = ROOT.TH1D("effphi_"+str(t),"effphi_"+str(t),32,-math.pi,math.pi) + histoData['geneta'][t] = ROOT.TH1D("geneta_"+str(t),"effeta_"+str(t),48,-2.4,2.4) + histoData['genphi'][t] = ROOT.TH1D("genphi_"+str(t),"genphi_"+str(t),32,-math.pi,math.pi) + + + + +etaLUT = ROOT.TH2D("etaLUT","etaLUT",256,0,256,128,0.0,1.0) + +from samples200 import * +toProcess = jpsi200 + +files=[] + +for p in toProcess: + files.append(strAppend(p)) + +#events=Events(['file:/uscmst1b_scratch/lpc1/3DayLifetime/bachtis/test.root']) +events=Events(files) + + + +displaced=0 + + + +BUNCHFACTOR=40000*2760.0/3564.0 + +counter=0; +for event in events: + + gen=fetchGEN(event,2.4) + sa=fetchKMTF(event,'l1tSAMuonsGmt:prompt',2.5) + if displaced==1: + gen=fetchGEN(event,0.) + sa=fetchKMTF(event,'l1tKMTFMuonsGmt:displaced',2.5) + + highq=[] + + #reject single stub muons + for s in sa: + if s.hwQual()>0: + highq.append(s) + sa=highq + + maxPT = None + maxPTB = None + maxPTO = None + maxPTE = None + + for s in sa: + if maxPT==None or s.pt()>maxPT: + maxPT=s.pt() + if (maxPTB==None or s.pt()>maxPTB) and abs(s.eta())<0.83: + maxPTB=s.pt() + if (maxPTO==None or s.pt()>maxPTO) and abs(s.eta())>0.83 and abs(s.eta())<1.2: + maxPTO=s.pt() + if (maxPTE==None or s.pt()>maxPTE) and abs(s.eta())>1.2: + maxPTE=s.pt() + if maxPT!=None: + rate.Fill(maxPT) + if maxPTB!=None: + rateB.Fill(maxPTB) + if maxPTO!=None: + rateO.Fill(maxPTO) + if maxPTE!=None: + rateE.Fill(maxPTE) + + + +# print('---------------------NEW EVENT---------------------') + if counter %10000 ==0: + print(counter) + +# if counter==150000: +# break; +# print(counter) +# print('Generated muons') + for m in gen: + +# print("gen pt=",m.pt()) + histoData['genpt'].Fill(m.pt()) + if abs(m.eta())<0.83: + histoData['genptB'].Fill(m.pt()) + elif abs(m.eta())>0.83 and abs(m.eta())<1.2: + histoData['genptO'].Fill(m.pt()) + else: + histoData['genptE'].Fill(m.pt()) + for t in thresholds: + if m.pt()>(float(t)+10.0): + histoData['geneta'][t].Fill(m.eta()) + histoData['genphi'][t].Fill(m.phi()) + #fill the etaLUT + for r in sa: + if abs(deltaPhi(r.phi(),m.phi()))<0.3 and r.pt()>float(t) and r.hwQual()>0: + code=0; + for s in r.stubs(): + code = code| ( (int(abs(s.etaRegion())+1))<<(2*(s.depthRegion()-1))) + etaLUT.Fill(code,abs(m.eta())) + + for t in thresholds: +# print("Threshold {}".format(t)) +# for s in sa: +# print("muon pt={}".format(s.pt())) + matched=False + for r in sa: +# print("SA over muon pt={}".format(r.pt())) + + if deltaR(r.eta(),r.phi(),m.eta(),m.phi())<0.5 and r.pt()>float(t) and r.hwQual()>0: + matched=True + break +# print("matched={}".format(matched)) + if matched: + histoData['effpt'][t].Fill(m.pt()) + if abs(m.eta())<0.83: + histoData['effptB'][t].Fill(m.pt()) + elif abs(m.eta())>0.83 and abs(m.eta())<1.2: + histoData['effptO'][t].Fill(m.pt()) + else: + histoData['effptE'][t].Fill(m.pt()) + if m.pt()>(t+10): + histoData['effeta'][t].Fill(m.eta()) + histoData['effphi'][t].Fill(m.phi()) + + counter=counter+1 + +f=ROOT.TFile("saStudy_results.root","RECREATE") +f.cd() +#c = histoData['rate'].GetCumulative(False) +#c.Scale(float(BUNCHFACTOR)/float(counter)) +#c.Write("rate") +histoData['genpt'].Write("genpt") +histoData['genptB'].Write("genptB") +histoData['genptO'].Write("genptO") +histoData['genptE'].Write("genptE") +etaLUT.Write() +rate.Write() +rateB.Write() +rateE.Write() +rateO.Write() + +c = rate.GetCumulative(False) +c.Scale(float(BUNCHFACTOR)/float(counter)) +c.Write("rate") +c = rateB.GetCumulative(False) +c.Scale(float(BUNCHFACTOR)/float(counter)) +c.Write("rateBarrel") +c = rateO.GetCumulative(False) +c.Scale(float(BUNCHFACTOR)/float(counter)) +c.Write("rateOverlap") +c = rateE.GetCumulative(False) +c.Scale(float(BUNCHFACTOR)/float(counter)) +c.Write("rateEndcap") + + +for t in thresholds: + histoData['effpt'][t].Write("numpt_"+str(t)) + histoData['effeta'][t].Write("numeta_"+str(t)) + histoData['effphi'][t].Write("numphi_"+str(t)) + histoData['geneta'][t].Write("geneta_"+str(t)) + histoData['genphi'][t].Write("genphi_"+str(t)) + + g = ROOT.TGraphAsymmErrors(histoData['effpt'][t],histoData['genpt']) + g.Write("eff_"+str(t)) + g = ROOT.TGraphAsymmErrors(histoData['effptB'][t],histoData['genptB']) + g.Write("effB_"+str(t)) + g = ROOT.TGraphAsymmErrors(histoData['effptO'][t],histoData['genptO']) + g.Write("effO_"+str(t)) + g = ROOT.TGraphAsymmErrors(histoData['effptE'][t],histoData['genptE']) + g.Write("effE_"+str(t)) + g = ROOT.TGraphAsymmErrors(histoData['effeta'][t],histoData['geneta'][t]) + g.Write("effeta_"+str(t)) + g = ROOT.TGraphAsymmErrors(histoData['effphi'][t],histoData['genphi'][t]) + g.Write("effphi_"+str(t)) + +f.Close() diff --git a/L1Trigger/Phase2L1GMT/test/submitCrab.py b/L1Trigger/Phase2L1GMT/test/submitCrab.py index ab0d0069b9924..0e1fc86e97d2e 100644 --- a/L1Trigger/Phase2L1GMT/test/submitCrab.py +++ b/L1Trigger/Phase2L1GMT/test/submitCrab.py @@ -19,29 +19,51 @@ 'MinBias200_c':'/MinBias_TuneCP5_14TeV-pythia8/Phase2HLTTDRWinter20DIGI-PU200_withNewMB_110X_mcRun4_realistic_v3_ext1-v2/GEN-SIM-DIGI-RAW' } +data_Fall22 = { + 'DYToLL' : '/DYToLL_M-50_TuneCP5_14TeV-pythia8/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + 'DsToTauTo3Mu' : '/DsToTauTo3Mu_TuneCP5_14TeV-pythia8/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + 'MinBias' : '/MinBias_TuneCP5_14TeV-pythia8/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + # 'Mu_0to200' : '/SingleMuon_Pt-0To200_Eta-1p4To3p1-gun/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + # 'Mu_to500' : '/SingleMuon_Pt-200To500_Eta-1p4To3p1-gun/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + 'TTTo2L2Nu' : '/TTTo2L2Nu_TuneCP5_14TeV-powheg-pythia8/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + 'TTToSemiLepton' : '/TTToSemiLepton_TuneCP5_14TeV-powheg-pythia8/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + 'TauTo3Mu' : '/TauTo3Mu_TuneCP5_14TeV-pythia8/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + # 'GNN' : '/DSTau3Mu_pCut1_14TeV_Pythia8/jschulte-PhaseIIMTDTDRAutumn18DR-PU200_103X_upgrade2023_realistic_v2_GEN-SIM-DIGI-RAW_part3-v1-0b09b1d51eb1b176460746cc4e457a22/USER' +} + +data_Spring23= { + 'DYToLL' : '/DYToLL_M-50_TuneCP5_14TeV-pythia8/Phase2Spring23DIGIRECOMiniAOD-PU200_L1TFix_Trk1GeV_131X_mcRun4_realistic_v9-v3/GEN-SIM-DIGI-RAW-MINIAOD', + 'DsToTauTo3Mu' : '/DsToTauTo3Mu_TuneCP5_14TeV-pythia8/Phase2Spring23DIGIRECOMiniAOD-PU200_131X_mcRun4_realistic_v5-v1/GEN-SIM-DIGI-RAW-MINIAOD', + 'MinBias' : '/MinBias_TuneCP5_14TeV-pythia8/Phase2Spring23DIGIRECOMiniAOD-PU200_L1TFix_Trk1GeV_131X_mcRun4_realistic_v9_ext1-v2/GEN-SIM-DIGI-RAW-MINIAOD', + # 'Mu_0to200' : '/SingleMuon_Pt-0To200_Eta-1p4To3p1-gun/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + # 'Mu_to500' : '/SingleMuon_Pt-200To500_Eta-1p4To3p1-gun/Phase2Fall22DRMiniAOD-PU200_125X_mcRun4_realistic_v2-v1/GEN-SIM-DIGI-RAW-MINIAOD', + 'TTTo2L2Nu' : '/TTTo2L2Nu_TuneCP5_14TeV-powheg-pythia8/Phase2Spring23DIGIRECOMiniAOD-PU200_Trk1GeV_131X_mcRun4_realistic_v5-v1/GEN-SIM-DIGI-RAW-MINIAOD', + # 'GNN' : '/DSTau3Mu_pCut1_14TeV_Pythia8/jschulte-PhaseIIMTDTDRAutumn18DR-PU200_103X_upgrade2023_realistic_v2_GEN-SIM-DIGI-RAW_part3-v1-0b09b1d51eb1b176460746cc4e457a22/USER' +} + -for tag,dataset in data.iteritems(): +for tag,dataset in data_Spring23.iteritems(): FILE=""" from CRABClient.UserUtilities import config config = config() config.General.requestName = 'skim_{tag}' -config.General.workArea = 'crab_projects' +config.General.workArea = 'crab_projects_Spring_v3' config.General.transferOutputs = True -config.General.transferLogs = False +config.General.transferLogs = True config.JobType.pluginName = 'Analysis' config.JobType.psetName = 'runGMT.py' config.Data.inputDataset = '{dataset}' config.Data.inputDBS = 'global' config.Data.splitting = 'FileBased' -config.Data.unitsPerJob = 1 -config.Data.outLFNDirBase = '/store/user/bachtis/L1TF4' -config.Data.publication = True +config.Data.unitsPerJob = 2 +config.Data.outLFNDirBase = '/store/group/lpctrig/benwu/GMT_Ntupler/Spring22_GMT_v3' +config.Data.publication = False config.Data.ignoreLocality = True config.Data.outputDatasetTag = 'PHASEII_{tag}' config.Site.storageSite = 'T3_US_FNALLPC' config.Site.whitelist = ['T2_US_*'] config.JobType.allowUndistributedCMSSW = True -config.JobType.maxMemoryMB = 4000 +config.JobType.maxMemoryMB = 5000 """.format(tag=tag,dataset=dataset) f=open("crab_{tag}.py".format(tag=tag),"w") print(FILE)