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 (backport to 10_2_X) #27879

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions RecoTauTag/RecoTau/plugins/DeepTauId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,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 @@ -601,7 +602,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();
Expand Down Expand Up @@ -907,9 +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;
Expand Down Expand Up @@ -1687,6 +1699,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
70 changes: 66 additions & 4 deletions RecoTauTag/RecoTau/python/tools/runTauIdMVA.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,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' : {
Expand Down Expand Up @@ -650,7 +652,9 @@ 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_)
Expand Down Expand Up @@ -705,7 +709,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)

)

Expand All @@ -714,6 +719,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)"

Expand Down
2 changes: 1 addition & 1 deletion RecoTauTag/RecoTau/test/runDeepTauIDsOnMiniAOD.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
updatedTauName = updatedTauName,
toKeep = [ "2017v2", "dR0p32017v2", "newDM2017v2",
# "deepTau2017v1",
"deepTau2017v2",
"deepTau2017v2p1",
# "DPFTau_2016_v0",
# "DPFTau_2016_v1",
"againstEle2018"
Expand Down