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

DNN-based Tau-Id discrimians (102X) #25386

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ca4ab8d
First implementation of deep tau id.
kandrosov Jun 15, 2018
32dd010
Building dpf isolation module
ocolegrove Aug 13, 2018
b9d7a01
Adding in v1
ocolegrove Aug 16, 2018
8ba178f
Adding in runTauIDMVA for other users
ocolegrove Aug 16, 2018
0d5af0b
making things fully reproducible
ocolegrove Aug 17, 2018
c439bfe
Reorganisation of configuration files: cff split to cfi and cff
mbluj Sep 25, 2018
12271fa
Some code cleaning
mbluj Sep 25, 2018
84cfb99
adapt to cfi/cff reorganization
mbluj Sep 26, 2018
dc7cbd3
Review of DPF and DeepTauId code.
MRD2F Oct 19, 2018
8e297d9
Added example of a python configuration file to produce pat::Tau coll…
MRD2F Oct 19, 2018
41e4edc
requested changes on runDeepTauIDsOnMiniAOD.py
MRD2F Oct 22, 2018
e1f055d
Clean runTauIdMVA.py tool and test config to run tauIDs
mbluj Oct 23, 2018
0417afd
Made DeepTauId and DPFIsolation thread-safe
MRD2F Oct 25, 2018
d854212
Finish implement thread-safe requirements on DPFIsolation
MRD2F Oct 25, 2018
efc0540
Disable DPFTau_2016_v1 and issue some warnings
MRD2F Oct 25, 2018
104d5b7
Merge pull request #103 from MRD2F/CMSSW_10_2_X_tau_pog_DNNTauID
mbluj Oct 29, 2018
7df8fdb
Remove assigning value of variable to itself
MRD2F Nov 29, 2018
8c3fb20
- Implemented on runTauIdMVA the option to work with new training fil…
MRD2F Oct 31, 2018
0eb0fda
- Implementation of global cache to avoid reloading graph for each th…
MRD2F Nov 2, 2018
c34d583
Applied changes on DeepTauBase to allow load new training files using…
MRD2F Nov 5, 2018
45c0003
Implemented TauWPThreshold class.
kandrosov Nov 2, 2018
ea94956
Remove the qm.pb input files and leaving just the quantized and the o…
MRD2F Nov 5, 2018
ee097de
-Overall, changes to improve memory usage, among these are:
MRD2F Nov 6, 2018
5d4d15a
Applied style comments
MRD2F Nov 8, 2018
a82f820
Applied style comments
MRD2F Nov 8, 2018
b595d46
Applied comments
MRD2F Nov 8, 2018
ac1ce8e
Change to be by default the original training file for deepTau, inste…
MRD2F Nov 8, 2018
505f4e8
Changes regarding forward-porting DNN-related developments from the P…
MRD2F Nov 17, 2018
cdce09b
Applied commets of previus PR
MRD2F Nov 13, 2018
6cb1168
cleaning code
MRD2F Nov 13, 2018
92df2ae
Modification in the config to work with new label in files
MRD2F Nov 14, 2018
8a0ab25
Applied comment about the expected format of name of training file
MRD2F Nov 14, 2018
72b193a
Fix in last commit
MRD2F Nov 14, 2018
cedab33
Applied last comments
MRD2F Nov 14, 2018
df546a5
Changes regarding forward-porting DNN-related developments from the P…
MRD2F Nov 17, 2018
95cca7a
Applied @perrotta comments on 104X
MRD2F Nov 21, 2018
daac1a3
Fix error
MRD2F Nov 21, 2018
3d5ab7c
Applied comments
MRD2F Nov 21, 2018
4344f17
Applied comments
MRD2F Nov 22, 2018
139ec49
Fix merge problem
MRD2F Nov 22, 2018
3142b41
Applied a few commets
MRD2F Nov 22, 2018
c8ef218
Applied more changes
MRD2F Nov 22, 2018
1da62c7
Applied a few small followups
MRD2F Nov 22, 2018
36a67b4
Fixed error on DPFIsolation
MRD2F Nov 22, 2018
99dbf40
Update DPFIsolation.cc
mbluj Nov 23, 2018
2f798ef
Merge branch 'CMSSW_10_2_X' into CMSSW_10_2_X_tau_pog_DNNTauIDs
mbluj Nov 30, 2018
a51c80a
Merge pull request #111 from MRD2F/CMSSW_10_2_6_tau_pog
mbluj Nov 30, 2018
644aadc
- RecoTauTag/RecoTau/plugins/DeepTauId.cc: Remove ' clusterVariables …
MRD2F Dec 3, 2018
35e5783
Added changes in RecoTauTag/RecoTau/python/tools/runTauIdMVA.py made …
MRD2F Dec 3, 2018
189cf5d
Fix error on runDeepTauIDsOnMiniAOD
MRD2F Dec 3, 2018
678a6d7
Change the GT in RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py
MRD2F Dec 3, 2018
c168174
Merge pull request #112 from MRD2F/CMSSW_10_2_6_tau_pog
mbluj Dec 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RecoTauTag/RecoTau/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<use name="FastSimulation/BaseParticlePropagator"/>
<use name="FastSimulation/Particle"/>
<use name="roottmva"/>
<use name="PhysicsTools/TensorFlow"/>
<export>
<lib name="1"/>
</export>
106 changes: 106 additions & 0 deletions RecoTauTag/RecoTau/interface/DeepTauBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#ifndef RecoTauTag_RecoTau_DeepTauBase_h
#define RecoTauTag_RecoTau_DeepTauBase_h

