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

Adding HZZ electron MVA ID #38355

Merged
merged 8 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
144 changes: 80 additions & 64 deletions PhysicsTools/NanoAOD/python/electrons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
run2_miniAOD_80XLegacy.toModify( slimmedElectronsUpdated, computeMiniIso = True )
##modify the past eras
for modifier in run2_miniAOD_80XLegacy,run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1:
modifier.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectronsTo106X"))
modifier.toModify(slimmedElectronsUpdated, src = "slimmedElectronsTo106X" )
############################FOR bitmapVIDForEle main defn#############################
electron_id_modules_WorkingPoints_nanoAOD = cms.PSet(
modules = cms.vstring(
Expand All @@ -46,6 +46,9 @@
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer16UL_ID_ISO_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer17UL_ID_ISO_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff',
),
WorkingPoints = cms.vstring(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
Expand Down Expand Up @@ -159,32 +162,32 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
)

(run2_egamma_2016 & tracker_apv_vfp30_2016).toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain")
correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain"
)

(run2_egamma_2016 & ~tracker_apv_vfp30_2016).toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_postVFP_RunFineEtaR9Gain")
correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_postVFP_RunFineEtaR9Gain"
)

run2_egamma_2017.toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2")
correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2"
)

run2_egamma_2018.toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_29Sep2020_RunFineEtaR9Gain")
correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_29Sep2020_RunFineEtaR9Gain"
)

run2_miniAOD_80XLegacy.toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Legacy2016_07Aug2017_FineEtaR9_v3_ele_unc")
correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Legacy2016_07Aug2017_FineEtaR9_v3_ele_unc"
)

for modifier in run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2:
modifier.toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_17Nov2017_v1_ele_unc")
correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_17Nov2017_v1_ele_unc"
)

run2_nanoAOD_102Xv1.toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_Step2Closure_CoarseEtaR9Gain_v2")
correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_Step2Closure_CoarseEtaR9Gain_v2"
)
##############################end calibratedPatElectronsNano############################33
#####################Start slimmedElectronsWithUserData###############################3
Expand All @@ -194,8 +197,9 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
userFloats = cms.PSet(
mvaFall17V1Iso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV1Values"),
mvaFall17V1noIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Values"),
mvaFall17V2Iso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values"),
mvaFall17V2noIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values"),
mvaIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values"),
mvaNoIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values"),
mvaHZZIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer18ULIdIsoValues"),
miniIsoChg = cms.InputTag("isoForEle:miniIsoChg"),
miniIsoAll = cms.InputTag("isoForEle:miniIsoAll"),
PFIsoChg = cms.InputTag("isoForEle:PFIsoChg"),
Expand All @@ -222,12 +226,12 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
mvaFall17V1noIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp80"),
mvaFall17V1noIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wpLoose"),

mvaFall17V2Iso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90"),
mvaFall17V2Iso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80"),
mvaFall17V2Iso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose"),
mvaFall17V2noIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90"),
mvaFall17V2noIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80"),
mvaFall17V2noIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose"),
mvaIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90"),
mvaIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80"),
mvaIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose"),
mvaNoIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90"),
mvaNoIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80"),
mvaNoIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose"),

cutbasedID_Fall17_V1_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-veto"),
cutbasedID_Fall17_V1_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-loose"),
Expand Down Expand Up @@ -264,47 +268,56 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):

