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

2017 Electron and Photon ID #10

Open
wants to merge 32 commits into
base: CMSSW_940pre3_EGID2017
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
79a1011
Added New 2017 Electron cutbased ID
lsoffi Dec 14, 2017
1f4558d
Added New 2017 Photon cutbased ID
lsoffi Dec 14, 2017
226478e
Fixing std::cout
lsoffi Dec 14, 2017
4c69929
fix to TagProbePairMaker.cc when #pairs >3
lsoffi Jan 11, 2018
81819e3
Fix to cutBasedElectronID_tools.py
lsoffi Jan 15, 2018
1a14373
Adding Photon MVA 2017
lsoffi Jan 16, 2018
aaab232
Adding 2017 MVA ID from K. Mondal
lsoffi Jan 16, 2018
c32d3a6
Adding cff for MVA Photon ID
lsoffi Jan 16, 2018
d60a810
Adding Photon MVA 2017
lsoffi Jan 16, 2018
08cae9e
Fix to slides reference MVA Photon ID
lsoffi Jan 16, 2018
dc1b557
Fit slides reference to effA for electrons ID
lsoffi Jan 16, 2018
b484303
Adding dumpPileup.py
lsoffi Jan 17, 2018
62e2f65
Removing duplicate config file
lsoffi Jan 26, 2018
70b3e77
code style and quality issue solved
lsoffi Jan 29, 2018
988c9f6
Required changes from @slava77 to cuts plugins implemented
lsoffi Jan 30, 2018
4525af1
Required changes from @slava77 to effective areas txt files implemented
lsoffi Jan 30, 2018
8c39751
Required changes from @slava77 to PhotonIDValueMapProducer.cc imple…
lsoffi Jan 30, 2018
cee0594
Required changes from @slava77 to PhotonMVAEstimatorRunIIFall17.cc …
lsoffi Jan 30, 2018
00efe2a
Required changes from @slava77 to PhotonMVAEstimatorRunIIFall17.cc a…
lsoffi Jan 30, 2018
4880382
Required changes from @slava77 to cutBasedElectronID_Fall17_94X_V1_P…
lsoffi Jan 30, 2018
e87b20b
Required changes from @slava77 to cutBasedElectronID_Fall17_94X_V1_c…
lsoffi Jan 30, 2018
b5943c6
Fixed double dash in cutBasedElectronID_Fall17_94X_V1_cff.py
lsoffi Jan 30, 2018
8769dcd
Fixed isPOG approved in cutBasedPhotonID_Fall17_94X_V1_cff.py
lsoffi Jan 30, 2018
e2d01da
Fix pdf in effAreaPhotons_cone03_pfNeutralHadrons_90percentBased.txt …
lsoffi Jan 31, 2018
183cfa6
Adding pdf link updated to all effA txt files
lsoffi Jan 31, 2018
febd5d8
added 2017 IDs to unit tests
lsoffi Feb 6, 2018
e617bda
Adding back 2015 IDs in runtests
lsoffi Feb 6, 2018
8c239d8
Adding back HEEP 7.0
lsoffi Feb 7, 2018
0a9d008
Adding V1p1 photon MVA w/o PV constrained
lsoffi Feb 13, 2018
3acb210
Adding V1p1 photon MVA w/o PV constrained adding V1p1 cff file
lsoffi Feb 13, 2018
961d574
Merged CMSSW_9_4_0_pre3_TnP_WithPVConstraint from repository lsoffi w…
lsoffi Feb 13, 2018
a1c8d5b
Removing doulbe implmentation and added an argument to computeWorstPF…
lsoffi Feb 20, 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 PhysicsTools/TagAndProbe/src/TagProbePairMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ tnp::TagProbePairMaker::arbitrate(TagProbePairs &pairs) const

