From 050763cf580de83f09678437be1487d12d0ba91d Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 20 Sep 2019 10:30:19 +0200 Subject: [PATCH] Revert "Temporarily revert "Disabled PCA inputs for deepTau v2 (10_6_X)"" --- .../Eras/python/Era_Run2_2016_cff.py | 3 +- .../Eras/python/Era_Run2_2017_cff.py | 3 +- .../Eras/python/Era_Run2_2018_cff.py | 3 +- Configuration/Eras/python/Era_Run3_cff.py | 3 +- .../python/Modifier_run2_tau_ul_2016_cff.py | 3 + .../python/Modifier_run2_tau_ul_2018_cff.py | 3 + .../StandardSequences/python/Eras.py | 1 + PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 12 ++-- PhysicsTools/NanoAOD/python/taus_cff.py | 28 ++++++-- .../PatAlgos/python/slimming/miniAOD_tools.py | 40 ++++++++--- RecoTauTag/RecoTau/plugins/DeepTauId.cc | 22 ++++-- .../RecoTau/python/tools/runTauIdMVA.py | 71 +++++++++++++++++-- .../RecoTau/test/runDeepTauIDsOnMiniAOD.py | 2 +- 13 files changed, 161 insertions(+), 33 deletions(-) create mode 100644 Configuration/Eras/python/Modifier_run2_tau_ul_2016_cff.py create mode 100644 Configuration/Eras/python/Modifier_run2_tau_ul_2018_cff.py diff --git a/Configuration/Eras/python/Era_Run2_2016_cff.py b/Configuration/Eras/python/Era_Run2_2016_cff.py index f68d93e2d1190..7f2974083842b 100644 --- a/Configuration/Eras/python/Era_Run2_2016_cff.py +++ b/Configuration/Eras/python/Era_Run2_2016_cff.py @@ -7,9 +7,10 @@ from Configuration.Eras.Modifier_run2_HLTconditions_2016_cff import run2_HLTconditions_2016 from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016 from Configuration.Eras.Modifier_run2_egamma_2016_cff import run2_egamma_2016 +from Configuration.Eras.Modifier_run2_tau_ul_2016_cff import run2_tau_ul_2016 from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring from Configuration.Eras.Modifier_pixel_2016_cff import pixel_2016 Run2_2016 = cms.ModifierChain(run2_common, run2_25ns_specific, - stage2L1Trigger, ctpps_2016, run2_HLTconditions_2016, run2_muon_2016, run2_egamma_2016, run2_L1prefiring,pixel_2016) + stage2L1Trigger, ctpps_2016, run2_HLTconditions_2016, run2_muon_2016, run2_egamma_2016, run2_tau_ul_2016, run2_L1prefiring, pixel_2016) diff --git a/Configuration/Eras/python/Era_Run2_2017_cff.py b/Configuration/Eras/python/Era_Run2_2017_cff.py index d99643e0a4015..50e3797012078 100644 --- a/Configuration/Eras/python/Era_Run2_2017_cff.py +++ b/Configuration/Eras/python/Era_Run2_2017_cff.py @@ -16,10 +16,11 @@ from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016 from Configuration.Eras.Modifier_run2_egamma_2017_cff import run2_egamma_2017 from Configuration.Eras.Modifier_run2_egamma_2016_cff import run2_egamma_2016 +from Configuration.Eras.Modifier_run2_tau_ul_2016_cff import run2_tau_ul_2016 from Configuration.Eras.Modifier_ctpps_2017_cff import ctpps_2017 from Configuration.Eras.Modifier_pixel_2016_cff import pixel_2016 -Run2_2017 = cms.ModifierChain(Run2_2016.copyAndExclude([run2_muon_2016, run2_HLTconditions_2016,run2_egamma_2016,pixel_2016]), +Run2_2017 = cms.ModifierChain(Run2_2016.copyAndExclude([run2_muon_2016, run2_HLTconditions_2016,run2_egamma_2016,run2_tau_ul_2016,pixel_2016]), phase1Pixel, run2_ECAL_2017, run2_HF_2017, run2_HCAL_2017, run2_HE_2017, run2_HEPlan1_2017, trackingPhase1, run2_GEM_2017, stage2L1Trigger_2017, run2_HLTconditions_2017, run2_muon_2017,run2_egamma_2017, ctpps_2017) diff --git a/Configuration/Eras/python/Era_Run2_2018_cff.py b/Configuration/Eras/python/Era_Run2_2018_cff.py index 9d5b9cbe74d48..59a6e6a01d712 100644 --- a/Configuration/Eras/python/Era_Run2_2018_cff.py +++ b/Configuration/Eras/python/Era_Run2_2018_cff.py @@ -14,10 +14,11 @@ from Configuration.Eras.Modifier_run2_muon_2017_cff import run2_muon_2017 from Configuration.Eras.Modifier_run2_egamma_2018_cff import run2_egamma_2018 from Configuration.Eras.Modifier_run2_egamma_2017_cff import run2_egamma_2017 +from Configuration.Eras.Modifier_run2_tau_ul_2018_cff import run2_tau_ul_2018 from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring from Configuration.Eras.Modifier_ctpps_2017_cff import ctpps_2017 from Configuration.Eras.Modifier_ctpps_2018_cff import ctpps_2018 Run2_2018 = cms.ModifierChain(Run2_2017.copyAndExclude([run2_HEPlan1_2017, run2_muon_2017, run2_L1prefiring, run2_HLTconditions_2017, run2_egamma_2017, ctpps_2017]), run2_CSC_2018, run2_HCAL_2018, run2_HB_2018, run2_HE_2018,run2_DT_2018, run2_SiPixel_2018, -run2_HLTconditions_2018, run2_muon_2018, run2_egamma_2018, ctpps_2018) +run2_HLTconditions_2018, run2_muon_2018, run2_egamma_2018, run2_tau_ul_2018, ctpps_2018) diff --git a/Configuration/Eras/python/Era_Run3_cff.py b/Configuration/Eras/python/Era_Run3_cff.py index 1ea38535bdb6b..e3c70e35cd8e4 100644 --- a/Configuration/Eras/python/Era_Run3_cff.py +++ b/Configuration/Eras/python/Era_Run3_cff.py @@ -6,6 +6,7 @@ from Configuration.Eras.Modifier_run3_HB_cff import run3_HB from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 from Configuration.Eras.Modifier_run2_egamma_2018_cff import run2_egamma_2018 +from Configuration.Eras.Modifier_run2_tau_ul_2018_cff import run2_tau_ul_2018 -Run3 = cms.ModifierChain(Run2_2018.copyAndExclude([run2_GEM_2017,run2_egamma_2018]), run3_common, run3_GEM, run3_HB) +Run3 = cms.ModifierChain(Run2_2018.copyAndExclude([run2_GEM_2017,run2_egamma_2018,run2_tau_ul_2018]), run3_common, run3_GEM, run3_HB) diff --git a/Configuration/Eras/python/Modifier_run2_tau_ul_2016_cff.py b/Configuration/Eras/python/Modifier_run2_tau_ul_2016_cff.py new file mode 100644 index 0000000000000..ab6b41a6f7292 --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_tau_ul_2016_cff.py @@ -0,0 +1,3 @@ +import FWCore.ParameterSet.Config as cms + +run2_tau_ul_2016 = cms.Modifier() diff --git a/Configuration/Eras/python/Modifier_run2_tau_ul_2018_cff.py b/Configuration/Eras/python/Modifier_run2_tau_ul_2018_cff.py new file mode 100644 index 0000000000000..1c6e930fee061 --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_tau_ul_2018_cff.py @@ -0,0 +1,3 @@ +import FWCore.ParameterSet.Config as cms + +run2_tau_ul_2018 = cms.Modifier() diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index c13ab308e3eff..6efd32e96f930 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -63,6 +63,7 @@ def __init__(self): 'tracker_apv_vfp30_2016', 'pf_badHcalMitigation', 'run2_miniAOD_80XLegacy','run2_miniAOD_94XFall17', 'run2_nanoAOD_92X', 'run2_nanoAOD_94XMiniAODv1', 'run2_nanoAOD_94XMiniAODv2', 'run2_nanoAOD_94X2016', 'run2_miniAOD_devel', 'run2_nanoAOD_102Xv1', + 'run2_tau_ul_2016', 'run2_tau_ul_2018', 'hcalHardcodeConditions', 'hcalSkipPacker', 'run2_HLTconditions_2016','run2_HLTconditions_2017','run2_HLTconditions_2018', 'bParking'] diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 3d02417cc8c34..be833315a1375 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -539,9 +539,9 @@ Plot1D('idMVAoldDM2017v1', 'idMVAoldDM2017v1', 128, -0.5, 127.5, 'IsolationMVArun2v1DBoldDMwLT ID working point (2017v1): bitmask 1 = VVLoose, 2 = VLoose, 4 = Loose, 8 = Medium, 16 = Tight, 32 = VTight, 64 = VVTight'), Plot1D('idMVAoldDM2017v2', 'idMVAoldDM2017v2', 128, -0.5, 127.5, 'IsolationMVArun2v1DBoldDMwLT ID working point (2017v2): bitmask 1 = VVLoose, 2 = VLoose, 4 = Loose, 8 = Medium, 16 = Tight, 32 = VTight, 64 = VVTight'), Plot1D('idMVAoldDMdR032017v2', 'idMVAoldDMdR032017v2', 128, -0.5, 127.5, 'IsolationMVArun2v1DBdR03oldDMwLT ID working point (217v2): bitmask 1 = VVLoose, 2 = VLoose, 4 = Loose, 8 = Medium, 16 = Tight, 32 = VTight, 64 = VVTight'), - Plot1D('idDeepTau2017v2VSe', 'idDeepTau2017v2VSe', 256, -0.5, 255.5, 'byDeepTau2017v2VSe ID working points (deepTau2017v2): bitmask 1 = VVVLoose, 2 = VVLoose, 4 = VLoose, 8 = Loose, 16 = Medium, 32 = Tight, 64 = VTight, 128 = VVTight'), - Plot1D('idDeepTau2017v2VSmu', 'idDeepTau2017v2VSmu', 16, -0.5, 15.5, 'byDeepTau2017v2VSmu ID working points (deepTau2017v2): bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight'), - Plot1D('idDeepTau2017v2VSjet', 'idDeepTau2017v2VSjet', 256, -0.5, 255.5, 'byDeepTau2017v2VSjet ID working points (deepTau2017v2): bitmask 1 = VVVLoose, 2 = VVLoose, 4 = VLoose, 8 = Loose, 16 = Medium, 32 = Tight, 64 = VTight, 128 = VVTight'), + Plot1D('idDeepTau2017v2p1VSe', 'idDeepTau2017v2p1VSe', 256, -0.5, 255.5, 'byDeepTau2017v2p1VSe ID working points (deepTau2017v2p1): bitmask 1 = VVVLoose, 2 = VVLoose, 4 = VLoose, 8 = Loose, 16 = Medium, 32 = Tight, 64 = VTight, 128 = VVTight'), + Plot1D('idDeepTau2017v2p1VSmu', 'idDeepTau2017v2p1VSmu', 16, -0.5, 15.5, 'byDeepTau2017v2p1VSmu ID working points (deepTau2017v2p1): bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight'), + Plot1D('idDeepTau2017v2p1VSjet', 'idDeepTau2017v2p1VSjet', 256, -0.5, 255.5, 'byDeepTau2017v2p1VSjet ID working points (deepTau2017v2p1): bitmask 1 = VVVLoose, 2 = VVLoose, 4 = VLoose, 8 = Loose, 16 = Medium, 32 = Tight, 64 = VTight, 128 = VVTight'), NoPlot('jetIdx'), Plot1D('leadTkDeltaEta', 'leadTkDeltaEta', 20, -0.1, 0.1, 'eta of the leading track, minus tau eta'), Plot1D('leadTkDeltaPhi', 'leadTkDeltaPhi', 20, -0.1, 0.1, 'phi of the leading track, minus tau phi'), @@ -563,9 +563,9 @@ Plot1D('rawMVAoldDM2017v1', 'rawMVAoldDM2017v1', 20, -1, 1, 'byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)'), Plot1D('rawMVAoldDM2017v2', 'rawMVAoldDM2017v2', 20, -1, 1, 'byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v2)'), Plot1D('rawMVAoldDMdR032017v2', 'rawMVAoldDMdR032017v2', 20, -1, 1, 'byIsolationMVArun2v1DBdR03oldDMwLT raw output discriminator (2017v2)'), - Plot1D('rawDeepTau2017v2VSe', 'rawDeepTau2017v2VSe', 20, 0, 1, 'byDeepTau2017v2VSe raw output discriminator (deepTau2017v2)'), - Plot1D('rawDeepTau2017v2VSmu', 'rawDeepTau2017v2VSmu', 20, 0, 1, 'byDeepTau2017v2VSmu raw output discriminator (deepTau2017v2)'), - Plot1D('rawDeepTau2017v2VSjet', 'rawDeepTau2017v2VSjet', 20, 0, 1, 'byDeepTau2017v2VSjet raw output discriminator (deepTau2017v2)'), + Plot1D('rawDeepTau2017v2p1VSe', 'rawDeepTau2017v2p1VSe', 20, 0, 1, 'byDeepTau2017v2p1VSe raw output discriminator (deepTau2017v2p1)'), + Plot1D('rawDeepTau2017v2p1VSmu', 'rawDeepTau2017v2p1VSmu', 20, 0, 1, 'byDeepTau2017v2p1VSmu raw output discriminator (deepTau2017v2p1)'), + Plot1D('rawDeepTau2017v2p1VSjet', 'rawDeepTau2017v2p1VSjet', 20, 0, 1, 'byDeepTau2017v2p1VSjet raw output discriminator (deepTau2017v2p1)'), ) ), TkMET = cms.PSet( diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index 1394b62b53bdf..674e4dd086af3 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -15,6 +15,14 @@ cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT2015') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2') || tauID('byVVVLooseDeepTau2017v2VSjet'))") ) +from Configuration.Eras.Modifier_run2_miniAOD_devel_cff import run2_miniAOD_devel +from Configuration.Eras.Modifier_run2_tau_ul_2016_cff import run2_tau_ul_2016 +from Configuration.Eras.Modifier_run2_tau_ul_2018_cff import run2_tau_ul_2018 +for era in [run2_miniAOD_devel,run2_tau_ul_2016,run2_tau_ul_2018]: + era.toModify(finalTaus, + 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_94X2016_cff import run2_nanoAOD_94X2016 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2 from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 @@ -131,6 +139,14 @@ def _tauId8WPMask(pattern,doc): idDeepTau2017v2VSmu = _tauId4WPMask("by%sDeepTau2017v2VSmu", doc="byDeepTau2017v2VSmu ID working points (deepTau2017v2)"), idDeepTau2017v2VSjet = _tauId8WPMask("by%sDeepTau2017v2VSjet", doc="byDeepTau2017v2VSjet ID working points (deepTau2017v2)"), ) +_deepTauVars2017v2p1 = cms.PSet( + rawDeepTau2017v2p1VSe = Var("tauID('byDeepTau2017v2p1VSeraw')", float, doc="byDeepTau2017v2p1VSe raw output discriminator (deepTau2017v2p1)", precision=10), + rawDeepTau2017v2p1VSmu = Var("tauID('byDeepTau2017v2p1VSmuraw')", float, doc="byDeepTau2017v2p1VSmu raw output discriminator (deepTau2017v2p1)", precision=10), + rawDeepTau2017v2p1VSjet = Var("tauID('byDeepTau2017v2p1VSjetraw')", float, doc="byDeepTau2017v2p1VSjet raw output discriminator (deepTau2017v2p1)", precision=10), + idDeepTau2017v2p1VSe = _tauId8WPMask("by%sDeepTau2017v2p1VSe", doc="byDeepTau2017v2p1VSe ID working points (deepTau2017v2p1)"), + idDeepTau2017v2p1VSmu = _tauId4WPMask("by%sDeepTau2017v2p1VSmu", doc="byDeepTau2017v2p1VSmu ID working points (deepTau2017v2p1)"), + idDeepTau2017v2p1VSjet = _tauId8WPMask("by%sDeepTau2017v2p1VSjet", doc="byDeepTau2017v2p1VSjet ID working points (deepTau2017v2p1)"), +) _variablesMiniV2 = cms.PSet( _tauVarsBase, @@ -138,7 +154,6 @@ def _tauId8WPMask(pattern,doc): _mvaIsoVars2015Reduced, _mvaIsoVars2017v1, _mvaIsoVars2017v2, - _deepTauVars2017v2 ) _variablesMiniV1 = _variablesMiniV2.clone() _variablesMiniV1.rawMVAoldDM = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10) @@ -150,16 +165,16 @@ def _tauId8WPMask(pattern,doc): _mvaIsoVars2015 ) -tauTable.variables=_variablesMiniV2 +tauTable.variables = cms.PSet(_variablesMiniV2,_deepTauVars2017v2) for era in [run2_nanoAOD_94XMiniAODv1,]: era.toModify(tauTable, variables = _variablesMiniV1 ) run2_miniAOD_80XLegacy.toModify(tauTable, - variables = _variables80X + variables = _variables80X ) -for era in [run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1]: +for era in [run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1]: era.toModify(tauTable.variables, rawDeepTau2017v2VSe = None, rawDeepTau2017v2VSmu = None, @@ -168,6 +183,11 @@ def _tauId8WPMask(pattern,doc): idDeepTau2017v2VSmu = None, idDeepTau2017v2VSjet = None ) +for era in [run2_miniAOD_devel,run2_tau_ul_2016,run2_tau_ul_2018]: + era.toModify(tauTable, + variables = cms.PSet(_variablesMiniV2,_deepTauVars2017v2p1) + ) + tauGenJets.GenParticles = cms.InputTag("prunedGenParticles") tauGenJets.includeNeutrinos = cms.bool(False) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 05e57cde1239d..f755cfa684d70 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -343,23 +343,45 @@ def miniAOD_customizeCommon(process): process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID ) #-- Adding DeepTauID - updatedTauName = 'slimmedTausDeepIDs' - noUpdatedTauName = 'slimmedTausNoDeepIDs' + # deepTau v2 + _updatedTauName = 'slimmedTausDeepIDsv2' + _noUpdatedTauName = 'slimmedTausNoDeepIDs' import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig tauIdEmbedder = tauIdConfig.TauIDEmbedder( process, cms, debug = False, - updatedTauName = updatedTauName, + updatedTauName = _updatedTauName, toKeep = ['deepTau2017v2'] ) tauIdEmbedder.runTauID() - addToProcessAndTask(noUpdatedTauName, process.slimmedTaus.clone(),process,task) + addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(),process,task) delattr(process, 'slimmedTaus') - process.deepTau2017v2.taus = noUpdatedTauName - process.slimmedTaus = getattr(process, updatedTauName).clone( - src = noUpdatedTauName + process.deepTau2017v2.taus = _noUpdatedTauName + process.slimmedTaus = getattr(process, _updatedTauName).clone( + src = _noUpdatedTauName ) - process.rerunMvaIsolationTask.add(process.slimmedTaus) - task.add(process.rerunMvaIsolationTask) + process.deepTauIDTask = cms.Task(process.deepTau2017v2, process.slimmedTaus) + task.add(process.deepTauIDTask) + + # deepTau v2p1 + _updatedTauNameNew = 'slimmedTausDeepIDsv2p1' + tauIdEmbedderNew = tauIdConfig.TauIDEmbedder( + process, cms, debug = False, + updatedTauName = _updatedTauNameNew, + toKeep = ['deepTau2017v2p1'] + ) + tauIdEmbedderNew.runTauID() + process.deepTau2017v2p1.taus = _noUpdatedTauName + deepTauIDTaskNew_ = cms.Task(process.deepTau2017v2p1,process.slimmedTaus) + + from Configuration.Eras.Modifier_run2_miniAOD_devel_cff import run2_miniAOD_devel + from Configuration.Eras.Modifier_run2_tau_ul_2016_cff import run2_tau_ul_2016 + from Configuration.Eras.Modifier_run2_tau_ul_2018_cff import run2_tau_ul_2018 + for era in [run2_miniAOD_devel,run2_tau_ul_2016,run2_tau_ul_2018]: + era.toReplaceWith(process.slimmedTaus, + getattr(process, _updatedTauNameNew).clone(src = _noUpdatedTauName)) + era.toReplaceWith(process.deepTauIDTask, + deepTauIDTaskNew_) + #-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018 diff --git a/RecoTauTag/RecoTau/plugins/DeepTauId.cc b/RecoTauTag/RecoTau/plugins/DeepTauId.cc index 36f60d7358e73..8f5412ed81e43 100644 --- a/RecoTauTag/RecoTau/plugins/DeepTauId.cc +++ b/RecoTauTag/RecoTau/plugins/DeepTauId.cc @@ -577,6 +577,7 @@ class DeepTauId : public deep_tau::DeepTauBase { desc.add("mem_mapped", false); desc.add("version", 2); desc.add("debug_level", 0); + desc.add("disable_dxy_pca", false); edm::ParameterSetDescription descWP; descWP.add("VVVLoose", "0"); @@ -601,7 +602,8 @@ class DeepTauId : public deep_tau::DeepTauBase { muons_token_(consumes(cfg.getParameter("muons"))), rho_token_(consumes(cfg.getParameter("rho"))), version(cfg.getParameter("version")), - debug_level(cfg.getParameter("debug_level")) + debug_level(cfg.getParameter("debug_level")), + disable_dxy_pca_(cfg.getParameter("disable_dxy_pca")) { if(version == 1) { input_layer_ = cache_->getGraph().node(0).name(); @@ -907,10 +909,19 @@ class DeepTauId : public deep_tau::DeepTauBase { get(dnn::neutralIsoPtSumdR03_over_dR05) = getValue(tau.tauID("neutralIsoPtSumdR03") / tau.tauID("neutralIsoPtSum")); get(dnn::photonPtSumOutsideSignalCone) = getValueNorm(tau.tauID("photonPtSumOutsideSignalConedR03"), 1.731f, 6.846f); get(dnn::puCorrPtSum) = getValueNorm(tau.tauID("puCorrPtSum"), 22.38f, 16.34f); - get(dnn::tau_dxy_pca_x) = getValueNorm(tau.dxy_PCA().x(), -0.0241f, 0.0074f); - get(dnn::tau_dxy_pca_y) = getValueNorm(tau.dxy_PCA().y(),0.0675f, 0.0128f); - get(dnn::tau_dxy_pca_z) = getValueNorm(tau.dxy_PCA().z(), 0.7973f, 3.456f); - + // The global PCA coordinates were used as inputs during the NN training, but it was decided to disable + // them for the inference, because modeling of dxy_PCA in MC poorly describes the data, and x and y coordinates + // in data results outside of the expected 5 std. dev. input validity range. On the other hand, + // these coordinates are strongly era-dependent. Kept as comment to document what NN expects. + if(!disable_dxy_pca_) { + get(dnn::tau_dxy_pca_x) = getValueNorm(tau.dxy_PCA().x(), -0.0241f, 0.0074f); + get(dnn::tau_dxy_pca_y) = getValueNorm(tau.dxy_PCA().y(),0.0675f, 0.0128f); + get(dnn::tau_dxy_pca_z) = getValueNorm(tau.dxy_PCA().z(), 0.7973f, 3.456f); + } else { + get(dnn::tau_dxy_pca_x) = 0; + get(dnn::tau_dxy_pca_y) = 0; + get(dnn::tau_dxy_pca_z) = 0; + } const bool tau_dxy_valid = std::isnormal(tau.dxy()) && tau.dxy() > - 10 && std::isnormal(tau.dxy_error()) && tau.dxy_error() > 0; if(tau_dxy_valid){ @@ -1698,6 +1709,7 @@ class DeepTauId : public deep_tau::DeepTauBase { std::string input_layer_, output_layer_; const unsigned version; const int debug_level; + const bool disable_dxy_pca_; std::shared_ptr tauBlockTensor_; std::array, 2> eGammaTensor_, muonTensor_, hadronsTensor_, convTensor_, zeroOutputTensor_; diff --git a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py index bb82085f7315f..f955eb6b29949 100644 --- a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py +++ b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py @@ -9,12 +9,14 @@ class TauIDEmbedder(object): """class to rerun the tau seq and acces trainings from the database""" availableDiscriminators = [ "2017v1", "2017v2", "newDM2017v2", "dR0p32017v2", "2016v1", "newDM2016v1", - "deepTau2017v1", "deepTau2017v2", "DPFTau_2016_v0", "DPFTau_2016_v1", "againstEle2018" + "deepTau2017v1", "deepTau2017v2", "deepTau2017v2p1", + "DPFTau_2016_v0", "DPFTau_2016_v1", + "againstEle2018" ] def __init__(self, process, cms, debug = False, updatedTauName = "slimmedTausNewID", - toKeep = ["deepTau2017v2"], + toKeep = ["deepTau2017v2p1"], tauIdDiscrMVA_trainings_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017", }, tauIdDiscrMVA_WPs_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' : { @@ -644,7 +646,10 @@ def runTauID(self): rho = self.cms.InputTag('fixedGridRhoAll'), graph_file = self.cms.vstring(file_names), mem_mapped = self.cms.bool(False), - version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1]) + version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1]), + debug_level = self.cms.int32(0), + disable_dxy_pca = self.cms.bool(False) + ) self.processDeepProducer('deepTau2017v1', tauIDSources, workingPoints_) @@ -699,7 +704,8 @@ def runTauID(self): graph_file = self.cms.vstring(file_names), mem_mapped = self.cms.bool(True), version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1]), - debug_level = self.cms.int32(0) + debug_level = self.cms.int32(0), + disable_dxy_pca = self.cms.bool(False) ) @@ -708,6 +714,63 @@ def runTauID(self): self.process.rerunMvaIsolationTask.add(self.process.deepTau2017v2) self.process.rerunMvaIsolationSequence += self.process.deepTau2017v2 + if "deepTau2017v2p1" in self.toKeep: + if self.debug: print ("Adding DeepTau IDs") + + workingPoints_ = { + "e": { + "VVVLoose": 0.0630386, + "VVLoose": 0.1686942, + "VLoose": 0.3628130, + "Loose": 0.6815435, + "Medium": 0.8847544, + "Tight": 0.9675541, + "VTight": 0.9859251, + "VVTight": 0.9928449, + }, + "mu": { + "VLoose": 0.1058354, + "Loose": 0.2158633, + "Medium": 0.5551894, + "Tight": 0.8754835, + }, + "jet": { + "VVVLoose": 0.2599605, + "VVLoose": 0.4249705, + "VLoose": 0.5983682, + "Loose": 0.7848675, + "Medium": 0.8834768, + "Tight": 0.9308689, + "VTight": 0.9573137, + "VVTight": 0.9733927, + }, + } + + file_names = [ + 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb', + 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb', + 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb', + ] + self.process.deepTau2017v2p1 = self.cms.EDProducer("DeepTauId", + electrons = self.cms.InputTag('slimmedElectrons'), + muons = self.cms.InputTag('slimmedMuons'), + taus = self.cms.InputTag('slimmedTaus'), + pfcands = self.cms.InputTag('packedPFCandidates'), + vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'), + rho = self.cms.InputTag('fixedGridRhoAll'), + graph_file = self.cms.vstring(file_names), + mem_mapped = self.cms.bool(True), + version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1]), + debug_level = self.cms.int32(0), + disable_dxy_pca = self.cms.bool(True) + + ) + + self.processDeepProducer('deepTau2017v2p1', tauIDSources, workingPoints_) + + self.process.rerunMvaIsolationTask.add(self.process.deepTau2017v2p1) + self.process.rerunMvaIsolationSequence += self.process.deepTau2017v2p1 + if "DPFTau_2016_v0" in self.toKeep: if self.debug: print ("Adding DPFTau isolation (v0)") diff --git a/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py b/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py index 77d5a166117ec..b8cdfd2c46190 100644 --- a/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py @@ -34,7 +34,7 @@ updatedTauName = updatedTauName, toKeep = [ "2017v2", "dR0p32017v2", "newDM2017v2", # "deepTau2017v1", - "deepTau2017v2", + "deepTau2017v2p1", # "DPFTau_2016_v0", # "DPFTau_2016_v1", "againstEle2018",