run2_nanoAOD_94X2016.toModify(slimmedElectronsWithUserData.userIntFromBools,
# MVAs and HEEP are already pre-computed. Cut-based too (except V2), but we re-add it for consistency with the nested bitmap
cutbasedID_Sum16_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
cutbasedID_Sum16_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
cutbasedID_Sum16_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
cutbasedID_Sum16_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
cutbasedID_Spring15_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
cutbasedID_Spring15_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
cutbasedID_Spring15_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
cutbasedID_Fall17_V2_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
cutbasedID_Fall17_V2_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
cutbasedID_Fall17_V2_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
cutbasedID_Fall17_V2_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
cutbasedID_Sum16_veto = "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
cutbasedID_Sum16_loose = "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
cutbasedID_Sum16_medium = "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
cutbasedID_Sum16_tight = "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
cutbasedID_HLT = "egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1",
cutbasedID_Spring15_veto = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
cutbasedID_Spring15_loose = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
cutbasedID_Spring15_medium = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
cutbasedID_Spring15_tight = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
cutbasedID_Fall17_V2_veto = "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
cutbasedID_Fall17_V2_loose = "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose",
cutbasedID_Fall17_V2_medium = "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium",
cutbasedID_Fall17_V2_tight = "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",

)

run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
mvaSpring16GP = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"),
mvaSpring16HZZ = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16HZZV1Values"),
mvaSpring16GP = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values",
mvaSpring16HZZ = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16HZZV1Values",
)

run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userIntFromBools,
mvaSpring16GP_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp90"),
mvaSpring16GP_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp80"),
mvaSpring16HZZ_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-HZZ-V1-wpLoose"),
cutbasedID_Sum16_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
cutbasedID_Sum16_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
cutbasedID_Sum16_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
cutbasedID_Sum16_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
cutbasedID_Spring15_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
cutbasedID_Spring15_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
cutbasedID_Spring15_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
mvaSpring16GP_WP90 = "egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp90",
mvaSpring16GP_WP80 = "egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp80",
mvaSpring16HZZ_WPL = "egmGsfElectronIDs:mvaEleID-Spring16-HZZ-V1-wpLoose",
cutbasedID_Sum16_veto = "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
cutbasedID_Sum16_loose = "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
cutbasedID_Sum16_medium = ("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
asculac marked this conversation as resolved.
Show resolved Hide resolved
cutbasedID_Sum16_tight = "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
cutbasedID_HLT = "egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1",
cutbasedID_Spring15_veto = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
cutbasedID_Spring15_loose = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
cutbasedID_Spring15_medium = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
cutbasedID_Spring15_tight = "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
)

