From ab31c930af666a3f4a4f3647cd72d28ebcbb7f81 Mon Sep 17 00:00:00 2001 From: Duchstf Date: Wed, 28 Feb 2024 10:09:39 -0600 Subject: [PATCH 1/4] fix input data types bug --- L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h | 4 ++-- L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h | 2 +- L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h index cf8302dcbf74c..c7407c0234b8f 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h @@ -10,7 +10,7 @@ #include "DataFormats/L1TParticleFlow/interface/layer1_emulator.h" #include "DataFormats/L1TParticleFlow/interface/PFCandidate.h" -typedef ap_ufixed<16, 14> pt_t; +typedef ap_ufixed<14, 12, AP_TRN, AP_SAT> pt_t; typedef ap_fixed<10, 4> etaphi_t; // Tau NN returns two values @@ -25,7 +25,7 @@ namespace L1TauEmu { //This way, the least significant bit of etaphi_t is exactly 0.01 //Even though 0.01 is not a power of 2 static constexpr float etaphi_base = 100. / 64; - typedef ap_ufixed<16, 14> pt_t; // 1 unit = 0.25 GeV; + typedef ap_ufixed<14, 12, AP_TRN, AP_SAT> pt_t; // 1 unit = 0.25 GeV; typedef ap_fixed<10, 4> etaphi_t; // 1 unit = 0.01; typedef ap_fixed<12, 6> detaphi_t; // type for the difference between etas or phis typedef ap_fixed<18, 9> detaphi2_t; // type for detaphi_t squared diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h index 1f1a2f73dbb98..86d8d63b20945 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h @@ -24,7 +24,7 @@ #define N_LAYER_20 1 // hls-fpga-machine-learning insert layer-precision -typedef ap_fixed<16, 6> input_t; +typedef ap_fixed<16, 9> input_t; typedef ap_fixed<24, 12> input2_t; typedef ap_fixed<16, 6> model_default_t; typedef ap_fixed<16, 6> layer2_t; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc index 9359f761dce2f..89e0a6edc6d04 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc @@ -97,10 +97,6 @@ void L1NNTauProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) process_SW(*l1PFCandidates, lTaus); } - if (lTaus->empty()) { - PFTau dummy; - lTaus->push_back(dummy); - } std::sort(lTaus->begin(), lTaus->end(), [](l1t::PFTau i, l1t::PFTau j) { return (i.pt() > j.pt()); }); iEvent.put(std::move(lTaus), "L1PFTausNN"); } @@ -259,7 +255,7 @@ void L1NNTauProducer::makeTau_HW(const l1t::PFCandidate& seed, //Firmware Tau l1ct::Tau l1ctTau; - l1ctTau.hwPt = l1ct::pt_t(pt * NN_ouput.nn_pt_correction); //l1gt is <16,11> and currently <16,14> + l1ctTau.hwPt = l1ct::pt_t(pt); //l1gt is <16,11> and currently <16,14> l1ctTau.hwEta = l1ct::Scales::makeGlbEta(seed.eta()); // seed.eta() and seed.phi() are in physical coordinates l1ctTau.hwPhi = l1ct::Scales::makeGlbPhi(seed.phi()); From 4172a5466f8f72f45acd46dc6364c244cf75b82b Mon Sep 17 00:00:00 2001 From: Duchstf Date: Thu, 29 Feb 2024 16:27:29 -0600 Subject: [PATCH 2/4] changes some stuff --- L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h | 2 +- L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h index 86d8d63b20945..a66f6bf59ea23 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h @@ -24,7 +24,7 @@ #define N_LAYER_20 1 // hls-fpga-machine-learning insert layer-precision -typedef ap_fixed<16, 9> input_t; +typedef ap_fixed<16, 10> input_t; typedef ap_fixed<24, 12> input2_t; typedef ap_fixed<16, 6> model_default_t; typedef ap_fixed<16, 6> layer2_t; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc index 89e0a6edc6d04..0b0e8064f3cfb 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc @@ -255,7 +255,7 @@ void L1NNTauProducer::makeTau_HW(const l1t::PFCandidate& seed, //Firmware Tau l1ct::Tau l1ctTau; - l1ctTau.hwPt = l1ct::pt_t(pt); //l1gt is <16,11> and currently <16,14> + l1ctTau.hwPt = l1ct::pt_t(pt * NN_ouput.nn_pt_correction); //l1gt is <16,11> and currently <16,14> l1ctTau.hwEta = l1ct::Scales::makeGlbEta(seed.eta()); // seed.eta() and seed.phi() are in physical coordinates l1ctTau.hwPhi = l1ct::Scales::makeGlbPhi(seed.phi()); From 82a5cc86047a97dc67e131e89164af20369fd6f7 Mon Sep 17 00:00:00 2001 From: Duchstf Date: Thu, 29 Feb 2024 16:32:21 -0600 Subject: [PATCH 3/4] modify working point --- DataFormats/L1TParticleFlow/interface/PFTau.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/DataFormats/L1TParticleFlow/interface/PFTau.h b/DataFormats/L1TParticleFlow/interface/PFTau.h index 4ff6acf2c081e..0a2fb9a3fe489 100644 --- a/DataFormats/L1TParticleFlow/interface/PFTau.h +++ b/DataFormats/L1TParticleFlow/interface/PFTau.h @@ -13,8 +13,8 @@ namespace l1t { static constexpr float PFTAU_NN_SLOPE = 0.2; static constexpr float PFTAU_NN_OVERALL_SCALE = 1. / 20.1; - static constexpr float PFTAU_NN_LOOSE_CUT = 0.28; - static constexpr float PFTAU_NN_TIGHT_CUT = 0.25; + static constexpr float PFTAU_NN_LOOSE_CUT = 0.22; + static constexpr float PFTAU_NN_TIGHT_CUT = 0.4; static constexpr float PFTAU_PF_LOOSE_CUT = 10.0; static constexpr float PFTAU_PF_TIGHT_CUT = 5.0; @@ -63,10 +63,7 @@ namespace l1t { return passLooseNN(); } bool passLoosePF() const { return fullIso_ < PFTAU_PF_LOOSE_CUT; } - bool passTightNN() const { - return iso_ * (PFTAU_NN_OFFSET + PFTAU_NN_SLOPE * (min(pt(), PFTAU_NN_PT_CUTOFF))) * PFTAU_NN_OVERALL_SCALE > - PFTAU_NN_TIGHT_CUT; - } + bool passTightNN() const { return iso_ > PFTAU_NN_TIGHT_CUT; } bool passTightNNMass() const { if (!passMass()) return false; From 83b1dcf8902fb549439d91a1d44cc6180e2158f3 Mon Sep 17 00:00:00 2001 From: Duchstf Date: Thu, 29 Feb 2024 16:36:45 -0600 Subject: [PATCH 4/4] add code formatting --- .../Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h b/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h index c7407c0234b8f..09a6ac4e69501 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h @@ -25,11 +25,11 @@ namespace L1TauEmu { //This way, the least significant bit of etaphi_t is exactly 0.01 //Even though 0.01 is not a power of 2 static constexpr float etaphi_base = 100. / 64; - typedef ap_ufixed<14, 12, AP_TRN, AP_SAT> pt_t; // 1 unit = 0.25 GeV; - typedef ap_fixed<10, 4> etaphi_t; // 1 unit = 0.01; - typedef ap_fixed<12, 6> detaphi_t; // type for the difference between etas or phis - typedef ap_fixed<18, 9> detaphi2_t; // type for detaphi_t squared - typedef ap_fixed<22, 16> pt_etaphi_t; // type for product of pt with deta or phi + typedef ap_ufixed<14, 12, AP_TRN, AP_SAT> pt_t; // 1 unit = 0.25 GeV; + typedef ap_fixed<10, 4> etaphi_t; // 1 unit = 0.01; + typedef ap_fixed<12, 6> detaphi_t; // type for the difference between etas or phis + typedef ap_fixed<18, 9> detaphi2_t; // type for detaphi_t squared + typedef ap_fixed<22, 16> pt_etaphi_t; // type for product of pt with deta or phi typedef ap_int<8> dxy_t; typedef ap_int<10> z0_t; typedef ap_uint<5> count_t; // type for multiplicity