From 601a5ff5e1e33d65879961d2c2140623329f52f1 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Wed, 5 Aug 2020 16:43:34 +0200 Subject: [PATCH 1/7] update anti-e MVA6 discriminators for AOD/miniAO with run2_miniAOD_devel modifier (UL re-miniAOD), and make configs more compact --- .../PatAlgos/python/slimming/miniAOD_tools.py | 5 +- .../Configuration/python/HPSPFTaus_cff.py | 109 ++++++++++++------ 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 654355faee9c4..8dca7cbbeba57 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -398,9 +398,12 @@ def miniAOD_customizeCommon(process): # note: default (AOD) behoviour of the tauID modified (leading track # extrapolation to ECAL enabled) in the HPS PFTau master # configuration for this era. + # and running retrained anti-e MVA6 discriminants as setup in the HPS + # PFTau master configuration _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy() _makePatTausTaskWithDeadECalVeto.add( - process.hpsPFTauDiscriminationByDeadECALElectronRejection + process.hpsPFTauDiscriminationByDeadECALElectronRejection, + process.hpsPFTauDiscriminationByMVA6ElectronRejectionTask ) run2_miniAOD_UL.toReplaceWith( process.makePatTausTask, _makePatTausTaskWithDeadECalVeto diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index c6a0f4a6d5f31..fedf60eba43fe 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -376,44 +376,82 @@ ) ## 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") ## 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") ## 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") ## 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_devel.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" +) +_vLooseElectronRejectionMappingMVA6v3 = copy.deepcopy(hpsPFTauDiscriminationByMVA6VLooseElectronRejection.mapping) +_vLooseElectronRejectionMappingMVA6v3[0].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_BL_WPeff98" +_vLooseElectronRejectionMappingMVA6v3[1].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_BL_WPeff98" +_vLooseElectronRejectionMappingMVA6v3[2].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_BL_WPeff98" +_vLooseElectronRejectionMappingMVA6v3[3].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_BL_WPeff98" +_vLooseElectronRejectionMappingMVA6v3[4].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_EC_WPeff98" +_vLooseElectronRejectionMappingMVA6v3[5].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_EC_WPeff98" +_vLooseElectronRejectionMappingMVA6v3[6].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_EC_WPeff98" +_vLooseElectronRejectionMappingMVA6v3[7].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_EC_WPeff98" +run2_miniAOD_devel.toModify( + hpsPFTauDiscriminationByMVA6VLooseElectronRejection, + mapping = _vLooseElectronRejectionMappingMVA6v3 +) +_looseElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) +for m in _looseElectronRejectionMappingMVA6v3: + m.cut = m.cut.value().replace("WPeff98", "WPeff90") +run2_miniAOD_devel.toModify( + hpsPFTauDiscriminationByMVA6LooseElectronRejection, + mapping = _looseElectronRejectionMappingMVA6v3 +) +_mediumElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) +for m in _mediumElectronRejectionMappingMVA6v3: + m.cut = m.cut.value().replace("WPeff98", "WPeff80") +run2_miniAOD_devel.toModify( + hpsPFTauDiscriminationByMVA6MediumElectronRejection, + mapping = _mediumElectronRejectionMappingMVA6v3 +) +_tightElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) +for m in _tightElectronRejectionMappingMVA6v3: + m.cut = m.cut.value().replace("WPeff98", "WPeff70") +run2_miniAOD_devel.toModify( + hpsPFTauDiscriminationByMVA6TightElectronRejection, + mapping = _tightElectronRejectionMappingMVA6v3 +) +_vTightElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) +for m in _vTightElectronRejectionMappingMVA6v3: + m.cut = m.cut.value().replace("WPeff98", "WPeff60") +run2_miniAOD_devel.toModify( + hpsPFTauDiscriminationByMVA6VTightElectronRejection, + mapping = _vTightElectronRejectionMappingMVA6v3 +) + +hpsPFTauDiscriminationByMVA6ElectronRejectionTask = cms.Task( + hpsPFTauDiscriminationByMVA6rawElectronRejection, + hpsPFTauDiscriminationByMVA6VLooseElectronRejection, + hpsPFTauDiscriminationByMVA6LooseElectronRejection, + hpsPFTauDiscriminationByMVA6MediumElectronRejection, + hpsPFTauDiscriminationByMVA6TightElectronRejection, + hpsPFTauDiscriminationByMVA6VTightElectronRejection +) # Define the HPS selection discriminator used in cleaning hpsSelectionDiscriminator.PFTauProducer = cms.InputTag("combinatoricRecoTaus") @@ -901,12 +939,7 @@ hpsPFTauDiscriminationByLooseElectronRejection, hpsPFTauDiscriminationByMediumElectronRejection, hpsPFTauDiscriminationByTightElectronRejection, - hpsPFTauDiscriminationByMVA6rawElectronRejection, - hpsPFTauDiscriminationByMVA6VLooseElectronRejection, - hpsPFTauDiscriminationByMVA6LooseElectronRejection, - hpsPFTauDiscriminationByMVA6MediumElectronRejection, - hpsPFTauDiscriminationByMVA6TightElectronRejection, - hpsPFTauDiscriminationByMVA6VTightElectronRejection, + hpsPFTauDiscriminationByMVA6ElectronRejectionTask, hpsPFTauDiscriminationByDeadECALElectronRejection, hpsPFTauDiscriminationByLooseMuonRejection3, hpsPFTauDiscriminationByTightMuonRejection3, From f6c56dae6bc36d70acb55afb452b9fec8e57e553 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 28 May 2020 16:22:35 +0200 Subject: [PATCH 2/7] 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 06b55a2b4f918..041cc957be1a7 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -550,6 +550,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..b356b42a40a83 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), @@ -81,6 +81,7 @@ def _tauId8WPMask(pattern,doc): idAntiMu = _tauId2WPMask("againstMuon%s3", doc= "Anti-muon discriminator V3: "), idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6"), + 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"), @@ -162,6 +163,19 @@ def _tauId8WPMask(pattern,doc): ) + +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 e14ec0e2d2dbcc5f1a0b5a4830cdb7f0d923956e Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 6 Aug 2020 12:08:11 +0200 Subject: [PATCH 3/7] Adjust to update of anti-e tauID to changes for UL re-MiniAOD --- PhysicsTools/NanoAOD/python/taus_cff.py | 41 +-- .../NanoAOD/python/taus_updatedMVAIds_cff.py | 269 ++++++------------ 2 files changed, 109 insertions(+), 201 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index b356b42a40a83..865a84b10ac8a 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -76,11 +76,7 @@ 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('againstElectronDeadECAL')", bool, doc = "Anti-electron dead-ECal discriminator"), # isoCI3hit = Var( "tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits")" doc="byCombinedIsolationDeltaBetaCorrRaw3Hits raw output discriminator"), @@ -112,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), @@ -136,7 +140,7 @@ def _tauId8WPMask(pattern,doc): _variablesMiniV2 = cms.PSet( _tauVarsBase, - _mvaAntiEVars2018, + _mvaAntiEVars, _mvaIsoVars2015Reduced, _mvaIsoVars2017v1, _mvaIsoVars2017v2, @@ -149,6 +153,7 @@ def _tauId8WPMask(pattern,doc): _variablesMiniV1.idMVAoldDM2017v1 = _tauId7WPMask( "by%sIsolationMVArun2v1DBoldDMwLT2017v1", doc="IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)") _variables80X = cms.PSet( _tauVarsBase, + _mvaAntiEVars2015, _mvaIsoVars2015 ) @@ -161,20 +166,18 @@ def _tauId8WPMask(pattern,doc): run2_miniAOD_80XLegacy.toModify(tauTable, variables = _variables80X ) +(~run2_miniAOD_devel).toModify(tauTable.variables, + idAntiEleDeadECal = None +) - - -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 - ) +run2_miniAOD_devel.toModify(tauTable.variables, + 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..f0b9d3e4aa751 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,11 +527,26 @@ againstElectronTightMVA62018 = cms.InputTag("patTauDiscriminationByTightElectronRejectionMVA62018"), againstElectronVTightMVA62018 = cms.InputTag("patTauDiscriminationByVTightElectronRejectionMVA62018") ) -_tauIDSourcesWithAntiE = cms.PSet( +_tauIDSourcesWithAntiE2018 = cms.PSet( + slimmedTausUpdated.tauIDSources.clone(), + _antiETauIDSources2018 +) +_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(), - _antiETauIDSources + _antiETauIDSources2015 ) -slimmedTausUpdated.tauIDSources=_tauIDSourcesWithAntiE +slimmedTausUpdated.tauIDSources = _tauIDSourcesWithAntiE2018 +run2_miniAOD_devel.toModify(slimmedTausUpdated, + tauIDSources = _tauIDSourcesWithAntiE2015) From e64bca63abce10477af478db1cb89885a30e5fd8 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 11 Aug 2020 20:05:55 +0200 Subject: [PATCH 4/7] migrate from run2_miniAOD_devel to run2_miniAOD_UL modifier (cont.) --- RecoTauTag/Configuration/python/HPSPFTaus_cff.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index fedf60eba43fe..6a1f8e066e45e 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -390,7 +390,7 @@ hpsPFTauDiscriminationByMVA6VTightElectronRejection = copy.deepcopy(hpsPFTauDiscriminationByMVA6VLooseElectronRejection) for m in hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping: m.cut = m.cut.value().replace("WPEff99", "WPEff79") -run2_miniAOD_devel.toModify( +run2_miniAOD_UL.toModify( hpsPFTauDiscriminationByMVA6rawElectronRejection, vetoEcalCracks = False, mvaName_NoEleMatch_woGwoGSF_BL = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_BL", @@ -411,35 +411,35 @@ _vLooseElectronRejectionMappingMVA6v3[5].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_EC_WPeff98" _vLooseElectronRejectionMappingMVA6v3[6].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_EC_WPeff98" _vLooseElectronRejectionMappingMVA6v3[7].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_EC_WPeff98" -run2_miniAOD_devel.toModify( +run2_miniAOD_UL.toModify( hpsPFTauDiscriminationByMVA6VLooseElectronRejection, mapping = _vLooseElectronRejectionMappingMVA6v3 ) _looseElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) for m in _looseElectronRejectionMappingMVA6v3: m.cut = m.cut.value().replace("WPeff98", "WPeff90") -run2_miniAOD_devel.toModify( +run2_miniAOD_UL.toModify( hpsPFTauDiscriminationByMVA6LooseElectronRejection, mapping = _looseElectronRejectionMappingMVA6v3 ) _mediumElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) for m in _mediumElectronRejectionMappingMVA6v3: m.cut = m.cut.value().replace("WPeff98", "WPeff80") -run2_miniAOD_devel.toModify( +run2_miniAOD_UL.toModify( hpsPFTauDiscriminationByMVA6MediumElectronRejection, mapping = _mediumElectronRejectionMappingMVA6v3 ) _tightElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) for m in _tightElectronRejectionMappingMVA6v3: m.cut = m.cut.value().replace("WPeff98", "WPeff70") -run2_miniAOD_devel.toModify( +run2_miniAOD_UL.toModify( hpsPFTauDiscriminationByMVA6TightElectronRejection, mapping = _tightElectronRejectionMappingMVA6v3 ) _vTightElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) for m in _vTightElectronRejectionMappingMVA6v3: m.cut = m.cut.value().replace("WPeff98", "WPeff60") -run2_miniAOD_devel.toModify( +run2_miniAOD_UL.toModify( hpsPFTauDiscriminationByMVA6VTightElectronRejection, mapping = _vTightElectronRejectionMappingMVA6v3 ) From ef784ddb33244aa77a335835eef2054338c5f746 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 18 Aug 2020 11:08:45 +0200 Subject: [PATCH 5/7] decouple configuration to rerun anti-e MVA6 discriminants from deadECal one --- .../PatAlgos/python/slimming/miniAOD_tools.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 8dca7cbbeba57..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' @@ -398,12 +408,9 @@ def miniAOD_customizeCommon(process): # note: default (AOD) behoviour of the tauID modified (leading track # extrapolation to ECAL enabled) in the HPS PFTau master # configuration for this era. - # and running retrained anti-e MVA6 discriminants as setup in the HPS - # PFTau master configuration _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy() _makePatTausTaskWithDeadECalVeto.add( - process.hpsPFTauDiscriminationByDeadECALElectronRejection, - process.hpsPFTauDiscriminationByMVA6ElectronRejectionTask + process.hpsPFTauDiscriminationByDeadECALElectronRejection ) run2_miniAOD_UL.toReplaceWith( process.makePatTausTask, _makePatTausTaskWithDeadECalVeto From 7cfdeaa99aaaf2e307e104f988e61100eeca48a1 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 18 Aug 2020 11:11:46 +0200 Subject: [PATCH 6/7] put modificators right after module definitions --- .../Configuration/python/HPSPFTaus_cff.py | 85 ++++++++----------- 1 file changed, 34 insertions(+), 51 deletions(-) diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index 6a1f8e066e45e..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,74 +386,45 @@ ) ) ) +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) 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) 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) 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) for m in hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping: m.cut = m.cut.value().replace("WPEff99", "WPEff79") 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" -) -_vLooseElectronRejectionMappingMVA6v3 = copy.deepcopy(hpsPFTauDiscriminationByMVA6VLooseElectronRejection.mapping) -_vLooseElectronRejectionMappingMVA6v3[0].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_BL_WPeff98" -_vLooseElectronRejectionMappingMVA6v3[1].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_BL_WPeff98" -_vLooseElectronRejectionMappingMVA6v3[2].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_BL_WPeff98" -_vLooseElectronRejectionMappingMVA6v3[3].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_BL_WPeff98" -_vLooseElectronRejectionMappingMVA6v3[4].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_EC_WPeff98" -_vLooseElectronRejectionMappingMVA6v3[5].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_EC_WPeff98" -_vLooseElectronRejectionMappingMVA6v3[6].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_EC_WPeff98" -_vLooseElectronRejectionMappingMVA6v3[7].cut = "RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_EC_WPeff98" -run2_miniAOD_UL.toModify( - hpsPFTauDiscriminationByMVA6VLooseElectronRejection, - mapping = _vLooseElectronRejectionMappingMVA6v3 -) -_looseElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) -for m in _looseElectronRejectionMappingMVA6v3: - m.cut = m.cut.value().replace("WPeff98", "WPeff90") -run2_miniAOD_UL.toModify( - hpsPFTauDiscriminationByMVA6LooseElectronRejection, - mapping = _looseElectronRejectionMappingMVA6v3 -) -_mediumElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) -for m in _mediumElectronRejectionMappingMVA6v3: - m.cut = m.cut.value().replace("WPeff98", "WPeff80") -run2_miniAOD_UL.toModify( - hpsPFTauDiscriminationByMVA6MediumElectronRejection, - mapping = _mediumElectronRejectionMappingMVA6v3 -) -_tightElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) -for m in _tightElectronRejectionMappingMVA6v3: - m.cut = m.cut.value().replace("WPeff98", "WPeff70") -run2_miniAOD_UL.toModify( - hpsPFTauDiscriminationByMVA6TightElectronRejection, - mapping = _tightElectronRejectionMappingMVA6v3 -) -_vTightElectronRejectionMappingMVA6v3 = copy.deepcopy(_vLooseElectronRejectionMappingMVA6v3) -for m in _vTightElectronRejectionMappingMVA6v3: - m.cut = m.cut.value().replace("WPeff98", "WPeff60") -run2_miniAOD_UL.toModify( - hpsPFTauDiscriminationByMVA6VTightElectronRejection, - mapping = _vTightElectronRejectionMappingMVA6v3 + hpsPFTauDiscriminationByMVA6VTightElectronRejection.mapping, + func = lambda mapping: _modMapping(mapping, "WPeff98", "WPeff60") ) hpsPFTauDiscriminationByMVA6ElectronRejectionTask = cms.Task( From c55431410df09eb6196d9b456876d5e04aea6517 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 27 Aug 2020 18:41:18 +0200 Subject: [PATCH 7/7] Rerun anti-e-in-deadECal tauID for all eras but run2_miniAOD_devel --- PhysicsTools/NanoAOD/python/taus_cff.py | 7 ++++--- .../NanoAOD/python/taus_updatedMVAIds_cff.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index 865a84b10ac8a..edcf7ecc92439 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -77,7 +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"), + 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"), @@ -166,11 +166,12 @@ def _tauId8WPMask(pattern,doc): run2_miniAOD_80XLegacy.toModify(tauTable, variables = _variables80X ) -(~run2_miniAOD_devel).toModify(tauTable.variables, - idAntiEleDeadECal = None +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)"), diff --git a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py index f0b9d3e4aa751..de9eef5e4fb23 100644 --- a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py @@ -548,6 +548,21 @@ 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