for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
modifier.toModify(slimmedElectronsWithUserData.userInts,
VIDNestedWPBitmapSpring15 = cms.InputTag("bitmapVIDForEleSpring15"),
VIDNestedWPBitmapSum16 = cms.InputTag("bitmapVIDForEleSum16"),
VIDNestedWPBitmapSpring15 = "bitmapVIDForEleSpring15",
VIDNestedWPBitmapSum16 = "bitmapVIDForEleSum16",
)
(~run2_nanoAOD_preUL & run2_egamma_2016).toModify(slimmedElectronsWithUserData.userFloats,
mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer16ULIdIsoValues",
)
(~run2_nanoAOD_preUL & run2_egamma_2017).toModify(slimmedElectronsWithUserData.userFloats,
mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer17ULIdIsoValues" ,
)
(~run2_nanoAOD_preUL & run2_egamma_2018).toModify(slimmedElectronsWithUserData.userFloats,
mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer18ULIdIsoValues",
)
#################################################END slimmedElectrons with user data#####################
#################################################finalElectrons#####################
finalElectrons = cms.EDFilter("PATElectronRefSelector",
Expand All @@ -331,7 +344,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
LepGood_dxy = cms.string("log(abs(dB('PV2D')))"),
LepGood_sip3d = cms.string("abs(dB('PV3D')/edB('PV3D'))"),
LepGood_dz = cms.string("log(abs(dB('PVDZ')))"),
LepGood_mvaFall17V2noIso = cms.string("userFloat('mvaFall17V2noIso')"),
LepGood_mvaFall17V2noIso = cms.string("userFloat('mvaNoIso')"),
)
)
run2_egamma_2016.toModify(electronMVATTH,
Expand Down Expand Up @@ -362,14 +375,15 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10),
scEtOverPt = Var("(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),

mvaFall17V2Iso = Var("userFloat('mvaFall17V2Iso')",float,doc="MVA Iso ID V2 score"),
mvaFall17V2Iso_WP80 = Var("userInt('mvaFall17V2Iso_WP80')",bool,doc="MVA Iso ID V2 WP80"),
mvaFall17V2Iso_WP90 = Var("userInt('mvaFall17V2Iso_WP90')",bool,doc="MVA Iso ID V2 WP90"),
mvaFall17V2Iso_WPL = Var("userInt('mvaFall17V2Iso_WPL')",bool,doc="MVA Iso ID V2 loose WP"),
mvaFall17V2noIso = Var("userFloat('mvaFall17V2noIso')",float,doc="MVA noIso ID V2 score"),
mvaFall17V2noIso_WP80 = Var("userInt('mvaFall17V2noIso_WP80')",bool,doc="MVA noIso ID V2 WP80"),
mvaFall17V2noIso_WP90 = Var("userInt('mvaFall17V2noIso_WP90')",bool,doc="MVA noIso ID V2 WP90"),
mvaFall17V2noIso_WPL = Var("userInt('mvaFall17V2noIso_WPL')",bool,doc="MVA noIso ID V2 loose WP"),
mvaIso = Var("userFloat('mvaIso')",float,doc="MVA Iso ID V2 score"),
mvaIso_WP80 = Var("userInt('mvaIso_WP80')",bool,doc="MVA Iso ID V2 WP80"),
mvaIso_WP90 = Var("userInt('mvaIso_WP90')",bool,doc="MVA Iso ID V2 WP90"),
mvaIso_WPL = Var("userInt('mvaIso_WPL')",bool,doc="MVA Iso ID V2 loose WP"),
mvaNoIso = Var("userFloat('mvaNoIso')",float,doc="MVA noIso ID V2 score"),
mvaNoIso_WP80 = Var("userInt('mvaNoIso_WP80')",bool,doc="MVA noIso ID V2 WP80"),
mvaNoIso_WP90 = Var("userInt('mvaNoIso_WP90')",bool,doc="MVA noIso ID V2 WP90"),
mvaNoIso_WPL = Var("userInt('mvaNoIso_WPL')",bool,doc="MVA noIso ID V2 loose WP"),
mvaHZZIso = Var("userFloat('mvaHZZIso')", float,doc="HZZ MVA Iso ID score"),

cutBased = Var("userInt('cutbasedID_Fall17_V2_veto')+userInt('cutbasedID_Fall17_V2_loose')+userInt('cutbasedID_Fall17_V2_medium')+userInt('cutbasedID_Fall17_V2_tight')",int,doc="cut-based ID Fall17 V2 (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
vidNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForEle_docstring),
Expand Down Expand Up @@ -536,22 +550,24 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
(run3_nanoAOD_devel).toModify(slimmedElectronsWithUserData.userFloats,
mvaFall17V1Iso = None,
mvaFall17V1noIso = None,
mvaFall17V2Iso = None,
mvaFall17V2noIso = None,
mvaIso = None,
mvaNoIso = None,
mvaHZZIso = None,
)
(run3_nanoAOD_devel).toModify(electronTable.variables,
mvaFall17V2Iso = None,
mvaFall17V2Iso_WP80 = None,
mvaFall17V2Iso_WP90 = None,
mvaFall17V2Iso_WPL = None,
mvaFall17V2noIso = None,
mvaFall17V2noIso_WP80 = None,
mvaFall17V2noIso_WP90 = None,
mvaFall17V2noIso_WPL = None,
mvaIso = None,
mvaIso_WP80 = None,
mvaIso_WP90 = None,
mvaIso_WPL = None,
mvaNoIso = None,
mvaNoIso_WP80 = None,
mvaNoIso_WP90 = None,
mvaNoIso_WPL = None,
vidNestedWPBitmapHEEP = None,
vidNestedWPBitmap = None,
cutBased = None,
cutBased_HEEP = None,
mvaHZZIso = None,
)

(run3_nanoAOD_devel).toReplaceWith(electronTablesTask, electronTablesTask.copyAndExclude([electronMVATTH]))
Expand Down
Loading