/*
* \class DeepTauBase
*
* Definition of the base class for tau identification using Deep NN.
*
* \author Konstantin Androsov, INFN Pisa
* \author Maria Rosaria Di Domenico, University of Siena & INFN Pisa
*/

#include <Math/VectorUtil.h>
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "PhysicsTools/TensorFlow/interface/TensorFlow.h"
#include "tensorflow/core/util/memmapped_file_system.h"
#include "DataFormats/PatCandidates/interface/Electron.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "DataFormats/PatCandidates/interface/PATTauDiscriminator.h"
#include "CommonTools/Utils/interface/StringObjectFunction.h"
#include "RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include <TF1.h>

namespace deep_tau {

class TauWPThreshold {
public:
explicit TauWPThreshold(const std::string& cut_str);
double operator()(const pat::Tau& tau) const;

private:
std::unique_ptr<TF1> fn_;
double value_;
};

class DeepTauCache {
public:
using GraphPtr = std::shared_ptr<tensorflow::GraphDef>;

DeepTauCache(const std::string& graph_name, bool mem_mapped);
~DeepTauCache();

// A Session allows concurrent calls to Run(), though a Session must
// be created / extended by a single thread.
tensorflow::Session& getSession() const { return *session_; }
const tensorflow::GraphDef& getGraph() const { return *graph_; }

private:
GraphPtr graph_;
tensorflow::Session* session_;
std::unique_ptr<tensorflow::MemmappedEnv> memmappedEnv_;
};

class DeepTauBase : public edm::stream::EDProducer<edm::GlobalCache<DeepTauCache>> {
public:
using TauType = pat::Tau;
using TauDiscriminator = pat::PATTauDiscriminator;
using TauCollection = std::vector<TauType>;
using TauRef = edm::Ref<TauCollection>;
using TauRefProd = edm::RefProd<TauCollection>;
using ElectronCollection = pat::ElectronCollection;
using MuonCollection = pat::MuonCollection;
using LorentzVectorXYZ = ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>;
using Cutter = TauWPThreshold;
using CutterPtr = std::unique_ptr<Cutter>;
using WPMap = std::map<std::string, CutterPtr>;

struct Output {
using ResultMap = std::map<std::string, std::unique_ptr<TauDiscriminator>>;
std::vector<size_t> num_, den_;

Output(const std::vector<size_t>& num, const std::vector<size_t>& den) : num_(num), den_(den) {}

ResultMap get_value(const edm::Handle<TauCollection>& taus, const tensorflow::Tensor& pred,
const WPMap& working_points) const;
};

using OutputCollection = std::map<std::string, Output>;


DeepTauBase(const edm::ParameterSet& cfg, const OutputCollection& outputs, const DeepTauCache* cache);
virtual ~DeepTauBase() {}

virtual void produce(edm::Event& event, const edm::EventSetup& es) override;

static std::unique_ptr<DeepTauCache> initializeGlobalCache(const edm::ParameterSet& cfg);
static void globalEndJob(const DeepTauCache* cache){ }
private:
virtual tensorflow::Tensor getPredictions(edm::Event& event, const edm::EventSetup& es,
edm::Handle<TauCollection> taus) = 0;
virtual void createOutputs(edm::Event& event, const tensorflow::Tensor& pred, edm::Handle<TauCollection> taus);

protected:
edm::EDGetTokenT<TauCollection> tausToken_;
std::map<std::string, WPMap> workingPoints_;
OutputCollection outputs_;
const DeepTauCache* cache_;
};

} // namespace deep_tau

#endif
1 change: 1 addition & 0 deletions RecoTauTag/RecoTau/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<use name="FastSimulation/BaseParticlePropagator"/>
<use name="PhysicsTools/TensorFlow"/>
<use name="root"/>
</library>
Loading