1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
6 from RecoTauTag.RecoTau.tauIdWPsDefs
import WORKING_POINTS_v2p1, WORKING_POINTS_v2p5
12 """class to rerun the tau seq and acces trainings from the database""" 13 availableDiscriminators = [
14 "2017v1",
"2017v2",
"newDM2017v2",
"dR0p32017v2",
"2016v1",
"newDM2016v1",
15 "deepTau2017v2",
"deepTau2017v2p1",
"deepTau2018v2p5",
21 def __init__(self, process, debug = False,
22 originalTauName = "slimmedTaus",
23 updatedTauName = "slimmedTausNewID",
25 toKeep = ["deepTau2017v2p1", "deepTau2018v2p5"],
26 tauIdDiscrMVA_trainings_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017", },
27 tauIdDiscrMVA_WPs_run2_2017 = {
28 'tauIdMVAIsoDBoldDMwLT2017' : {
29 'Eff95' :
"DBoldDMwLTEff95",
30 'Eff90' :
"DBoldDMwLTEff90",
31 'Eff80' :
"DBoldDMwLTEff80",
32 'Eff70' :
"DBoldDMwLTEff70",
33 'Eff60' :
"DBoldDMwLTEff60",
34 'Eff50' :
"DBoldDMwLTEff50",
35 'Eff40' :
"DBoldDMwLTEff40" 38 tauIdDiscrMVA_2017_version =
"v1",
41 super(TauIDEmbedder, self).
__init__()
47 self.
process.
load(
'RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
48 if len(conditionDB) != 0:
49 self.
process.CondDBTauConnection.connect = cms.string(conditionDB)
50 self.
process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
60 if discr
not in TauIDEmbedder.availableDiscriminators:
61 raise RuntimeError(
'TauIDEmbedder: discriminator "{}" is not supported'.
format(discr))
66 """returns 'CMSSW_X_Y_Z'""" 67 cmssw_version = os.environ[
"CMSSW_VERSION"]
68 if debug:
print (
"get_cmssw_version:", cmssw_version)
73 """returns '(release, subversion, patch)' (without 'CMSSW_')""" 74 v = klass.get_cmssw_version().
split(
"CMSSW_")[1].
split(
"_")[0:3]
75 if debug:
print (
"get_cmssw_version_number:", v)
80 return int(v[0]),
int(v[1]), patch
84 version = release * 10000 + subversion * 100 + patch + 1
85 if debug:
print (
"versionToInt:", version)
91 split_cmssw_version = klass.get_cmssw_version_number()
92 if klass.versionToInt(release, subversion, patch) > klass.versionToInt(split_cmssw_version[0], split_cmssw_version[1], split_cmssw_version[2]):
93 if debug:
print (
"is_above_cmssw_version:",
False)
96 if debug:
print (
"is_above_cmssw_version:",
True)
100 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)))
103 if self.
debug:
print (
"loadMVA_WPs_run2_2017: performed")
107 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
109 record = cms.string(
'GBRWrapperRcd'),
116 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
118 record = cms.string(
'PhysicsTGraphPayloadRcd'),
124 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
126 record = cms.string(
'PhysicsTFormulaPayloadRcd'),
133 _rerunMvaIsolationTask = cms.Task()
134 _rerunMvaIsolationSequence = cms.Sequence()
135 tauIDSources = cms.PSet()
138 if "2017v1" in self.
toKeep:
141 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
144 'tauIdMVAIsoDBoldDMwLT2017' : {
145 'Eff95' :
"DBoldDMwLTEff95",
146 'Eff90' :
"DBoldDMwLTEff90",
147 'Eff80' :
"DBoldDMwLTEff80",
148 'Eff70' :
"DBoldDMwLTEff70",
149 'Eff60' :
"DBoldDMwLTEff60",
150 'Eff50' :
"DBoldDMwLTEff50",
151 'Eff40' :
"DBoldDMwLTEff40" 156 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")
159 _byIsolationOldDMMVArun2017v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v1raw"+self.
postfix 160 setattr(self.
process,_byIsolationOldDMMVArun2017v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
162 Prediscriminants = noPrediscriminants,
163 loadMVAfromDB = cms.bool(
True),
164 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
165 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
166 verbosity = cms.int32(0)
169 _byIsolationOldDMMVArun2017v1 =
"rerunDiscriminationByIsolationOldDMMVArun2017v1"+self.
postfix 170 setattr(self.
process,_byIsolationOldDMMVArun2017v1,patDiscriminationByIsolationMVArun2v1.clone(
172 Prediscriminants = noPrediscriminants,
173 toMultiplex = _byIsolationOldDMMVArun2017v1raw,
174 loadMVAfromDB = cms.bool(
True),
175 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"),
178 category = cms.uint32(0),
179 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
180 variable = cms.string(
"pt"),
183 workingPoints = cms.vstring(
194 _rerunIsolationOldDMMVArun2017v1Task = cms.Task(
195 getattr(self.
process,_byIsolationOldDMMVArun2017v1raw),
196 getattr(self.
process,_byIsolationOldDMMVArun2017v1)
198 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v1Task)
199 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v1Task)
201 tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"raw")
202 tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff95")
203 tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff90")
204 tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff80")
205 tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff70")
206 tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff60")
207 tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff50")
208 tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff40")
211 if "2017v2" in self.
toKeep:
214 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
217 'tauIdMVAIsoDBoldDMwLT2017' : {
218 'Eff95' :
"DBoldDMwLTEff95",
219 'Eff90' :
"DBoldDMwLTEff90",
220 'Eff80' :
"DBoldDMwLTEff80",
221 'Eff70' :
"DBoldDMwLTEff70",
222 'Eff60' :
"DBoldDMwLTEff60",
223 'Eff50' :
"DBoldDMwLTEff50",
224 'Eff40' :
"DBoldDMwLTEff40" 229 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")
232 _byIsolationOldDMMVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v2raw"+self.
postfix 233 setattr(self.
process,_byIsolationOldDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
235 Prediscriminants = noPrediscriminants,
236 loadMVAfromDB = cms.bool(
True),
237 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
238 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
239 verbosity = cms.int32(0)
242 _byIsolationOldDMMVArun2017v2 =
"rerunDiscriminationByIsolationOldDMMVArun2017v2"+self.
postfix 243 setattr(self.
process,_byIsolationOldDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
245 Prediscriminants = noPrediscriminants,
246 toMultiplex = _byIsolationOldDMMVArun2017v2raw,
247 loadMVAfromDB = cms.bool(
True),
248 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"),
251 category = cms.uint32(0),
252 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
253 variable = cms.string(
"pt"),
256 workingPoints = cms.vstring(
265 verbosity = cms.int32(0)
268 _rerunIsolationOldDMMVArun2017v2Task = cms.Task(
269 getattr(self.
process,_byIsolationOldDMMVArun2017v2raw),
270 getattr(self.
process,_byIsolationOldDMMVArun2017v2)
272 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v2Task)
273 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v2Task)
275 tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"raw")
276 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff95")
277 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff90")
278 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff80")
279 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff70")
280 tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff60")
281 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff50")
282 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff40")
284 if "newDM2017v2" in self.
toKeep:
287 'tauIdMVAIsoDBnewDMwLT2017' :
"tauIdMVAIsoDBnewDMwLT2017",
290 'tauIdMVAIsoDBnewDMwLT2017' : {
291 'Eff95' :
"DBnewDMwLTEff95",
292 'Eff90' :
"DBnewDMwLTEff90",
293 'Eff80' :
"DBnewDMwLTEff80",
294 'Eff70' :
"DBnewDMwLTEff70",
295 'Eff60' :
"DBnewDMwLTEff60",
296 'Eff50' :
"DBnewDMwLTEff50",
297 'Eff40' :
"DBnewDMwLTEff40" 302 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")
305 _byIsolationNewDMMVArun2017v2raw =
"rerunDiscriminationByIsolationNewDMMVArun2017v2raw"+self.
postfix 306 setattr(self.
process,_byIsolationNewDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
308 Prediscriminants = noPrediscriminants,
309 loadMVAfromDB = cms.bool(
True),
310 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
311 mvaOpt = cms.string(
"DBnewDMwLTwGJ"),
312 verbosity = cms.int32(0)
315 _byIsolationNewDMMVArun2017v2 =
"rerunDiscriminationByIsolationNewDMMVArun2017v2"+self.
postfix 316 setattr(self.
process,_byIsolationNewDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
318 Prediscriminants = noPrediscriminants,
319 toMultiplex = _byIsolationNewDMMVArun2017v2raw,
320 loadMVAfromDB = cms.bool(
True),
321 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"),
324 category = cms.uint32(0),
325 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
326 variable = cms.string(
"pt"),
329 workingPoints = cms.vstring(
338 verbosity = cms.int32(0)
341 _rerunIsolationNewDMMVArun2017v2Task = cms.Task(
342 getattr(self.
process,_byIsolationNewDMMVArun2017v2raw),
343 getattr(self.
process,_byIsolationNewDMMVArun2017v2)
345 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2017v2Task)
346 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2017v2Task)
348 tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"raw")
349 tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff95")
350 tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff90")
351 tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff80")
352 tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff70")
353 tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff60")
354 tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff50")
355 tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff40")
357 if "dR0p32017v2" in self.
toKeep:
360 'tauIdMVAIsoDBoldDMdR0p3wLT2017' :
"tauIdMVAIsoDBoldDMdR0p3wLT2017",
363 'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
364 'Eff95' :
"DBoldDMdR0p3wLTEff95",
365 'Eff90' :
"DBoldDMdR0p3wLTEff90",
366 'Eff80' :
"DBoldDMdR0p3wLTEff80",
367 'Eff70' :
"DBoldDMdR0p3wLTEff70",
368 'Eff60' :
"DBoldDMdR0p3wLTEff60",
369 'Eff50' :
"DBoldDMdR0p3wLTEff50",
370 'Eff40' :
"DBoldDMdR0p3wLTEff40" 375 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")
378 _byIsolationOldDMdR0p3MVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw"+self.
postfix 379 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
381 Prediscriminants = noPrediscriminants,
382 loadMVAfromDB = cms.bool(
True),
383 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
384 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
385 srcChargedIsoPtSum = cms.string(
'chargedIsoPtSumdR03'),
386 srcFootprintCorrection = cms.string(
'footprintCorrectiondR03'),
387 srcNeutralIsoPtSum = cms.string(
'neutralIsoPtSumdR03'),
388 srcPhotonPtSumOutsideSignalCone = cms.string(
'photonPtSumOutsideSignalConedR03'),
389 verbosity = cms.int32(0)
392 _byIsolationOldDMdR0p3MVArun2017v2 =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2"+self.
postfix 393 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
395 Prediscriminants = noPrediscriminants,
396 toMultiplex = _byIsolationOldDMdR0p3MVArun2017v2raw,
397 loadMVAfromDB = cms.bool(
True),
398 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"),
401 category = cms.uint32(0),
402 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
403 variable = cms.string(
"pt"),
406 workingPoints = cms.vstring(
415 verbosity = cms.int32(0)
418 _rerunIsolationOldDMdR0p3MVArun2017v2Task = cms.Task(
419 getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw),
420 getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2)
422 _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
423 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
425 tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"raw")
426 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff95")
427 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff90")
428 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff80")
429 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff70")
430 tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff60")
431 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff50")
432 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff40")
461 if "2016v1" in self.
toKeep:
462 _byIsolationOldDMMVArun2016v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2v1raw"+self.
postfix 463 setattr(self.
process,_byIsolationOldDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
465 Prediscriminants = noPrediscriminants,
466 loadMVAfromDB = cms.bool(
True),
467 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
468 mvaOpt = cms.string(
"DBoldDMwLT"),
469 verbosity = cms.int32(0)
472 _byIsolationOldDMMVArun2016v1 =
"rerunDiscriminationByIsolationOldDMMVArun2v1"+self.
postfix 473 setattr(self.
process,_byIsolationOldDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
475 Prediscriminants = noPrediscriminants,
476 toMultiplex = _byIsolationOldDMMVArun2016v1raw,
477 loadMVAfromDB = cms.bool(
True),
478 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
481 category = cms.uint32(0),
482 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
483 variable = cms.string(
"pt"),
486 workingPoints = cms.vstring(
496 _rerunIsolationOldDMMVArun2016v1Task = cms.Task(
497 getattr(self.
process,_byIsolationOldDMMVArun2016v1raw),
498 getattr(self.
process,_byIsolationOldDMMVArun2016v1)
500 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2016v1Task)
501 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2016v1Task)
503 tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"raw")
504 tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff90")
505 tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff80")
506 tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff70")
507 tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff60")
508 tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff50")
509 tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff40")
512 if "newDM2016v1" in self.
toKeep:
513 _byIsolationNewDMMVArun2016v1raw =
"rerunDiscriminationByIsolationNewDMMVArun2v1raw"+self.
postfix 514 setattr(self.
process,_byIsolationNewDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
516 Prediscriminants = noPrediscriminants,
517 loadMVAfromDB = cms.bool(
True),
518 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
519 mvaOpt = cms.string(
"DBnewDMwLT"),
520 verbosity = cms.int32(0)
523 _byIsolationNewDMMVArun2016v1 =
"rerunDiscriminationByIsolationNewDMMVArun2v1"+self.
postfix 524 setattr(self.
process,_byIsolationNewDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
526 Prediscriminants = noPrediscriminants,
527 toMultiplex = _byIsolationNewDMMVArun2016v1raw,
528 loadMVAfromDB = cms.bool(
True),
529 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
532 category = cms.uint32(0),
533 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
534 variable = cms.string(
"pt"),
537 workingPoints = cms.vstring(
547 _rerunIsolationNewDMMVArun2016v1Task = cms.Task(
548 getattr(self.
process,_byIsolationNewDMMVArun2016v1raw),
549 getattr(self.
process,_byIsolationNewDMMVArun2016v1)
551 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2016v1Task)
552 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2016v1Task)
554 tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"raw")
555 tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff90")
556 tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff80")
557 tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff70")
558 tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff60")
559 tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff50")
560 tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff40")
562 if "deepTau2017v2" in self.
toKeep:
563 if self.
debug:
print (
"Adding DeepTau IDs")
565 _deepTauName =
"deepTau2017v2" 566 workingPoints_ = WORKING_POINTS_v2p1
569 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
570 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
571 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
575 Prediscriminants = noPrediscriminants,
577 graph_file = file_names,
578 version = full_version[1],
584 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
585 _rerunMvaIsolationTask.add(_deepTauProducer)
586 _rerunMvaIsolationSequence += _deepTauProducer
589 if "deepTau2017v2p1" in self.
toKeep:
590 if self.
debug:
print (
"Adding DeepTau IDs")
592 _deepTauName =
"deepTau2017v2p1" 593 workingPoints_ = WORKING_POINTS_v2p1
596 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
597 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
598 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
602 Prediscriminants = noPrediscriminants,
604 graph_file = file_names,
605 version = full_version[1],
607 disable_dxy_pca =
True 612 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
613 _rerunMvaIsolationTask.add(_deepTauProducer)
614 _rerunMvaIsolationSequence += _deepTauProducer
616 if "deepTau2018v2p5" in self.
toKeep:
617 if self.
debug:
print (
"Adding DeepTau IDs")
619 _deepTauName =
"deepTau2018v2p5" 627 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_core.pb',
628 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_inner.pb',
629 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_outer.pb',
633 Prediscriminants = noPrediscriminants,
635 graph_file = file_names,
636 version = full_version[1],
637 sub_version = full_version[2],
638 disable_dxy_pca =
True,
639 disable_hcalFraction_workaround =
True,
640 disable_CellIndex_workaround =
True 645 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
646 _rerunMvaIsolationTask.add(_deepTauProducer)
647 _rerunMvaIsolationSequence += _deepTauProducer
649 if "againstEle2018" in self.
toKeep:
650 antiElectronDiscrMVA6_version =
"MVA6v3_noeveto" 654 _byElectronRejectionMVA62018Raw =
"patTauDiscriminationByElectronRejectionMVA62018Raw"+self.
postfix 655 setattr(self.
process,_byElectronRejectionMVA62018Raw,patTauDiscriminationAgainstElectronMVA6.clone(
657 Prediscriminants = noPrediscriminants,
658 srcElectrons = cms.InputTag(
'slimmedElectrons'),
659 vetoEcalCracks = cms.bool(
False),
660 mvaName_NoEleMatch_wGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL',
661 mvaName_NoEleMatch_wGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC',
662 mvaName_NoEleMatch_woGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL',
663 mvaName_NoEleMatch_woGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC',
664 mvaName_wGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL',
665 mvaName_wGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC',
666 mvaName_woGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL',
667 mvaName_woGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC' 671 _byElectronRejectionMVA62018 =
"patTauDiscriminationByElectronRejectionMVA62018"+self.
postfix 672 setattr(self.
process,
"patTauDiscriminationByElectronRejectionMVA62018"+self.
postfix,patTauDiscriminantCutMultiplexer.clone(
674 Prediscriminants = noPrediscriminants,
675 toMultiplex = _byElectronRejectionMVA62018Raw,
678 category = cms.uint32(0),
679 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL'),
680 variable = cms.string(
'pt')
683 category = cms.uint32(2),
684 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL'),
685 variable = cms.string(
'pt')
688 category = cms.uint32(5),
689 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL'),
690 variable = cms.string(
'pt')
693 category = cms.uint32(7),
694 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL'),
695 variable = cms.string(
'pt')
698 category = cms.uint32(8),
699 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC'),
700 variable = cms.string(
'pt')
703 category = cms.uint32(10),
704 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC'),
705 variable = cms.string(
'pt')
708 category = cms.uint32(13),
709 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC'),
710 variable = cms.string(
'pt')
713 category = cms.uint32(15),
714 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC'),
715 variable = cms.string(
'pt')
718 workingPoints = cms.vstring(
727 _patTauDiscriminationByElectronRejectionMVA62018Task = cms.Task(
728 getattr(self.
process,_byElectronRejectionMVA62018Raw),
729 getattr(self.
process,_byElectronRejectionMVA62018)
731 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA62018Task)
732 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA62018Task)
734 _againstElectronTauIDSources = cms.PSet(
735 againstElectronMVA6Raw2018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"raw"),
736 againstElectronMVA6category2018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"category"),
737 againstElectronVLooseMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff98"),
738 againstElectronLooseMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff90"),
739 againstElectronMediumMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff80"),
740 againstElectronTightMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff70"),
741 againstElectronVTightMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff60")
743 _tauIDSourcesWithAgainistEle = cms.PSet(
744 tauIDSources.clone(),
745 _againstElectronTauIDSources
747 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
749 if "newDMPhase2v1" in self.
toKeep:
750 if self.
debug:
print (
"Adding newDMPhase2v1 ID")
752 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)))
753 _byIsolationNewDMMVAPhase2raw =
"rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw"+self.
postfix 754 setattr(self.
process,_byIsolationNewDMMVAPhase2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
756 Prediscriminants = noPrediscriminants,
757 loadMVAfromDB =
True,
758 mvaName =
'RecoTauTag_tauIdMVAIsoPhase2',
759 mvaOpt =
'DBnewDMwLTwGJPhase2',
763 _byIsolationNewDMMVAPhase2 =
"rerunDiscriminationByIsolationMVADBnewDMwLTPhase2"+self.
postfix 764 setattr(self.
process,_byIsolationNewDMMVAPhase2,patDiscriminationByIsolationMVArun2v1.clone(
766 Prediscriminants = noPrediscriminants,
767 toMultiplex = _byIsolationNewDMMVAPhase2raw,
768 loadMVAfromDB =
True,
769 mvaOutput_normalization =
'RecoTauTag_tauIdMVAIsoPhase2_mvaOutput_normalization',
772 category = cms.uint32(0),
773 cut = cms.string(
"RecoTauTag_tauIdMVAIsoPhase2"),
774 variable = cms.string(
"pt"),
777 workingPoints = cms.vstring(
787 _rerunIsolationMVADBnewDMwLTPhase2Task = cms.Task(
788 getattr(self.
process,_byIsolationNewDMMVAPhase2raw),
789 getattr(self.
process,_byIsolationNewDMMVAPhase2)
791 _rerunMvaIsolationTask.add(_rerunIsolationMVADBnewDMwLTPhase2Task)
792 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationMVADBnewDMwLTPhase2Task)
794 tauIDSources.byIsolationMVADBnewDMwLTPhase2raw =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"raw")
795 tauIDSources.byVVLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VVLoose")
796 tauIDSources.byVLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VLoose")
797 tauIDSources.byLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Loose")
798 tauIDSources.byMediumIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Medium")
799 tauIDSources.byTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Tight")
800 tauIDSources.byVTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VTight")
801 tauIDSources.byVVTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VVTight")
803 if "againstElePhase2v1" in self.
toKeep:
804 if self.
debug:
print (
"Adding anti-e Phase2v1 ID")
807 from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6Phase2_cff
import patTauDiscriminationAgainstElectronMVA6Phase2Raw, patTauDiscriminationAgainstElectronMVA6Phase2, mergedSlimmedElectronsForTauId
808 _byElectronRejectionMVA6Phase2v1Raw =
"patTauDiscriminationByElectronRejectionMVA6Phase2v1Raw"+self.
postfix 809 setattr(self.
process,_byElectronRejectionMVA6Phase2v1Raw,patTauDiscriminationAgainstElectronMVA6Phase2Raw.clone(
811 Prediscriminants = noPrediscriminants
814 _byElectronRejectionMVA6Phase2v1 =
"patTauDiscriminationByElectronRejectionMVA6Phase2v1"+self.
postfix 815 setattr(self.
process,_byElectronRejectionMVA6Phase2v1,patTauDiscriminationAgainstElectronMVA6Phase2.clone(
817 Prediscriminants = noPrediscriminants,
818 toMultiplex = _byElectronRejectionMVA6Phase2v1Raw
821 if not hasattr(self.
process,
"mergedSlimmedElectronsForTauId"):
822 self.
process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
823 _patTauDiscriminationByElectronRejectionMVA6Phase2v1Task = cms.Task(
824 self.
process.mergedSlimmedElectronsForTauId,
825 getattr(self.
process,_byElectronRejectionMVA6Phase2v1Raw),
826 getattr(self.
process,_byElectronRejectionMVA6Phase2v1)
828 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
829 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
831 _againstElectronTauIDPhase2v1Sources = cms.PSet(
832 againstElectronMVA6RawPhase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"raw"),
833 againstElectronMVA6categoryPhase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"category"),
834 againstElectronVLooseMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_VLoose"),
835 againstElectronLooseMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Loose"),
836 againstElectronMediumMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Medium"),
837 againstElectronTightMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Tight"),
838 againstElectronVTightMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_VTight")
840 _tauIDSourcesWithAgainistElePhase2v1 = cms.PSet(
841 tauIDSources.clone(),
842 _againstElectronTauIDPhase2v1Sources
844 tauIDSources =_tauIDSourcesWithAgainistElePhase2v1.clone()
848 embedID = cms.EDProducer(
"PATTauIDEmbedder",
850 tauIDSources = tauIDSources
854 tauIDSources = cms.PSet(
858 if not hasattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix):
859 setattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix,_rerunMvaIsolationTask)
861 _updatedRerunMvaIsolationTask = getattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix)
862 _updatedRerunMvaIsolationTask.add(_rerunMvaIsolationTask)
863 setattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix,_updatedRerunMvaIsolationTask)
864 if not hasattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix):
865 setattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix,_rerunMvaIsolationSequence)
867 _updatedRerunMvaIsolationSequence = getattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix)
868 _updatedRerunMvaIsolationSequence += _rerunMvaIsolationSequence
869 setattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix,_updatedRerunMvaIsolationSequence)
873 for target,points
in workingPoints_.items():
874 setattr(tauIDSources,
'by{}VS{}raw'.
format(producer_name[0].upper()+producer_name[1:], target),
875 cms.PSet(inputTag = cms.InputTag(producer_name+self.
postfix,
'VS{}'.
format(target)), workingPointIndex = cms.int32(-1)))
878 for index, (point,cut)
in enumerate(points.items()):
879 cut_expressions.append(
str(cut))
881 setattr(tauIDSources,
'by{}{}VS{}'.
format(point, producer_name[0].upper()+producer_name[1:], target),
882 cms.PSet(inputTag = cms.InputTag(producer_name+self.
postfix,
'VS{}'.
format(target)), workingPointIndex = cms.int32(index)))
883 if len(cut_expressions) > 0:
884 setattr(getattr(self.
process, producer_name+self.
postfix),
'VS{}WP'.
format(target), cms.vstring(*cut_expressions))
888 """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \ 889 (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \ 890 {year}v{version}p{subversion}""" 891 version_search = re.search(
'(20[1,2][125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
892 if not version_search:
893 raise RuntimeError(
'File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \ 894 Unable to extract version number.'.
format(file_name))
895 year = version_search.group(1)
896 version = version_search.group(2)
897 subversion = version_search.group(3)
898 if len(subversion) > 0:
899 subversion = subversion[1:]
902 return int(year),
int(version),
int(subversion)
tauIdDiscrMVA_2017_version
def is_above_cmssw_version(klass, release=9, subversion=4, patch=0, debug=False)
def getDeepTauVersion(self, file_name)
def get_cmssw_version_number(klass, debug=False)
tauIdDiscrMVA_WPs_run2_2017
def get_cmssw_version(debug=False)
tauIdDiscrMVA_trainings_run2_2017
def loadMVA_WPs_run2_2017(self)
def processDeepProducer(self, producer_name, tauIDSources, workingPoints_)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
def tauIDMVAinputs(self, module, wp)
def versionToInt(release=9, subversion=4, patch=0, debug=False)