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
EGM-certified electron IDs for 2016 data: cut-based and MVA #16979
Merged
cmsbuild
merged 22 commits into
cms-sw:CMSSW_9_0_X
from
ikrav:egm_id_80X_v2_rebased_CMSSW_9_0_X_2016-12-07-2300
Dec 29, 2016
Merged
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4aafe54
New HLT-safe electron cut-based selection in VID, incl. python and a …
ikrav 546f35f
Bug fixes, added debug statements
ikrav 1497401
A try to fix segv
ikrav 0156a24
Fixed AOD vs miniAOD detection
ikrav a6de594
Corrected cut settings
ikrav 346471a
New cut-based electron ID tuned on 80X
ikrav e998037
Fixed a text comment
ikrav 550d947
Fixed a typo in cut values
ikrav 53a0277
Added 80X electron MVA implementation. Restructured location of MVA c…
ikrav 991abfa
Added general purpose ID
Werbellin f128e50
Remove preliminary HZZ setup
Werbellin 15638d0
Update documentation, bugfixes
Werbellin a98a1f1
Adjused MD5 sums of the electron MVA IDs
ikrav 398dace
A few changes to make new electron MVA work in FWLite
ikrav 2703f94
Removed a header from an MVA base class that appears unnecessary and …
ikrav 114eb89
Merged egm_id_80X_v2_rebased_CMSSW_9_0_X_2016-12-07-2300 from reposit…
ikrav b8160c5
Removed TROOT.h include, appears unnecessary
ikrav ade3f84
Replaced several import* with explicitly named imports
ikrav 9bc7e83
Replaced import * with explicit list in a python configuration file.
ikrav 0df48ee
Adjusted variable names to comply with CMS coding guidelines that req…
ikrav b8feed8
Fixed a typo introduced with the previous commit when lots of variabl…
ikrav 8424971
Fixed variable names in GsfEleNormalizedGsfChi2Cut to comply CMS codi…
ikrav File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_HLT_ecalPFClusterIso.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file contains Effective Area constants for | ||
# computing pile-up corrections for the ECAL PF Cluster isolation used by HLT | ||
# for an electron object. | ||
# Documentation: | ||
# slide 5 in | ||
# https://indico.cern.ch/event/491507/contributions/2192817/attachments/1285452/1911768/EGM_HLTsafeCuts_31May16.pdf | ||
# | ||
# |eta| min |eta| max effective area | ||
0.0000 1.4790 0.165 | ||
1.4790 5.0000 0.132 |
10 changes: 10 additions & 0 deletions
10
RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_HLT_hcalPFClusterIso.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file contains Effective Area constants for | ||
# computing pile-up corrections for the HCAL PF Cluster isolation used by HLT | ||
# for an electron object. | ||
# Documentation: | ||
# slide 5 in | ||
# https://indico.cern.ch/event/491507/contributions/2192817/attachments/1285452/1911768/EGM_HLTsafeCuts_31May16.pdf | ||
# | ||
# |eta| min |eta| max effective area | ||
0.0000 1.4790 0.060 | ||
1.4790 5.0000 0.131 |
16 changes: 16 additions & 0 deletions
16
...ectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file contains Effective Area constants for | ||
# computing pile-up corrections for the neutral hadron and photon | ||
# isolation for an electron object. | ||
# Documentation: | ||
# https://indico.cern.ch/event/482673/contributions/2187022/attachments/1282446/1905912/talk_electron_ID_spring16.pdf | ||
# | ||
# The effective areas are based on 90% efficient contours | ||
# | ||
# |eta| min |eta| max effective area | ||
0.0000 1.0000 0.1703 | ||
1.0000 1.4790 0.1715 | ||
1.4790 2.0000 0.1213 | ||
2.0000 2.2000 0.1230 | ||
2.2000 2.3000 0.1635 | ||
2.3000 2.4000 0.1937 | ||
2.4000 5.0000 0.2393 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
154 changes: 154 additions & 0 deletions
154
RecoEgamma/ElectronIdentification/interface/ElectronMVAEstimatorRun2Spring16GeneralPurpose.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#ifndef RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Spring16GeneralPurpose_H | ||
#define RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Spring16GeneralPurpose_H | ||
|
||
#include "RecoEgamma/EgammaTools/interface/AnyMVAEstimatorRun2Base.h" | ||
|
||
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" | ||
|
||
#include "DataFormats/BeamSpot/interface/BeamSpot.h" | ||
|
||
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h" | ||
#include "DataFormats/EgammaCandidates/interface/Conversion.h" | ||
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h" | ||
|
||
#include "CondFormats/EgammaObjects/interface/GBRForest.h" | ||
|
||
#include <vector> | ||
#include <string> | ||
#include "TMVA/Factory.h" | ||
#include "TMVA/Tools.h" | ||
#include "TMVA/Reader.h" | ||
|
||
class ElectronMVAEstimatorRun2Spring16GeneralPurpose : public AnyMVAEstimatorRun2Base{ | ||
|
||
public: | ||
|
||
// Define here the number and the meaning of the categories | ||
// for this specific MVA | ||
const int nCategories = 3; | ||
enum mvaCategories { | ||
UNDEFINED = -1, | ||
CAT_EB1_PT10plus = 0, | ||
CAT_EB2_PT10plus = 1, | ||
CAT_EE_PT10plus = 2 | ||
}; | ||
|
||
// Define the struct that contains all necessary for MVA variables | ||
// Note: all variables have to be floats for TMVA Reader, even if | ||
// the training was done with ints. | ||
struct AllVariables { | ||
// Pure ECAL -> shower shapes | ||
float see; // 0 | ||
float spp; // 1 | ||
float OneMinusE1x5E5x5; // 2 | ||
float R9; // 3 | ||
float etawidth; // 4 | ||
float phiwidth; // 5 | ||
float HoE; // 6 | ||
// Endcap only variables | ||
float PreShowerOverRaw; // 7 | ||
//Pure tracking variables | ||
float kfhits; // 8 | ||
float kfchi2; // 9 | ||
float gsfchi2; // 10 | ||
// Energy matching | ||
float fbrem; // 11 | ||
|
||
float gsfhits; // 12 | ||
float expectedMissingInnerHits; // 13 | ||
float convVtxFitProbability; // 14 | ||
|
||
float EoP; // 15 | ||
float eleEoPout; // 16 | ||
float IoEmIoP; // 17 | ||
// Geometrical matchings | ||
float deta; // 18 | ||
float dphi; // 19 | ||
float detacalo; // 20 | ||
// Spectator variables | ||
float pt; // 21 | ||
float isBarrel; // 22 | ||
float isEndcap; // 23 | ||
float SCeta; // 24 | ||
// | ||
float eClass; // 25 | ||
float pfRelIso; // 26 | ||
float expectedInnerHits; // 27 | ||
float vtxconv; // 28 | ||
float mcEventWeight; // 29 | ||
float mcCBmatchingCategory; // 30 | ||
|
||
}; | ||
|
||
// Constructor and destructor | ||
ElectronMVAEstimatorRun2Spring16GeneralPurpose(const edm::ParameterSet& conf); | ||
ElectronMVAEstimatorRun2Spring16GeneralPurpose(); // For Reflex. Not to be used in reality | ||
ElectronMVAEstimatorRun2Spring16GeneralPurpose(const std::string &mvaTag, const std::string &conversionsTag = "reducedEgamma:reducedConversions", const std::string &beamspotTag = "offlineBeamSpot"); | ||
void init(const std::vector <std::string> weightFileNames); | ||
~ElectronMVAEstimatorRun2Spring16GeneralPurpose(); | ||
|
||
|
||
|
||
// Calculation of the MVA value (VID accessor) | ||
float mvaValue( const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override; | ||
// Calculation of the MVA value (fwlite-compatible accessor) | ||
float mvaValue( const reco::GsfElectron * particle, const edm::EventBase &) const ; | ||
// Calculation of the MVA value (bare version) | ||
float mvaValue( const int iCategory, const std::vector<float> & vars) const ; | ||
|
||
// Utility functions | ||
std::unique_ptr<const GBRForest> createSingleReader(const int iCategory, | ||
const edm::FileInPath &weightFile); | ||
|
||
virtual int getNCategories() const override { return nCategories; } | ||
bool isEndcapCategory( int category ) const; | ||
virtual const std::string& getName() const override final { return _name; } | ||
virtual const std::string& getTag() const override final { return _tag; } | ||
|
||
// Functions that should work on both pat and reco electrons | ||
// (use the fact that pat::Electron inherits from reco::GsfElectron) | ||
std::vector<float> fillMVAVariables(const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override; | ||
std::vector<float> fillMVAVariables( const reco::GsfElectron * particle, const edm::Handle<reco::ConversionCollection> conversions, const reco::BeamSpot *beamSpot) const ; | ||
int findCategory( const edm::Ptr<reco::Candidate>& particle) const override; | ||
int findCategory( const reco::GsfElectron * particle) const ; | ||
// The function below ensures that the variables passed to MVA are | ||
// within reasonable bounds | ||
void constrainMVAVariables(AllVariables&) const; | ||
|
||
// Call this function once after the constructor to declare | ||
// the needed event content pieces to the framework | ||
void setConsumes(edm::ConsumesCollector&&) const override final; | ||
// Call this function once per event to retrieve all needed | ||
// event content pices | ||
|
||
private: | ||
|
||
// MVA name. This is a unique name for this MVA implementation. | ||
// It will be used as part of ValueMap names. | ||
// For simplicity, keep it set to the class name. | ||
const std::string _name = "ElectronMVAEstimatorRun2Spring16GeneralPurpose"; | ||
// MVA tag. This is an additional string variable to distinguish | ||
// instances of the estimator of this class configured with different | ||
// weight files. | ||
const std::string _tag; | ||
|
||
// Data members | ||
std::vector< std::unique_ptr<const GBRForest> > _gbrForests; | ||
|
||
// All variables needed by this MVA | ||
const std::string _MethodName; | ||
AllVariables _allMVAVars; | ||
|
||
// | ||
// Declare all tokens that will be needed to retrieve misc | ||
// data from the event content required by this MVA | ||
// | ||
const edm::InputTag _beamSpotLabel; | ||
// Conversions in AOD and miniAOD have different names | ||
const edm::InputTag _conversionsLabelAOD; | ||
const edm::InputTag _conversionsLabelMiniAOD; | ||
|
||
|
||
}; | ||
|
||
#endif |
157 changes: 157 additions & 0 deletions
157
RecoEgamma/ElectronIdentification/interface/ElectronMVAEstimatorRun2Spring16HZZ.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
#ifndef RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Spring16HZZ_H | ||
#define RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Spring16HZZ_H | ||
|
||
#include "RecoEgamma/EgammaTools/interface/AnyMVAEstimatorRun2Base.h" | ||
|
||
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" | ||
|
||
#include "DataFormats/BeamSpot/interface/BeamSpot.h" | ||
|
||
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h" | ||
#include "DataFormats/EgammaCandidates/interface/Conversion.h" | ||
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h" | ||
|
||
#include "CondFormats/EgammaObjects/interface/GBRForest.h" | ||
|
||
#include <vector> | ||
#include <string> | ||
#include "TMVA/Factory.h" | ||
#include "TMVA/Tools.h" | ||
#include "TMVA/Reader.h" | ||
|
||
class ElectronMVAEstimatorRun2Spring16HZZ : public AnyMVAEstimatorRun2Base{ | ||
|
||
public: | ||
|
||
// Define here the number and the meaning of the categories | ||
// for this specific MVA | ||
const int nCategories = 6; | ||
enum mvaCategories { | ||
UNDEFINED = -1, | ||
CAT_EB1_PT5to10 = 0, | ||
CAT_EB2_PT5to10 = 1, | ||
CAT_EE_PT5to10 = 2, | ||
CAT_EB1_PT10plus = 3, | ||
CAT_EB2_PT10plus = 4, | ||
CAT_EE_PT10plus = 5 | ||
}; | ||
|
||
// Define the struct that contains all necessary for MVA variables | ||
// Note: all variables have to be floats for TMVA Reader, even if | ||
// the training was done with ints. | ||
struct AllVariables { | ||
// Pure ECAL -> shower shapes | ||
float see; // 0 | ||
float spp; // 1 | ||
float OneMinusE1x5E5x5; // 2 | ||
float R9; // 3 | ||
float etawidth; // 4 | ||
float phiwidth; // 5 | ||
float HoE; // 6 | ||
// Endcap only variables | ||
float PreShowerOverRaw; // 7 | ||
//Pure tracking variables | ||
float kfhits; // 8 | ||
float kfchi2; // 9 | ||
float gsfchi2; // 10 | ||
// Energy matching | ||
float fbrem; // 11 | ||
|
||
float gsfhits; // 12 | ||
float expectedMissingInnerHits; // 13 | ||
float convVtxFitProbability; // 14 | ||
|
||
float EoP; // 15 | ||
float eleEoPout; // 16 | ||
float IoEmIoP; // 17 | ||
// Geometrical matchings | ||
float deta; // 18 | ||
float dphi; // 19 | ||
float detacalo; // 20 | ||
// Spectator variables | ||
float pt; // 21 | ||
float isBarrel; // 22 | ||
float isEndcap; // 23 | ||
float SCeta; // 24 | ||
// | ||
float eClass; // 25 | ||
float pfRelIso; // 26 | ||
float expectedInnerHits; // 27 | ||
float vtxconv; // 28 | ||
float mcEventWeight; // 29 | ||
float mcCBmatchingCategory; // 30 | ||
|
||
}; | ||
|
||
// Constructor and destructor | ||
ElectronMVAEstimatorRun2Spring16HZZ(const edm::ParameterSet& conf); | ||
ElectronMVAEstimatorRun2Spring16HZZ(); // For Reflex. Not to be used in reality | ||
ElectronMVAEstimatorRun2Spring16HZZ(const std::string &mvaTag, const std::string &conversionsTag = "reducedEgamma:reducedConversions", const std::string &beamspotTag = "offlineBeamSpot"); | ||
void init(const std::vector <std::string> weightFileNames); | ||
~ElectronMVAEstimatorRun2Spring16HZZ(); | ||
|
||
|
||
|
||
// Calculation of the MVA value (VID accessor) | ||
float mvaValue( const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override; | ||
// Calculation of the MVA value (fwlite-compatible accessor) | ||
float mvaValue( const reco::GsfElectron * particle, const edm::EventBase &) const ; | ||
// Calculation of the MVA value (bare version) | ||
float mvaValue( const int iCategory, const std::vector<float> & vars) const ; | ||
|
||
// Utility functions | ||
std::unique_ptr<const GBRForest> createSingleReader(const int iCategory, | ||
const edm::FileInPath &weightFile); | ||
|
||
virtual int getNCategories() const override { return nCategories; } | ||
bool isEndcapCategory( int category ) const; | ||
virtual const std::string& getName() const override final { return _name; } | ||
virtual const std::string& getTag() const override final { return _tag; } | ||
|
||
// Functions that should work on both pat and reco electrons | ||
// (use the fact that pat::Electron inherits from reco::GsfElectron) | ||
std::vector<float> fillMVAVariables(const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override; | ||
std::vector<float> fillMVAVariables( const reco::GsfElectron * particle, const edm::Handle<reco::ConversionCollection> conversions, const reco::BeamSpot *beamSpot) const ; | ||
int findCategory( const edm::Ptr<reco::Candidate>& particle) const override; | ||
int findCategory( const reco::GsfElectron * particle) const ; | ||
// The function below ensures that the variables passed to MVA are | ||
// within reasonable bounds | ||
void constrainMVAVariables(AllVariables&) const; | ||
|
||
// Call this function once after the constructor to declare | ||
// the needed event content pieces to the framework | ||
void setConsumes(edm::ConsumesCollector&&) const override final; | ||
// Call this function once per event to retrieve all needed | ||
// event content pices | ||
|
||
private: | ||
|
||
// MVA name. This is a unique name for this MVA implementation. | ||
// It will be used as part of ValueMap names. | ||
// For simplicity, keep it set to the class name. | ||
const std::string _name = "ElectronMVAEstimatorRun2Spring16HZZ"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More prohibited names with leading underbars, lines 132-152. |
||
// MVA tag. This is an additional string variable to distinguish | ||
// instances of the estimator of this class configured with different | ||
// weight files. | ||
const std::string _tag; | ||
|
||
// Data members | ||
std::vector< std::unique_ptr<const GBRForest> > _gbrForests; | ||
|
||
// All variables needed by this MVA | ||
const std::string _MethodName; | ||
AllVariables _allMVAVars; | ||
|
||
// | ||
// Declare all tokens that will be needed to retrieve misc | ||
// data from the event content required by this MVA | ||
// | ||
const edm::InputTag _beamSpotLabel; | ||
// Conversions in AOD and miniAOD have different names | ||
const edm::InputTag _conversionsLabelAOD; | ||
const edm::InputTag _conversionsLabelMiniAOD; | ||
|
||
|
||
}; | ||
|
||
#endif |
2 changes: 1 addition & 1 deletion
2
RecoEgamma/ElectronIdentification/plugins/ElectronMVAEstimatorRun2Phys14NonTrig.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
RecoEgamma/ElectronIdentification/plugins/ElectronMVAEstimatorRun2Spring15NonTrig.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
RecoEgamma/ElectronIdentification/plugins/ElectronMVAEstimatorRun2Spring15Trig.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...amma/ElectronIdentification/plugins/ElectronMVAEstimatorRun2Spring16GeneralPurpose_Reg.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "RecoEgamma/ElectronIdentification/interface/ElectronMVAEstimatorRun2Spring16GeneralPurpose.h" | ||
|
||
DEFINE_EDM_PLUGIN(AnyMVAEstimatorRun2Factory, | ||
ElectronMVAEstimatorRun2Spring16GeneralPurpose, | ||
"ElectronMVAEstimatorRun2Spring16GeneralPurpose"); |
5 changes: 5 additions & 0 deletions
5
RecoEgamma/ElectronIdentification/plugins/ElectronMVAEstimatorRun2Spring16HZZ_Reg.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "RecoEgamma/ElectronIdentification/interface/ElectronMVAEstimatorRun2Spring16HZZ.h" | ||
|
||
DEFINE_EDM_PLUGIN(AnyMVAEstimatorRun2Factory, | ||
ElectronMVAEstimatorRun2Spring16HZZ, | ||
"ElectronMVAEstimatorRun2Spring16HZZ"); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 are still prohibited variables names that start with "_" here and on lines 136-149.