bool TTpair=false;
for (TagProbePairs::iterator it2 = pairs.begin(); it2 != ed; ++it2) { // first check for Tag-Tag pairs
if (it2->tag.isNull()) continue; // skip already invalidated pairs
if(it!=it2 && it->probe==it2->tag && it->tag==it2->probe){
//std::cout << "----------> probe is tag!!!!" << std::endl;
TTpair=true;
Expand Down
7 changes: 7 additions & 0 deletions PhysicsTools/TagAndProbe/test/utilities/dumpPileup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python
import sys
import ROOT
fin=ROOT.TFile.Open(sys.argv[1])
pu = fin.Get("pileup")
pileup = map( pu.GetBinContent, xrange(1,pu.GetNbinsX()+1) )
print ",".join(map(lambda x: "%1.3g"%x, pileup))
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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/662749/contributions/2763091/attachments/1545124/2424854/talk_electron_ID_fall17.pdf
#
# The effective areas are based on 90% efficient contours
#
# |eta| min |eta| max effective area
0.0000 1.0000 0.1566
1.0000 1.4790 0.1626
1.4790 2.0000 0.1073
2.0000 2.2000 0.0854
2.2000 2.3000 0.1051
2.3000 2.4000 0.1204
2.4000 5.0000 0.1524
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "PhysicsTools/SelectorUtils/interface/CutApplicatorWithEventContentBase.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"

class GsfEleHadronicOverEMEnergyScaledCut : public CutApplicatorWithEventContentBase {
public:
GsfEleHadronicOverEMEnergyScaledCut(const edm::ParameterSet& c) :
CutApplicatorWithEventContentBase(c),
barrelC0_(c.getParameter<double>("barrelC0")),
barrelCE_(c.getParameter<double>("barrelCE")),
barrelCr_(c.getParameter<double>("barrelCr")),
endcapC0_(c.getParameter<double>("endcapC0")),
endcapCE_(c.getParameter<double>("endcapCE")),
endcapCr_(c.getParameter<double>("endcapCr")),
barrelCutOff_(c.getParameter<double>("barrelCutOff"))
{
edm::InputTag rhoTag = c.getParameter<edm::InputTag>("rho");
contentTags_.emplace("rho",rhoTag);

}

result_type operator()(const reco::GsfElectronPtr&) const final;

void setConsumes(edm::ConsumesCollector&) final;
void getEventContent(const edm::EventBase&) final;

double value(const reco::CandidatePtr& cand) const final;

CandidateType candidateType() const final {
return ELECTRON;
}

private:
const float barrelC0_, barrelCE_, barrelCr_, endcapC0_, endcapCE_, endcapCr_, barrelCutOff_;
edm::Handle<double> rhoHandle_;
};

DEFINE_EDM_PLUGIN(CutApplicatorFactory,
GsfEleHadronicOverEMEnergyScaledCut,
"GsfEleHadronicOverEMEnergyScaledCut");

void GsfEleHadronicOverEMEnergyScaledCut::setConsumes(edm::ConsumesCollector& cc) {
auto rho = cc.consumes<double>(contentTags_["rho"]);
contentTokens_.emplace("rho",rho);
}

void GsfEleHadronicOverEMEnergyScaledCut::getEventContent(const edm::EventBase& ev) {
ev.getByLabel(contentTags_["rho"],rhoHandle_);
}


CutApplicatorBase::result_type GsfEleHadronicOverEMEnergyScaledCut::operator()(const reco::GsfElectronPtr& cand) const {

const double rho = rhoHandle_.isValid() ? (float)(*rhoHandle_) : 0;
const float energy = cand->superCluster()->energy();
const float c0 = (std::abs(cand->superCluster()->position().eta()) < barrelCutOff_ ? barrelC0_ : endcapC0_);
const float cE = (std::abs(cand->superCluster()->position().eta()) < barrelCutOff_ ? barrelCE_ : endcapCE_);
const float cR = (std::abs(cand->superCluster()->position().eta()) < barrelCutOff_ ? barrelCr_ : endcapCr_);
return cand->hadronicOverEm() < c0 + cE/energy + cR*rho/energy;
}

double GsfEleHadronicOverEMEnergyScaledCut::value(const reco::CandidatePtr& cand) const {
reco::GsfElectronPtr ele(cand);
return ele->hadronicOverEm();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
from PhysicsTools.SelectorUtils.centralIDRegistry import central_id_registry

import FWCore.ParameterSet.Config as cms

# Common functions and classes for ID definition are imported here:
from RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_tools \
import ( EleWorkingPoint_V4,
IsolationCutInputs_V2,
configureVIDCutBasedEleID_V4 )

#
# The ID cuts below are optimized IDs on Spring16 simulation with 80X-based production
# The cut values are taken from the twiki:
# https://twiki.cern.ch/twiki/bin/view/CMS/CutBasedElectronIdentificationRun2
# (where they may not stay, if a newer version of cuts becomes available for these
# conditions)
# See also the presentation explaining these working points (this will not change):
# https://indico.cern.ch/event/662751/contributions/2778044/attachments/1562080/2459801/171121_egamma_workshop.pdf
#
# First, define cut values
#

# Veto working point Barrel and Endcap
#V1 of IDs good for Moriond 18
idName = "cutBasedElectronID-Fall17-94X-V1-veto"
WP_Veto_EB = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0128 , # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.00523 , # dEtaInSeedCut
dPhiInCut = 0.159 , # dPhiInCut
hOverECut_C0 = 0.05 , # hOverECut
hOverECut_CE = 1.12 ,
hOverECut_Cr = 0.0368 ,
relCombIsolationWithEALowPtCut = 0.168 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.168 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.193 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 2 # missingHitsCut
)

WP_Veto_EE = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0445 , # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.00984 , # dEtaInSeedCut
dPhiInCut = 0.157 , # dPhiInCut
hOverECut_C0 = 0.05 , # hOverECut
hOverECut_CE = 0.5 ,
hOverECut_Cr = 0.201 ,
relCombIsolationWithEALowPtCut = 0.185 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.185 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.0962 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 3 # missingHitsCut
)

# Loose working point Barrel and Endcap
idName = "cutBasedElectronID-Fall17-94X-V1-loose"
WP_Loose_EB = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0105 , # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.00387 , # dEtaInSeedCut
dPhiInCut = 0.0716 , # dPhiInCut
hOverECut_C0 = 0.05 , # hOverECut
hOverECut_CE = 1.12 ,
hOverECut_Cr = 0.0368 ,
relCombIsolationWithEALowPtCut = 0.133 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.133 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.129 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 1 # missingHitsCut
)

