Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled PCA inputs for deepTau v2 #27878

Merged
12 changes: 6 additions & 6 deletions PhysicsTools/NanoAOD/python/nanoDQM_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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(
Expand Down
46 changes: 27 additions & 19 deletions PhysicsTools/NanoAOD/python/taus_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

finalTaus = cms.EDFilter("PATTauRefSelector",
src = cms.InputTag("slimmedTausUpdated"),
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'))")
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'))")
)

for era in [run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1]:
Expand All @@ -26,8 +26,8 @@
)
from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
run2_miniAOD_80XLegacy.toModify(finalTaus,
src = cms.InputTag("slimmedTaus"),
cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))")
src = cms.InputTag("slimmedTaus"),
cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))")
)

##################### Tables for final output and docs ##########################
Expand Down Expand Up @@ -124,13 +124,13 @@ def _tauId8WPMask(pattern,doc):
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),
rawDeepTau2017v2VSmu = Var("tauID('byDeepTau2017v2VSmuraw')", float, doc="byDeepTau2017v2VSmu raw output discriminator (deepTau2017v2)", precision=10),
rawDeepTau2017v2VSjet = Var("tauID('byDeepTau2017v2VSjetraw')", float, doc="byDeepTau2017v2VSjet raw output discriminator (deepTau2017v2)", precision=10),
idDeepTau2017v2VSe = _tauId8WPMask("by%sDeepTau2017v2VSe", doc="byDeepTau2017v2VSe ID working points (deepTau2017v2)"),
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(
Expand All @@ -139,7 +139,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)
Expand All @@ -152,7 +151,7 @@ def _tauId8WPMask(pattern,doc):
_mvaIsoVars2015
)

tauTable.variables=_variablesMiniV2
tauTable.variables = cms.PSet(_variablesMiniV2,_deepTauVars2017v2p1)

for era in [run2_nanoAOD_94XMiniAODv1,]:
era.toModify(tauTable,
Expand All @@ -161,14 +160,23 @@ def _tauId8WPMask(pattern,doc):
run2_miniAOD_80XLegacy.toModify(tauTable,
variables = _variables80X
)
for era in [run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1]:
for era in [run2_nanoAOD_94XMiniAODv1]:
era.toModify(tauTable.variables,
rawDeepTau2017v2VSe = None,
rawDeepTau2017v2VSmu = None,
rawDeepTau2017v2VSjet = None,
idDeepTau2017v2VSe = None,
idDeepTau2017v2VSmu = None,
idDeepTau2017v2VSjet = None,
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)")
)
for era in [run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1]:
era.toModify(tauTable.variables,
rawDeepTau2017v2p1VSe = None,
rawDeepTau2017v2p1VSmu = None,
rawDeepTau2017v2p1VSjet = None,
idDeepTau2017v2p1VSe = None,
idDeepTau2017v2p1VSmu = None,
idDeepTau2017v2p1VSjet = None,
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)"),
Expand Down
22 changes: 12 additions & 10 deletions PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,23 +343,25 @@ def miniAOD_customizeCommon(process):
process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
)
#-- Adding DeepTauID
updatedTauName = 'slimmedTausDeepIDs'
noUpdatedTauName = 'slimmedTausNoDeepIDs'
# deepTau v2p1
_updatedTauName = 'slimmedTausDeepIDsv2p1'
_noUpdatedTauName = 'slimmedTausNoDeepIDs'
import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
tauIdEmbedder = tauIdConfig.TauIDEmbedder(
process, cms, debug = False,
updatedTauName = updatedTauName,
toKeep = ['deepTau2017v2']
updatedTauName = _updatedTauName,
toKeep = ['deepTau2017v2p1']
)
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.deepTau2017v2p1.taus = _noUpdatedTauName
process.slimmedTaus = getattr(process, _updatedTauName).clone(
src = _noUpdatedTauName
)
process.rerunMvaIsolationTask.add(process.slimmedTaus)
task.add(process.rerunMvaIsolationTask)
process.deepTauIDTask = cms.Task(process.deepTau2017v2p1, process.slimmedTaus)
task.add(process.deepTauIDTask)

#-- 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
Expand Down
21 changes: 17 additions & 4 deletions RecoTauTag/RecoTau/plugins/DeepTauId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ class DeepTauId : public deep_tau::DeepTauBase {
desc.add<bool>("mem_mapped", false);
desc.add<unsigned>("version", 2);
desc.add<int>("debug_level", 0);
desc.add<bool>("disable_dxy_pca", false);

edm::ParameterSetDescription descWP;
descWP.add<std::string>("VVVLoose", "0");
Expand All @@ -855,7 +856,8 @@ class DeepTauId : public deep_tau::DeepTauBase {
muons_token_(consumes<MuonCollection>(cfg.getParameter<edm::InputTag>("muons"))),
rho_token_(consumes<double>(cfg.getParameter<edm::InputTag>("rho"))),
version(cfg.getParameter<unsigned>("version")),
debug_level(cfg.getParameter<int>("debug_level")) {
debug_level(cfg.getParameter<int>("debug_level")),
disable_dxy_pca_(cfg.getParameter<bool>("disable_dxy_pca")) {
if (version == 1) {
input_layer_ = cache_->getGraph().node(0).name();
output_layer_ = cache_->getGraph().node(cache_->getGraph().node_size() - 1).name();
Expand Down Expand Up @@ -1171,9 +1173,19 @@ class DeepTauId : public deep_tau::DeepTauBase {
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;
Expand Down Expand Up @@ -2048,6 +2060,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<tensorflow::Tensor> tauBlockTensor_;
std::array<std::shared_ptr<tensorflow::Tensor>, 2> eGammaTensor_, muonTensor_, hadronsTensor_, convTensor_,
zeroOutputTensor_;
Expand Down
Loading