-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phase2 L1 NN Tau #30505
Phase2 L1 NN Tau #30505
Conversation
assign upgrade |
The code-checks are being triggered in jenkins. |
assign l1 |
-code-checks ERROR: Build errors found during clang-tidy run.
|
void addTau(l1t::PFCandidate &iCand, | ||
const l1t::PFCandidateCollection &iParts, | ||
std::unique_ptr<PFTauCollection> &outputTaus); | ||
float deltaR(auto iPart1, auto iPart2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also, abbreviated function templates using auto are a C++20 feature, not supported in CMSSW yet, hence the compilation error in the PR test)
#ifndef L1TRIGGER_PHASE2L1PARTICLEFLOW_L1NNTAU_H | ||
#define L1TRIGGER_PHASE2L1PARTICLEFLOW_L1NNTAU_H | ||
|
||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unneeded include
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
#include <iostream> | ||
#include <vector> | ||
#include <TLorentzVector.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unneeded include
@@ -0,0 +1,30 @@ | |||
#ifndef L1TRIGGER_PHASE2L1PARTICLEFLOWS_TAUNNID_H | |||
#define L1TRIGGER_PHASE2L1PARTICLEFLOWS_TAuNNID_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inconsistent flags, please check spelling/capitalization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fNParticles_(cfg.getParameter<int>("nparticles")), | ||
fL1PFToken_(consumes<vector<l1t::PFCandidate> >(cfg.getParameter<edm::InputTag>("L1PFObjects"))) { | ||
std::string lNNFile = cfg.getParameter<std::string>("NNFileName"); //,"L1Trigger/Phase2L1Taus/data/tau_3layer.pb"); | ||
fTauNNId = new TauNNId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memory leak, please use smart pointer
also, member variable should end in underscore
#include "L1Trigger/Phase2L1ParticleFlow/interface/TauNNId.h" | ||
#include <iostream> | ||
#include <cmath> | ||
#include <TMath.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unneeded include
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
delete graphDef_; | ||
} | ||
void TauNNId::initialize(const std::string &iInput, const std::string &iWeightFile, int iNParticles) { | ||
std::string cmssw_base_src = getenv("CMSSW_BASE"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use FileInPath to get the full path automatically
fEta_ = std::make_unique<float>(fNParticles_); | ||
fPhi_ = std::make_unique<float>(fNParticles_); | ||
fId_ = std::make_unique<float>(fNParticles_); | ||
fInput_ = iInput; //tensorflow::run(session_, { { "input_1:0",input } }, { "dense_4/Sigmoid:0" }, &outputs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
NNvectorVar_.push_back(0); | ||
continue; | ||
} | ||
fId_.get()[i0] == l1t::PFCandidate::Photon ? NNvectorVar_.push_back(1) : NNvectorVar_.push_back(0); //Photon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplify: NNvectorVar_.push_back(fId_.get()[i0] == l1t::PFCandidate::Photon);
(also for lines below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fPt_.get()[i0] = iParts[i0].pt(); | ||
fEta_.get()[i0] = iSeed.eta() - iParts[i0].eta(); | ||
float lDPhi = iSeed.phi() - iParts[i0].phi(); | ||
if (lDPhi > TMath::Pi()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
The code-checks are being triggered in jenkins. |
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30505/16702
Code check has found code style and quality issues which could be resolved by applying following patch(s)
|
addressed cmments and now rebasing off of #30510 |
235c856
to
7eed165
Compare
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30505/16727
|
Comparison is ready Comparison Summary:
|
+1 |
|
||
private: | ||
tensorflow::Session *session_; | ||
tensorflow::GraphDef *graphDef_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How big is the graph? I think we've typically shared the graph across the stream modules in an edm::GlobalCache
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, a smart pointer could be used (though it seems like that isn't common practice for CMSSW TF code at the moment, something to be improved globally)
return; | ||
} | ||
pfChargedHadrons_seeds.push_back(pfChargedHadrons_sort[0]); | ||
for (unsigned int i0 = 1; i0 < pfChargedHadrons_sort.size(); i0++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be range-based loop
pfChargedHadrons_seeds.push_back(pfChargedHadrons_sort[0]); | ||
for (unsigned int i0 = 1; i0 < pfChargedHadrons_sort.size(); i0++) { | ||
bool pMatch = false; | ||
for (unsigned int i1 = 0; i1 < pfChargedHadrons_seeds.size(); i1++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be range-based loop
if (int(pfChargedHadrons_seeds.size()) > fMaxTaus_ - 1) | ||
break; | ||
} | ||
for (unsigned int i0 = 0; i0 < pfChargedHadrons_seeds.size(); i0++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be range-based loop
TLorentzVector lCand; | ||
lCand.SetPtEtaPhiM(0, 0, 0, 0); | ||
int lId = 0; | ||
for (auto l1PFCand : iParts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto&
l1t::PFTau l1PFTau(tempP4, NN, 0, lId); | ||
outputTaus->push_back(l1PFTau); | ||
} | ||
float L1NNTauProducer::deltaR(const l1t::PFCandidate& iPart1, const l1t::PFCandidate& iPart2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fMaxTaus_(cfg.getParameter<int>("maxtaus")), | ||
fNParticles_(cfg.getParameter<int>("nparticles")), | ||
fL1PFToken_(consumes<vector<l1t::PFCandidate> >(cfg.getParameter<edm::InputTag>("L1PFObjects"))) { | ||
std::string lNNFile = cfg.getParameter<std::string>("NNFileName"); //,"L1Trigger/Phase2L1Taus/data/tau_3layer.pb"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
|
||
private: | ||
tensorflow::Session *session_; | ||
tensorflow::GraphDef *graphDef_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, a smart pointer could be used (though it seems like that isn't common practice for CMSSW TF code at the moment, something to be improved globally)
fPt_.get()[i0] = iParts[i0].pt(); | ||
fEta_.get()[i0] = iSeed.eta() - iParts[i0].eta(); | ||
float lDPhi = iSeed.phi() - iParts[i0].phi(); | ||
if (lDPhi > M_PI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
std::sort(iParts.begin(), iParts.end(), [](l1t::PFCandidate i, l1t::PFCandidate j) { return (i.pt() > j.pt()); }); | ||
for (unsigned int i0 = 0; i0 < iParts.size(); i0++) { | ||
if (i0 > 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this hardcoded? is it the same as the "nparticles" python parameter? if so, just use that...
(also, just make the loop condition i0 < std::min(iParts.size(),fNparticles_)
)
@rekovic there is a conflict |
@rekovic there are also still comments to be addressed |
@rekovic what is the status of this PR |
@rekovic ping |
-1 |
@rekovic please let me know when you want to open this PR back |
PR description:
This is effectively the PR #30482 (L1Trigger/Phase2L1ParticleFlow package which has been reviewed fully) augmented by the very last one commit dd150ad which adds the producer for L1 NN Taus, contained in the following five files:
The NNTau producer is added to the Phase2 L1T sequence in
@kpedro88
Please review those.
PR validation:
if this PR is a backport please specify the original PR and why you need to backport that PR:
Before submitting your pull requests, make sure you followed this checklist: