From 3b5b3d612a8b4a51e00ce99c9e0b669fd119c4fc Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Mon, 8 Apr 2024 11:58:24 +0200 Subject: [PATCH 1/4] Remove unused cff file to update tauIDs in Nano --- PhysicsTools/NanoAOD/python/nano_cff.py | 2 +- PhysicsTools/NanoAOD/python/taus_cff.py | 4 - .../NanoAOD/python/taus_updatedMVAIds_cff.py | 303 ------------------ 3 files changed, 1 insertion(+), 308 deletions(-) delete mode 100644 PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 515c0c75d066a..0bd85285a9d2c 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -119,7 +119,7 @@ def nanoAOD_addTauIds(process, idsToRun=[]): process.finalTaus.src = updatedTauName #remember to adjust the selection and tables with added IDs - process.tauTask.add( process.rerunMvaIsolationTaskForNano , process.patTauMVAIDsTask ) + process.tauTask.add( process.rerunMvaIsolationTaskForNano, getattr(process, updatedTauName) ) return process diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index d9586ed72a404..c90c20881c5c9 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -8,10 +8,6 @@ from PhysicsTools.PatAlgos.patTauSignalCandidatesProducer_cfi import patTauSignalCandidatesProducer -##################### Updated tau collection with MVA-based tau-Ids rerun ####### -# Used only in some eras -from PhysicsTools.NanoAOD.taus_updatedMVAIds_cff import * - ##################### User floats producers, selectors ########################## # Original DeepTau v2p5 in 12_4_X doesn't include WPs in MINIAOD diff --git a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py deleted file mode 100644 index b12dcc17e9b32..0000000000000 --- a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py +++ /dev/null @@ -1,303 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -##################### Updated tau collection with MVA-based tau-Ids rerun ####### -# Used only in some eras -from RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi import * -from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import * -from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants - -### MVAIso 2017v2 -## DBoldDM -# Raw -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw = patDiscriminationByIsolationMVArun2v1raw.clone( - PATTauProducer = cms.InputTag('slimmedTaus'), - Prediscriminants = noPrediscriminants, - loadMVAfromDB = cms.bool(True), - mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), # name of the training you want to use - mvaOpt = cms.string("DBoldDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score) - verbosity = cms.int32(0) -) -# WPs -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT = patDiscriminationByIsolationMVArun2v1.clone( - PATTauProducer = cms.InputTag('slimmedTaus'), - Prediscriminants = noPrediscriminants, - toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw'), - loadMVAfromDB = cms.bool(True), - mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT_mvaOutput_normalization"), # normalization fo the training you want to use - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), # this is the name of the working point you want to use - variable = cms.string("pt"), - ) - ), - workingPoints = cms.vstring( - "_VVLoose", - "_VLoose", - "_Loose", - "_Medium", - "_Tight", - "_VTight", - "_VVTight" - ) -) -# MVAIso DBoldDM Seqeunce -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask = cms.Task( - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw, - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT -) -## DBnewDM -# Raw -patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone( - mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"), # name of the training you want to use - mvaOpt = cms.string("DBnewDMwLTwGJ") # option you want to use for your training (i.e., which variables are used to compute the BDT score) -) -# WPs -patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone( - toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw'), - mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT_mvaOutput_normalization"), # normalization fo the training you want to use - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"), # this is the name of the working point you want to use - variable = cms.string("pt"), - ) - ) -) -# MVAIso DBnewDM Seqeunce -patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask = cms.Task( - patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw, - patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT -) -## DBoldDMdR0p3 -# Raw -patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTraw = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone( - mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"), # name of the training you want to use - mvaOpt = cms.string("DBoldDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score) - srcChargedIsoPtSum = cms.string('chargedIsoPtSumdR03'), - srcFootprintCorrection = cms.string('footprintCorrectiondR03'), - srcNeutralIsoPtSum = cms.string('neutralIsoPtSumdR03'), - srcPUcorrPtSum = cms.string('puCorrPtSum'), - srcPhotonPtSumOutsideSignalCone = cms.string('photonPtSumOutsideSignalConedR03') -) -# WPs -patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone( - toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTraw'), - mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT_mvaOutput_normalization"), # normalization fo the training you want to use - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"), # this is the name of the working point you want to use - variable = cms.string("pt"), - ) - ) -) -# MVAIso DBoldDMdR0p3 Seqeunce -patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTTask = cms.Task( - patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTraw, - patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT -) -### MVAIso 2017v1 for Nano on top of MiniAODv1 -## DBoldDM -# Raw -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2017v1 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone( - mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"), # name of the training you want to use - mvaOpt = cms.string("DBoldDMwLTwGJ") # option you want to use for your training (i.e., which variables are used to compute the BDT score) -) -# WPs -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone( - toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2017v1'), - mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"), # normalization fo the training you want to use - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"), # this is the name of the working point you want to use - variable = cms.string("pt"), - ) - ), - workingPoints = cms.vstring( - "_WPEff95", - "_WPEff90", - "_WPEff80", - "_WPEff70", - "_WPEff60", - "_WPEff50", - "_WPEff40" - ) -) -# MVAIso DBoldDM Seqeunce -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1Task = cms.Task( - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2017v1, - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1 -) -### MVAIso 2015 for Nano on top of MiniAODv2 -## DBoldDM -# Raw -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2015 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone( - mvaName = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"), # name of the training you want to use - mvaOpt = cms.string("DBoldDMwLT") # option you want to use for your training (i.e., which variables are used to compute the BDT score) -) -# WPs -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone( - toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2015'), - mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1_mvaOutput_normalization"), # normalization fo the training you want to use - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"), # this is the name of the working point you want to use - variable = cms.string("pt"), - ) - ), - workingPoints = cms.vstring( - "_WPEff90", - "_WPEff80", - "_WPEff70", - "_WPEff60", - "_WPEff50", - "_WPEff40" - ) -) -# MVAIso DBoldDM Seqeunce -patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015Task = cms.Task( - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2015, - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015 -) - - -### Define new anit-e discriminants (2018) -antiElectronDiscrMVA6_version = "MVA" -## Raw -from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6 -patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone( - PATTauProducer = 'slimmedTaus', - Prediscriminants = noPrediscriminants, #already selected for MiniAOD - srcElectrons = 'slimmedElectrons', - vetoEcalCracks = False, #keep tau candidates in EB-EE cracks - mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_BL', - mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_EC', - mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_BL', - mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_EC', - mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_BL', - mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_EC', - mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_BL', - mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_EC' -) -## anti-e 2018 WPs -from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer -# VLoose -patTauDiscriminationByElectronRejectionMVA62018 = patTauDiscriminantCutMultiplexer.clone( - PATTauProducer = patTauDiscriminationByElectronRejectionMVA62018Raw.PATTauProducer, - Prediscriminants = patTauDiscriminationByElectronRejectionMVA62018Raw.Prediscriminants, - toMultiplex = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"), - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_BL'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(2), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_BL'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(5), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_BL'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(7), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_BL'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(8), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_EC'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(10), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_EC'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(13), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_EC'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(15), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_EC'), - variable = cms.string('pt') - ) - ), - rawValues = cms.vstring( - "discriminator", - "category" - ), - workingPoints = cms.vstring( - "_VLoose", - "_Loose", - "_Medium", - "_Tight", - "_VTight" - ) -) -### Define v1 anit-e discriminants (2015) -antiElectronDiscrMVA6v1_version = "MVA6v1" -## Raw -patTauDiscriminationByElectronRejectionMVA62015Raw = patTauDiscriminationAgainstElectronMVA6.clone( - PATTauProducer = 'slimmedTaus', - Prediscriminants = noPrediscriminants, #already selected for MiniAOD - srcElectrons = 'slimmedElectrons', - vetoEcalCracks = True, #don't keep tau candidates in EB-EE cracks for v1 - mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_wGwoGSF_BL', - mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_wGwoGSF_EC', - mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_woGwoGSF_BL', - mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_woGwoGSF_EC', - mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_wGwGSF_BL', - mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_wGwGSF_EC', - mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_woGwGSF_BL', - mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_woGwGSF_EC' -) -## anti-e v1 WPs -patTauDiscriminationByElectronRejectionMVA62015 = patTauDiscriminationByElectronRejectionMVA62018.clone( - PATTauProducer = patTauDiscriminationByElectronRejectionMVA62015Raw.PATTauProducer, - Prediscriminants = patTauDiscriminationByElectronRejectionMVA62015Raw.Prediscriminants, - toMultiplex = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62015Raw"), - rawValues = cms.vstring( - "discriminator", - "category" - ), - workingPoints = cms.vstring( - "_WPEff99", - "_WPEff96", - "_WPEff91", - "_WPEff85", - "_WPEff79" - ) -) -for m in patTauDiscriminationByElectronRejectionMVA62015.mapping: - m.cut = m.cut.value().replace(antiElectronDiscrMVA6_version, antiElectronDiscrMVA6v1_version + "_gbr") - -patTauDiscriminationByElectronRejectionTask = cms.Task( - patTauDiscriminationByElectronRejectionMVA62015Raw, - patTauDiscriminationByElectronRejectionMVA62015 -) - - -### put all new MVA tau-Id stuff to one Sequence -patTauMVAIDsTask = cms.Task( - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask, - patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask, - patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTTask, - patTauDiscriminationByElectronRejectionTask, - patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015Task -) - -slimmedTausUpdated = cms.EDProducer("PATTauIDEmbedder", - src = cms.InputTag('slimmedTaus'), - tauIDSources = cms.PSet() # PSet defined below in era dependent way -) - -patTauMVAIDsTask.add(slimmedTausUpdated) From fcff0c8de5322e623e014fcdf3979d1e3dc9ad69 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Mon, 8 Apr 2024 12:00:24 +0200 Subject: [PATCH 2/4] Test tauID rereco with payloads from GT --- .../test/rerunMVAIsolationOnMiniAOD.py | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py index 1342776f98a2d..1fddd18f7c2a4 100644 --- a/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py @@ -24,11 +24,7 @@ fileName = cms.string('rerunTauID_miniAOD.root') ) -#from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, '76X_mcRun2_asymptotic_RunIIFall15DR76_v1', '') - from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants -process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi') from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import * from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import * @@ -36,11 +32,8 @@ PATTauProducer = cms.InputTag('slimmedTaus'), Prediscriminants = noPrediscriminants, loadMVAfromDB = cms.bool(True), - ## run with old MVA training - #mvaName = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"), - ## run with new MVA training - mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"), - mvaOpt = cms.string("DBoldDMwLT"), + mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), + mvaOpt = cms.string("DBoldDMwLTwGJ"), verbosity = cms.int32(0) ) @@ -49,21 +42,22 @@ Prediscriminants = noPrediscriminants, toMultiplex = cms.InputTag('rerunDiscriminationByIsolationMVArun2v1raw'), loadMVAfromDB = cms.bool(True), - mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1_mvaOutput_normalization"), + mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT_mvaOutput_normalization"), mapping = cms.VPSet( cms.PSet( category = cms.uint32(0), - cut = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"), + cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), variable = cms.string("pt"), ) ), workingPoints = cms.vstring( - "_WPEff90", - "_WPEff80", - "_WPEff70", - "_WPEff60", - "_WPEff50", - "_WPEff40" + "_VVLoose", + "_VLoose", + "_Loose", + "_Medium", + "_Tight", + "_VTight", + "_VVTight" ) ) @@ -76,14 +70,14 @@ vetoEcalCracks = cms.bool(False), returnMVA = cms.bool(True), method = cms.string("BDTG"), - mvaName_NoEleMatch_woGwoGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_BL"), - mvaName_NoEleMatch_wGwoGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_BL"), - mvaName_woGwGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_BL"), - mvaName_wGwGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_BL"), - mvaName_NoEleMatch_woGwoGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_EC"), - mvaName_NoEleMatch_wGwoGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_EC"), - mvaName_woGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_EC"), - mvaName_wGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_EC"), + mvaName_NoEleMatch_woGwoGSF_BL = cms.string("RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_BL"), + mvaName_NoEleMatch_wGwoGSF_BL = cms.string("RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_BL"), + mvaName_woGwGSF_BL = cms.string("RecoTauTag_antiElectronMVA_woGwGSF_BL"), + mvaName_wGwGSF_BL = cms.string("RecoTauTag_antiElectronMVA_wGwGSF_BL"), + mvaName_NoEleMatch_woGwoGSF_EC = cms.string("RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_EC"), + mvaName_NoEleMatch_wGwoGSF_EC = cms.string("RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_EC"), + mvaName_woGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA_woGwGSF_EC"), + mvaName_wGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA_wGwGSF_EC"), minMVANoEleMatchWOgWOgsfBL = cms.double(0.0), minMVANoEleMatchWgWOgsfBL = cms.double(0.0), minMVAWOgWgsfBL = cms.double(0.0), @@ -113,12 +107,13 @@ def tauIDMVAinputs(module, wp): src = cms.InputTag('slimmedTaus'), tauIDSources = cms.PSet( byIsolationMVArun2v1DBoldDMwLTrawNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "raw"), - byVLooseIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff90"), - byLooseIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff80"), - byMediumIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff70"), - byTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff60"), - byVTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff50"), - byVVTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff40"), + byVVLooseIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_VVLoose"), + byVLooseIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_VLoose"), + byLooseIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_Loose"), + byMediumIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_Medium"), + byTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_Tight"), + byVTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_VTight"), + byVVTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_VVTight"), againstElectronMVA6RawNew = tauIDMVAinputs("rerunDiscriminationAgainstElectronMVA6", "raw") ), ) From 160e10ccce04e0a57baeeb7444176420c01d9bf4 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Mon, 8 Apr 2024 13:04:07 +0200 Subject: [PATCH 3/4] Define but not regiser payloads --- .../loadRecoTauTagMVAsFromPrepDB_cfi.py | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/RecoTauTag/Configuration/python/loadRecoTauTagMVAsFromPrepDB_cfi.py b/RecoTauTag/Configuration/python/loadRecoTauTagMVAsFromPrepDB_cfi.py index e4e4b76a72af5..7b89bbfd57852 100644 --- a/RecoTauTag/Configuration/python/loadRecoTauTagMVAsFromPrepDB_cfi.py +++ b/RecoTauTag/Configuration/python/loadRecoTauTagMVAsFromPrepDB_cfi.py @@ -19,7 +19,7 @@ ) #### -# register tau ID (= isolation) discriminator MVA +# define payloads names of tau ID (= isolation) discriminator MVA tauIdDiscrMVA_trainings = { 'tauIdMVAoldDMwoLT' : "tauIdMVAoldDMwoLT", 'tauIdMVAoldDMwLT' : "tauIdMVAoldDMwLT", @@ -215,6 +215,8 @@ 'tauIdMVAIsoPhase2_v1' : "mvaOutput_normalization", } +''' +# register the tau ID payloads tauIdDiscrMVA_version = "v1" for training, gbrForestName in tauIdDiscrMVA_trainings.items(): loadRecoTauTagMVAsFromPrepDB.toGet.append( @@ -339,9 +341,10 @@ label = cms.untracked.string("RecoTauTag_%s_mvaOutput_normalization" % (training)) ) ) +''' #### -## register anti-electron discriminator MVA +## define payloads of anti-electron discriminator MVA # MVA5 antiElectronDiscrMVA5_categories = { '0' : "gbr_NoEleMatch_woGwoGSF_BL", @@ -363,6 +366,8 @@ } antiElectronDiscrMVA5_WPs = [ "eff99", "eff96", "eff91", "eff85", "eff79" ] antiElectronDiscrMVA5_version = "v1" +''' +# ...and register for category, gbrForestName in antiElectronDiscrMVA5_categories.items(): loadRecoTauTagMVAsFromPrepDB.toGet.append( cms.PSet( @@ -379,6 +384,7 @@ label = cms.untracked.string("RecoTauTag_antiElectronMVA5%s_%s_WP%s" % (antiElectronDiscrMVA5_version, gbrForestName, WP)) ) ) +''' # MVA6v1 antiElectronDiscrMVA6_categories = { @@ -393,6 +399,8 @@ } antiElectronDiscrMVA6_WPs = [ "Eff99", "Eff96", "Eff91", "Eff85", "Eff79" ] antiElectronDiscrMVA6_version = "v1" +''' +# ...and register for category, gbrForestName in antiElectronDiscrMVA6_categories.items(): loadRecoTauTagMVAsFromPrepDB.toGet.append( cms.PSet( @@ -409,10 +417,14 @@ label = cms.untracked.string("RecoTauTag_antiElectronMVA6%s_%s_WP%s" % (antiElectronDiscrMVA6_version, gbrForestName, WP)) ) ) +''' + # MVA6v3 # MB: categories as in MVA6v1 antiElectronDiscrMVA6_2017_WPs = [ "eff98", "eff90", "eff80", "eff70", "eff60" ] antiElectronDiscrMVA6_2017_version = "v3_noeveto" +''' +# ...and register for category, gbrForestName in antiElectronDiscrMVA6_categories.items(): loadRecoTauTagMVAsFromPrepDB.toGet.append( cms.PSet( @@ -429,6 +441,7 @@ label = cms.untracked.string("RecoTauTag_antiElectronMVA6%s_%s_WP%s" % (antiElectronDiscrMVA6_2017_version, gbrForestName, WP)) ) ) +''' # MVA6 phase2 antiElectronDiscrMVA_phase2_categories = { @@ -447,6 +460,8 @@ } antiElectronDiscrMVA_phase2_WPs = [ "Eff98", "Eff90", "Eff80", "Eff70", "Eff60" ] antiElectronDiscrMVA_phase2_version = "v1" +''' +# ...and register for category, gbrForestName in antiElectronDiscrMVA_phase2_categories.items(): loadRecoTauTagMVAsFromPrepDB.toGet.append( cms.PSet( @@ -463,12 +478,15 @@ label = cms.untracked.string("RecoTauTag_antiElectronPhase2MVA6%s_%s_WP%s" % (antiElectronDiscrMVA_phase2_version, gbrForestName, WP)) ) ) +''' #### -# register anti-muon discriminator MVA +# define payloads of anti-muon discriminator MVA antiMuonDiscrMVA_WPs = [ "eff99_5", "eff99_0", "eff98_0" ] antiMuonDiscrMVA_version = "v1" gbrForestName = "againstMuonMVA" +''' +# ...and register loadRecoTauTagMVAsFromPrepDB.toGet.append( cms.PSet( record = cms.string('GBRWrapperRcd'), @@ -491,3 +509,4 @@ label = cms.untracked.string("RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, antiMuonDiscrMVA_version)) ) ) +''' From 64d14c27d95025d956bb27f866a9ec344c7df612 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 9 Apr 2024 18:33:41 +0200 Subject: [PATCH 4/4] Use tauIDs with payloads from GT --- .../NanoAOD/python/boostedTaus_cff.py | 15 +- PhysicsTools/NanoAOD/python/nano_cff.py | 2 +- .../python/tools/adaptToRunAtMiniAOD.py | 2 +- .../RecoTau/python/tools/runTauIdMVA.py | 435 +++++++++++++++--- .../RecoTau/test/runDeepTauIDsOnMiniAOD.py | 4 +- 5 files changed, 382 insertions(+), 76 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py index cf214b3c184e5..a620e6265ac08 100644 --- a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py +++ b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py @@ -15,7 +15,7 @@ ) run2_nanoAOD_106Xv2.toModify( finalBoostedTaus, - cut = "pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2017v2DBoldDMwLT2017') || tauID('byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017') || tauID('byVVLooseIsolationMVArun2017v2DBnewDMwLT2017'))" + cut = "pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBoldDMdR0p3wLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT'))" ) boostedTauTable = simpleCandidateFlatTableProducer.clone( @@ -49,8 +49,8 @@ ) #MVA 2017 v2 dR<0.3 variables _boostedTauVarsMVAIsoDr03 = cms.PSet( - rawMVAoldDMdR032017v2 = Var("tauID('byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017')",float,doc='byIsolationMVArun2DBoldDMdR0p3wLT raw output discriminator (2017v2)'), - idMVAoldDMdR032017v2 = _tauIdWPMask("by%sIsolationMVArun2017v2DBoldDMdR0p3wLT2017",choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),doc="IsolationMVArun2DBoldDMdR0p3wLT ID working point (2017v2)") + rawMVAoldDMdR032017v2 = Var("tauID('byIsolationMVArun2DBoldDMdR0p3wLTraw')",float,doc='byIsolationMVArun2DBoldDMdR0p3wLT raw output discriminator (2017v2)'), + idMVAoldDMdR032017v2 = _tauIdWPMask("by%sIsolationMVArun2DBoldDMdR0p3wLT",choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),doc="IsolationMVArun2DBoldDMdR0p3wLT ID working point (2017v2)") ) #AntiEle MVA 2018 variables _boostedTauVarsAntiEleMVA = cms.PSet( @@ -73,15 +73,6 @@ run2_nanoAOD_106Xv2.toModify( boostedTauTable, variables = _boostedTauVarsWithDr03 -).toModify( - boostedTauTable.variables, - rawMVAoldDM2017v2 = Var("tauID('byIsolationMVArun2017v2DBoldDMwLTraw2017')",float, doc="byIsolationMVArun2DBoldDMwLT raw output discriminator (2017v2)",precision=10), - rawMVAnewDM2017v2 = Var("tauID('byIsolationMVArun2017v2DBnewDMwLTraw2017')",float,doc='byIsolationMVArun2DBnewDMwLT raw output discriminator (2017v2)',precision=10), - idMVAnewDM2017v2 = _tauIdWPMask("by%sIsolationMVArun2017v2DBnewDMwLT2017", choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),doc="IsolationMVArun2DBnewDMwLT ID working point (2017v2)"), - idMVAoldDM2017v2 = _tauIdWPMask("by%sIsolationMVArun2017v2DBoldDMwLT2017",choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),doc="IsolationMVArun2DBoldDMwLT ID working point (2017v2)"), - rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw2018')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10), - rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category2018')", "int16", doc="Anti-electron MVA discriminator V6 category (2018)"), - idAntiEle2018 = _tauIdWPMask("againstElectron%sMVA62018", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2018)") ) boostedTausMCMatchLepTauForTable = tausMCMatchLepTauForTable.clone( diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 0bd85285a9d2c..6eed023afee92 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -260,7 +260,7 @@ def nanoAOD_customizeCommon(process): idsToAdd = cms.vstring() ) run2_nanoAOD_106Xv2.toModify( - nanoAOD_boostedTau_switch, idsToAdd = ["2017v2", "dR0p32017v2", "newDM2017v2","againstEle2018"] + nanoAOD_boostedTau_switch, idsToAdd = ["mvaIso", "mvaIsoNewDM", "mvaIsoDR0p3", "againstEle"] ).toModify( process, lambda p : nanoAOD_addBoostedTauIds(p, nanoAOD_boostedTau_switch.idsToAdd.value()) ) diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py index a47392dac4dc2..5dc39227607a3 100644 --- a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -281,7 +281,7 @@ def adaptTauToMiniAODReReco(self,reclusterJets=True): toKeep = ['deepTau2017v2p1'] #For boosted do not run deepTauIDs, but add still used Run-2 anti-e MVA if self.runBoosted: - toKeep = ['againstEle2018'] + toKeep = ['againstEle'] import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig tauIdEmbedder = tauIdConfig.TauIDEmbedder( self.process, debug = False, diff --git a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py index 4cf3f8ff47240..309964e2476e9 100644 --- a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py +++ b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py @@ -11,32 +11,24 @@ class TauIDEmbedder(object): """class to rerun the tau seq and acces trainings from the database""" - availableDiscriminators = [ + experimentalDiscriminators = [ "2017v1", "2017v2", "newDM2017v2", "dR0p32017v2", "2016v1", "newDM2016v1", - "deepTau2017v2", "deepTau2017v2p1", "deepTau2018v2p5", "deepTau2026v2p5", - "againstEle2018", - "newDMPhase2v1", - "againstElePhase2v1" + "againstEle2018" ] + availableDiscriminators = experimentalDiscriminators.copy() + availableDiscriminators.extend([ + "mvaIso", "mvaIsoNewDM", "mvaIsoDR0p3", #payloads from GT (2017v2) + "againstEle", #payloads from GT (2018) + "newDMPhase2v1", #payloads from phase2 GT + "againstElePhase2v1", #payloads from phase2 GT + "deepTau2017v2", "deepTau2017v2p1", "deepTau2018v2p5", "deepTau2026v2p5" + ]) def __init__(self, process, debug = False, originalTauName = "slimmedTaus", updatedTauName = "slimmedTausNewID", postfix = "", toKeep = ["deepTau2017v2p1", "deepTau2018v2p5", "deepTau2026v2p5"], - tauIdDiscrMVA_trainings_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017", }, - tauIdDiscrMVA_WPs_run2_2017 = { - 'tauIdMVAIsoDBoldDMwLT2017' : { - 'Eff95' : "DBoldDMwLTEff95", - 'Eff90' : "DBoldDMwLTEff90", - 'Eff80' : "DBoldDMwLTEff80", - 'Eff70' : "DBoldDMwLTEff70", - 'Eff60' : "DBoldDMwLTEff60", - 'Eff50' : "DBoldDMwLTEff50", - 'Eff40' : "DBoldDMwLTEff40" - } - }, - tauIdDiscrMVA_2017_version = "v1", conditionDB = "" # preparational DB: 'frontier://FrontierPrep/CMS_CONDITIONS' ): super(TauIDEmbedder, self).__init__() @@ -45,22 +37,21 @@ def __init__(self, process, debug = False, self.originalTauName = originalTauName self.updatedTauName = updatedTauName self.postfix = postfix - self.process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi') - if len(conditionDB) != 0: - self.process.CondDBTauConnection.connect = cms.string(conditionDB) - self.process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB) - # if debug: - # print self.process.CondDBTauConnection.connect - # print dir(self.process.loadRecoTauTagMVAsFromPrepDB) - # print self.process.loadRecoTauTagMVAsFromPrepDB.parameterNames_ - self.tauIdDiscrMVA_trainings_run2_2017 = tauIdDiscrMVA_trainings_run2_2017 - self.tauIdDiscrMVA_WPs_run2_2017 = tauIdDiscrMVA_WPs_run2_2017 - self.tauIdDiscrMVA_2017_version = tauIdDiscrMVA_2017_version for discr in toKeep: if discr not in TauIDEmbedder.availableDiscriminators: raise RuntimeError('TauIDEmbedder: discriminator "{}" is not supported'.format(discr)) self.toKeep = toKeep + if not set(toKeep).isdisjoint(TauIDEmbedder.experimentalDiscriminators): + print('There are experimental tauIDs not from GT') + self.process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi') + if len(conditionDB) != 0: + self.process.CondDBTauConnection.connect = cms.string(conditionDB) + self.process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB) + # if debug: + # print self.process.CondDBTauConnection.connect + # print dir(self.process.loadRecoTauTagMVAsFromPrepDB) + # print self.process.loadRecoTauTagMVAsFromPrepDB.parameterNames_ @staticmethod def get_cmssw_version(debug = False): @@ -130,11 +121,202 @@ def loadMVA_WPs_run2_2017(self): ) ) + def load_againstElectronMVA6(self): + if self.debug: print ("load_againstElectronMVA6: performed") + global cms + antiElectronDiscrMVA6_categories = { + '0' : "gbr_NoEleMatch_woGwoGSF_BL", + '2' : "gbr_NoEleMatch_wGwoGSF_BL", + '5' : "gbr_woGwGSF_BL", + '7' : "gbr_wGwGSF_BL", + '8' : "gbr_NoEleMatch_woGwoGSF_EC", + '10' : "gbr_NoEleMatch_wGwoGSF_EC", + '13' : "gbr_woGwGSF_EC", + '15' : "gbr_wGwGSF_EC" + } + for category, gbrForestName in antiElectronDiscrMVA6_categories.items(): + self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append( + cms.PSet( + record = cms.string('GBRWrapperRcd'), + tag = cms.string("RecoTauTag_antiElectronMVA6%s_%s" % (self.antiElectronDiscrMVA6_version, gbrForestName)), + label = cms.untracked.string("RecoTauTag_antiElectronMVA6%s_%s" % (self.antiElectronDiscrMVA6_version, gbrForestName)) + ) + ) + for WP in self.antiElectronDiscrMVA6_WPs: + self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append( + cms.PSet( + record = cms.string('PhysicsTGraphPayloadRcd'), + tag = cms.string("RecoTauTag_antiElectronMVA6%s_%s_WP%s" % (self.antiElectronDiscrMVA6_version, gbrForestName, WP)), + label = cms.untracked.string("RecoTauTag_antiElectronMVA6%s_%s_WP%s" % (self.antiElectronDiscrMVA6_version, gbrForestName, WP)) + ) + ) + def runTauID(self): _rerunMvaIsolationTask = cms.Task() _rerunMvaIsolationSequence = cms.Sequence() tauIDSources = cms.PSet() + # MVAIso tauIDs with version given by payloads in GT (2017v2) + if "mvaIso" in self.toKeep: + _byIsolationOldDMMVAraw = "rerunDiscriminationByIsolationOldDMMVAraw"+self.postfix + setattr(self.process,_byIsolationOldDMMVAraw,patDiscriminationByIsolationMVArun2v1raw.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, + loadMVAfromDB = cms.bool(True), + mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), + mvaOpt = cms.string("DBoldDMwLTwGJ"), + verbosity = cms.int32(0) + )) + + _byIsolationOldDMMVA = "rerunDiscriminationByIsolationOldDMMVA"+self.postfix + setattr(self.process,_byIsolationOldDMMVA,patDiscriminationByIsolationMVArun2v1.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, + toMultiplex = _byIsolationOldDMMVAraw, + loadMVAfromDB = cms.bool(True), + mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations + mapping = cms.VPSet( + cms.PSet( + category = cms.uint32(0), + cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), #writeTauIdDiscrWPs + variable = cms.string("pt"), + ) + ), + workingPoints = cms.vstring( + "_VVLoose", + "_VLoose", + "_Loose", + "_Medium", + "_Tight", + "_VTight", + "_VVTight" + ) + )) + + _rerunIsolationOldDMMVATask = cms.Task( + getattr(self.process,_byIsolationOldDMMVAraw), + getattr(self.process,_byIsolationOldDMMVA) + ) + _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVATask) + _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVATask) + + tauIDSources.byIsolationMVArun2DBoldDMwLTraw = self.tauIDMVAinputs(_byIsolationOldDMMVA, "raw") + tauIDSources.byVVLooseIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VVLoose") + tauIDSources.byVLooseIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VLoose") + tauIDSources.byLooseIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_Loose") + tauIDSources.byMediumIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_Medium") + tauIDSources.byTightIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_Tight") + tauIDSources.byVTightIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VTight") + tauIDSources.byVVTightIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VVTight") + + if "mvaIsoNewDM" in self.toKeep: + _byIsolationNewDMMVAraw = "rerunDiscriminationByIsolationNewDMMVAraw"+self.postfix + setattr(self.process,_byIsolationNewDMMVAraw,patDiscriminationByIsolationMVArun2v1raw.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, + loadMVAfromDB = cms.bool(True), + mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"), + mvaOpt = cms.string("DBnewDMwLTwGJ"), + verbosity = cms.int32(0) + )) + + _byIsolationNewDMMVA = "rerunDiscriminationByIsolationNewDMMVA"+self.postfix + setattr(self.process,_byIsolationNewDMMVA,patDiscriminationByIsolationMVArun2v1.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, + toMultiplex = _byIsolationNewDMMVAraw, + loadMVAfromDB = cms.bool(True), + mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations + mapping = cms.VPSet( + cms.PSet( + category = cms.uint32(0), + cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"), #writeTauIdDiscrWPs + variable = cms.string("pt"), + ) + ), + workingPoints = cms.vstring( + "_VVLoose", + "_VLoose", + "_Loose", + "_Medium", + "_Tight", + "_VTight", + "_VVTight" + ) + )) + + _rerunIsolationNewDMMVATask = cms.Task( + getattr(self.process,_byIsolationNewDMMVAraw), + getattr(self.process,_byIsolationNewDMMVA) + ) + _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVATask) + _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVATask) + + tauIDSources.byIsolationMVArun2DBnewDMwLTraw = self.tauIDMVAinputs(_byIsolationNewDMMVA, "raw") + tauIDSources.byVVLooseIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VVLoose") + tauIDSources.byVLooseIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VLoose") + tauIDSources.byLooseIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_Loose") + tauIDSources.byMediumIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_Medium") + tauIDSources.byTightIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_Tight") + tauIDSources.byVTightIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VTight") + tauIDSources.byVVTightIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VVTight") + + if "mvaIsoDR0p3" in self.toKeep: + _byIsolationOldDMdR0p3MVAraw = "rerunDiscriminationByIsolationOldDMdR0p3MVAraw"+self.postfix + setattr(self.process,_byIsolationOldDMdR0p3MVAraw,patDiscriminationByIsolationMVArun2v1raw.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, + loadMVAfromDB = cms.bool(True), + mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"), + mvaOpt = cms.string("DBoldDMwLTwGJ"), + srcChargedIsoPtSum = cms.string('chargedIsoPtSumdR03'), + srcFootprintCorrection = cms.string('footprintCorrectiondR03'), + srcNeutralIsoPtSum = cms.string('neutralIsoPtSumdR03'), + srcPhotonPtSumOutsideSignalCone = cms.string('photonPtSumOutsideSignalConedR03'), + verbosity = cms.int32(0) + )) + + _byIsolationOldDMdR0p3MVA = "rerunDiscriminationByIsolationOldDMdR0p3MVA"+self.postfix + setattr(self.process,_byIsolationOldDMdR0p3MVA,patDiscriminationByIsolationMVArun2v1.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, + toMultiplex = _byIsolationOldDMdR0p3MVAraw, + loadMVAfromDB = cms.bool(True), + mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations + mapping = cms.VPSet( + cms.PSet( + category = cms.uint32(0), + cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"), #writeTauIdDiscrWPs + variable = cms.string("pt"), + ) + ), + workingPoints = cms.vstring( + "_VVLoose", + "_VLoose", + "_Loose", + "_Medium", + "_Tight", + "_VTight", + "_VVTight" + ) + )) + + _rerunIsolationOldDMdR0p3MVATask = cms.Task( + getattr(self.process,_byIsolationOldDMdR0p3MVAraw), + getattr(self.process,_byIsolationOldDMdR0p3MVA) + ) + _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVATask) + _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVATask) + + tauIDSources.byIsolationMVArun2DBoldDMdR0p3wLTraw = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "raw") + tauIDSources.byVVLooseIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VVLoose") + tauIDSources.byVLooseIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VLoose") + tauIDSources.byLooseIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_Loose") + tauIDSources.byMediumIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_Medium") + tauIDSources.byTightIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_Tight") + tauIDSources.byVTightIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VTight") + tauIDSources.byVVTightIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VVTight") + # rerun the seq to obtain the 2017 nom training with 0.5 iso cone, old DM, ptph>1, trained on 2017MCv1 if "2017v1" in self.toKeep: self.tauIdDiscrMVA_2017_version = "v1" @@ -153,9 +335,8 @@ def runTauID(self): } } # update the list of available in DB samples - if not self.is_above_cmssw_version(9, 4, 4, self.debug): - if self.debug: print ("runTauID: not is_above_cmssw_version(9, 4, 4). Will update the list of available in DB samples to access 2017v1") - self.loadMVA_WPs_run2_2017() + if self.debug: print ("runTauID: Will update the list of available in DB samples to access 2017v1") + self.loadMVA_WPs_run2_2017() _byIsolationOldDMMVArun2017v1raw = "rerunDiscriminationByIsolationOldDMMVArun2017v1raw"+self.postfix setattr(self.process,_byIsolationOldDMMVArun2017v1raw,patDiscriminationByIsolationMVArun2v1raw.clone( @@ -208,7 +389,6 @@ def runTauID(self): tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff50") tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff40") - if "2017v2" in self.toKeep: self.tauIdDiscrMVA_2017_version = "v2" self.tauIdDiscrMVA_trainings_run2_2017 = { @@ -226,9 +406,8 @@ def runTauID(self): } } - if not self.is_above_cmssw_version(9, 4, 5, self.debug): - if self.debug: print ("runTauID: not is_above_cmssw_version(9, 4, 5). Will update the list of available in DB samples to access 2017v2") - self.loadMVA_WPs_run2_2017() + if self.debug: print ("runTauID: Will update the list of available in DB samples to access 2017v2") + self.loadMVA_WPs_run2_2017() _byIsolationOldDMMVArun2017v2raw = "rerunDiscriminationByIsolationOldDMMVArun2017v2raw"+self.postfix setattr(self.process,_byIsolationOldDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone( @@ -299,9 +478,8 @@ def runTauID(self): } } - if not self.is_above_cmssw_version(9, 4, 5, self.debug): - if self.debug: print ("runTauID: not is_above_cmssw_version(9, 4, 5). Will update the list of available in DB samples to access newDM2017v2") - self.loadMVA_WPs_run2_2017() + if self.debug: print ("runTauID: Will update the list of available in DB samples to access newDM2017v2") + self.loadMVA_WPs_run2_2017() _byIsolationNewDMMVArun2017v2raw = "rerunDiscriminationByIsolationNewDMMVArun2017v2raw"+self.postfix setattr(self.process,_byIsolationNewDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone( @@ -372,9 +550,8 @@ def runTauID(self): } } - if not self.is_above_cmssw_version(9, 4, 5, self.debug): - if self.debug: print ("runTauID: not is_above_cmssw_version(9, 4, 5). Will update the list of available in DB samples to access dR0p32017v2") - self.loadMVA_WPs_run2_2017() + if self.debug: print ("runTauID: Will update the list of available in DB samples to access dR0p32017v2") + self.loadMVA_WPs_run2_2017() _byIsolationOldDMdR0p3MVArun2017v2raw = "rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw"+self.postfix setattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone( @@ -494,6 +671,23 @@ def runTauID(self): ) )) + self.tauIdDiscrMVA_2017_version = "v1" + self.tauIdDiscrMVA_trainings_run2_2017 = { + 'tauIdMVAIsoDBoldDMwLT2016' : "tauIdMVAIsoDBoldDMwLT2016", + } + self.tauIdDiscrMVA_WPs_run2_2017 = { + 'tauIdMVAIsoDBoldDMwLT2016' : { + 'Eff90' : "DBoldDMwLT2016Eff90", + 'Eff80' : "DBoldDMwLT2016Eff80", + 'Eff70' : "DBoldDMwLT2016Eff70", + 'Eff60' : "DBoldDMwLT2016Eff60", + 'Eff50' : "DBoldDMwLT2016Eff50", + 'Eff40' : "DBoldDMwLT2016Eff40" + } + } + if self.debug: print ("runTauID: Will update the list of available in DB samples to access 2016v1") + self.loadMVA_WPs_run2_2017() + _rerunIsolationOldDMMVArun2016v1Task = cms.Task( getattr(self.process,_byIsolationOldDMMVArun2016v1raw), getattr(self.process,_byIsolationOldDMMVArun2016v1) @@ -531,7 +725,7 @@ def runTauID(self): mapping = cms.VPSet( cms.PSet( category = cms.uint32(0), - cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"), + cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"), variable = cms.string("pt"), ) ), @@ -545,6 +739,23 @@ def runTauID(self): ) )) + self.tauIdDiscrMVA_2017_version = "v1" + self.tauIdDiscrMVA_trainings_run2_2017 = { + 'tauIdMVAIsoDBnewDMwLT2016' : "tauIdMVAIsoDBnewDMwLT2016", + } + self.tauIdDiscrMVA_WPs_run2_2017 = { + 'tauIdMVAIsoDBnewDMwLT2016' : { + 'Eff90' : "DBnewDMwLT2016Eff90", + 'Eff80' : "DBnewDMwLT2016Eff80", + 'Eff70' : "DBnewDMwLT2016Eff70", + 'Eff60' : "DBnewDMwLT2016Eff60", + 'Eff50' : "DBnewDMwLT2016Eff50", + 'Eff40' : "DBnewDMwLT2016Eff40" + } + } + if self.debug: print ("runTauID: Will update the list of available in DB samples to access newDM2016v1") + self.loadMVA_WPs_run2_2017() + _rerunIsolationNewDMMVArun2016v1Task = cms.Task( getattr(self.process,_byIsolationNewDMMVArun2016v1raw), getattr(self.process,_byIsolationNewDMMVArun2016v1) @@ -758,7 +969,8 @@ def runTauID(self): _rerunMvaIsolationSequence += _deepTauProducer if "againstEle2018" in self.toKeep: - antiElectronDiscrMVA6_version = "MVA6v3_noeveto" + self.antiElectronDiscrMVA6_version = "v3_noeveto" + self.antiElectronDiscrMVA6_WPs = [ "eff98", "eff90", "eff80", "eff70", "eff60" ] ### Define new anti-e discriminants ## Raw from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6 @@ -768,14 +980,14 @@ def runTauID(self): Prediscriminants = noPrediscriminants, #already selected for MiniAOD srcElectrons = cms.InputTag('slimmedElectrons'), vetoEcalCracks = cms.bool(False), #keep taus in EB-EE cracks - mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL', - mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC', - mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL', - mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC', - mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL', - mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC', - mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL', - mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC' + mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL', + mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC', + mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL', + mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC', + mvaName_wGwGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL', + mvaName_wGwGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC', + mvaName_woGwGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL', + mvaName_woGwGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC' )) ## WPs from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer @@ -787,42 +999,42 @@ def runTauID(self): mapping = cms.VPSet( cms.PSet( category = cms.uint32(0), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL'), variable = cms.string('pt') ), cms.PSet( category = cms.uint32(2), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL'), variable = cms.string('pt') ), cms.PSet( category = cms.uint32(5), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL'), variable = cms.string('pt') ), cms.PSet( category = cms.uint32(7), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL'), variable = cms.string('pt') ), cms.PSet( category = cms.uint32(8), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC'), variable = cms.string('pt') ), cms.PSet( category = cms.uint32(10), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC'), variable = cms.string('pt') ), cms.PSet( category = cms.uint32(13), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'), variable = cms.string('pt') ), cms.PSet( category = cms.uint32(15), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC'), + cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC'), variable = cms.string('pt') ) ), @@ -834,6 +1046,10 @@ def runTauID(self): "_WPeff60" ) )) + + if self.debug: print ("runTauID: Will update the list of available in DB samples to access againstEle 2018") + self.load_againstElectronMVA6() + ### Put all new anti-e discrminats to a sequence _patTauDiscriminationByElectronRejectionMVA62018Task = cms.Task( getattr(self.process,_byElectronRejectionMVA62018Raw), @@ -857,6 +1073,105 @@ def runTauID(self): ) tauIDSources =_tauIDSourcesWithAgainistEle.clone() + if "againstEle" in self.toKeep: + ### Define new anti-e discriminants + ## Raw + from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6 + _byElectronRejectionMVA6Raw = "patTauDiscriminationByElectronRejectionMVA6Raw"+self.postfix + setattr(self.process,_byElectronRejectionMVA6Raw,patTauDiscriminationAgainstElectronMVA6.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, #already selected for MiniAOD + srcElectrons = cms.InputTag('slimmedElectrons'), + vetoEcalCracks = cms.bool(False), #keep taus in EB-EE cracks + mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_BL', + mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_EC', + mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_BL', + mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_EC', + mvaName_wGwGSF_BL = 'RecoTauTag_antiElectronMVA_wGwGSF_BL', + mvaName_wGwGSF_EC = 'RecoTauTag_antiElectronMVA_wGwGSF_EC', + mvaName_woGwGSF_BL = 'RecoTauTag_antiElectronMVA_woGwGSF_BL', + mvaName_woGwGSF_EC = 'RecoTauTag_antiElectronMVA_woGwGSF_EC' + )) + ## WPs + from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer + _byElectronRejectionMVA6 = "patTauDiscriminationByElectronRejectionMVA6"+self.postfix + setattr(self.process,"patTauDiscriminationByElectronRejectionMVA6"+self.postfix,patTauDiscriminantCutMultiplexer.clone( + PATTauProducer = self.originalTauName, + Prediscriminants = noPrediscriminants, + toMultiplex = _byElectronRejectionMVA6Raw, + mapping = cms.VPSet( + cms.PSet( + category = cms.uint32(0), + cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_BL'), + variable = cms.string('pt') + ), + cms.PSet( + category = cms.uint32(2), + cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_BL'), + variable = cms.string('pt') + ), + cms.PSet( + category = cms.uint32(5), + cut = cms.string('RecoTauTag_antiElectronMVA_woGwGSF_BL'), + variable = cms.string('pt') + ), + cms.PSet( + category = cms.uint32(7), + cut = cms.string('RecoTauTag_antiElectronMVA_wGwGSF_BL'), + variable = cms.string('pt') + ), + cms.PSet( + category = cms.uint32(8), + cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_EC'), + variable = cms.string('pt') + ), + cms.PSet( + category = cms.uint32(10), + cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_EC'), + variable = cms.string('pt') + ), + cms.PSet( + category = cms.uint32(13), + cut = cms.string('RecoTauTag_antiElectronMVA_woGwGSF_EC'), + variable = cms.string('pt') + ), + cms.PSet( + category = cms.uint32(15), + cut = cms.string('RecoTauTag_antiElectronMVA_wGwGSF_EC'), + variable = cms.string('pt') + ) + ), + workingPoints = cms.vstring( + "_VLoose", + "_Loose", + "_Medium", + "_Tight", + "_VTight" + ) + )) + ### Put all new anti-e discrminats to a sequence + _patTauDiscriminationByElectronRejectionMVA6Task = cms.Task( + getattr(self.process,_byElectronRejectionMVA6Raw), + getattr(self.process,_byElectronRejectionMVA6) + ) + _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Task) + _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Task) + + _againstElectronTauIDSources = cms.PSet( + againstElectronMVA6Raw = self.tauIDMVAinputs(_byElectronRejectionMVA6, "raw"), + againstElectronMVA6category = self.tauIDMVAinputs(_byElectronRejectionMVA6, "category"), + againstElectronVLooseMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_VLoose"), + againstElectronLooseMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_Loose"), + againstElectronMediumMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_Medium"), + againstElectronTightMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_Tight"), + againstElectronVTightMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_VTight") + ) + _tauIDSourcesWithAgainistEle = cms.PSet( + tauIDSources.clone(), + _againstElectronTauIDSources + ) + tauIDSources =_tauIDSourcesWithAgainistEle.clone() + if "newDMPhase2v1" in self.toKeep: if self.debug: print ("Adding newDMPhase2v1 ID") def tauIDMVAinputs(module, wp): diff --git a/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py b/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py index e5a6e78043c1a..5075338056c80 100644 --- a/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py @@ -48,13 +48,13 @@ # Add new TauIDs import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig -toKeep = [ "2017v2", "dR0p32017v2", "newDM2017v2", +toKeep = [ "mvaIso", "mvaIsoDR0p3", "mvaIsoNewDM", # "deepTau2017v1", "deepTau2017v2p1", "deepTau2018v2p5", # "DPFTau_2016_v0", # "DPFTau_2016_v1", - "againstEle2018", + "againstEle", ] if phase2: toKeep = [ "newDMPhase2v1",