From 4e4b4fe0ba5275f141193ab9525f6f85184aec05 Mon Sep 17 00:00:00 2001 From: Silvio Donato Date: Wed, 3 Feb 2021 19:42:17 +0100 Subject: [PATCH] Revert "EMTF Emulator Update to Add Displaced Muon pT & Dxy Assignment" --- DataFormats/L1TMuon/interface/EMTFTrack.h | 16 -- L1Trigger/L1TMuonEndCap/BuildFile.xml | 1 - L1Trigger/L1TMuonEndCap/interface/Common.h | 7 - L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h | 5 - .../L1TMuonEndCap/interface/PtAssignment.h | 7 +- .../interface/PtAssignmentEngineAux.h | 4 - .../interface/PtAssignmentEngineDxy.h | 42 --- .../L1TMuonEndCap/interface/VersionControl.h | 1 - .../L1TMuonEndCap/python/simEmtfDigis_cfi.py | 2 - L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc | 5 - .../L1TMuonEndCap/src/MicroGMTConverter.cc | 2 - L1Trigger/L1TMuonEndCap/src/PtAssignment.cc | 39 +-- .../src/PtAssignmentEngineAux.cc | 26 -- .../src/PtAssignmentEngineDxy.cc | 262 ------------------ .../L1TMuonEndCap/src/SectorProcessor.cc | 5 +- L1Trigger/L1TMuonEndCap/src/VersionControl.cc | 1 - 16 files changed, 4 insertions(+), 421 deletions(-) delete mode 100644 L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineDxy.h delete mode 100644 L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineDxy.cc diff --git a/DataFormats/L1TMuon/interface/EMTFTrack.h b/DataFormats/L1TMuon/interface/EMTFTrack.h index 299a7d2e74b29..c556e768c928c 100644 --- a/DataFormats/L1TMuon/interface/EMTFTrack.h +++ b/DataFormats/L1TMuon/interface/EMTFTrack.h @@ -60,8 +60,6 @@ namespace l1t { second_bx(-99), pt(-99), pt_XML(-99), - pt_dxy(-99), - dxy(-99), zone(-99), ph_num(-99), ph_q(-99), @@ -72,8 +70,6 @@ namespace l1t { phi_loc(-99), phi_glob(-999), gmt_pt(-99), - gmt_pt_dxy(-99), - gmt_dxy(-99), gmt_phi(-999), gmt_eta(-999), gmt_quality(-99), @@ -139,8 +135,6 @@ namespace l1t { void set_second_bx(int bits) { second_bx = bits; } void set_pt(float val) { pt = val; } void set_pt_XML(float val) { pt_XML = val; } - void set_pt_dxy(float val) { pt_dxy = val; } - void set_dxy(float val) { dxy = val; } void set_zone(int bits) { zone = bits; } void set_ph_num(int bits) { ph_num = bits; } void set_ph_q(int bits) { ph_q = bits; } @@ -151,8 +145,6 @@ namespace l1t { void set_phi_loc(float val) { phi_loc = val; } void set_phi_glob(float val) { phi_glob = val; } void set_gmt_pt(int bits) { gmt_pt = bits; } - void set_gmt_pt_dxy(int bits) { gmt_pt_dxy = bits; } - void set_gmt_dxy(int bits) { gmt_dxy = bits; } void set_gmt_phi(int bits) { gmt_phi = bits; } void set_gmt_eta(int bits) { gmt_eta = bits; } void set_gmt_quality(int bits) { gmt_quality = bits; } @@ -177,8 +169,6 @@ namespace l1t { int Second_BX() const { return second_bx; } float Pt() const { return pt; } float Pt_XML() const { return pt_XML; } - float Pt_dxy() const { return pt_dxy; } - float Dxy() const { return dxy; } int Zone() const { return zone; } int Ph_num() const { return ph_num; } int Ph_q() const { return ph_q; } @@ -189,8 +179,6 @@ namespace l1t { float Phi_loc() const { return phi_loc; } float Phi_glob() const { return phi_glob; } int GMT_pt() const { return gmt_pt; } - int GMT_pt_dxy() const { return gmt_pt_dxy; } - int GMT_dxy() const { return gmt_dxy; } int GMT_phi() const { return gmt_phi; } int GMT_eta() const { return gmt_eta; } int GMT_quality() const { return gmt_quality; } @@ -221,8 +209,6 @@ namespace l1t { int second_bx; // -3 - +3. float pt; // 0 - 255 float pt_XML; // 0 - 999 - float pt_dxy; // 0 - 127 - float dxy; // 0 - 3 int zone; // 0 - 3. int ph_num; int ph_q; @@ -233,8 +219,6 @@ namespace l1t { float phi_loc; // -22 - 60 (Range? - AWB 03.03.17) float phi_glob; // +/-180. int gmt_pt; - int gmt_pt_dxy; - int gmt_dxy; int gmt_phi; int gmt_eta; int gmt_quality; diff --git a/L1Trigger/L1TMuonEndCap/BuildFile.xml b/L1Trigger/L1TMuonEndCap/BuildFile.xml index 21810b917c9a9..b0e1ace8a2804 100644 --- a/L1Trigger/L1TMuonEndCap/BuildFile.xml +++ b/L1Trigger/L1TMuonEndCap/BuildFile.xml @@ -7,4 +7,3 @@ - diff --git a/L1Trigger/L1TMuonEndCap/interface/Common.h b/L1Trigger/L1TMuonEndCap/interface/Common.h index a2eea8d0bdd3a..94c5795bab458 100644 --- a/L1Trigger/L1TMuonEndCap/interface/Common.h +++ b/L1Trigger/L1TMuonEndCap/interface/Common.h @@ -64,13 +64,6 @@ namespace emtf { template using zone_array = std::array; - // NN features and predictions - constexpr int NUM_FEATURES = 23; // NN features - constexpr int NUM_PREDICTIONS = 2; // NN outputs - - using Feature = std::array; - using Prediction = std::array; - } // namespace emtf #endif diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h b/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h index 4765f8d447aab..086d89ccf46e4 100644 --- a/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h +++ b/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h @@ -15,7 +15,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/VersionControl.h" #include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineDxy.h" class EMTFSetup { public: @@ -36,8 +35,6 @@ class EMTFSetup { PtAssignmentEngine* getPtAssignmentEngine() const { return pt_assign_engine_.get(); } - PtAssignmentEngineDxy* getPtAssignmentEngineDxy() const { return pt_assign_engine_dxy_.get(); } - // Setters //void set_fw_version(unsigned version) { fw_ver_ = version; } //void set_pt_lut_version(unsigned version) { pt_lut_ver_ = version; } @@ -65,8 +62,6 @@ class EMTFSetup { // Polymorphic class std::unique_ptr pt_assign_engine_; - // Displaced muon pT assignment - std::unique_ptr pt_assign_engine_dxy_; // Version numbers. Note: may be different from those in ConditionHelper unsigned fw_ver_; diff --git a/L1Trigger/L1TMuonEndCap/interface/PtAssignment.h b/L1Trigger/L1TMuonEndCap/interface/PtAssignment.h index 0faa20f4c0c58..f499f604f2db9 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PtAssignment.h +++ b/L1Trigger/L1TMuonEndCap/interface/PtAssignment.h @@ -4,13 +4,11 @@ #include "L1Trigger/L1TMuonEndCap/interface/Common.h" class PtAssignmentEngine; -class PtAssignmentEngineDxy; class PtAssignmentEngineAux; class PtAssignment { public: void configure(PtAssignmentEngine* pt_assign_engine, - PtAssignmentEngineDxy* pt_assign_engine_dxy, int verbose, int endcap, int sector, @@ -22,8 +20,7 @@ class PtAssignment { bool bugNegPt, bool bugGMTPhi, bool promoteMode7, - int modeQualVer, - std::string pbFileName); + int modeQualVer); void process(EMTFTrackCollection& best_tracks); @@ -32,8 +29,6 @@ class PtAssignment { private: PtAssignmentEngine* pt_assign_engine_; - PtAssignmentEngineDxy* pt_assign_engine_dxy_; - int verbose_, endcap_, sector_, bx_; bool bugGMTPhi_, promoteMode7_; diff --git a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h index d05cfaf807a1f..feeb826ade0c1 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h +++ b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h @@ -14,10 +14,8 @@ class PtAssignmentEngineAux { public: // Functions for GMT quantities int getGMTPt(float pt) const; - int getGMTPtDxy(float pt) const; float getPtFromGMTPt(int gmt_pt) const; - float getPtFromGMTPtDxy(int gmt_pt_dxy) const; int getGMTPhi(int phi) const; int getGMTPhiV2(int phi) const; @@ -27,8 +25,6 @@ class PtAssignmentEngineAux { int getGMTQuality(int mode, int theta, bool promoteMode7, int version) const; std::pair getGMTCharge(int mode, const std::vector& phidiffs) const; - - int getGMTDxy(float dxy) const; }; #endif diff --git a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineDxy.h b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineDxy.h deleted file mode 100644 index ead89ac7bebe9..0000000000000 --- a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineDxy.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef L1TMuonEndCap_PtAssignmentEngineDxy_h -#define L1TMuonEndCap_PtAssignmentEngineDxy_h - -#include -#include -#include -#include -#include -#include - -#include "L1Trigger/L1TMuonEndCap/interface/Common.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h" -#include "PhysicsTools/TensorFlow/interface/TensorFlow.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" - -class PtAssignmentEngineDxy { -public: - explicit PtAssignmentEngineDxy(); - virtual ~PtAssignmentEngineDxy(); - - void configure(int verbose, const std::string pbFileNameDxy); - - const PtAssignmentEngineAux2017& aux() const; - - virtual void calculate_pt_dxy(const EMTFTrack& track, emtf::Feature& feature, emtf::Prediction& prediction) const; - - virtual void preprocessing_dxy(const EMTFTrack& track, emtf::Feature& feature) const; - - virtual void call_tensorflow_dxy(const emtf::Feature& feature, emtf::Prediction& prediction) const; - -protected: - int verbose_; - - tensorflow::GraphDef* graphDefDxy_; - tensorflow::Session* sessionDxy_; - std::string pbFileNameDxy_; - std::string pbFilePathDxy_; - std::string inputNameDxy_; - std::vector outputNamesDxy_; -}; - -#endif \ No newline at end of file diff --git a/L1Trigger/L1TMuonEndCap/interface/VersionControl.h b/L1Trigger/L1TMuonEndCap/interface/VersionControl.h index a782008114ffb..468a5865c636a 100644 --- a/L1Trigger/L1TMuonEndCap/interface/VersionControl.h +++ b/L1Trigger/L1TMuonEndCap/interface/VersionControl.h @@ -56,7 +56,6 @@ class VersionControl { bool readPtLUTFile_, fixMode15HighPt_; bool bug9BitDPhi_, bugMode7CLCT_, bugNegPt_, bugGMTPhi_, promoteMode7_; int modeQualVer_; - std::string pbFileName_; }; #endif diff --git a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py index aab3459047547..48826260ea81a 100644 --- a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py +++ b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py @@ -121,8 +121,6 @@ BugGMTPhi = cms.bool(False), # Some drift in uGMT phi conversion, off by up to a few degrees PromoteMode7 = cms.bool(False), # Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality ModeQualVer = cms.int32(2), # Version 2 contains modified mode-quality mapping for 2018 - - ProtobufFileName = cms.string('model_graph.displ.5.pb'), # Protobuf file name to be used by NN based pT assignment ), ) diff --git a/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc b/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc index 711f94e75838d..7cdbb8fcdfe3b 100644 --- a/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc +++ b/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc @@ -13,7 +13,6 @@ EMTFSetup::EMTFSetup(const edm::ParameterSet& iConfig) version_control_(iConfig), sector_processor_lut_(), pt_assign_engine_(nullptr), - pt_assign_engine_dxy_(nullptr), fw_ver_(0), pt_lut_ver_(0), pc_lut_ver_(0) { @@ -28,11 +27,7 @@ EMTFSetup::EMTFSetup(const edm::ParameterSet& iConfig) throw cms::Exception("L1TMuonEndCap") << "Cannot recognize the era option: " << era(); } - // No era setup for displaced pT assignment engine - pt_assign_engine_dxy_ = std::make_unique(); - emtf_assert(pt_assign_engine_ != nullptr); - emtf_assert(pt_assign_engine_dxy_ != nullptr); } EMTFSetup::~EMTFSetup() {} diff --git a/L1Trigger/L1TMuonEndCap/src/MicroGMTConverter.cc b/L1Trigger/L1TMuonEndCap/src/MicroGMTConverter.cc index 92dd50fe199c5..cdfc1e1e77d4d 100644 --- a/L1Trigger/L1TMuonEndCap/src/MicroGMTConverter.cc +++ b/L1Trigger/L1TMuonEndCap/src/MicroGMTConverter.cc @@ -11,8 +11,6 @@ void MicroGMTConverter::convert(const int global_event_BX, int sector = in_track.Sector() - 1; out_cand.setHwPt(in_track.GMT_pt()); - out_cand.setHwPtUnconstrained(in_track.GMT_pt_dxy()); - out_cand.setHwDXY(in_track.GMT_dxy()); out_cand.setHwPhi(in_track.GMT_phi()); out_cand.setHwEta(in_track.GMT_eta()); out_cand.setHwSign(in_track.GMT_charge()); diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc index a17bcaea4791d..ae38ae9d55365 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc @@ -1,10 +1,8 @@ #include "L1Trigger/L1TMuonEndCap/interface/PtAssignment.h" #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineDxy.h" void PtAssignment::configure(PtAssignmentEngine* pt_assign_engine, - PtAssignmentEngineDxy* pt_assign_engine_dxy, int verbose, int endcap, int sector, @@ -16,15 +14,11 @@ void PtAssignment::configure(PtAssignmentEngine* pt_assign_engine, bool bugNegPt, bool bugGMTPhi, bool promoteMode7, - int modeQualVer, - std::string pbFileName) { + int modeQualVer) { emtf_assert(pt_assign_engine != nullptr); - emtf_assert(pt_assign_engine_dxy != nullptr); pt_assign_engine_ = pt_assign_engine; - pt_assign_engine_dxy_ = pt_assign_engine_dxy; - verbose_ = verbose; endcap_ = endcap; sector_ = sector; @@ -32,8 +26,6 @@ void PtAssignment::configure(PtAssignmentEngine* pt_assign_engine, pt_assign_engine_->configure(verbose_, readPtLUTFile, fixMode15HighPt, bug9BitDPhi, bugMode7CLCT, bugNegPt); - pt_assign_engine_dxy_->configure(verbose_, pbFileName); - bugGMTPhi_ = bugGMTPhi; promoteMode7_ = promoteMode7; modeQualVer_ = modeQualVer; @@ -69,17 +61,11 @@ void PtAssignment::process(EMTFTrackCollection& best_tracks) { gmt_eta = (gmt_eta < 0) ? ~(-gmt_eta) : gmt_eta; } - // Assign prompt & displaced pT + // Assign pT address_t address = 0; float xmlpt = 0.; float pt = 0.; int gmt_pt = 0; - - float pt_dxy = 0.; - float dxy = 0.; - int gmt_pt_dxy = 0; - int gmt_dxy = 0; - if (track.Mode() != 1) { address = pt_assign_engine_->calculate_address(track); xmlpt = pt_assign_engine_->calculate_pt(address); @@ -104,23 +90,6 @@ void PtAssignment::process(EMTFTrackCollection& best_tracks) { pt = (gmt_pt <= 0) ? 0 : (gmt_pt - 1) * 0.5; // Decode integer pT (result is in 0.5 GeV step) - // Calculate displaced pT and d0 using NN - emtf::Feature feature; - emtf::Prediction prediction; - - feature.fill(0); - prediction.fill(0); - - pt_assign_engine_dxy_->calculate_pt_dxy(track, feature, prediction); - - pt_dxy = std::abs(1.0 / prediction.at(0)); - dxy = prediction.at(1); - - gmt_pt_dxy = aux().getGMTPtDxy(pt_dxy); - gmt_dxy = aux().getGMTDxy(dxy); - - pt_dxy = aux().getPtFromGMTPtDxy(gmt_pt_dxy); - int gmt_quality = 0; if (track.Mode() != 1) { gmt_quality = aux().getGMTQuality(track.Mode(), track.Theta_fp(), promoteMode7_, modeQualVer_); @@ -155,13 +124,9 @@ void PtAssignment::process(EMTFTrackCollection& best_tracks) { track.set_PtLUT(tmp_LUT); track.set_pt_XML(xmlpt); track.set_pt(pt); - track.set_pt_dxy(pt_dxy); - track.set_dxy(dxy); track.set_charge((gmt_charge.second == 1) ? ((gmt_charge.first == 1) ? -1 : +1) : 0); track.set_gmt_pt(gmt_pt); - track.set_gmt_pt_dxy(gmt_pt_dxy); - track.set_gmt_dxy(gmt_dxy); track.set_gmt_phi(gmt_phi); track.set_gmt_eta(gmt_eta); track.set_gmt_quality(gmt_quality); diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux.cc index 02c8e5834305d..aa97d91970417 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux.cc @@ -16,37 +16,11 @@ int PtAssignmentEngineAux::getGMTPt(float pt) const { return gmt_pt; } -int PtAssignmentEngineAux::getGMTPtDxy(float pt) const { - // compressed pt = pt*1 (scale) + 1 (pt = 0 is empty candidate) - int gmt_pt_dxy = (pt * 1) + 1; - gmt_pt_dxy = (gmt_pt_dxy > 255) ? 255 : gmt_pt_dxy; - return gmt_pt_dxy; -} - -int PtAssignmentEngineAux::getGMTDxy(float dxy) const { - int gmt_dxy = 0; - if (std::abs(dxy) < 25.) { - gmt_dxy = 0; - } else if (std::abs(dxy) < 50.) { - gmt_dxy = 1; - } else if (std::abs(dxy) < 75.) { - gmt_dxy = 2; - } else { - gmt_dxy = 3; - } - return gmt_dxy; -} - float PtAssignmentEngineAux::getPtFromGMTPt(int gmt_pt) const { float pt = (gmt_pt <= 0) ? 0 : 0.5 * (gmt_pt - 1); return pt; } -float PtAssignmentEngineAux::getPtFromGMTPtDxy(int gmt_pt_dxy) const { - float pt = (gmt_pt_dxy <= 0) ? 0 : 1.0 * (gmt_pt_dxy - 1); - return pt; -} - int PtAssignmentEngineAux::getGMTPhi(int phi) const { // convert phi into gmt scale according to DN15-017 // full scale is -16 to 100, or 116 values, covers range -10 to 62.5 deg diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineDxy.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineDxy.cc deleted file mode 100644 index d5db52dabb3fe..0000000000000 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineDxy.cc +++ /dev/null @@ -1,262 +0,0 @@ -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineDxy.h" - -#include -#include -#include - -#include "helper.h" // assert_no_abort - -PtAssignmentEngineDxy::PtAssignmentEngineDxy() : graphDefDxy_(nullptr), sessionDxy_(nullptr) {} - -PtAssignmentEngineDxy::~PtAssignmentEngineDxy() { - if (sessionDxy_ != nullptr) { - tensorflow::closeSession(sessionDxy_); - } - delete graphDefDxy_; -} - -void PtAssignmentEngineDxy::configure(int verbose, const std::string pbFileNameDxy) { - verbose_ = verbose; - - pbFileNameDxy_ = pbFileNameDxy; - std::string pbFilePathDxy_ = "L1Trigger/L1TMuon/data/emtf_luts/" + pbFileNameDxy_; - - inputNameDxy_ = "batch_normalization_1_input"; - outputNamesDxy_ = {"dense_4/BiasAdd"}; - - if (graphDefDxy_ == nullptr) { - graphDefDxy_ = tensorflow::loadGraphDef(edm::FileInPath(pbFilePathDxy_).fullPath()); - } - emtf_assert(graphDefDxy_ != nullptr); - - if (sessionDxy_ == nullptr) { - sessionDxy_ = tensorflow::createSession(graphDefDxy_); - } - - emtf_assert(sessionDxy_ != nullptr); -} - -const PtAssignmentEngineAux2017& PtAssignmentEngineDxy::aux() const { - static const PtAssignmentEngineAux2017 instance; - return instance; -} - -void PtAssignmentEngineDxy::calculate_pt_dxy(const EMTFTrack& track, - emtf::Feature& feature, - emtf::Prediction& prediction) const { - // This is called for each track instead of for entire track collection as was done in Phase-2 implementation - preprocessing_dxy(track, feature); - call_tensorflow_dxy(feature, prediction); - return; -} - -void PtAssignmentEngineDxy::preprocessing_dxy(const EMTFTrack& track, emtf::Feature& feature) const { - // Mimic Phase-1 EMTF input calculations - // 6 delta Phis: S1-S2, S1-S3, S1-S4, S2-S3, S2-S4, S3-S4 - // 6 delta Thetas: S1-S2, S1-S3, S1-S4, S2-S3, S2-S4, S3-S4 - // 4 bends : set to zero if no CSC hit and thus RPC hit is used - // 1 FR bit: for ME1 only - // 1 Ring bit: for ME1 only - // 1 track Theta taken from stub coordinate in ME2, ME3, ME4 (in this priority) - // 4 RPC bits indicating if ME or RE hit was used in each station (S1, S2, S3, S4) - // Total: 23 variables - static std::array x_dphi; - static std::array x_dtheta; - static std::array x_bend_emtf; - static std::array x_fr_emtf; - static std::array x_trk_theta; - static std::array x_me11ring; - static std::array x_rpcbit; - - // Initialize to zeros - x_dphi.fill(0); - x_dtheta.fill(0); - // - x_bend_emtf.fill(0); - x_fr_emtf.fill(0); - x_trk_theta.fill(0); - x_me11ring.fill(0); - x_rpcbit.fill(0); - - EMTFPtLUT data = track.PtLUT(); - - const int invalid_dtheta = 127; - const int invalid_dphi = 8191; - - // // Variables to extract from the PtLUT - int dPhi_12, dPhi_13, dPhi_14, dPhi_23, dPhi_24, dPhi_34; - int dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34; - int fr_1; - int bend_1, bend_2, bend_3, bend_4; - int rpc_1, rpc_2, rpc_3, rpc_4; - int St1_ring2 = data.st1_ring2; - - int pat1 = -99, pat2 = -99, pat3 = -99, pat4 = -99; - - // // Which stations have hits - int st1 = (track.Mode() >= 8); - int st2 = ((track.Mode() % 8) >= 4); - int st3 = ((track.Mode() % 4) >= 2); - int st4 = ((track.Mode() % 2) == 1); - - // Get valid pattern values - if (st1) - pat1 = data.cpattern[0]; - if (st2) - pat2 = data.cpattern[1]; - if (st3) - pat3 = data.cpattern[2]; - if (st4) - pat4 = data.cpattern[3]; - - // F/R bit - fr_1 = data.fr[0]; - - // RPC hit in station - rpc_1 = (st1 ? (pat1 == 0) : 0); - rpc_2 = (st2 ? (pat2 == 0) : 0); - rpc_3 = (st3 ? (pat3 == 0) : 0); - rpc_4 = (st4 ? (pat4 == 0) : 0); - - // Calculate bends from patterns - bend_1 = aux().calcBendFromPattern(pat1, track.Endcap()); - bend_2 = aux().calcBendFromPattern(pat2, track.Endcap()); - bend_3 = aux().calcBendFromPattern(pat3, track.Endcap()); - bend_4 = aux().calcBendFromPattern(pat4, track.Endcap()); - - // Invalid bend value is 0 in the NN - if (bend_1 == -99) - bend_1 = 0; - if (bend_2 == -99) - bend_2 = 0; - if (bend_3 == -99) - bend_3 = 0; - if (bend_4 == -99) - bend_4 = 0; - - // In the emulator RPCs get assigned abs(bend) = 5. This needs to be 0 for the NN. - if (std::abs(bend_1) == 5 && rpc_1 == 1) - bend_1 = 0; - if (std::abs(bend_2) == 5 && rpc_2 == 1) - bend_2 = 0; - if (std::abs(bend_3) == 5 && rpc_3 == 1) - bend_3 = 0; - if (std::abs(bend_4) == 5 && rpc_4 == 1) - bend_4 = 0; - - // Calculate delta phi - dPhi_12 = (data.delta_ph[0] != invalid_dphi) ? data.delta_ph[0] * (data.sign_ph[0] ? 1 : -1) : 0; - dPhi_13 = (data.delta_ph[1] != invalid_dphi) ? data.delta_ph[1] * (data.sign_ph[1] ? 1 : -1) : 0; - dPhi_14 = (data.delta_ph[2] != invalid_dphi) ? data.delta_ph[2] * (data.sign_ph[2] ? 1 : -1) : 0; - dPhi_23 = (data.delta_ph[3] != invalid_dphi) ? data.delta_ph[3] * (data.sign_ph[3] ? 1 : -1) : 0; - dPhi_24 = (data.delta_ph[4] != invalid_dphi) ? data.delta_ph[4] * (data.sign_ph[4] ? 1 : -1) : 0; - dPhi_34 = (data.delta_ph[5] != invalid_dphi) ? data.delta_ph[5] * (data.sign_ph[5] ? 1 : -1) : 0; - - // Calculate delta theta - dTh_12 = (data.delta_th[0] != invalid_dtheta) ? data.delta_th[0] * (data.sign_th[0] ? 1 : -1) : 0; - dTh_13 = (data.delta_th[1] != invalid_dtheta) ? data.delta_th[1] * (data.sign_th[1] ? 1 : -1) : 0; - dTh_14 = (data.delta_th[2] != invalid_dtheta) ? data.delta_th[2] * (data.sign_th[2] ? 1 : -1) : 0; - dTh_23 = (data.delta_th[3] != invalid_dtheta) ? data.delta_th[3] * (data.sign_th[3] ? 1 : -1) : 0; - dTh_24 = (data.delta_th[4] != invalid_dtheta) ? data.delta_th[4] * (data.sign_th[4] ? 1 : -1) : 0; - dTh_34 = (data.delta_th[5] != invalid_dtheta) ? data.delta_th[5] * (data.sign_th[5] ? 1 : -1) : 0; - - // Set dPhi and dTheta values to 0 if there was no hit in the station - if (!st1) { - dPhi_12 = 0; - dPhi_13 = 0; - dPhi_14 = 0; - - dTh_12 = 0; - dTh_13 = 0; - dTh_14 = 0; - } - if (!st2) { - dPhi_12 = 0; - dPhi_23 = 0; - dPhi_24 = 0; - - dTh_12 = 0; - dTh_23 = 0; - dTh_24 = 0; - } - if (!st3) { - dPhi_13 = 0; - dPhi_23 = 0; - dPhi_34 = 0; - - dTh_13 = 0; - dTh_23 = 0; - dTh_34 = 0; - } - if (!st4) { - dPhi_14 = 0; - dPhi_24 = 0; - dPhi_34 = 0; - - dTh_14 = 0; - dTh_24 = 0; - dTh_34 = 0; - } - - // Set NN inputs - - // NN was trained with the wrong sign convention. TO BE CHANGED LATER! - x_dphi[0] = dPhi_12; - x_dphi[1] = dPhi_13; - x_dphi[2] = dPhi_14; - x_dphi[3] = dPhi_23; - x_dphi[4] = dPhi_24; - x_dphi[5] = dPhi_34; - - // NN was trained with the wrong sign convention. TO BE CHANGED LATER! - x_dtheta[0] = dTh_12; - x_dtheta[1] = dTh_13; - x_dtheta[2] = dTh_14; - x_dtheta[3] = dTh_23; - x_dtheta[4] = dTh_24; - x_dtheta[5] = dTh_34; - - // NN was trained with the wrong sign convention. TO BE CHANGED LATER! - x_bend_emtf[0] = bend_1; - x_bend_emtf[1] = bend_2; - x_bend_emtf[2] = bend_3; - x_bend_emtf[3] = bend_4; - - x_fr_emtf[0] = fr_1; - x_trk_theta[0] = track.Theta_fp(); - x_me11ring[0] = St1_ring2; - - x_rpcbit[0] = rpc_1; - x_rpcbit[1] = rpc_2; - x_rpcbit[2] = rpc_3; - x_rpcbit[3] = rpc_4; - - feature = {{x_dphi[0], x_dphi[1], x_dphi[2], x_dphi[3], x_dphi[4], x_dphi[5], - x_dtheta[0], x_dtheta[1], x_dtheta[2], x_dtheta[3], x_dtheta[4], x_dtheta[5], - x_bend_emtf[0], x_bend_emtf[1], x_bend_emtf[2], x_bend_emtf[3], x_fr_emtf[0], x_trk_theta[0], - x_me11ring[0], x_rpcbit[0], x_rpcbit[1], x_rpcbit[2], x_rpcbit[3]}}; - return; -} - -void PtAssignmentEngineDxy::call_tensorflow_dxy(const emtf::Feature& feature, emtf::Prediction& prediction) const { - static tensorflow::Tensor input(tensorflow::DT_FLOAT, {1, emtf::NUM_FEATURES}); - static std::vector outputs; - emtf_assert(feature.size() == emtf::NUM_FEATURES); - - float* d = input.flat().data(); - std::copy(feature.begin(), feature.end(), d); - tensorflow::run(sessionDxy_, {{inputNameDxy_, input}}, outputNamesDxy_, &outputs); - emtf_assert(outputs.size() == 1); - emtf_assert(prediction.size() == emtf::NUM_PREDICTIONS); - - const float reg_pt_scale = 100.0; // a scale factor applied to regression during training - const float reg_dxy_scale = 1.0; // a scale factor applied to regression during training - - prediction.at(0) = outputs[0].matrix()(0, 0); - prediction.at(1) = outputs[0].matrix()(0, 1); - - // Remove scale factor used during training - prediction.at(0) /= reg_pt_scale; - prediction.at(1) /= reg_dxy_scale; - return; -} diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc index a06e6e5e3e48a..ba9159d808150 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc @@ -70,7 +70,6 @@ void SectorProcessor::process_single_bx(int bx, auto tp_geom_ = &(setup_->getGeometryTranslator()); auto pc_lut_ = &(setup_->getSectorProcessorLUT()); auto pt_assign_engine_ = setup_->getPtAssignmentEngine(); - auto pt_assign_engine_dxy_ = setup_->getPtAssignmentEngineDxy(); // ___________________________________________________________________________ // Configure @@ -151,7 +150,6 @@ void SectorProcessor::process_single_bx(int bx, PtAssignment pt_assign; pt_assign.configure(pt_assign_engine_, - pt_assign_engine_dxy_, verbose_, endcap_, sector_, @@ -163,8 +161,7 @@ void SectorProcessor::process_single_bx(int bx, cfg.bugNegPt_, cfg.bugGMTPhi_, cfg.promoteMode7_, - cfg.modeQualVer_, - cfg.pbFileName_); + cfg.modeQualVer_); std::map selected_dt_map; std::map selected_csc_map; diff --git a/L1Trigger/L1TMuonEndCap/src/VersionControl.cc b/L1Trigger/L1TMuonEndCap/src/VersionControl.cc index 0e902b8d6b8ce..a518296cbd1ad 100644 --- a/L1Trigger/L1TMuonEndCap/src/VersionControl.cc +++ b/L1Trigger/L1TMuonEndCap/src/VersionControl.cc @@ -60,7 +60,6 @@ VersionControl::VersionControl(const edm::ParameterSet& iConfig) : config_(iConf bugGMTPhi_ = spPAParams16.getParameter("BugGMTPhi"); promoteMode7_ = spPAParams16.getParameter("PromoteMode7"); modeQualVer_ = spPAParams16.getParameter("ModeQualVer"); - pbFileName_ = spPAParams16.getParameter("ProtobufFileName"); } VersionControl::~VersionControl() {}