Skip to content
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

Conversation

rekovic
Copy link
Contributor

@rekovic rekovic commented Jul 2, 2020

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:

  • L1Trigger/Phase2L1ParticleFlow/interface/L1NNTauProducer.hh
  • L1Trigger/Phase2L1ParticleFlow/interface/TauNNId.h
  • L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc
  • L1Trigger/Phase2L1ParticleFlow/python/L1NNTauProducer_cff.py
  • L1Trigger/Phase2L1ParticleFlow/src/TauNNId.cc

The NNTau producer is added to the Phase2 L1T sequence in

  • L1Trigger/Configuration/python/SimL1Emulator_cff.py

@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:

@rekovic
Copy link
Contributor Author

rekovic commented Jul 2, 2020

assign upgrade

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

The code-checks are being triggered in jenkins.

@rekovic
Copy link
Contributor Author

rekovic commented Jul 2, 2020

assign l1

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

-code-checks

ERROR: Build errors found during clang-tidy run.

L1Trigger/Phase2L1ParticleFlow/interface/L1NNTauProducer.hh:30:16: error: 'auto' not allowed in function prototype [clang-diagnostic-error]
  float deltaR(auto iPart1, auto iPart2);
               ^
L1Trigger/Phase2L1ParticleFlow/interface/L1NNTauProducer.hh:30:29: error: 'auto' not allowed in function prototype [clang-diagnostic-error]
  float deltaR(auto iPart1, auto iPart2);
                            ^
L1Trigger/Phase2L1ParticleFlow/interface/L1NNTauProducer.hh:31:16: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override]
--
L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc:99:31: error: 'auto' not allowed in function prototype [clang-diagnostic-error]
float L1NNTauProducer::deltaR(auto iPart1, auto iPart2) {
                              ^
L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc:99:44: error: 'auto' not allowed in function prototype [clang-diagnostic-error]
float L1NNTauProducer::deltaR(auto iPart1, auto iPart2) {
                                           ^
Suppressed 3048 warnings (3044 in non-user code, 4 with check filters).
--
gmake: *** [config/SCRAM/GMake/Makefile.coderules:128: code-checks] Error 2
gmake: *** [There are compilation/build errors. Please see the detail log above.] Error 2

void addTau(l1t::PFCandidate &iCand,
const l1t::PFCandidateCollection &iParts,
std::unique_ptr<PFTauCollection> &outputTaus);
float deltaR(auto iPart1, auto iPart2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unneeded include

Copy link
Contributor Author

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>
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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();
Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded include

Copy link
Contributor Author

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");
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete commented-out code

Copy link
Contributor Author

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
Copy link
Contributor

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)

Copy link
Contributor Author

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 2, 2020

-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)

@rekovic
Copy link
Contributor Author

rekovic commented Jul 3, 2020

addressed cmments and now rebasing off of #30510

@rekovic rekovic force-pushed the pr111x-L1ParticleFlow-Phase2-clean-with-Tau branch from 235c856 to 7eed165 Compare July 3, 2020 07:29
@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 3, 2020

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 3, 2020

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-30505/16727

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 7, 2020

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-c57de4/7737/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 2 differences found in the comparisons
  • DQMHistoTests: Total files compared: 37
  • DQMHistoTests: Total histograms compared: 2787364
  • DQMHistoTests: Total failures: 5
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 2787308
  • DQMHistoTests: Total skipped: 50
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.004 KiB( 36 files compared)
  • DQMHistoSizes: changed ( 10224.0 ): 0.004 KiB MessageLogger/Warnings
  • Checked 154 log files, 17 edm output root files, 37 DQM output files

@rekovic
Copy link
Contributor Author

rekovic commented Jul 7, 2020

+1


private:
tensorflow::Session *session_;
tensorflow::GraphDef *graphDef_;
Copy link
Contributor

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.

Copy link
Contributor

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++) {
Copy link
Contributor

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++) {
Copy link
Contributor

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++) {
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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");
Copy link
Contributor

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_;
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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_))

@cmsbuild cmsbuild mentioned this pull request Jul 8, 2020
@silviodonato
Copy link
Contributor

@rekovic there is a conflict

@cmsbuild cmsbuild added the urgent label Jul 9, 2020
@kpedro88
Copy link
Contributor

kpedro88 commented Jul 9, 2020

@rekovic there are also still comments to be addressed

@kpedro88
Copy link
Contributor

@rekovic what is the status of this PR

@kpedro88
Copy link
Contributor

@rekovic ping
(clearly this PR is not actually "urgent"...)

@kpedro88
Copy link
Contributor

-1
to remove from upgrade list

@silviodonato
Copy link
Contributor

@rekovic please let me know when you want to open this PR back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants