diff --git a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py index 61d8b4e56d594..1fb58bb74becd 100644 --- a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py +++ b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py @@ -5,17 +5,16 @@ ##################### Import reusable funtions and objects from std taus ######## from PhysicsTools.NanoAOD.taus_cff import _tauIdWPMask, tausMCMatchLepTauForTable, tausMCMatchHadTauForTable,tauMCTable - ##################### User floats producers, selectors ########################## finalBoostedTaus = cms.EDFilter("PATTauRefSelector", src = cms.InputTag("slimmedTausBoosted"), - cut = cms.string("pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT'))") + cut = cms.string("pt > 25 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT') || tauID('byBoostedDeepTau20161718v2p0VSjetraw') > {})".format(0.82)) ) run2_nanoAOD_106Xv2.toModify( finalBoostedTaus, - cut = "pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBoldDMdR0p3wLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT'))" + cut = "pt > 25 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBoldDMdR0p3wLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT') || tauID('byBoostedDeepTau20161718v2p0VSjetraw') > {})".format(0.82) ) boostedTauTable = simplePATTauFlatTableProducer.clone( @@ -59,16 +58,25 @@ idAntiEle2018 = _tauIdWPMask("againstElectron%sMVA6", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2018)") ) +#DeepBoostedTau ID raw score branches +_boostedDeepTauRunIIv2p0Vars = cms.PSet( + rawBoostedDeepTauRunIIv2p0VSe = Var("tauID('byBoostedDeepTau20161718v2p0VSeraw')", float, doc="BoostedDeepTau(v2p0) tagger for boostedTaus raw scores Vs e", precision=10), + rawBoostedDeepTauRunIIv2p0VSmu = Var("tauID('byBoostedDeepTau20161718v2p0VSmuraw')", float, doc="BoostedDeepTau(v2p0) tagger for boostedTaus raw scores Vs mu", precision=10), + rawBoostedDeepTauRunIIv2p0VSjet = Var("tauID('byBoostedDeepTau20161718v2p0VSjetraw')", float, doc="BoostedDeepTau(v2p0) tagger for boostedTaus raw scores Vs jet", precision=10) +) + boostedTauTable.variables = cms.PSet( _boostedTauVarsBase, _boostedTauVarsMVAIso, - _boostedTauVarsAntiEleMVA + _boostedTauVarsAntiEleMVA, + _boostedDeepTauRunIIv2p0Vars ) _boostedTauVarsWithDr03 = cms.PSet( _boostedTauVarsBase, _boostedTauVarsMVAIso, _boostedTauVarsMVAIsoDr03, - _boostedTauVarsAntiEleMVA + _boostedTauVarsAntiEleMVA, + _boostedDeepTauRunIIv2p0Vars ) run2_nanoAOD_106Xv2.toModify( boostedTauTable, diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index af8cdcb90379b..d571131cad653 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -971,6 +971,9 @@ Plot1D('rawIsodR03', 'rawIsodR03', 20, 0, 200, 'combined isolation (deltaBeta corrections, dR=0.3)'), Plot1D('rawMVAnewDM2017v2', 'rawMVAnewDM2017v2', 20, -1, 1, 'byIsolationMVArun2017v2DBnewDMwLT raw output discriminator (2017v2)'), Plot1D('rawMVAoldDM2017v2', 'rawMVAoldDM2017v2', 20, -1, 1, 'byIsolationMVArun2017v2DBoldDMwLT raw output discriminator (2017v2)'), + Plot1D('rawBoostedDeepTauRunIIv2p0VSe', 'rawBoostedDeepTauRunIIv2p0VSe', 20, 0, 1, 'BoostedDeepTau(v2p0) tagger for boostedTaus raw scores Vs e'), + Plot1D('rawBoostedDeepTauRunIIv2p0VSjet', 'rawBoostedDeepTauRunIIv2p0VSjet', 20, 0, 1, 'BoostedDeepTau(v2p0) tagger for boostedTaus raw scores Vs jet'), + Plot1D('rawBoostedDeepTauRunIIv2p0VSmu', 'rawBoostedDeepTauRunIIv2p0VSmu', 20, 0, 1, 'BoostedDeepTau(v2p0) tagger for boostedTaus raw scores Vs mu'), ) ), L1PreFiringWeight = cms.PSet( diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index a4c8469df8602..f97b28674b0e3 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -269,7 +269,12 @@ def nanoAOD_customizeCommon(process): idsToAdd = cms.vstring() ) run2_nanoAOD_106Xv2.toModify( - nanoAOD_boostedTau_switch, idsToAdd = ["mvaIso", "mvaIsoNewDM", "mvaIsoDR0p3", "againstEle"] + nanoAOD_boostedTau_switch, idsToAdd = ["mvaIso", "mvaIsoNewDM", "mvaIsoDR0p3", "againstEle", "boostedDeepTauRunIIv2p0"] + ).toModify( + process, lambda p : nanoAOD_addBoostedTauIds(p, nanoAOD_boostedTau_switch.idsToAdd.value()) + ) + run3_nanoAOD_pre142X.toModify( + nanoAOD_boostedTau_switch, idsToAdd = ["boostedDeepTauRunIIv2p0"] ).toModify( process, lambda p : nanoAOD_addBoostedTauIds(p, nanoAOD_boostedTau_switch.idsToAdd.value()) ) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 7ac0a8c05378a..b498a98c82b76 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -307,6 +307,23 @@ def _add_deepFlavour(process): #-- Adding boosted taus from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus addBoostedTaus(process) + #-- Adding DeepTauID for boosted taus + import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig + _updatedBoostedTauName = 'slimmedTausBoostedDeepIDs' + _noUpdatedBoostedTauName = 'slimmedTausBoostedNoDeepIDs' + boostedTauIdEmbedder = tauIdConfig.TauIDEmbedder( + process, debug = False, + originalTauName = _noUpdatedBoostedTauName, + updatedTauName = _updatedBoostedTauName, + postfix = 'BoostedForMini', + toKeep = ['boostedDeepTauRunIIv2p0'] + ) + boostedTauIdEmbedder.runTauID() + addToProcessAndTask(_noUpdatedBoostedTauName, process.slimmedTausBoosted.clone(),process,task) + delattr(process, 'slimmedTausBoosted') + process.slimmedTausBoosted = getattr(process, _updatedBoostedTauName).clone() + process.rerunMvaIsolationTaskBoostedForMini.add(process.slimmedTausBoosted) + task.add(process.rerunMvaIsolationTaskBoostedForMini) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") process.load("RecoTauTag.Configuration.HPSPFTaus_cff") #-- Adding customization for 94X 2017 legacy reMniAOD @@ -326,7 +343,6 @@ def _add_deepFlavour(process): #-- Adding DeepTauID _updatedTauName = 'slimmedTausDeepIDs' _noUpdatedTauName = 'slimmedTausNoDeepIDs' - import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig tauIdEmbedder = tauIdConfig.TauIDEmbedder( process, debug = False, originalTauName = _noUpdatedTauName, diff --git a/RecoTauTag/RecoTau/interface/DeepTauIdBase.h b/RecoTauTag/RecoTau/interface/DeepTauIdBase.h index 95e940afdfe67..e494ddcb030d2 100644 --- a/RecoTauTag/RecoTau/interface/DeepTauIdBase.h +++ b/RecoTauTag/RecoTau/interface/DeepTauIdBase.h @@ -109,7 +109,7 @@ namespace { }; inline std::vector varsToDrop = { tau_phi, tau_dxy_pca_x, tau_dxy_pca_y, tau_dxy_pca_z}; // indices of vars to be dropped in the full var enum - } // namespace TauBlockInputs + } // namespace TauBlockInputs namespace EgammaBlockInputs { enum vars { @@ -1074,7 +1074,7 @@ class DeepTauIdBase : public Producer { if (sub_version_ == 1) { scalingParamsMap_ = &sc::scalingParamsMap_v2p1; - } else if (sub_version_ == 5) { + } else if ((sub_version_ == 5) || ((sub_version_ == 0) && (year_ == 20161718))) { std::sort(TauBlockInputs::varsToDrop.begin(), TauBlockInputs::varsToDrop.end()); for (auto v : TauBlockInputs::varsToDrop) { tauInputs_indices_.at(v) = TauBlockInputs::NumberOfInputs - TauBlockInputs::varsToDrop.size(); @@ -1083,6 +1083,8 @@ class DeepTauIdBase : public Producer { } if (year_ == 2026) { scalingParamsMap_ = &sc::scalingParamsMap_PhaseIIv2p5; + } else if ((sub_version_ == 0) && (year_ == 20161718)) { + scalingParamsMap_ = &sc::scalingParamsMap_BoostedRun2_v2p0; } else { scalingParamsMap_ = &sc::scalingParamsMap_v2p5; } @@ -1298,7 +1300,7 @@ class DeepTauIdBase : public Producer { if (sub_version_ == 1) get(dnn::footprintCorrection) = sp.scale(tau_funcs.getFootprintCorrectiondR03(tau, tau_ref), tauInputs_indices_[dnn::footprintCorrection]); - else if (sub_version_ == 5) { + else if ((sub_version_ == 5) || ((sub_version_ == 0) && (year_ == 20161718))) { if (is_online_) get(dnn::footprintCorrection) = sp.scale(tau_funcs.getFootprintCorrectiondR03(tau, tau_ref), tauInputs_indices_[dnn::footprintCorrection]); @@ -1372,7 +1374,7 @@ class DeepTauIdBase : public Producer { sp.scale(tau_funcs.getFlightLength(tau, tau_index).z(), tauInputs_indices_[dnn::tau_flightLength_z]); if (sub_version_ == 1) get(dnn::tau_flightLength_sig) = 0.55756444; //This value is set due to a bug in the training - else if (sub_version_ == 5) + else if ((sub_version_ == 5) || ((sub_version_ == 0) && (year_ == 20161718))) get(dnn::tau_flightLength_sig) = sp.scale(tau_funcs.getFlightLengthSig(tau, tau_index), tauInputs_indices_[dnn::tau_flightLength_sig]); @@ -1436,7 +1438,7 @@ class DeepTauIdBase : public Producer { // to account for swapped order of PfCand_gamma and Electron blocks for v2p5 training w.r.t. v2p1 int fill_index_offset_e = 0; int fill_index_offset_PFg = 0; - if (sub_version_ == 5) { + if ((sub_version_ == 5) || ((sub_version_ == 0) && (year_ == 20161718))) { fill_index_offset_e = scalingParamsMap_->at(std::make_pair(ft_PFg, false)).mean_.size(); // size of PF gamma features fill_index_offset_PFg = diff --git a/RecoTauTag/RecoTau/interface/DeepTauScaling.h b/RecoTauTag/RecoTau/interface/DeepTauScaling.h index 182346cf893ee..3802a8e8398bc 100644 --- a/RecoTauTag/RecoTau/interface/DeepTauScaling.h +++ b/RecoTauTag/RecoTau/interface/DeepTauScaling.h @@ -724,6 +724,283 @@ namespace deep_tau { }; // end scalingParamsMap_v2p5 + // Scaling parameters added for BoostedDeepTau v2p0 IDs for boostedTaus + const std::map, ScalingParams> scalingParamsMap_BoostedRun2_v2p0 = { + {std::make_pair(FeatureT::TauFlat, false), + { + //mean_GP + {25.0, 510.0, 0.0, 0.622, 1.926, 0, 1, 0, 42.94, 0, + 6.999, 42.46, 0, 0, 0, 1.422, 20.69, 0, 0.001955, 2.333, + 0, 0.002899, 2.782, 0.0001181, 0, 10.85, -0.001526, -0.0005461, -0.001127, -5.308, + 0.5, 0.5, 0.004013, 0.5, 1.543, 0, 0.5, 0, 1.57079632679, 2.947, + 0.0, 0, 0.003125}, + //std_GP + {25.0, 490.0, 2.3, 0.6156, 1.089, 1, 1, 1, 100.9, 1, 19.13, 121.6, 1, + 1, 1, 6.161, 18.41, 1, 0.009373, 3.935, 1, 0.01412, 3.926, 0.3395, 1, 147.0, + 0.817, 0.8158, 1.837, 9.015, 0.5, 0.5, 0.01159, 0.5, 4.234, 1, 0.5, 1, 1.57079632679, + 3.66, 1.0, 1, 0.03355}, + //lim_min_GP + {-1.0, -1.0, -1.0, -5, -5, -inf, -inf, -inf, -5, -inf, -5, -5, -inf, -inf, -inf, + -5, -5, -inf, -5, -5, -inf, -5, -5, -5, -inf, -5, -5, -5, -5, -5, + -1.0, -1.0, -5, -1.0, -5, -inf, -1.0, -inf, -1.0, -5, -1.0, -inf, -5}, + //lim_max_GP + {1.0, 1.0, 1.0, 5, 5, inf, inf, inf, 5, inf, 5, 5, inf, inf, inf, 5, 5, inf, 5, 5, inf, 5, + 5, 5, inf, 5, 5, 5, 5, 5, 1.0, 1.0, 5, 1.0, 5, inf, 1.0, inf, 1.0, 5, 1.0, inf, 5}, + + }}, // end TauFlat + + {std::make_pair(FeatureT::GridGlobal, false), + { + //mean_GP + {25.0, 510.0, 0.0, 0}, + //std_GP + {25.0, 490.0, 2.3, 1}, + //lim_min_GP + {-1.0, -1.0, -1.0, -inf}, + //lim_max_GP + {1.0, 1.0, 1.0, inf}, + }}, // end GridGlobal + + {std::make_pair(FeatureT::PfCand_electron, false), + { + //mean_GP + {0, 0.5296, 0.0, 0.0, 0, 0, 0, 0, 5.0, -0.0004758, 0.0005222, + 0.01039, 0.001353, 0.001985, 0.02035, 0, -0.002186, 2.675, 0.01001, 99.29, 4.52, 12.43}, + //std_GP + {1, 1.508, 0.5, 0.5, 1, 1, 1, 1, 5.0, 0.3307, 0.326, + 2.593, 1.058, 1.075, 3.202, 1, 0.4468, 6.082, 2.571, 378.5, 15.09, 3.515}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -1.0, -5, -5, -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, 1.0, 5, 5, 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5}, + + }}, // end PfCand_electron, is_inner=false + + {std::make_pair(FeatureT::PfCand_electron, true), + { + //mean_GP + {0, 0.9756, 0.0, 0.0, 0, 0, 0, 0, 5.0, 2.092e-05, -1.775e-05, + 0.0008577, 0.0002263, 5.592e-06, 0.0005022, 0, 1.286e-05, 1.396, 0.0008577, 17.23, 2.443, 14.52}, + //std_GP + {1, 0.1756, 0.1, 0.1, 1, 1, 1, 1, 5.0, 0.02507, 0.02448, + 0.4693, 0.1855, 0.1991, 0.6996, 1, 0.03483, 3.208, 0.4693, 203.6, 9.155, 3.095}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -1.0, -5, -5, -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, 1.0, 5, 5, 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5}, + + }}, // end PfCand_electron, is_inner=true + + {std::make_pair(FeatureT::PfCand_gamma, false), + { + //mean_GP + {0, 0.0188, 0.0, 0.0, 0, 0, 0, 0, + 0, 3.5, 5.772e-07, 1.242e-06, -9.272e-07, 0.002195, 0.0008768, 0.002605, + 0, -0.01067, 3.456, -0.01241, 90.32, 3.51, 12.56}, + //std_GP + {1, 0.1668, 0.5, 0.5, 1, 1, 1, 1, 1, 3.5, 0.004348, 0.004227, + 0.02717, 0.9785, 0.9745, 1.853, 1, 0.7017, 8.255, 3.143, 389.7, 14.66, 4.179}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -inf, -1.0, -5, -5, + -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, inf, 1.0, 5, 5, 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5}, + + }}, // end PfCand_gamma, is_inner=false + + {std::make_pair(FeatureT::PfCand_gamma, true), + { + //mean_GP + {0, 0.432, 0.0, 0.0, 0, 0, 0, 0, + 0, 3.5, -4.771e-06, -1.346e-05, -5.6e-06, 0.002579, 0.0006076, 0.00243, + 0, -0.006341, 3.475, -0.003692, 81.19, 4.392, 11.97}, + //std_GP + {1, 0.6669, 0.1, 0.1, 1, 1, 1, 1, 1, 3.5, 0.01989, 0.01664, + 0.1996, 1.074, 1.074, 2.307, 1, 0.6659, 8.764, 5.124, 362.7, 17.24, 4.257}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -inf, -1.0, -5, -5, + -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, inf, 1.0, 5, 5, 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5}, + + }}, // end PfCand_gamma, is_inner=true + + {std::make_pair(FeatureT::Electron, false), + { + //mean_GP + {0, 0.639, 0.0, 0.0, 0, 1.422, 0.2507, 1.849, 1.22, 1.221, + 0.5587, 0.5588, 1.107, 1.51, 28.08, 3.667, 2.723, 6.103, 3.063, -2.107e-05, + -0.0009144, -0.0007777, -0.000229, -0.0006306, -0.0002614, 0, 0, 0.0009277, 25.86, 0.03157, + 5.659, 14.69, 5.883, 5.938, 0, 1.92, 12.97}, + //std_GP + {1, 1.737, 0.5, 0.5, 1, 4.675, 0.4625, 2.366, 51.67, 51.67, 4.228, 4.228, 4.931, + 1.887, 48.65, 19.1, 16.89, 36.95, 21.04, 0.08013, 0.08983, 0.09281, 0.1013, 0.1021, 0.1341, 1, + 1, 0.006744, 89.11, 0.1741, 41.99, 2.904, 193.2, 4.225, 1, 5.94, 5.211}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, + -5, -5, -5, -5, -5, -5, -inf, -inf, -5, -5, -5, -5, -5, -5, -5, -inf, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, inf, inf, 5, 5, 5, 5, 5, 5, 5, inf, 5, 5}, + + }}, // end Electron, is_inner=false + + {std::make_pair(FeatureT::Electron, true), + { + //mean_GP + {0, 1.019, 0.0, 0.0, 0, 1.728, 0.1058, 1.964, 2.415, 2.415, + 0.8938, 0.8938, 1.629, 2.017, 74.29, 2.361, 1.963, 6.631, 4.339, 2.437e-05, + 6.556e-06, 1.221e-05, 9.284e-05, 8.955e-05, 0.0002721, 0, 0, 0.000552, 19.23, 0.003983, + 3.172, 16.12, 3.077, 4.594, 0, 2.347, 15.11}, + //std_GP + {1, 0.6477, 0.1, 0.1, 1, 1.09, 0.2543, 2.165, 229.9, 229.9, 28.39, 28.39, 2.592, + 1.266, 56.95, 4.558, 3.866, 22.93, 16.01, 0.00759, 0.01344, 0.01435, 0.02339, 0.02578, 0.0431, 1, + 1, 0.003065, 65.85, 0.03472, 14.33, 2.669, 100.9, 2.304, 1, 6.815, 4.786}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, + -5, -5, -5, -5, -5, -5, -inf, -inf, -5, -5, -5, -5, -5, -5, -5, -inf, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, inf, inf, 5, 5, 5, 5, 5, 5, 5, inf, 5, 5}, + + }}, // end Electron, is_inner=true + + {std::make_pair(FeatureT::PfCand_muon, false), + { + //mean_GP + {0, 0.3069, 0.0, 0.0, 0, 0, 0, 0, 0, 5.5, 0.002564, 0.002138, + -0.02319, 0.002726, 0.003231, -0.02213, 0, -0.01843, 12.3, -0.02323, 215.1, 0.9003, 16.24}, + //std_GP + {1, 1.105, 0.5, 0.5, 1, 1, 1, 1, 1, 5.5, 1.116, 1.113, + 6.667, 1.445, 1.442, 7.106, 1, 1.577, 74.65, 6.672, 464.2, 2.841, 6.138}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -inf, -1.0, -5, -5, + -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, inf, 1.0, 5, 5, 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5}, + + }}, // end PfCand_muon, is_inner=false + + {std::make_pair(FeatureT::PfCand_muon, true), + { + //mean_GP + {0, 0.9569, 0.0, 0.0, 0, 0, 0, 0, + 0, 5.5, -8.717e-05, -5.207e-05, -0.004623, 0.0002897, -0.0002568, -0.005295, + 0, -1.742e-05, 1.37, -0.004624, 9.428, 0.6257, 16.65}, + //std_GP + {1, 0.2011, 0.1, 0.1, 1, 1, 1, 1, 1, 5.5, 0.07502, 0.07406, + 0.8187, 0.3524, 0.3537, 1.063, 1, 0.1054, 8.667, 0.8187, 148.1, 0.9767, 4.303}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -inf, -1.0, -5, -5, + -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, inf, 1.0, 5, 5, 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5}, + + }}, // end PfCand_muon, is_inner=true + + {std::make_pair(FeatureT::Muon, false), + { + //mean_GP + {0, 0.5049, 0.0, 0.0, 0.003816, 15.83, 0, 43.85, 18.36, 0, 0, 0, 0.3329, + 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 3.5, 3.0, 2.0, 2.0, 6.0, + 6.0, 6.0, 4.0, 12.0, 6.0, 6.0, 6.0, 2.0, 2.0, 1.0, 1.0}, + //std_GP + {1, 149.0, 0.5, 0.5, 1.447, 87.94, 1, 465.1, 9.36, 1, 1, 1, 0.5782, + 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 3.5, 3.0, 2.0, 2.0, 6.0, + 6.0, 6.0, 4.0, 12.0, 6.0, 6.0, 6.0, 2.0, 2.0, 1.0, 1.0}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -5, -5, -inf, -5, -5, -inf, -inf, -inf, -5, + -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, + -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, + //lim_max_GP + {inf, 5, 1.0, 1.0, 5, 5, inf, 5, 5, inf, inf, inf, 5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, + + }}, // end Muon, is_inner=false + + {std::make_pair(FeatureT::Muon, true), + { + //mean_GP + {0, 0.8256, 0.0, 0.0, 0.0006146, 3.845, 0, 21.54, 19.47, 0, 0, 0, 0.1571, + 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 3.5, 3.0, 2.0, 2.0, 6.0, + 6.0, 6.0, 4.0, 12.0, 6.0, 6.0, 6.0, 2.0, 2.0, 1.0, 1.0}, + //std_GP + {1, 36.23, 0.1, 0.1, 0.1437, 24.66, 1, 261.6, 7.661, 1, 1, 1, 0.434, + 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 3.5, 3.0, 2.0, 2.0, 6.0, + 6.0, 6.0, 4.0, 12.0, 6.0, 6.0, 6.0, 2.0, 2.0, 1.0, 1.0}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -5, -5, -inf, -5, -5, -inf, -inf, -inf, -5, + -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, + -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, + //lim_max_GP + {inf, 5, 1.0, 1.0, 5, 5, inf, 5, 5, inf, inf, inf, 5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, + + }}, // end Muon, is_inner=true + + {std::make_pair(FeatureT::PfCand_chHad, false), + { + //mean_GP + {0, 0.0191, 0.0, 0.0, 0, 0, 0, 0, 0, + 0, 0, 6.0, 0.0001957, -0.001691, -0.01458, 0.001266, 0.0003823, -0.01261, + 0, -0.01382, 6.517, -0.01976, 266.4, 0.7886, 12.81, 0, 1.3}, + //std_GP + {1, 0.1126, 0.5, 0.5, 1, 1, 1, 1, 1, 1, 1, 6.0, 1.68, 1.689, + 8.038, 1.877, 1.885, 8.228, 1, 2.405, 34.23, 7.63, 414.6, 3.429, 6.363, 1, 1.3}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -inf, -inf, -inf, -1.0, -5, -5, + -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5, -inf, -1.0}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, inf, inf, inf, 1.0, 5, 5, + 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5, inf, 1.0}, + }}, // end PfCand_chHad, is_inner=false + + {std::make_pair(FeatureT::PfCand_chHad, true), + { + //mean_GP + {0, 0.2193, 0.0, 0.0, 0, 0, 0, 0, 0, + 0, 0, 6.0, -0.0002255, -0.000324, -0.003971, 0.002356, 0.001573, -0.000732, + 0, -0.0006407, 3.897, -0.003331, 30.88, 0.976, 13.8, 0, 1.3}, + //std_GP + {1, 0.3191, 0.1, 0.1, 1, 1, 1, 1, 1, 1, 1, 6.0, 0.6118, 0.6153, + 2.924, 1.378, 1.373, 3.908, 1, 0.7228, 14.35, 2.303, 164.5, 4.321, 5.13, 1, 1.3}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf, -inf, -inf, -inf, -inf, -1.0, -5, -5, + -5, -5, -5, -5, -inf, -5, -5, -5, -5, -5, -5, -inf, -1.0}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf, inf, inf, inf, inf, 1.0, 5, 5, + 5, 5, 5, 5, inf, 5, 5, 5, 5, 5, 5, inf, 1.0}, + + }}, // end PfCand_chHad, is_inner=true + + {std::make_pair(FeatureT::PfCand_nHad, false), + { + //mean_GP + {0, 0.03963, 0.0, 0.0, 0, 0, 0}, + //std_GP + {1, 0.1872, 0.5, 0.5, 1, 1, 1}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf}, + + }}, // end PfCand_nHad, is_inner=false + + {std::make_pair(FeatureT::PfCand_nHad, true), + { + //mean_GP + {0, 0.3073, 0.0, 0.0, 0, 0, 0}, + //std_GP + {1, 0.3819, 0.1, 0.1, 1, 1, 1}, + //lim_min_GP + {-inf, -5, -1.0, -1.0, -inf, -inf, -inf}, + //lim_max_GP + {inf, 5, 1.0, 1.0, inf, inf, inf}, + + }}, // end PfCand_nHad, is_inner=true + + }; // end of ScalingParams BoostedDeepTau v2p0 IDs for boostedTaus + const std::map, ScalingParams> scalingParamsMap_PhaseIIv2p5 = { {std::make_pair(FeatureT::TauFlat, false), { diff --git a/RecoTauTag/RecoTau/plugins/DeepTauId.cc b/RecoTauTag/RecoTau/plugins/DeepTauId.cc index dcb264a1647e0..3a1b0f1b3f163 100644 --- a/RecoTauTag/RecoTau/plugins/DeepTauId.cc +++ b/RecoTauTag/RecoTau/plugins/DeepTauId.cc @@ -93,7 +93,7 @@ class DeepTauId : public DeepTauIdBase { if (sub_version_ == 1) { tauBlockTensor_ = std::make_unique( tensorflow::DT_FLOAT, tensorflow::TensorShape{1, TauBlockInputs::NumberOfInputs}); - } else if (sub_version_ == 5) { + } else if ((sub_version_ == 5) || ((sub_version_ == 0) && (year_ == 20161718))) { tauBlockTensor_ = std::make_unique( tensorflow::DT_FLOAT, tensorflow::TensorShape{1, diff --git a/RecoTauTag/RecoTau/python/tauIdWPsDefs.py b/RecoTauTag/RecoTau/python/tauIdWPsDefs.py index e78cc00381529..b9d88c6606b85 100644 --- a/RecoTauTag/RecoTau/python/tauIdWPsDefs.py +++ b/RecoTauTag/RecoTau/python/tauIdWPsDefs.py @@ -56,6 +56,11 @@ } } +WORKING_POINTS_BOOSTED_v2p0 = { + "e": {}, + "mu": {}, + "jet": {} +} WORKING_POINTS_PHASEII_v2p5 = { "e": { "VVVLoose": 0.2376, diff --git a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py index d8cba685cf236..d3d0bdd1a3594 100644 --- a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py +++ b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py @@ -4,7 +4,7 @@ from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import patDiscriminationByIsolationMVArun2v1raw, patDiscriminationByIsolationMVArun2v1 from RecoTauTag.RecoTau.DeepTau_cfi import DeepTau from RecoTauTag.RecoTau.DeepTauIdSonicProducer_cfi import DeepTauIdSonicProducer -from RecoTauTag.RecoTau.tauIdWPsDefs import WORKING_POINTS_v2p1, WORKING_POINTS_v2p5, WORKING_POINTS_PHASEII_v2p5 +from RecoTauTag.RecoTau.tauIdWPsDefs import WORKING_POINTS_v2p1, WORKING_POINTS_v2p5, WORKING_POINTS_PHASEII_v2p5, WORKING_POINTS_BOOSTED_v2p0 import os import re @@ -21,7 +21,7 @@ class TauIDEmbedder(object): "againstEle", #payloads from GT (2018) "newDMPhase2v1", #payloads from phase2 GT "againstElePhase2v1", #payloads from phase2 GT - "deepTau2017v2", "deepTau2017v2p1", "deepTau2018v2p5", "deepTau2026v2p5" + "deepTau2017v2", "deepTau2017v2p1", "deepTau2018v2p5", "boostedDeepTauRunIIv2p0", "deepTau2026v2p5" ]) def __init__(self, process, debug = False, @@ -930,6 +930,37 @@ def runTauID(self): _rerunMvaIsolationTask.add(_deepTauProducer) _rerunMvaIsolationSequence += _deepTauProducer + if "boostedDeepTauRunIIv2p0" in self.toKeep: + if self.debug: print ("Adding BoostedDeepTau v2p0 IDs for boostedTaus") + + _deepTauName = "boostedDeepTau20161718v2p0" + workingPoints_ = WORKING_POINTS_BOOSTED_v2p0 + + file_names = [ + 'core:RecoTauTag/TrainingFiles/data/BoostedDeepTauId/boosteddeepTau_RunIIv2p0_core.pb', + 'inner:RecoTauTag/TrainingFiles/data/BoostedDeepTauId/boosteddeepTau_RunIIv2p0_inner.pb', + 'outer:RecoTauTag/TrainingFiles/data/BoostedDeepTauId/boosteddeepTau_RunIIv2p0_outer.pb', + ] + full_version = self.getDeepTauVersion(file_names[0]) + setattr(self.process,_deepTauName+self.postfix,DeepTau.clone( + Prediscriminants = noPrediscriminants, + taus = self.originalTauName, + graph_file = file_names, + year = full_version[0], + version = full_version[1], + sub_version = full_version[2], + disable_dxy_pca = True, + disable_hcalFraction_workaround = True, + save_inputs = False, + disable_CellIndex_workaround = True + )) + + self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_) + + _deepTauProducer = getattr(self.process,_deepTauName+self.postfix) + _rerunMvaIsolationTask.add(_deepTauProducer) + _rerunMvaIsolationSequence += _deepTauProducer + if "deepTau2026v2p5" in self.toKeep: if self.debug: print ("Adding Phase2 DeepTau v2p5 IDs") @@ -1314,11 +1345,12 @@ def getDeepTauVersion(self, file_name): """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \ (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \ {year}v{version}p{subversion}""" - version_search = re.search('(20[1,2][125678])v([0-9]+)(p[0-9]+|)[\\._]', file_name) + version_search = re.search('(20[1,2][125678]|RunII)v([0-9]+)(p[0-9]+|)[\\._]', file_name) if not version_search: raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \ Unable to extract version number.'.format(file_name)) year = version_search.group(1) + if year == 'RunII': year = 20161718 version = version_search.group(2) subversion = version_search.group(3) if len(subversion) > 0: