Skip to content

Commit

Permalink
Merge pull request #25293 from guitargeek/PhotonID_10_4_X
Browse files Browse the repository at this point in the history
Egamma Fall17 V2 Photon IDs
  • Loading branch information
cmsbuild committed Nov 28, 2018
2 parents 8524867 + 8ec3c83 commit 18b524f
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 1 deletion.
2 changes: 2 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Expand Up @@ -316,8 +316,10 @@ def miniAOD_customizeCommon(process):
#VID Photon IDs
process.patPhotons.addPhotonID = cms.bool(True)
photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff']
switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
Expand Down
@@ -0,0 +1,9 @@
# The constants are based on 90% contours of isolation.
# |eta| min |eta| max effective area
0.0000 1.0000 0.0112
1.0000 1.4790 0.0108
1.4790 2.0000 0.0106
2.0000 2.2000 0.01002
2.2000 2.3000 0.0098
2.3000 2.4000 0.0089
2.4000 5.0000 0.0087
@@ -0,0 +1,9 @@
# The constants are based on 90% contours of isolation.
# |eta| min |eta| max effective area
0.0000 1.0000 0.0668
1.0000 1.4790 0.1054
1.4790 2.0000 0.0786
2.0000 2.2000 0.0233
2.2000 2.3000 0.0078
2.3000 2.4000 0.0028
2.4000 5.0000 0.0137
@@ -0,0 +1,9 @@
# The constants are based on 90% contours of isolation.
# |eta| min |eta| max effective area
0.0000 1.0000 0.1113
1.0000 1.4790 0.0953
1.4790 2.0000 0.0619
2.0000 2.2000 0.0837
2.2000 2.3000 0.1070
2.3000 2.4000 0.1212
2.4000 5.0000 0.1466
@@ -0,0 +1,154 @@
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.PhotonIdentification.Identification.cutBasedPhotonID_tools \
import ( WorkingPoint_V2,
IsolationCutInputs,
configureVIDCutBasedPhoID_V5 )

# The cut values are taken from the twiki:
# https://twiki.cern.ch/twiki/bin/viewauth/CMS/CutBasedPhotonIdentificationRun2
# (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/732974/contributions/3072291/attachments/1685029/2709189/PhotonIDStudy.pdf


#
# First, define cut values
#

# Loose working point Barrel and Endcap
idName = "cutBasedPhotonID-Fall17-94X-V2-loose"
WP_Loose_EB = WorkingPoint_V2(
idName , # idName
0.04596 , # hOverECut
0.0106 , # full5x5_SigmaIEtaIEtaCut
# Isolation cuts are generally absIso < C1 + pt*C2, except for NeuHad is < C1 + pt*C2 + pt*pt*C3
1.694 , # absPFChaHadIsoWithEACut_C1
0 , # absPFChaHadIsoWithEACut_C2
24.032 , # absPFNeuHadIsoWithEACut_C1
0.01512 , # absPFNeuHadIsoWithEACut_C2
0.00002259 , # absPFNeuHadIsoWithEACut_C3
2.876 , # absPFPhoIsoWithEACut_C1
0.004017 # absPFPhoIsoWithEACut_C2
)
WP_Loose_EE = WorkingPoint_V2(
idName , #idName
0.0590 , # hOverECut
0.0272 , # full5x5_SigmaIEtaIEtaCut
# Isolation cuts are generally absIso < C1 + pt*C2, except for NeuHad is < C1 + pt*C2 + pt*pt*C3
2.089 , # absPFChaHadIsoWithEACut_C1
0.00 , # absPFChaHadIsoWithEACut_C2
19.722 , # absPFNeuHadIsoWithEACut_C1
0.0117 , # absPFNeuHadIsoWithEACut_C2
0.000023 , # absPFNeuHadIsoWithEACut_C3
4.162 , # absPFPhoIsoWithEACut_C1
0.0037 # absPFPhoIsoWithEACut_C2
)

# Medium working point Barrel and Endcap
idName = "cutBasedPhotonID-Fall17-94X-V2-medium"
WP_Medium_EB = WorkingPoint_V2(
idName , # idName
0.02197 , # hOverECut
0.01015 , # full5x5_SigmaIEtaIEtaCut
# Isolation cuts are generally absIso < C1 + pt*C2, except for NeuHad is < C1 + pt*C2 + pt*pt*C3
1.141 , # absPFChaHadIsoWithEACut_C1
0.00 , # absPFChaHadIsoWithEACut_C2
1.189 , # absPFNeuHadIsoWithEACut_C1
0.01512 , # absPFNeuHadIsoWithEACut_C2
0.00002259 , # absPFNeuHadIsowithEACut_C3
2.08 , # absPFPhoIsoWithEACut_C1
0.004017 # absPFPhoIsoWithEACut_C2
)

