1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
10 """class to rerun the tau seq and acces trainings from the database"""
11 availableDiscriminators = [
12 "2017v1",
"2017v2",
"newDM2017v2",
"dR0p32017v2",
"2016v1",
"newDM2016v1",
13 "deepTau2017v1",
"deepTau2017v2",
"deepTau2017v2p1",
14 "DPFTau_2016_v0",
"DPFTau_2016_v1",
19 updatedTauName = "slimmedTausNewID",
20 toKeep = ["deepTau2017v2p1"],
21 tauIdDiscrMVA_trainings_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017", },
22 tauIdDiscrMVA_WPs_run2_2017 = {
23 'tauIdMVAIsoDBoldDMwLT2017' : {
24 'Eff95' :
"DBoldDMwLTEff95",
25 'Eff90' :
"DBoldDMwLTEff90",
26 'Eff80' :
"DBoldDMwLTEff80",
27 'Eff70' :
"DBoldDMwLTEff70",
28 'Eff60' :
"DBoldDMwLTEff60",
29 'Eff50' :
"DBoldDMwLTEff50",
30 'Eff40' :
"DBoldDMwLTEff40"
33 tauIdDiscrMVA_2017_version =
"v1",
36 super(TauIDEmbedder, self).
__init__()
40 self.
process.
load(
'RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
41 if len(conditionDB) != 0:
42 self.
process.CondDBTauConnection.connect = cms.string(conditionDB)
43 self.
process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
53 if discr
not in TauIDEmbedder.availableDiscriminators:
54 raise RuntimeError(
'TauIDEmbedder: discriminator "{}" is not supported'.
format(discr))
60 """returns 'CMSSW_X_Y_Z'"""
61 cmssw_version = os.environ[
"CMSSW_VERSION"]
62 if debug:
print (
"get_cmssw_version:", cmssw_version)
67 """returns '(release, subversion, patch)' (without 'CMSSW_')"""
68 v = klass.get_cmssw_version().
split(
"CMSSW_")[1].
split(
"_")[0:3]
69 if debug:
print (
"get_cmssw_version_number:", v)
74 return int(v[0]),
int(v[1]), patch
78 version = release * 10000 + subversion * 100 + patch + 1
79 if debug:
print (
"versionToInt:", version)
85 split_cmssw_version = klass.get_cmssw_version_number()
86 if klass.versionToInt(release, subversion, patch) > klass.versionToInt(split_cmssw_version[0], split_cmssw_version[1], split_cmssw_version[2]):
87 if debug:
print (
"is_above_cmssw_version:",
False)
90 if debug:
print (
"is_above_cmssw_version:",
True)
94 return cms.PSet(inputTag = cms.InputTag(module), workingPointIndex = cms.int32(-1
if wp==
"raw" else -2
if wp==
"category" else getattr(self.
process, module).workingPoints.index(wp)))
97 if self.
debug:
print (
"loadMVA_WPs_run2_2017: performed")
101 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
103 record = cms.string(
'GBRWrapperRcd'),
110 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
112 record = cms.string(
'PhysicsTGraphPayloadRcd'),
118 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
120 record = cms.string(
'PhysicsTFormulaPayloadRcd'),
127 self.
process.rerunMvaIsolationTask = cms.Task()
128 self.
process.rerunMvaIsolationSequence = cms.Sequence()
129 tauIDSources = cms.PSet()
132 if "2017v1" in self.
toKeep:
135 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
138 'tauIdMVAIsoDBoldDMwLT2017' : {
139 'Eff95' :
"DBoldDMwLTEff95",
140 'Eff90' :
"DBoldDMwLTEff90",
141 'Eff80' :
"DBoldDMwLTEff80",
142 'Eff70' :
"DBoldDMwLTEff70",
143 'Eff60' :
"DBoldDMwLTEff60",
144 'Eff50' :
"DBoldDMwLTEff50",
145 'Eff40' :
"DBoldDMwLTEff40"
150 if self.
debug:
print (
"runTauID: not is_above_cmssw_version(9, 4, 4). Will update the list of available in DB samples to access 2017v1")
153 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
154 PATTauProducer = cms.InputTag(
'slimmedTaus'),
155 Prediscriminants = noPrediscriminants,
156 loadMVAfromDB = cms.bool(
True),
157 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
158 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
159 verbosity = cms.int32(0)
162 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v1 = patDiscriminationByIsolationMVArun2v1.clone(
163 PATTauProducer = cms.InputTag(
'slimmedTaus'),
164 Prediscriminants = noPrediscriminants,
165 toMultiplex = cms.InputTag(
'rerunDiscriminationByIsolationOldDMMVArun2017v1raw'),
166 loadMVAfromDB = cms.bool(
True),
167 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"),
170 category = cms.uint32(0),
171 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
172 variable = cms.string(
"pt"),
175 workingPoints = cms.vstring(
187 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw,
188 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v1
193 tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"raw")
194 tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"_WPEff95")
195 tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"_WPEff90")
196 tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"_WPEff80")
197 tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"_WPEff70")
198 tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"_WPEff60")
199 tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"_WPEff50")
200 tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v1",
"_WPEff40")
203 if "2017v2" in self.
toKeep:
206 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
209 'tauIdMVAIsoDBoldDMwLT2017' : {
210 'Eff95' :
"DBoldDMwLTEff95",
211 'Eff90' :
"DBoldDMwLTEff90",
212 'Eff80' :
"DBoldDMwLTEff80",
213 'Eff70' :
"DBoldDMwLTEff70",
214 'Eff60' :
"DBoldDMwLTEff60",
215 'Eff50' :
"DBoldDMwLTEff50",
216 'Eff40' :
"DBoldDMwLTEff40"
221 if self.
debug:
print (
"runTauID: not is_above_cmssw_version(9, 4, 5). Will update the list of available in DB samples to access 2017v2")
224 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
225 PATTauProducer = cms.InputTag(
'slimmedTaus'),
226 Prediscriminants = noPrediscriminants,
227 loadMVAfromDB = cms.bool(
True),
228 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
229 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
230 verbosity = cms.int32(0)
233 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v2 = patDiscriminationByIsolationMVArun2v1.clone(
234 PATTauProducer = cms.InputTag(
'slimmedTaus'),
235 Prediscriminants = noPrediscriminants,
236 toMultiplex = cms.InputTag(
'rerunDiscriminationByIsolationOldDMMVArun2017v2raw'),
237 loadMVAfromDB = cms.bool(
True),
238 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"),
241 category = cms.uint32(0),
242 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
243 variable = cms.string(
"pt"),
246 workingPoints = cms.vstring(
255 verbosity = cms.int32(0)
259 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw,
260 self.
process.rerunDiscriminationByIsolationOldDMMVArun2017v2
265 tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"raw")
266 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"_WPEff95")
267 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"_WPEff90")
268 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"_WPEff80")
269 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"_WPEff70")
270 tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"_WPEff60")
271 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"_WPEff50")
272 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2017v2",
"_WPEff40")
274 if "newDM2017v2" in self.
toKeep:
277 'tauIdMVAIsoDBnewDMwLT2017' :
"tauIdMVAIsoDBnewDMwLT2017",
280 'tauIdMVAIsoDBnewDMwLT2017' : {
281 'Eff95' :
"DBnewDMwLTEff95",
282 'Eff90' :
"DBnewDMwLTEff90",
283 'Eff80' :
"DBnewDMwLTEff80",
284 'Eff70' :
"DBnewDMwLTEff70",
285 'Eff60' :
"DBnewDMwLTEff60",
286 'Eff50' :
"DBnewDMwLTEff50",
287 'Eff40' :
"DBnewDMwLTEff40"
292 if self.
debug:
print (
"runTauID: not is_above_cmssw_version(9, 4, 5). Will update the list of available in DB samples to access newDM2017v2")
295 self.
process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
296 PATTauProducer = cms.InputTag(
'slimmedTaus'),
297 Prediscriminants = noPrediscriminants,
298 loadMVAfromDB = cms.bool(
True),
299 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
300 mvaOpt = cms.string(
"DBnewDMwLTwGJ"),
301 verbosity = cms.int32(0)
304 self.
process.rerunDiscriminationByIsolationNewDMMVArun2017v2 = patDiscriminationByIsolationMVArun2v1.clone(
305 PATTauProducer = cms.InputTag(
'slimmedTaus'),
306 Prediscriminants = noPrediscriminants,
307 toMultiplex = cms.InputTag(
'rerunDiscriminationByIsolationNewDMMVArun2017v2raw'),
308 loadMVAfromDB = cms.bool(
True),
309 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"),
312 category = cms.uint32(0),
313 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
314 variable = cms.string(
"pt"),
317 workingPoints = cms.vstring(
326 verbosity = cms.int32(0)
330 self.
process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw,
331 self.
process.rerunDiscriminationByIsolationNewDMMVArun2017v2
336 tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"raw")
337 tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"_WPEff95")
338 tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"_WPEff90")
339 tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"_WPEff80")
340 tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"_WPEff70")
341 tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"_WPEff60")
342 tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"_WPEff50")
343 tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2017v2",
"_WPEff40")
345 if "dR0p32017v2" in self.
toKeep:
348 'tauIdMVAIsoDBoldDMdR0p3wLT2017' :
"tauIdMVAIsoDBoldDMdR0p3wLT2017",
351 'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
352 'Eff95' :
"DBoldDMdR0p3wLTEff95",
353 'Eff90' :
"DBoldDMdR0p3wLTEff90",
354 'Eff80' :
"DBoldDMdR0p3wLTEff80",
355 'Eff70' :
"DBoldDMdR0p3wLTEff70",
356 'Eff60' :
"DBoldDMdR0p3wLTEff60",
357 'Eff50' :
"DBoldDMdR0p3wLTEff50",
358 'Eff40' :
"DBoldDMdR0p3wLTEff40"
363 if self.
debug:
print (
"runTauID: not is_above_cmssw_version(9, 4, 5). Will update the list of available in DB samples to access dR0p32017v2")
366 self.
process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
367 PATTauProducer = cms.InputTag(
'slimmedTaus'),
368 Prediscriminants = noPrediscriminants,
369 loadMVAfromDB = cms.bool(
True),
370 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
371 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
372 srcChargedIsoPtSum = cms.string(
'chargedIsoPtSumdR03'),
373 srcFootprintCorrection = cms.string(
'footprintCorrectiondR03'),
374 srcNeutralIsoPtSum = cms.string(
'neutralIsoPtSumdR03'),
375 srcPhotonPtSumOutsideSignalCone = cms.string(
'photonPtSumOutsideSignalConedR03'),
376 verbosity = cms.int32(0)
379 self.
process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2= patDiscriminationByIsolationMVArun2v1.clone(
380 PATTauProducer = cms.InputTag(
'slimmedTaus'),
381 Prediscriminants = noPrediscriminants,
382 toMultiplex = cms.InputTag(
'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw'),
383 loadMVAfromDB = cms.bool(
True),
384 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"),
387 category = cms.uint32(0),
388 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
389 variable = cms.string(
"pt"),
392 workingPoints = cms.vstring(
401 verbosity = cms.int32(0)
405 self.
process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw,
406 self.
process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2
411 tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"raw")
412 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"_WPEff95")
413 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"_WPEff90")
414 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"_WPEff80")
415 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"_WPEff70")
416 tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"_WPEff60")
417 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"_WPEff50")
418 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2",
"_WPEff40")
447 if "2016v1" in self.
toKeep:
448 self.
process.rerunDiscriminationByIsolationOldDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
449 PATTauProducer = cms.InputTag(
'slimmedTaus'),
450 Prediscriminants = noPrediscriminants,
451 loadMVAfromDB = cms.bool(
True),
452 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
453 mvaOpt = cms.string(
"DBoldDMwLT"),
454 verbosity = cms.int32(0)
457 self.
process.rerunDiscriminationByIsolationOldDMMVArun2v1 = patDiscriminationByIsolationMVArun2v1.clone(
458 PATTauProducer = cms.InputTag(
'slimmedTaus'),
459 Prediscriminants = noPrediscriminants,
460 toMultiplex = cms.InputTag(
'rerunDiscriminationByIsolationOldDMMVArun2v1raw'),
461 loadMVAfromDB = cms.bool(
True),
462 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
465 category = cms.uint32(0),
466 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
467 variable = cms.string(
"pt"),
470 workingPoints = cms.vstring(
481 self.
process.rerunDiscriminationByIsolationOldDMMVArun2v1raw,
482 self.
process.rerunDiscriminationByIsolationOldDMMVArun2v1
487 tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2v1",
"raw")
488 tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2v1",
"_WPEff90")
489 tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2v1",
"_WPEff80")
490 tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2v1",
"_WPEff70")
491 tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2v1",
"_WPEff60")
492 tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2v1",
"_WPEff50")
493 tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationOldDMMVArun2v1",
"_WPEff40")
496 if "newDM2016v1" in self.
toKeep:
497 self.
process.rerunDiscriminationByIsolationNewDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
498 PATTauProducer = cms.InputTag(
'slimmedTaus'),
499 Prediscriminants = noPrediscriminants,
500 loadMVAfromDB = cms.bool(
True),
501 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
502 mvaOpt = cms.string(
"DBnewDMwLT"),
503 verbosity = cms.int32(0)
506 self.
process.rerunDiscriminationByIsolationNewDMMVArun2v1 = patDiscriminationByIsolationMVArun2v1.clone(
507 PATTauProducer = cms.InputTag(
'slimmedTaus'),
508 Prediscriminants = noPrediscriminants,
509 toMultiplex = cms.InputTag(
'rerunDiscriminationByIsolationNewDMMVArun2v1raw'),
510 loadMVAfromDB = cms.bool(
True),
511 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
514 category = cms.uint32(0),
515 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
516 variable = cms.string(
"pt"),
519 workingPoints = cms.vstring(
530 self.
process.rerunDiscriminationByIsolationNewDMMVArun2v1raw,
531 self.
process.rerunDiscriminationByIsolationNewDMMVArun2v1
536 tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2v1",
"raw")
537 tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2v1",
"_WPEff90")
538 tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2v1",
"_WPEff80")
539 tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2v1",
"_WPEff70")
540 tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2v1",
"_WPEff60")
541 tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2v1",
"_WPEff50")
542 tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(
"rerunDiscriminationByIsolationNewDMMVArun2v1",
"_WPEff40")
544 if "deepTau2017v1" in self.
toKeep:
545 if self.
debug:
print (
"Adding DeepTau IDs")
549 "VVVLoose" : 0.96424,
559 "VVVLoose" : 0.959619,
560 "VVLoose" : 0.997687,
580 file_names = [
'RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v1_20L1024N_quantized.pb']
581 self.
process.deepTau2017v1 = cms.EDProducer(
"DeepTauId",
582 electrons = cms.InputTag(
'slimmedElectrons'),
583 muons = cms.InputTag(
'slimmedMuons'),
584 taus = cms.InputTag(
'slimmedTaus'),
585 pfcands = cms.InputTag(
'packedPFCandidates'),
586 vertices = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
587 rho = cms.InputTag(
'fixedGridRhoAll'),
588 graph_file = cms.vstring(file_names),
589 mem_mapped = cms.bool(
False),
591 debug_level = cms.int32(0),
592 disable_dxy_pca = cms.bool(
False)
597 self.
process.rerunMvaIsolationTask.add(self.
process.deepTau2017v1)
598 self.
process.rerunMvaIsolationSequence += self.
process.deepTau2017v1
600 if "deepTau2017v2" in self.
toKeep:
601 if self.
debug:
print (
"Adding DeepTau IDs")
605 "VVVLoose": 0.0630386,
606 "VVLoose": 0.1686942,
612 "VVTight": 0.9928449,
621 "VVVLoose": 0.2599605,
622 "VVLoose": 0.4249705,
628 "VVTight": 0.9733927,
633 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
634 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
635 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
637 self.
process.deepTau2017v2 = cms.EDProducer(
"DeepTauId",
638 electrons = cms.InputTag(
'slimmedElectrons'),
639 muons = cms.InputTag(
'slimmedMuons'),
640 taus = cms.InputTag(
'slimmedTaus'),
641 pfcands = cms.InputTag(
'packedPFCandidates'),
642 vertices = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
643 rho = cms.InputTag(
'fixedGridRhoAll'),
644 graph_file = cms.vstring(file_names),
645 mem_mapped = cms.bool(
False),
647 debug_level = cms.int32(0),
648 disable_dxy_pca = cms.bool(
False)
653 self.
process.rerunMvaIsolationTask.add(self.
process.deepTau2017v2)
654 self.
process.rerunMvaIsolationSequence += self.
process.deepTau2017v2
656 if "deepTau2017v2p1" in self.
toKeep:
657 if self.
debug:
print (
"Adding DeepTau IDs")
661 "VVVLoose": 0.0630386,
662 "VVLoose": 0.1686942,
668 "VVTight": 0.9928449,
677 "VVVLoose": 0.2599605,
678 "VVLoose": 0.4249705,
684 "VVTight": 0.9733927,
689 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
690 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
691 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
693 self.
process.deepTau2017v2p1 = cms.EDProducer(
"DeepTauId",
694 electrons = cms.InputTag(
'slimmedElectrons'),
695 muons = cms.InputTag(
'slimmedMuons'),
696 taus = cms.InputTag(
'slimmedTaus'),
697 pfcands = cms.InputTag(
'packedPFCandidates'),
698 vertices = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
699 rho = cms.InputTag(
'fixedGridRhoAll'),
700 graph_file = cms.vstring(file_names),
701 mem_mapped = cms.bool(
False),
703 debug_level = cms.int32(0),
704 disable_dxy_pca = cms.bool(
True),
705 is_online = cms.bool(
False)
710 self.
process.rerunMvaIsolationTask.add(self.
process.deepTau2017v2p1)
711 self.
process.rerunMvaIsolationSequence += self.
process.deepTau2017v2p1
713 if "DPFTau_2016_v0" in self.
toKeep:
714 if self.
debug:
print (
"Adding DPFTau isolation (v0)")
718 "Tight" :
"if(decayMode == 0) return (0.898328 - 0.000160992 * pt);" + \
719 "if(decayMode == 1) return (0.910138 - 0.000229923 * pt);" + \
720 "if(decayMode == 10) return (0.873958 - 0.0002328 * pt);" + \
730 file_names = [
'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v0_quantized.pb' ]
731 self.
process.dpfTau2016v0 = cms.EDProducer(
"DPFIsolation",
732 pfcands = cms.InputTag(
'packedPFCandidates'),
733 taus = cms.InputTag(
'slimmedTaus'),
734 vertices = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
735 graph_file = cms.vstring(file_names),
737 mem_mapped = cms.bool(
False)
743 self.
process.rerunMvaIsolationSequence += self.
process.dpfTau2016v0
746 if "DPFTau_2016_v1" in self.
toKeep:
747 print (
"Adding DPFTau isolation (v1)")
748 print (
"WARNING: WPs are not defined for DPFTau_2016_v1")
749 print (
"WARNING: The score of DPFTau_2016_v1 is inverted: i.e. for Sig->0, for Bkg->1 with -1 for undefined input (preselection not passed).")
752 "all": {
"Tight" : 0.123}
755 file_names = [
'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v1_quantized.pb' ]
756 self.
process.dpfTau2016v1 = cms.EDProducer(
"DPFIsolation",
757 pfcands = cms.InputTag(
'packedPFCandidates'),
758 taus = cms.InputTag(
'slimmedTaus'),
759 vertices = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
760 graph_file = cms.vstring(file_names),
762 mem_mapped = cms.bool(
False)
768 self.
process.rerunMvaIsolationSequence += self.
process.dpfTau2016v1
770 if "againstEle2018" in self.
toKeep:
771 antiElectronDiscrMVA6_version =
"MVA6v3_noeveto"
774 from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6_cfi
import patTauDiscriminationAgainstElectronMVA6
775 self.
process.patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone(
776 Prediscriminants = noPrediscriminants,
777 vetoEcalCracks = cms.bool(
False),
778 mvaName_NoEleMatch_wGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL',
779 mvaName_NoEleMatch_wGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC',
780 mvaName_NoEleMatch_woGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL',
781 mvaName_NoEleMatch_woGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC',
782 mvaName_wGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL',
783 mvaName_wGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC',
784 mvaName_woGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL',
785 mvaName_woGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC'
789 self.
process.patTauDiscriminationByElectronRejectionMVA62018 = patTauDiscriminantCutMultiplexer.clone(
790 PATTauProducer = self.
process.patTauDiscriminationByElectronRejectionMVA62018Raw.PATTauProducer,
791 Prediscriminants = self.
process.patTauDiscriminationByElectronRejectionMVA62018Raw.Prediscriminants,
792 toMultiplex = cms.InputTag(
"patTauDiscriminationByElectronRejectionMVA62018Raw"),
795 category = cms.uint32(0),
796 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL'),
797 variable = cms.string(
'pt')
800 category = cms.uint32(2),
801 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL'),
802 variable = cms.string(
'pt')
805 category = cms.uint32(5),
806 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL'),
807 variable = cms.string(
'pt')
810 category = cms.uint32(7),
811 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL'),
812 variable = cms.string(
'pt')
815 category = cms.uint32(8),
816 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC'),
817 variable = cms.string(
'pt')
820 category = cms.uint32(10),
821 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC'),
822 variable = cms.string(
'pt')
825 category = cms.uint32(13),
826 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC'),
827 variable = cms.string(
'pt')
830 category = cms.uint32(15),
831 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC'),
832 variable = cms.string(
'pt')
835 workingPoints = cms.vstring(
844 self.
process.patTauDiscriminationByElectronRejectionMVA62018Task = cms.Task(
845 self.
process.patTauDiscriminationByElectronRejectionMVA62018Raw,
846 self.
process.patTauDiscriminationByElectronRejectionMVA62018
848 self.
process.patTauDiscriminationByElectronRejectionMVA62018Seq = cms.Sequence(self.
process.patTauDiscriminationByElectronRejectionMVA62018Task)
849 self.
process.rerunMvaIsolationTask.add(self.
process.patTauDiscriminationByElectronRejectionMVA62018Task)
850 self.
process.rerunMvaIsolationSequence += self.
process.patTauDiscriminationByElectronRejectionMVA62018Seq
852 _againstElectronTauIDSources = cms.PSet(
853 againstElectronMVA6Raw2018 = self.
tauIDMVAinputs(
"patTauDiscriminationByElectronRejectionMVA62018",
"raw"),
854 againstElectronMVA6category2018 = self.
tauIDMVAinputs(
"patTauDiscriminationByElectronRejectionMVA62018",
"category"),
855 againstElectronVLooseMVA62018 = self.
tauIDMVAinputs(
"patTauDiscriminationByElectronRejectionMVA62018",
"_WPeff98"),
856 againstElectronLooseMVA62018 = self.
tauIDMVAinputs(
"patTauDiscriminationByElectronRejectionMVA62018",
"_WPeff90"),
857 againstElectronMediumMVA62018 = self.
tauIDMVAinputs(
"patTauDiscriminationByElectronRejectionMVA62018",
"_WPeff80"),
858 againstElectronTightMVA62018 = self.
tauIDMVAinputs(
"patTauDiscriminationByElectronRejectionMVA62018",
"_WPeff70"),
859 againstElectronVTightMVA62018 = self.
tauIDMVAinputs(
"patTauDiscriminationByElectronRejectionMVA62018",
"_WPeff60")
861 _tauIDSourcesWithAgainistEle = cms.PSet(
862 tauIDSources.clone(),
863 _againstElectronTauIDSources
865 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
870 embedID = cms.EDProducer(
"PATTauIDEmbedder",
871 src = cms.InputTag(
'slimmedTaus'),
872 tauIDSources = tauIDSources
876 tauIDSources = cms.PSet(
883 for target,points
in six.iteritems(workingPoints_):
884 setattr(tauIDSources,
'by{}VS{}raw'.
format(producer_name[0].
upper()+producer_name[1:], target),
885 cms.PSet(inputTag = cms.InputTag(producer_name,
'VS{}'.
format(target)), workingPointIndex = cms.int32(-1)))
888 for index, (point,cut)
in enumerate(six.iteritems(points)):
889 cut_expressions.append(
str(cut))
891 setattr(tauIDSources,
'by{}{}VS{}'.
format(point, producer_name[0].
upper()+producer_name[1:], target),
892 cms.PSet(inputTag = cms.InputTag(producer_name,
'VS{}'.
format(target)), workingPointIndex = cms.int32(index)))
894 setattr(getattr(self.
process, producer_name),
'VS{}WP'.
format(target), cms.vstring(*cut_expressions))
898 """returns the DNN version. File name should contain a version label with data takig year (2011-2, 2015-8) and \
899 version number (vX), e.g. 2017v0, in general the following format: {year}v{version}"""
900 version_search = re.search(
'201[125678]v([0-9]+)[\._]', file_name)
901 if not version_search:
902 raise RuntimeError(
'File "{}" has an invalid name pattern, should be in the format "{year}v{version}". \
903 Unable to extract version number.'.
format(file_name))
904 version = version_search.group(1)
908 """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \
909 (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \
910 {year}v{version}p{subversion}"""
911 version_search = re.search(
'(201[125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
912 if not version_search:
913 raise RuntimeError(
'File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \
914 Unable to extract version number.'.
format(file_name))
915 year = version_search.group(1)
916 version = version_search.group(2)
917 subversion = version_search.group(3)
918 if len(subversion) > 0:
919 subversion = subversion[1:]
922 return int(year),
int(version),
int(subversion)