WP_Loose_EE = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0356 , # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.0072 , # dEtaInSeedCut
dPhiInCut = 0.147 , # dPhiInCut
hOverECut_C0 = 0.0414 , # hOverECut
hOverECut_CE = 0.5 ,
hOverECut_Cr = 0.201 ,
relCombIsolationWithEALowPtCut = 0.146 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.146 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.0875 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 1 # missingHitsCut
)

# Medium working point Barrel and Endcap
idName = "cutBasedElectronID-Fall17-94X-V1-medium"
WP_Medium_EB = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0105, # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.00365, # dEtaInSeedCut
dPhiInCut = 0.0588 , # dPhiInCut
hOverECut_C0 = 0.026 , # hOverECut
hOverECut_CE = 1.12 ,
hOverECut_Cr = 0.0368 ,
relCombIsolationWithEALowPtCut = 0.0718 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.0718 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.0327 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 1 # missingHitsCut
)

WP_Medium_EE = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0309 , # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.00625 , # dEtaInSeedCut
dPhiInCut = 0.0355 , # dPhiInCut
hOverECut_C0 = 0.026 , # hOverECut
hOverECut_CE = 0.5 ,
hOverECut_Cr = 0.201 ,
relCombIsolationWithEALowPtCut = 0.143 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.143 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.0335 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 1 # missingHitsCut
)

# Tight working point Barrel and Endcap
idName = "cutBasedElectronID-Fall17-94X-V1-tight"
WP_Tight_EB = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0104 , # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.00353 , # dEtaInSeedCut
dPhiInCut = 0.0499 , # dPhiInCut
hOverECut_C0 = 0.026 , # hOverECut
hOverECut_CE = 1.12 ,
hOverECut_Cr = 0.0368 ,
relCombIsolationWithEALowPtCut = 0.0361 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.0361 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.0278 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 1 # missingHitsCut
)