WP_Medium_EE = WorkingPoint_V2(
idName , #idName
0.0326 , # hOverECut
0.0272 , # full5x5_SigmaIEtaIEtaCut
# Isolation cuts are generally absIso < C1 + pt*C2, except for NeuHad is < C1 + pt*C2 + pt*pt*C3
1.051 , # absPFChaHadIsoWithEACut_C1
0.00 , # absPFChaHadIsoWithEACut_C2
2.718 , # absPFNeuHadIsoWithEACut_C1
0.0117 , # absPFNeuHadIsoWithEACut_C2
0.000023 , # absPFNeuHadIsowithEACut_C3
3.867 , # absPFPhoIsoWithEACut_C1
0.0037 # absPFPhoIsoWithEACut_C2
)

# Tight working point Barrel and Endcap
idName = "cutBasedPhotonID-Fall17-94X-V2-tight"
WP_Tight_EB = WorkingPoint_V2(
idName , # idName
0.02148 , # hOverECut
0.00996 , # full5x5_SigmaIEtaIEtaCut
# Isolation cuts are generally absIso < C1 + pt*C2, except for NeuHad is < C1 + pt*C2 + pt*pt*C3
0.65 , # absPFChaHadIsoWithEACut_C1
0.00 , # absPFChaHadIsoWithEACut_C2
0.317 , # absPFNeuHadIsoWithEACut_C1
0.01512 , # absPFNeuHadIsoWithEACut_C2
0.00002259 , # absPFNeuHadIsowithEACut_C3
2.044 , # absPFPhoIsoWithEACut_C1
0.004017 # absPFPhoIsoWithEACut_C2
)

WP_Tight_EE = WorkingPoint_V2(
idName , #idName
0.0321 , # hOverECut
0.0271 , # full5x5_SigmaIEtaIEtaCut
# Isolation cuts are generally absIso < C1 + pt*C2, except for NeuHad is < C1 + pt*C2 + pt*pt*C3
0.517 , # absPFChaHadIsoWithEACut_C1
0.00 , # absPFChaHadIsoWithEACut_C2
2.716 , # absPFNeuHadIsoWithEACut_C1
0.0117 , # absPFNeuHadIsoWithEACut_C2
0.000023 , # absPFNeuHadIsowithEACut_C3
3.032 , # absPFPhoIsoWithEACut_C1
0.0037 # absPFPhoIsoWithEACut_C2
)


# Second, define where to find the precomputed isolations and what effective
# areas to use for pile-up correction
isoInputs = IsolationCutInputs(
# chHadIsolationMapName
'photonIDValueMapProducer:phoChargedIsolation' ,
# chHadIsolationEffAreas
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfChargedHadrons_90percentBased_V2.txt",
# neuHadIsolationMapName
'photonIDValueMapProducer:phoNeutralHadronIsolation' ,
# neuHadIsolationEffAreas
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfNeutralHadrons_90percentBased_V2.txt" ,
# phoIsolationMapName
"photonIDValueMapProducer:phoPhotonIsolation" ,
# phoIsolationEffAreas
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfPhotons_90percentBased_V2.txt"
)

#
# Finally, set up VID configuration for all cuts
#
cutBasedPhotonID_Fall17_94X_V2_loose = configureVIDCutBasedPhoID_V5 ( WP_Loose_EB, WP_Loose_EE, isoInputs)
cutBasedPhotonID_Fall17_94X_V2_medium = configureVIDCutBasedPhoID_V5 ( WP_Medium_EB, WP_Medium_EE, isoInputs)
cutBasedPhotonID_Fall17_94X_V2_tight = configureVIDCutBasedPhoID_V5 ( 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 "calculateMD5 <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(cutBasedPhotonID_Fall17_94X_V2_loose.idName,
'4578dfcceb0bfd1ba5ac28973c843fd0')
central_id_registry.register(cutBasedPhotonID_Fall17_94X_V2_medium.idName,
'28b186c301061395f394a81266c8d7de')
central_id_registry.register(cutBasedPhotonID_Fall17_94X_V2_tight.idName,
'6f4f0ed6a8bf2de8dcf0bc3349b0546d')

