From ad7fa6a19fb38dba2901c1a84044f6b59a35f6ad Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 28 May 2020 16:22:35 +0200 Subject: [PATCH 1/3] Add tauID againist electrons in dead ECal regions --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 1 + PhysicsTools/NanoAOD/python/taus_cff.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 33a6b8ea6633c..80c28b9adc731 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -591,6 +591,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 f2184ca56afdd..314a39b5f5c4a 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), @@ -77,6 +77,7 @@ def _tauId8WPMask(pattern,doc): photonsOutsideSignalCone = Var( "tauID('photonPtSumOutsideSignalCone')", float, doc = "sum of photons outside signal cone", precision=10), idAntiMu = _tauId2WPMask("againstMuon%s3", doc= "Anti-muon discriminator V3: "), + idAntiEleDeadECal = Var("tauID('againstElectronDeadECAL')", 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"), @@ -166,6 +167,19 @@ def _tauId8WPMask(pattern,doc): idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6 (2015)") ) + +from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff import run2_nanoAOD_92X +from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2 +from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016 +from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 +from Configuration.Eras.Modifier_run2_nanoAOD_106Xv1_cff import run2_nanoAOD_106Xv1 +for era in [run2_miniAOD_80XLegacy, run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, \ + run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, \ + run2_nanoAOD_106Xv1]: + era.toModify(tauTable.variables, + idAntiEleDeadECal = None + ) + tauGenJets.GenParticles = cms.InputTag("prunedGenParticles") tauGenJets.includeNeutrinos = cms.bool(False) From d4755887b6380e76edb2f9bef930753fda51bb67 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Mon, 10 Aug 2020 12:03:06 +0200 Subject: [PATCH 2/3] Run anti-ele-in-deadECal to add it to nano with legacy nano eras --- PhysicsTools/NanoAOD/python/taus_cff.py | 10 +------ .../NanoAOD/python/taus_updatedMVAIds_cff.py | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index 314a39b5f5c4a..c7c125a349cf3 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -15,12 +15,10 @@ cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT2015') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2') || tauID('byVVVLooseDeepTau2017v2p1VSjet'))") ) -from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff import run2_nanoAOD_94XMiniAODv1 for era in [run2_nanoAOD_94XMiniAODv1,]: era.toModify(finalTaus, cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v1') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2') || tauID('byVVVLooseDeepTau2017v2p1VSjet'))") ) -from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy run2_miniAOD_80XLegacy.toModify(finalTaus, src = cms.InputTag("slimmedTaus"), cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))") @@ -167,17 +165,11 @@ def _tauId8WPMask(pattern,doc): idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6 (2015)") ) - -from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff import run2_nanoAOD_92X -from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2 -from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016 -from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 -from Configuration.Eras.Modifier_run2_nanoAOD_106Xv1_cff import run2_nanoAOD_106Xv1 for era in [run2_miniAOD_80XLegacy, run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, \ run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, \ run2_nanoAOD_106Xv1]: era.toModify(tauTable.variables, - idAntiEleDeadECal = None + idAntiEleDeadECal = Var("tauID('againstElectronDeadECALForNano')", bool, doc = "Anti-electron dead-ECal discriminator"), ) tauGenJets.GenParticles = cms.InputTag("prunedGenParticles") diff --git a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py index 5dbc2b104a6de..8b39eacd14de7 100644 --- a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py @@ -4,8 +4,14 @@ # Used only in some eras from RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi import * from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import * +from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy +from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff import run2_nanoAOD_92X from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff import run2_nanoAOD_94XMiniAODv1 +from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2 +from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016 +from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 +from Configuration.Eras.Modifier_run2_nanoAOD_106Xv1_cff import run2_nanoAOD_106Xv1 ### MVAIso 2017v2 ## DBoldDM @@ -169,7 +175,6 @@ antiElectronDiscrMVA6_version = "MVA" ## Raw from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6 -from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone( PATTauProducer = 'slimmedTaus', Prediscriminants = noPrediscriminants, #already selected for MiniAOD @@ -411,6 +416,29 @@ def tauIDMVAinputs(module, wp): tauIDSources = _tauIDSourcesWithAntiE2018 ) +## 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.PSet( + inputTag = cms.InputTag("patTauDiscriminationAgainstElectronDeadECALForNano"), + workingPointIndex = cms.int32(-99) + ) +) +for era in [run2_miniAOD_80XLegacy,run2_nanoAOD_92X,run2_nanoAOD_94XMiniAODv1,\ + run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,\ + run2_nanoAOD_106Xv1]: + era.toReplaceWith(patTauMVAIDsSeq,_patTauMVAIDsSeqWithAntiEdeadECal) + era.toModify(slimmedTausUpdated, + tauIDSources = _tauIDSourcesWithAntiEdeadECal + ) + patTauMVAIDsSeq += slimmedTausUpdated From 5374da2e6e88bd23da5403d887e9fda80482f14c Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 11 Aug 2020 16:01:23 +0200 Subject: [PATCH 3/3] Remove anti-e deadECal discriminant tauTable for run2_nanoAOD_80XLegacy --- PhysicsTools/NanoAOD/python/taus_cff.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index c7c125a349cf3..3d81192572a88 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -165,9 +165,10 @@ def _tauId8WPMask(pattern,doc): idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6 (2015)") ) -for era in [run2_miniAOD_80XLegacy, run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, \ - run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, \ - run2_nanoAOD_106Xv1]: +run2_miniAOD_80XLegacy.toModify(tauTable.variables, + idAntiEleDeadECal = None) +for era in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \ + run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]: era.toModify(tauTable.variables, idAntiEleDeadECal = Var("tauID('againstElectronDeadECALForNano')", bool, doc = "Anti-electron dead-ECal discriminator"), )