WP_Tight_EE = EleWorkingPoint_V4(
idName = idName , # idName
full5x5_sigmaIEtaIEtaCut = 0.0305 , # full5x5_sigmaIEtaIEtaCut
dEtaInSeedCut = 0.00567 , # dEtaInSeedCut
dPhiInCut = 0.0165 , # dPhiInCut
hOverECut_C0 = 0.026 , # hOverECut
hOverECut_CE = 0.5 ,
hOverECut_Cr = 0.201 ,
relCombIsolationWithEALowPtCut = 0.094 , # relCombIsolationWithEALowPtCut
relCombIsolationWithEAHighPtCut= 0.094 , # relCombIsolationWithEAHighPtCut
absEInverseMinusPInverseCut = 0.0158 , # absEInverseMinusPInverseCut
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut = 1 # missingHitsCut
)

# Second, define what effective areas to use for pile-up correction
isoInputs = IsolationCutInputs_V2(
# phoIsolationEffAreas
"RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_92X.txt"
)


#
# Set up VID configuration for all cuts and working points
#

cutBasedElectronID_Fall17_94X_V1_veto = configureVIDCutBasedEleID_V4(WP_Veto_EB, WP_Veto_EE, isoInputs)
cutBasedElectronID_Fall17_94X_V1_loose = configureVIDCutBasedEleID_V4(WP_Loose_EB, WP_Loose_EE, isoInputs)
cutBasedElectronID_Fall17_94X_V1_medium = configureVIDCutBasedEleID_V4(WP_Medium_EB, WP_Medium_EE, isoInputs)
cutBasedElectronID_Fall17_94X_V1_tight = configureVIDCutBasedEleID_V4(WP_Tight_EB, WP_Tight_EE, isoInputs)


# The MD5 sum numbers below reflect the exact set of cut variables
# and values above. If anything changes, one has to
# 1) comment out the lines below about the registry,
# 2) run "calculateIdMD5 <this file name> <one of the VID config names just above>
# 3) update the MD5 sum strings below and uncomment the lines again.
#

central_id_registry.register(cutBasedElectronID_Fall17_94X_V1_veto.idName,
'43be9b381a8d9b0910b7f81a5ad8ff3a')
central_id_registry.register(cutBasedElectronID_Fall17_94X_V1_loose.idName,
'0b8456d622494441fe713a6858e0f7c1')
central_id_registry.register(cutBasedElectronID_Fall17_94X_V1_medium.idName,
'a238ee70910de53d36866e89768500e9')
central_id_registry.register(cutBasedElectronID_Fall17_94X_V1_tight.idName,
'4acb2d2796efde7fba75380ce8823fc2')