cutBasedPhotonID_Fall17_94X_V2_loose.isPOGApproved = cms.untracked.bool(True)
cutBasedPhotonID_Fall17_94X_V2_medium.isPOGApproved = cms.untracked.bool(True)
cutBasedPhotonID_Fall17_94X_V2_tight.isPOGApproved = cms.untracked.bool(True)
@@ -0,0 +1,55 @@
from RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_tools import *
#
# In this file we define the locations of the MVA weights, cuts on the MVA values
# for specific working points, and configure those cuts in VID
#
#
# The following MVA is derived for Fall17 samples for photons.
# See more documentation in these presentations:
# https://indico.cern.ch/event/697079/contributions/2968123/attachments/1632966/2604131/PhotonID_EGM_13.04.2018.pdf
#
mvaTag = "RunIIFall17v2"
mvaVariablesFile = "RecoEgamma/PhotonIdentification/data/PhotonMVAEstimatorRun2VariablesFall17V1p1.txt"
mvaWeightFiles = [
path.join(weightFileBaseDir, "Fall17/EB_V2.weights.xml.gz"),
path.join(weightFileBaseDir, "Fall17/EE_V2.weights.xml.gz"),
]
# Set up the VID working point parameters
wpConfig = [
# The working point for this MVA that is expected to have about 90% signal
# efficiency in each category for photons with pt>30 GeV (somewhat lower
# for lower pt photons).
{"idName" : "mvaPhoID-RunIIFall17-v2-wp90",
"cuts" : { "EB" : -0.02,
"EE" : -0.26 }},
# The working point for this MVA that is expected to have about 90% signal
# efficiency in each category for photons with pt>30 GeV (somewhat lower
# for lower pt photons).
{"idName" : "mvaPhoID-RunIIFall17-v2-wp80",
"cuts" : { "EB" : 0.42,
"EE" : 0.14 }},
]
# Create the PSet that will be fed to the MVA value map producer and the
# VPset's for VID cuts
configs = configureFullVIDMVAPhoID(mvaTag=mvaTag,
variablesFile=mvaVariablesFile,
weightFiles=mvaWeightFiles,
wpConfig=wpConfig,
# Category parameters
nCategories = cms.int32(2),
categoryCuts = category_cuts)
mvaPhoID_RunIIFall17_v2_producer_config = configs["producer_config"]
mvaPhoID_RunIIFall17_v2_wp90 = configs["VID_config"]["mvaPhoID-RunIIFall17-v2-wp90"]
mvaPhoID_RunIIFall17_v2_wp80 = configs["VID_config"]["mvaPhoID-RunIIFall17-v2-wp80"]
# 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( mvaPhoID_RunIIFall17_v2_wp90.idName,
'5c06832759b1faf7dd6fc45ed1aef3a2')
central_id_registry.register( mvaPhoID_RunIIFall17_v2_wp80.idName,
'3013ddce7a3ad8b54827c29f5d92282e')
mvaPhoID_RunIIFall17_v2_wp90.isPOGApproved = cms.bool(True)
mvaPhoID_RunIIFall17_v2_wp80.isPOGApproved = cms.bool(True)
Expand Up @@ -14,6 +14,9 @@
from RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff import *
mvaConfigsForPhoProducer.append( mvaPhoID_RunIIFall17_v1p1_producer_config )

from RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff import *
mvaConfigsForPhoProducer.append( mvaPhoID_RunIIFall17_v2_producer_config )

photonMVAValueMapProducer = cms.EDProducer('PhotonMVAValueMapProducer',
# The module automatically detects AOD vs miniAOD, so we configure both
#
Expand Down
4 changes: 3 additions & 1 deletion RecoEgamma/PhotonIdentification/test/runtests.sh
Expand Up @@ -7,10 +7,12 @@ ids_to_test=(
'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff'
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff'
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1_cff'
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff'
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff'
)

for id_set in "${ids_to_test[@]}"; do
echo Checking: $id_set
cmsRun ${LOCAL_TEST_DIR}/runPhoton_VID.py 1 $id_set || die "Failure using runPhoton_VID.py on AOD $id_set" $?
cmsRun ${LOCAL_TEST_DIR}/runPhoton_VID.py 0 $id_set || die "Failure using runPhoton_VID.py on MiniAOD $id_set" $?
done
done
3 changes: 3 additions & 0 deletions RecoEgamma/PhotonIdentification/test/testPhotonMVA_cfg.py
Expand Up @@ -40,6 +40,7 @@
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
]

#add them to the VID producer
Expand All @@ -66,11 +67,13 @@
"photonMVAValueMapProducer:PhotonMVAEstimatorRun2Spring16NonTrigV1Values",
"photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v1Values",
"photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v1p1Values",
"photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v2Values",
),
phoMVAValMapLabels = cms.untracked.vstring(
"Spring16NonTrigV1",
"Fall17v1",
"Fall17v1p1",
"Fall17v2",
),
phoMVACats = cms.untracked.vstring(
"photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v1Categories",
Expand Down

0 comments on commit 18b524f

Please sign in to comment.