diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index d142fb3c9594a..04f5dfe3a1f27 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -616,6 +616,7 @@ NoPlot('genPartIdx'), Plot1D('idAntiEle', 'idAntiEle', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6: bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'), Plot1D('idAntiEle2018', 'idAntiEle2018', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6 (2018): bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'), + Plot1D('idAntiEleDeadECal', 'idAntiEleDeadECal', 2, -0.5, 1.5, "tauID('againstElectronDeadECAL')"), Plot1D('idAntiMu', 'idAntiMu', 4, -0.5, 3.5, 'Anti-muon discriminator V3: : bitmask 1 = Loose, 2 = Tight'), Plot1D('idDecayMode', 'idDecayMode', 2, -0.5, 1.5, "tauID('decayModeFinding')"), Plot1D('idDecayModeNewDMs', 'idDecayModeNewDMs', 2, -0.5, 1.5, "tauID('decayModeFindingNewDMs')"), diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index c44a4612c121a..edcf7ecc92439 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -55,7 +55,7 @@ def _tauId8WPMask(pattern,doc): variables = cms.PSet() # PSet defined below in era dependent way ) _tauVarsBase = cms.PSet(P4Vars, - charge = Var("charge", int, doc="electric charge"), + charge = Var("charge", int, doc="electric charge"), jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"), decayMode = Var("decayMode()",int), idDecayMode = Var("tauID('decayModeFinding')", bool), @@ -76,11 +76,8 @@ def _tauId8WPMask(pattern,doc): puCorr = Var( "tauID('puCorrPtSum')", float, doc = "pileup correction", precision=10), photonsOutsideSignalCone = Var( "tauID('photonPtSumOutsideSignalCone')", float, doc = "sum of photons outside signal cone", precision=10), - rawAntiEle = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator", precision=10), - rawAntiEleCat = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category"), - idAntiMu = _tauId2WPMask("againstMuon%s3", doc= "Anti-muon discriminator V3: "), - idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6"), + idAntiEleDeadECal = Var("tauID('againstElectronDeadECALForNano')", bool, doc = "Anti-electron dead-ECal discriminator"), # isoCI3hit = Var( "tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits")" doc="byCombinedIsolationDeltaBetaCorrRaw3Hits raw output discriminator"), # photonOutsideSigCone = Var( "tauID("photonPtSumOutsideSignalCone")" doc="photonPtSumOutsideSignalCone raw output discriminator"), @@ -111,10 +108,18 @@ def _tauId8WPMask(pattern,doc): idMVAoldDM2017v2 = _tauId7WPMask( "by%sIsolationMVArun2v1DBoldDMwLT2017v2", doc="IsolationMVArun2v1DBoldDMwLT ID working point (2017v2)"), idMVAoldDMdR032017v2 = _tauId7WPMask( "by%sIsolationMVArun2v1DBdR03oldDMwLT2017v2", doc="IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2017v2)") ) -_mvaAntiEVars2018 = cms.PSet( +_mvaAntiEVars = cms.PSet( rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw2018')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10), rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category2018')", int, doc="Anti-electron MVA discriminator V6 category (2018)"), idAntiEle2018 = _tauId5WPMask("againstElectron%sMVA62018", doc= "Anti-electron MVA discriminator V6 (2018)"), + rawAntiEle = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10), + rawAntiEleCat = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2015)"), + idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6 (2015)"), +) +_mvaAntiEVars2015 = cms.PSet( + rawAntiEle = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10), + rawAntiEleCat = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2015)"), + idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6 (2015)") ) _deepTauVars2017v2 = cms.PSet( rawDeepTau2017v2VSe = Var("tauID('byDeepTau2017v2VSeraw')", float, doc="byDeepTau2017v2VSe raw output discriminator (deepTau2017v2)", precision=10), @@ -135,7 +140,7 @@ def _tauId8WPMask(pattern,doc): _variablesMiniV2 = cms.PSet( _tauVarsBase, - _mvaAntiEVars2018, + _mvaAntiEVars, _mvaIsoVars2015Reduced, _mvaIsoVars2017v1, _mvaIsoVars2017v2, @@ -148,6 +153,7 @@ def _tauId8WPMask(pattern,doc): _variablesMiniV1.idMVAoldDM2017v1 = _tauId7WPMask( "by%sIsolationMVArun2v1DBoldDMwLT2017v1", doc="IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)") _variables80X = cms.PSet( _tauVarsBase, + _mvaAntiEVars2015, _mvaIsoVars2015 ) @@ -160,7 +166,19 @@ def _tauId8WPMask(pattern,doc): run2_miniAOD_80XLegacy.toModify(tauTable, variables = _variables80X ) +run2_miniAOD_80XLegacy.toModify(tauTable.variables, + idAntiEleDeadECal = None +) +run2_miniAOD_devel.toModify(tauTable.variables, + idAntiEleDeadECal = Var("tauID('againstElectronDeadECAL')", bool, doc = "Anti-electron dead-ECal discriminator"), + rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10), + rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2018)"), + idAntiEle2018 = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6 (2018)"), + rawAntiEle = Var("tauID('againstElectronMVA6Raw2015')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10), + rawAntiEleCat = Var("tauID('againstElectronMVA6category2015')", int, doc="Anti-electron MVA discriminator V6 category (2015"), + idAntiEle = _tauId5WPMask("againstElectron%sMVA62015", doc= "Anti-electron MVA discriminator V6 (2015)") +) tauGenJets.GenParticles = cms.InputTag("prunedGenParticles") tauGenJets.includeNeutrinos = cms.bool(False) diff --git a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py index 99a9c0dbfbeeb..de9eef5e4fb23 100644 --- a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py @@ -4,6 +4,7 @@ # Used only in some eras from RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi import * from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import * +from Configuration.Eras.Modifier_run2_miniAOD_devel_cff import run2_miniAOD_devel ### MVAIso 2017v2 ## DBoldDM @@ -286,7 +287,7 @@ ) -### Define new anit-e discriminants +### Define new anit-e discriminants (2018) antiElectronDiscrMVA6_version = "MVA6v3_noeveto" ## Raw from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6 @@ -355,187 +356,64 @@ ) ) # Loose -patTauDiscriminationByLooseElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone( - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff90'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(2), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff90'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(5), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff90'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(7), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff90'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(8), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff90'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(10), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff90'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(13), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff90'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(15), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff90'), - variable = cms.string('pt') - ) - ) -) +patTauDiscriminationByLooseElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone() +for m in patTauDiscriminationByLooseElectronRejectionMVA62018.mapping: + m.cut = m.cut.value().replace("WPeff98", "WPeff90") # Medium -patTauDiscriminationByMediumElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone( - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff80'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(2), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff80'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(5), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff80'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(7), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff80'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(8), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff80'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(10), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff80'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(13), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff80'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(15), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff80'), - variable = cms.string('pt') - ) - ) -) +patTauDiscriminationByMediumElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone() +for m in patTauDiscriminationByMediumElectronRejectionMVA62018.mapping: + m.cut = m.cut.value().replace("WPeff98", "WPeff80") # Tight -patTauDiscriminationByTightElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone( - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff70'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(2), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff70'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(5), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff70'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(7), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff70'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(8), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff70'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(10), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff70'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(13), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff70'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(15), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff70'), - variable = cms.string('pt') - ) - ) -) +patTauDiscriminationByTightElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone() +for m in patTauDiscriminationByTightElectronRejectionMVA62018.mapping: + m.cut = m.cut.value().replace("WPeff98", "WPeff70") # VTight -patTauDiscriminationByVTightElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone( - mapping = cms.VPSet( - cms.PSet( - category = cms.uint32(0), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff60'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(2), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff60'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(5), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff60'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(7), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff60'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(8), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff60'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(10), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff60'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(13), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff60'), - variable = cms.string('pt') - ), - cms.PSet( - category = cms.uint32(15), - cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff60'), - variable = cms.string('pt') - ) - ) +patTauDiscriminationByVTightElectronRejectionMVA62018 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone() +for m in patTauDiscriminationByVTightElectronRejectionMVA62018.mapping: + m.cut = m.cut.value().replace("WPeff98", "WPeff60") +### Define v1 anit-e discriminants (2015) +antiElectronDiscrMVA6v1_version = "MVA6v1" +## Raw +patTauDiscriminationByElectronRejectionMVA62015Raw = patTauDiscriminationAgainstElectronMVA6.clone( + Prediscriminants = noPrediscriminants, #already selected for MiniAOD + 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 +# VLoose +patTauDiscriminationByVLooseElectronRejectionMVA62015 = patTauDiscriminationByVLooseElectronRejectionMVA62018.clone( + PATTauProducer = patTauDiscriminationByElectronRejectionMVA62015Raw.PATTauProducer, + Prediscriminants = patTauDiscriminationByElectronRejectionMVA62015Raw.Prediscriminants, + toMultiplex = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62015Raw"), + key = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62015Raw","category") +) +for m in patTauDiscriminationByVLooseElectronRejectionMVA62015.mapping: + m.cut = m.cut.value().replace(antiElectronDiscrMVA6_version, antiElectronDiscrMVA6v1_version).replace("WPeff98", "WPEff99") +# Loose +patTauDiscriminationByLooseElectronRejectionMVA62015 = patTauDiscriminationByVLooseElectronRejectionMVA62015.clone() +for m in patTauDiscriminationByLooseElectronRejectionMVA62015.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff96") +# Medium +patTauDiscriminationByMediumElectronRejectionMVA62015 = patTauDiscriminationByVLooseElectronRejectionMVA62015.clone() +for m in patTauDiscriminationByMediumElectronRejectionMVA62015.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff91") +# Tight +patTauDiscriminationByTightElectronRejectionMVA62015 = patTauDiscriminationByVLooseElectronRejectionMVA62015.clone() +for m in patTauDiscriminationByTightElectronRejectionMVA62015.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff85") +# VTight +patTauDiscriminationByVTightElectronRejectionMVA62015 = patTauDiscriminationByVLooseElectronRejectionMVA62015.clone() +for m in patTauDiscriminationByVTightElectronRejectionMVA62015.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff79") ### Put all anti-e tau-IDs into a sequence -patTauDiscriminationByElectronRejectionSeq = cms.Sequence( +_patTauDiscriminationByElectronRejection2018Seq = cms.Sequence( patTauDiscriminationByElectronRejectionMVA62018Raw +patTauDiscriminationByVLooseElectronRejectionMVA62018 +patTauDiscriminationByLooseElectronRejectionMVA62018 @@ -543,6 +421,18 @@ +patTauDiscriminationByTightElectronRejectionMVA62018 +patTauDiscriminationByVTightElectronRejectionMVA62018 ) +_patTauDiscriminationByElectronRejection2015Seq = cms.Sequence( + patTauDiscriminationByElectronRejectionMVA62015Raw + +patTauDiscriminationByVLooseElectronRejectionMVA62015 + +patTauDiscriminationByLooseElectronRejectionMVA62015 + +patTauDiscriminationByMediumElectronRejectionMVA62015 + +patTauDiscriminationByTightElectronRejectionMVA62015 + +patTauDiscriminationByVTightElectronRejectionMVA62015 +) +patTauDiscriminationByElectronRejectionSeq = _patTauDiscriminationByElectronRejection2018Seq.copy() +run2_miniAOD_devel.toReplaceWith(patTauDiscriminationByElectronRejectionSeq, + _patTauDiscriminationByElectronRejection2015Seq) + ### put all new MVA tau-Id stuff to one Sequence _patTauMVAIDsSeq2017v2 = cms.Sequence( @@ -621,14 +511,14 @@ _tauIDSources2017v2.clone(), _tauIDSources2015 ) -slimmedTausUpdated.tauIDSources=_tauIDSourcesWith2015 +slimmedTausUpdated.tauIDSources = _tauIDSourcesWith2015 for era in [run2_nanoAOD_94XMiniAODv1,]: era.toModify(slimmedTausUpdated, tauIDSources = _tauIDSourcesWith2017v1 ) -_antiETauIDSources = cms.PSet( +_antiETauIDSources2018 = cms.PSet( againstElectronMVA6Raw2018 = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"), againstElectronMVA6category2018 = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw","category"), againstElectronVLooseMVA62018 = cms.InputTag("patTauDiscriminationByVLooseElectronRejectionMVA62018"), @@ -637,12 +527,42 @@ againstElectronTightMVA62018 = cms.InputTag("patTauDiscriminationByTightElectronRejectionMVA62018"), againstElectronVTightMVA62018 = cms.InputTag("patTauDiscriminationByVTightElectronRejectionMVA62018") ) -_tauIDSourcesWithAntiE = cms.PSet( +_tauIDSourcesWithAntiE2018 = cms.PSet( slimmedTausUpdated.tauIDSources.clone(), - _antiETauIDSources + _antiETauIDSources2018 ) -slimmedTausUpdated.tauIDSources=_tauIDSourcesWithAntiE +_antiETauIDSources2015 = cms.PSet( + againstElectronMVA6Raw2015 = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62015Raw"), + againstElectronMVA6category2015 = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62015Raw","category"), + againstElectronVLooseMVA62015 = cms.InputTag("patTauDiscriminationByVLooseElectronRejectionMVA62015"), + againstElectronLooseMVA62015 = cms.InputTag("patTauDiscriminationByLooseElectronRejectionMVA62015"), + againstElectronMediumMVA62015 = cms.InputTag("patTauDiscriminationByMediumElectronRejectionMVA62015"), + againstElectronTightMVA62015 = cms.InputTag("patTauDiscriminationByTightElectronRejectionMVA62015"), + againstElectronVTightMVA62015 = cms.InputTag("patTauDiscriminationByVTightElectronRejectionMVA62015") +) +_tauIDSourcesWithAntiE2015 = cms.PSet( + slimmedTausUpdated.tauIDSources.clone(), + _antiETauIDSources2015 +) +slimmedTausUpdated.tauIDSources = _tauIDSourcesWithAntiE2018 +run2_miniAOD_devel.toModify(slimmedTausUpdated, + tauIDSources = _tauIDSourcesWithAntiE2015) +## anti-electron in dead-ECal regions +from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronDeadECAL_cfi import patTauDiscriminationAgainstElectronDeadECAL +patTauDiscriminationAgainstElectronDeadECALForNano = patTauDiscriminationAgainstElectronDeadECAL.clone( + PATTauProducer = 'slimmedTaus', + Prediscriminants = noPrediscriminants +) +_patTauMVAIDsSeqWithAntiEdeadECal = patTauMVAIDsSeq.copy() +_patTauMVAIDsSeqWithAntiEdeadECal += patTauDiscriminationAgainstElectronDeadECALForNano +_tauIDSourcesWithAntiEdeadECal = cms.PSet( + slimmedTausUpdated.tauIDSources.clone(), + againstElectronDeadECALForNano = cms.InputTag("patTauDiscriminationAgainstElectronDeadECALForNano") +) +(~run2_miniAOD_devel).toReplaceWith(patTauMVAIDsSeq,_patTauMVAIDsSeqWithAntiEdeadECal) +(~run2_miniAOD_devel).toModify(slimmedTausUpdated, + tauIDSources = _tauIDSourcesWithAntiEdeadECal) patTauMVAIDsSeq += slimmedTausUpdated diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 654355faee9c4..9aff6e21f381c 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -345,7 +345,7 @@ def miniAOD_customizeCommon(process): addBoostedTaus(process) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") process.load("RecoTauTag.Configuration.HPSPFTaus_cff") - #-- Adding customization for 94X 2017 legacy reMniAOD + #-- Adding customization for 94X 2017 legacy reMiniAOD from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy() _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask, @@ -355,6 +355,16 @@ def miniAOD_customizeCommon(process): run2_miniAOD_94XFall17.toReplaceWith( process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID ) + #-- Adding customization for UL reMiniAOD: + # running retrained anti-e MVA6 discriminants as setup in the HPS PFTau + # master configuration for this era. + _makePatTausTaskWithMVA6ElectronRejection = process.makePatTausTask.copy() + _makePatTausTaskWithMVA6ElectronRejection.add( + process.hpsPFTauDiscriminationByMVA6ElectronRejectionTask + ) + run2_miniAOD_UL.toReplaceWith( + process.makePatTausTask, _makePatTausTaskWithMVA6ElectronRejection + ) #-- Adding DeepTauID # deepTau v2 _updatedTauName = 'slimmedTausDeepIDsv2' diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index c6a0f4a6d5f31..04a96fa1a1ef7 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -324,6 +324,18 @@ mvaName_woGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_EC"), mvaName_wGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_EC") ) +run2_miniAOD_UL.toModify( + hpsPFTauDiscriminationByMVA6rawElectronRejection, + vetoEcalCracks = False, + mvaName_NoEleMatch_woGwoGSF_BL = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_BL", + mvaName_NoEleMatch_wGwoGSF_BL = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_BL", + mvaName_woGwGSF_BL = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_BL", + mvaName_wGwGSF_BL = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_BL", + mvaName_NoEleMatch_woGwoGSF_EC = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_EC", + mvaName_NoEleMatch_wGwoGSF_EC = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_EC", + mvaName_woGwGSF_EC = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_EC", + mvaName_wGwGSF_EC = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_EC" +) ## ByMVA6VLooseElectronRejection hpsPFTauDiscriminationByMVA6VLooseElectronRejection = recoTauDiscriminantCutMultiplexer.clone( PFTauProducer = cms.InputTag('hpsPFTauProducer'), @@ -374,46 +386,55 @@ ) ) ) +def _modMapping(mapping, wpIn, wpOut, verIn="v1", verOut="v3_noeveto"): + for m in mapping: + m.cut = m.cut.value().replace(verIn, verOut) + m.cut = m.cut.value().replace(wpIn, wpOut) +run2_miniAOD_UL.toModify( + hpsPFTauDiscriminationByMVA6VLooseElectronRejection.mapping, + func = lambda mapping: _modMapping(mapping, "WPEff99", "WPeff98") +) ## ByMVA6LooseElectronRejection hpsPFTauDiscriminationByMVA6LooseElectronRejection = copy.deepcopy(hpsPFTauDiscriminationByMVA6VLooseElectronRejection) -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[0].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_BL_WPEff96") -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[1].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_BL_WPEff96") -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[2].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_BL_WPEff96") -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[3].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_BL_WPEff96") -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[4].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_EC_WPEff96") -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[5].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_EC_WPEff96") -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[6].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_EC_WPEff96") -hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping[7].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_EC_WPEff96") +for m in hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff96") +run2_miniAOD_UL.toModify( + hpsPFTauDiscriminationByMVA6LooseElectronRejection.mapping, + func = lambda mapping: _modMapping(mapping, "WPeff98", "WPeff90") +) ## ByMVA6VMediumElectronRejection hpsPFTauDiscriminationByMVA6MediumElectronRejection = copy.deepcopy(hpsPFTauDiscriminationByMVA6VLooseElectronRejection) -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[0].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_BL_WPEff91") -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[1].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_BL_WPEff91") -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[2].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_BL_WPEff91") -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[3].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_BL_WPEff91") -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[4].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_EC_WPEff91") -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[5].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_EC_WPEff91") -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[6].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_EC_WPEff91") -hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping[7].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_EC_WPEff91") +for m in hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff91") +run2_miniAOD_UL.toModify( + hpsPFTauDiscriminationByMVA6MediumElectronRejection.mapping, + func = lambda mapping: _modMapping(mapping, "WPeff98", "WPeff80") +) ## ByMVA6TightElectronRejection hpsPFTauDiscriminationByMVA6TightElectronRejection = copy.deepcopy(hpsPFTauDiscriminationByMVA6VLooseElectronRejection) -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[0].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_BL_WPEff85") -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[1].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_BL_WPEff85") -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[2].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_BL_WPEff85") -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[3].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_BL_WPEff85") -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[4].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_EC_WPEff85") -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[5].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_EC_WPEff85") -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[6].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_EC_WPEff85") -hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping[7].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_EC_WPEff85") +for m in hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff85") +run2_miniAOD_UL.toModify( + hpsPFTauDiscriminationByMVA6TightElectronRejection.mapping, + func = lambda mapping: _modMapping(mapping, "WPeff98", "WPeff70") +) ## ByMVA6VTightElectronRejection hpsPFTauDiscriminationByMVA6VTightElectronRejection = copy.deepcopy(hpsPFTauDiscriminationByMVA6VLooseElectronRejection) -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[0].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_BL_WPEff79") -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[1].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_BL_WPEff79") -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[2].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_BL_WPEff79") -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[3].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_BL_WPEff79") -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[4].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_woGwoGSF_EC_WPEff79") -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[5].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_NoEleMatch_wGwoGSF_EC_WPEff79") -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[6].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_woGwGSF_EC_WPEff79") -hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping[7].cut = cms.string("RecoTauTag_antiElectronMVA6v1_gbr_wGwGSF_EC_WPEff79") +for m in hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping: + m.cut = m.cut.value().replace("WPEff99", "WPEff79") +run2_miniAOD_UL.toModify( + hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping, + func = lambda mapping: _modMapping(mapping, "WPeff98", "WPeff60") +) + +hpsPFTauDiscriminationByMVA6ElectronRejectionTask = cms.Task( + hpsPFTauDiscriminationByMVA6rawElectronRejection, + hpsPFTauDiscriminationByMVA6VLooseElectronRejection, + hpsPFTauDiscriminationByMVA6LooseElectronRejection, + hpsPFTauDiscriminationByMVA6MediumElectronRejection, + hpsPFTauDiscriminationByMVA6TightElectronRejection, + hpsPFTauDiscriminationByMVA6VTightElectronRejection +) # Define the HPS selection discriminator used in cleaning hpsSelectionDiscriminator.PFTauProducer = cms.InputTag("combinatoricRecoTaus") @@ -901,12 +922,7 @@ hpsPFTauDiscriminationByLooseElectronRejection, hpsPFTauDiscriminationByMediumElectronRejection, hpsPFTauDiscriminationByTightElectronRejection, - hpsPFTauDiscriminationByMVA6rawElectronRejection, - hpsPFTauDiscriminationByMVA6VLooseElectronRejection, - hpsPFTauDiscriminationByMVA6LooseElectronRejection, - hpsPFTauDiscriminationByMVA6MediumElectronRejection, - hpsPFTauDiscriminationByMVA6TightElectronRejection, - hpsPFTauDiscriminationByMVA6VTightElectronRejection, + hpsPFTauDiscriminationByMVA6ElectronRejectionTask, hpsPFTauDiscriminationByDeadECALElectronRejection, hpsPFTauDiscriminationByLooseMuonRejection3, hpsPFTauDiscriminationByTightMuonRejection3,