### for now until we have a database...
cutBasedElectronID_Fall17_94X_V1_veto.isPOGApproved = cms.untracked.bool(True)
cutBasedElectronID_Fall17_94X_V1_loose.isPOGApproved = cms.untracked.bool(True)
cutBasedElectronID_Fall17_94X_V1_medium.isPOGApproved = cms.untracked.bool(True)
cutBasedElectronID_Fall17_94X_V1_tight.isPOGApproved = cms.untracked.bool(True)
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,41 @@ def __init__(self,
# conversion veto cut needs no parameters, so not mentioned
self.missingHitsCut = missingHitsCut

class EleWorkingPoint_V4:
"""
This is a container class to hold numerical cut values for either
the barrel or endcap set of cuts for electron cut-based ID
With respect to V3, the hOverE cut is made energy and pileup dependend as presented in
https://indico.cern.ch/event/662749/contributions/2763092/attachments/1545209/2425054/talk_electron_ID_2017.pdf
"""
def __init__(self,
idName,
dEtaInSeedCut,
dPhiInCut,
full5x5_sigmaIEtaIEtaCut,
hOverECut_C0,
hOverECut_CE,
hOverECut_Cr,
absEInverseMinusPInverseCut,
relCombIsolationWithEALowPtCut,
relCombIsolationWithEAHighPtCut,
# conversion veto cut needs no parameters, so not mentioned
missingHitsCut
):
self.idName = idName
self.dEtaInSeedCut = dEtaInSeedCut
self.dPhiInCut = dPhiInCut
self.full5x5_sigmaIEtaIEtaCut = full5x5_sigmaIEtaIEtaCut
self.hOverECut_C0 = hOverECut_C0
self.hOverECut_CE = hOverECut_CE
self.hOverECut_Cr = hOverECut_Cr
self.absEInverseMinusPInverseCut = absEInverseMinusPInverseCut
self.relCombIsolationWithEALowPtCut = relCombIsolationWithEALowPtCut
self.relCombIsolationWithEAHighPtCut = relCombIsolationWithEAHighPtCut
# conversion veto cut needs no parameters, so not mentioned
self.missingHitsCut = missingHitsCut


class EleHLTSelection_V1:
"""
This is a container class to hold numerical cut values for either
Expand Down Expand Up @@ -225,6 +260,23 @@ def psetHadronicOverEMCut(wpEB, wpEE):
isIgnored = cms.bool(False)
)

# Configure energy and pileup dependend H/E cut
def psetHadronicOverEMEnergyScaledCut(wpEB, wpEE):
return cms.PSet(
cutName = cms.string('GsfEleHadronicOverEMEnergyScaledCut'),
barrelC0 = cms.double( wpEB.hOverECut_C0 ),
barrelCE = cms.double( wpEB.hOverECut_CE ),
barrelCr = cms.double( wpEB.hOverECut_Cr ),
endcapC0 = cms.double( wpEE.hOverECut_C0 ),
endcapCE = cms.double( wpEE.hOverECut_CE ),
endcapCr = cms.double( wpEE.hOverECut_Cr ),
rho = cms.InputTag("fixedGridRhoFastjetAll"),
barrelCutOff = cms.double(ebCutOff),
needsAdditionalProducts = cms.bool(True),
isIgnored = cms.bool(False)
)


# Configure |1/E-1/p| cut
def psetEInerseMinusPInverseCut(wpEB, wpEE):
return cms.PSet(
Expand Down Expand Up @@ -590,6 +642,35 @@ def configureVIDCutBasedEleID_V3( wpEB, wpEE, isoInputs ):
#
return parameterSet

def configureVIDCutBasedEleID_V4( wpEB, wpEE, isoInputs ):
"""
This function configures the full cms.PSet for a VID ID and returns it.
The inputs: two objects of the type WorkingPoint_V3, one
containing the cuts for the Barrel (EB) and the other one for the Endcap (EE).
The third argument is an object that contains information necessary
for isolation calculations.
In this version, the energy and pileup dependend hOverE is introduced
"""
# print "VID: Configuring cut set %s" % wpEB.idName
parameterSet = cms.PSet(
#
idName = cms.string( wpEB.idName ), # same name stored in the _EB and _EE objects
cutFlow = cms.VPSet(
psetMinPtCut(),
psetPhoSCEtaMultiRangeCut(), # eta cut
psetDEtaInSeedCut(wpEB, wpEE), # dEtaIn seed cut
psetDPhiInCut(wpEB, wpEE), # dPhiIn cut
psetPhoFull5x5SigmaIEtaIEtaCut(wpEB, wpEE), # full 5x5 sigmaIEtaIEta cut
psetHadronicOverEMEnergyScaledCut(wpEB, wpEE), # H/E cut
psetEInerseMinusPInverseCut(wpEB, wpEE), # |1/e-1/p| cut
psetEffAreaPFIsoCut(wpEB, wpEE, isoInputs), # rel. comb. PF isolation cut
psetConversionVetoCut(),
psetMissingHitsCut(wpEB, wpEE)
)
)
#
return parameterSet


# -----------------------------
# HLT-safe common definitions
Expand Down
Loading