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 "deepTau2017v2",
"deepTau2017v2p1",
"deepTau2018v2p5",
19 def __init__(self, process, debug = False,
20 originalTauName = "slimmedTaus",
21 updatedTauName = "slimmedTausNewID",
23 toKeep = ["deepTau2017v2p1", "deepTau2018v2p5"],
24 tauIdDiscrMVA_trainings_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017", },
25 tauIdDiscrMVA_WPs_run2_2017 = {
26 'tauIdMVAIsoDBoldDMwLT2017' : {
27 'Eff95' :
"DBoldDMwLTEff95",
28 'Eff90' :
"DBoldDMwLTEff90",
29 'Eff80' :
"DBoldDMwLTEff80",
30 'Eff70' :
"DBoldDMwLTEff70",
31 'Eff60' :
"DBoldDMwLTEff60",
32 'Eff50' :
"DBoldDMwLTEff50",
33 'Eff40' :
"DBoldDMwLTEff40" 36 tauIdDiscrMVA_2017_version =
"v1",
39 super(TauIDEmbedder, self).
__init__()
45 self.
process.
load(
'RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
46 if len(conditionDB) != 0:
47 self.
process.CondDBTauConnection.connect = cms.string(conditionDB)
48 self.
process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
58 if discr
not in TauIDEmbedder.availableDiscriminators:
59 raise RuntimeError(
'TauIDEmbedder: discriminator "{}" is not supported'.
format(discr))
65 """returns 'CMSSW_X_Y_Z'""" 66 cmssw_version = os.environ[
"CMSSW_VERSION"]
67 if debug:
print (
"get_cmssw_version:", cmssw_version)
72 """returns '(release, subversion, patch)' (without 'CMSSW_')""" 73 v = klass.get_cmssw_version().
split(
"CMSSW_")[1].
split(
"_")[0:3]
74 if debug:
print (
"get_cmssw_version_number:", v)
79 return int(v[0]),
int(v[1]), patch
83 version = release * 10000 + subversion * 100 + patch + 1
84 if debug:
print (
"versionToInt:", version)
90 split_cmssw_version = klass.get_cmssw_version_number()
91 if klass.versionToInt(release, subversion, patch) > klass.versionToInt(split_cmssw_version[0], split_cmssw_version[1], split_cmssw_version[2]):
92 if debug:
print (
"is_above_cmssw_version:",
False)
95 if debug:
print (
"is_above_cmssw_version:",
True)
99 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)))
102 if self.
debug:
print (
"loadMVA_WPs_run2_2017: performed")
106 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
108 record = cms.string(
'GBRWrapperRcd'),
115 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
117 record = cms.string(
'PhysicsTGraphPayloadRcd'),
123 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
125 record = cms.string(
'PhysicsTFormulaPayloadRcd'),
132 _rerunMvaIsolationTask = cms.Task()
133 _rerunMvaIsolationSequence = cms.Sequence()
134 tauIDSources = cms.PSet()
137 if "2017v1" in self.
toKeep:
140 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
143 'tauIdMVAIsoDBoldDMwLT2017' : {
144 'Eff95' :
"DBoldDMwLTEff95",
145 'Eff90' :
"DBoldDMwLTEff90",
146 'Eff80' :
"DBoldDMwLTEff80",
147 'Eff70' :
"DBoldDMwLTEff70",
148 'Eff60' :
"DBoldDMwLTEff60",
149 'Eff50' :
"DBoldDMwLTEff50",
150 'Eff40' :
"DBoldDMwLTEff40" 155 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")
158 _byIsolationOldDMMVArun2017v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v1raw"+self.
postfix 159 setattr(self.
process,_byIsolationOldDMMVArun2017v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
161 Prediscriminants = noPrediscriminants,
162 loadMVAfromDB = cms.bool(
True),
163 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
164 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
165 verbosity = cms.int32(0)
168 _byIsolationOldDMMVArun2017v1 =
"rerunDiscriminationByIsolationOldDMMVArun2017v1"+self.
postfix 169 setattr(self.
process,_byIsolationOldDMMVArun2017v1,patDiscriminationByIsolationMVArun2v1.clone(
171 Prediscriminants = noPrediscriminants,
172 toMultiplex = _byIsolationOldDMMVArun2017v1raw,
173 loadMVAfromDB = cms.bool(
True),
174 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"),
177 category = cms.uint32(0),
178 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
179 variable = cms.string(
"pt"),
182 workingPoints = cms.vstring(
193 _rerunIsolationOldDMMVArun2017v1Task = cms.Task(
194 getattr(self.
process,_byIsolationOldDMMVArun2017v1raw),
195 getattr(self.
process,_byIsolationOldDMMVArun2017v1)
197 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v1Task)
198 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v1Task)
200 tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"raw")
201 tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff95")
202 tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff90")
203 tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff80")
204 tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff70")
205 tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff60")
206 tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff50")
207 tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff40")
210 if "2017v2" in self.
toKeep:
213 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
216 'tauIdMVAIsoDBoldDMwLT2017' : {
217 'Eff95' :
"DBoldDMwLTEff95",
218 'Eff90' :
"DBoldDMwLTEff90",
219 'Eff80' :
"DBoldDMwLTEff80",
220 'Eff70' :
"DBoldDMwLTEff70",
221 'Eff60' :
"DBoldDMwLTEff60",
222 'Eff50' :
"DBoldDMwLTEff50",
223 'Eff40' :
"DBoldDMwLTEff40" 228 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")
231 _byIsolationOldDMMVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v2raw"+self.
postfix 232 setattr(self.
process,_byIsolationOldDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
234 Prediscriminants = noPrediscriminants,
235 loadMVAfromDB = cms.bool(
True),
236 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
237 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
238 verbosity = cms.int32(0)
241 _byIsolationOldDMMVArun2017v2 =
"rerunDiscriminationByIsolationOldDMMVArun2017v2"+self.
postfix 242 setattr(self.
process,_byIsolationOldDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
244 Prediscriminants = noPrediscriminants,
245 toMultiplex = _byIsolationOldDMMVArun2017v2raw,
246 loadMVAfromDB = cms.bool(
True),
247 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"),
250 category = cms.uint32(0),
251 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
252 variable = cms.string(
"pt"),
255 workingPoints = cms.vstring(
264 verbosity = cms.int32(0)
267 _rerunIsolationOldDMMVArun2017v2Task = cms.Task(
268 getattr(self.
process,_byIsolationOldDMMVArun2017v2raw),
269 getattr(self.
process,_byIsolationOldDMMVArun2017v2)
271 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v2Task)
272 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v2Task)
274 tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"raw")
275 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff95")
276 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff90")
277 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff80")
278 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff70")
279 tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff60")
280 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff50")
281 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff40")
283 if "newDM2017v2" in self.
toKeep:
286 'tauIdMVAIsoDBnewDMwLT2017' :
"tauIdMVAIsoDBnewDMwLT2017",
289 'tauIdMVAIsoDBnewDMwLT2017' : {
290 'Eff95' :
"DBnewDMwLTEff95",
291 'Eff90' :
"DBnewDMwLTEff90",
292 'Eff80' :
"DBnewDMwLTEff80",
293 'Eff70' :
"DBnewDMwLTEff70",
294 'Eff60' :
"DBnewDMwLTEff60",
295 'Eff50' :
"DBnewDMwLTEff50",
296 'Eff40' :
"DBnewDMwLTEff40" 301 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")
304 _byIsolationNewDMMVArun2017v2raw =
"rerunDiscriminationByIsolationNewDMMVArun2017v2raw"+self.
postfix 305 setattr(self.
process,_byIsolationNewDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
307 Prediscriminants = noPrediscriminants,
308 loadMVAfromDB = cms.bool(
True),
309 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
310 mvaOpt = cms.string(
"DBnewDMwLTwGJ"),
311 verbosity = cms.int32(0)
314 _byIsolationNewDMMVArun2017v2 =
"rerunDiscriminationByIsolationNewDMMVArun2017v2"+self.
postfix 315 setattr(self.
process,_byIsolationNewDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
317 Prediscriminants = noPrediscriminants,
318 toMultiplex = _byIsolationNewDMMVArun2017v2raw,
319 loadMVAfromDB = cms.bool(
True),
320 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"),
323 category = cms.uint32(0),
324 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
325 variable = cms.string(
"pt"),
328 workingPoints = cms.vstring(
337 verbosity = cms.int32(0)
340 _rerunIsolationNewDMMVArun2017v2Task = cms.Task(
341 getattr(self.
process,_byIsolationNewDMMVArun2017v2raw),
342 getattr(self.
process,_byIsolationNewDMMVArun2017v2)
344 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2017v2Task)
345 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2017v2Task)
347 tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"raw")
348 tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff95")
349 tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff90")
350 tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff80")
351 tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff70")
352 tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff60")
353 tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff50")
354 tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff40")
356 if "dR0p32017v2" in self.
toKeep:
359 'tauIdMVAIsoDBoldDMdR0p3wLT2017' :
"tauIdMVAIsoDBoldDMdR0p3wLT2017",
362 'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
363 'Eff95' :
"DBoldDMdR0p3wLTEff95",
364 'Eff90' :
"DBoldDMdR0p3wLTEff90",
365 'Eff80' :
"DBoldDMdR0p3wLTEff80",
366 'Eff70' :
"DBoldDMdR0p3wLTEff70",
367 'Eff60' :
"DBoldDMdR0p3wLTEff60",
368 'Eff50' :
"DBoldDMdR0p3wLTEff50",
369 'Eff40' :
"DBoldDMdR0p3wLTEff40" 374 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")
377 _byIsolationOldDMdR0p3MVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw"+self.
postfix 378 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
380 Prediscriminants = noPrediscriminants,
381 loadMVAfromDB = cms.bool(
True),
382 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
383 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
384 srcChargedIsoPtSum = cms.string(
'chargedIsoPtSumdR03'),
385 srcFootprintCorrection = cms.string(
'footprintCorrectiondR03'),
386 srcNeutralIsoPtSum = cms.string(
'neutralIsoPtSumdR03'),
387 srcPhotonPtSumOutsideSignalCone = cms.string(
'photonPtSumOutsideSignalConedR03'),
388 verbosity = cms.int32(0)
391 _byIsolationOldDMdR0p3MVArun2017v2 =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2"+self.
postfix 392 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
394 Prediscriminants = noPrediscriminants,
395 toMultiplex = _byIsolationOldDMdR0p3MVArun2017v2raw,
396 loadMVAfromDB = cms.bool(
True),
397 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"),
400 category = cms.uint32(0),
401 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
402 variable = cms.string(
"pt"),
405 workingPoints = cms.vstring(
414 verbosity = cms.int32(0)
417 _rerunIsolationOldDMdR0p3MVArun2017v2Task = cms.Task(
418 getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw),
419 getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2)
421 _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
422 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
424 tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"raw")
425 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff95")
426 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff90")
427 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff80")
428 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff70")
429 tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff60")
430 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff50")
431 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff40")
460 if "2016v1" in self.
toKeep:
461 _byIsolationOldDMMVArun2016v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2v1raw"+self.
postfix 462 setattr(self.
process,_byIsolationOldDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
464 Prediscriminants = noPrediscriminants,
465 loadMVAfromDB = cms.bool(
True),
466 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
467 mvaOpt = cms.string(
"DBoldDMwLT"),
468 verbosity = cms.int32(0)
471 _byIsolationOldDMMVArun2016v1 =
"rerunDiscriminationByIsolationOldDMMVArun2v1"+self.
postfix 472 setattr(self.
process,_byIsolationOldDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
474 Prediscriminants = noPrediscriminants,
475 toMultiplex = _byIsolationOldDMMVArun2016v1raw,
476 loadMVAfromDB = cms.bool(
True),
477 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
480 category = cms.uint32(0),
481 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
482 variable = cms.string(
"pt"),
485 workingPoints = cms.vstring(
495 _rerunIsolationOldDMMVArun2016v1Task = cms.Task(
496 getattr(self.
process,_byIsolationOldDMMVArun2016v1raw),
497 getattr(self.
process,_byIsolationOldDMMVArun2016v1)
499 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2016v1Task)
500 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2016v1Task)
502 tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"raw")
503 tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff90")
504 tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff80")
505 tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff70")
506 tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff60")
507 tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff50")
508 tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff40")
511 if "newDM2016v1" in self.
toKeep:
512 _byIsolationNewDMMVArun2016v1raw =
"rerunDiscriminationByIsolationNewDMMVArun2v1raw"+self.
postfix 513 setattr(self.
process,_byIsolationNewDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
515 Prediscriminants = noPrediscriminants,
516 loadMVAfromDB = cms.bool(
True),
517 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
518 mvaOpt = cms.string(
"DBnewDMwLT"),
519 verbosity = cms.int32(0)
522 _byIsolationNewDMMVArun2016v1 =
"rerunDiscriminationByIsolationNewDMMVArun2v1"+self.
postfix 523 setattr(self.
process,_byIsolationNewDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
525 Prediscriminants = noPrediscriminants,
526 toMultiplex = _byIsolationNewDMMVArun2016v1raw,
527 loadMVAfromDB = cms.bool(
True),
528 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
531 category = cms.uint32(0),
532 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
533 variable = cms.string(
"pt"),
536 workingPoints = cms.vstring(
546 _rerunIsolationNewDMMVArun2016v1Task = cms.Task(
547 getattr(self.
process,_byIsolationNewDMMVArun2016v1raw),
548 getattr(self.
process,_byIsolationNewDMMVArun2016v1)
550 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2016v1Task)
551 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2016v1Task)
553 tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"raw")
554 tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff90")
555 tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff80")
556 tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff70")
557 tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff60")
558 tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff50")
559 tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff40")
561 if "deepTau2017v2" in self.
toKeep:
562 if self.
debug:
print (
"Adding DeepTau IDs")
564 _deepTauName =
"deepTau2017v2" 567 "VVVLoose": 0.0630386,
568 "VVLoose": 0.1686942,
574 "VVTight": 0.9928449,
583 "VVVLoose": 0.2599605,
584 "VVLoose": 0.4249705,
590 "VVTight": 0.9733927,
595 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
596 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
597 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
601 Prediscriminants = noPrediscriminants,
603 graph_file = file_names,
604 version = full_version[1],
610 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
611 _rerunMvaIsolationTask.add(_deepTauProducer)
612 _rerunMvaIsolationSequence += _deepTauProducer
615 if "deepTau2017v2p1" in self.
toKeep:
616 if self.
debug:
print (
"Adding DeepTau IDs")
618 _deepTauName =
"deepTau2017v2p1" 621 "VVVLoose": 0.0630386,
622 "VVLoose": 0.1686942,
628 "VVTight": 0.9928449,
637 "VVVLoose": 0.2599605,
638 "VVLoose": 0.4249705,
644 "VVTight": 0.9733927,
649 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
650 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
651 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
655 Prediscriminants = noPrediscriminants,
657 graph_file = file_names,
658 version = full_version[1],
660 disable_dxy_pca =
True 665 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
666 _rerunMvaIsolationTask.add(_deepTauProducer)
667 _rerunMvaIsolationSequence += _deepTauProducer
669 if "deepTau2018v2p5" in self.
toKeep:
670 if self.
debug:
print (
"Adding DeepTau IDs")
672 _deepTauName =
"deepTau2018v2p5" 680 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_core.pb',
681 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_inner.pb',
682 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_outer.pb',
686 Prediscriminants = noPrediscriminants,
688 graph_file = file_names,
689 version = full_version[1],
690 sub_version = full_version[2],
691 disable_dxy_pca =
True,
692 disable_hcalFraction_workaround =
True,
693 disable_CellIndex_workaround =
True 698 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
699 _rerunMvaIsolationTask.add(_deepTauProducer)
700 _rerunMvaIsolationSequence += _deepTauProducer
702 if "againstEle2018" in self.
toKeep:
703 antiElectronDiscrMVA6_version =
"MVA6v3_noeveto" 707 _byElectronRejectionMVA62018Raw =
"patTauDiscriminationByElectronRejectionMVA62018Raw"+self.
postfix 708 setattr(self.
process,_byElectronRejectionMVA62018Raw,patTauDiscriminationAgainstElectronMVA6.clone(
710 Prediscriminants = noPrediscriminants,
711 srcElectrons = cms.InputTag(
'slimmedElectrons'),
712 vetoEcalCracks = cms.bool(
False),
713 mvaName_NoEleMatch_wGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL',
714 mvaName_NoEleMatch_wGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC',
715 mvaName_NoEleMatch_woGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL',
716 mvaName_NoEleMatch_woGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC',
717 mvaName_wGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL',
718 mvaName_wGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC',
719 mvaName_woGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL',
720 mvaName_woGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC' 724 _byElectronRejectionMVA62018 =
"patTauDiscriminationByElectronRejectionMVA62018"+self.
postfix 725 setattr(self.
process,
"patTauDiscriminationByElectronRejectionMVA62018"+self.
postfix,patTauDiscriminantCutMultiplexer.clone(
727 Prediscriminants = noPrediscriminants,
728 toMultiplex = _byElectronRejectionMVA62018Raw,
731 category = cms.uint32(0),
732 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL'),
733 variable = cms.string(
'pt')
736 category = cms.uint32(2),
737 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL'),
738 variable = cms.string(
'pt')
741 category = cms.uint32(5),
742 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL'),
743 variable = cms.string(
'pt')
746 category = cms.uint32(7),
747 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL'),
748 variable = cms.string(
'pt')
751 category = cms.uint32(8),
752 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC'),
753 variable = cms.string(
'pt')
756 category = cms.uint32(10),
757 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC'),
758 variable = cms.string(
'pt')
761 category = cms.uint32(13),
762 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC'),
763 variable = cms.string(
'pt')
766 category = cms.uint32(15),
767 cut = cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC'),
768 variable = cms.string(
'pt')
771 workingPoints = cms.vstring(
780 _patTauDiscriminationByElectronRejectionMVA62018Task = cms.Task(
781 getattr(self.
process,_byElectronRejectionMVA62018Raw),
782 getattr(self.
process,_byElectronRejectionMVA62018)
784 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA62018Task)
785 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA62018Task)
787 _againstElectronTauIDSources = cms.PSet(
788 againstElectronMVA6Raw2018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"raw"),
789 againstElectronMVA6category2018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"category"),
790 againstElectronVLooseMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff98"),
791 againstElectronLooseMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff90"),
792 againstElectronMediumMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff80"),
793 againstElectronTightMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff70"),
794 againstElectronVTightMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff60")
796 _tauIDSourcesWithAgainistEle = cms.PSet(
797 tauIDSources.clone(),
798 _againstElectronTauIDSources
800 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
802 if "newDMPhase2v1" in self.
toKeep:
803 if self.
debug:
print (
"Adding newDMPhase2v1 ID")
805 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)))
806 _byIsolationNewDMMVAPhase2raw =
"rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw"+self.
postfix 807 setattr(self.
process,_byIsolationNewDMMVAPhase2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
809 Prediscriminants = noPrediscriminants,
810 loadMVAfromDB =
True,
811 mvaName =
'RecoTauTag_tauIdMVAIsoPhase2',
812 mvaOpt =
'DBnewDMwLTwGJPhase2',
816 _byIsolationNewDMMVAPhase2 =
"rerunDiscriminationByIsolationMVADBnewDMwLTPhase2"+self.
postfix 817 setattr(self.
process,_byIsolationNewDMMVAPhase2,patDiscriminationByIsolationMVArun2v1.clone(
819 Prediscriminants = noPrediscriminants,
820 toMultiplex = _byIsolationNewDMMVAPhase2raw,
821 loadMVAfromDB =
True,
822 mvaOutput_normalization =
'RecoTauTag_tauIdMVAIsoPhase2_mvaOutput_normalization',
825 category = cms.uint32(0),
826 cut = cms.string(
"RecoTauTag_tauIdMVAIsoPhase2"),
827 variable = cms.string(
"pt"),
830 workingPoints = cms.vstring(
840 _rerunIsolationMVADBnewDMwLTPhase2Task = cms.Task(
841 getattr(self.
process,_byIsolationNewDMMVAPhase2raw),
842 getattr(self.
process,_byIsolationNewDMMVAPhase2)
844 _rerunMvaIsolationTask.add(_rerunIsolationMVADBnewDMwLTPhase2Task)
845 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationMVADBnewDMwLTPhase2Task)
847 tauIDSources.byIsolationMVADBnewDMwLTPhase2raw =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"raw")
848 tauIDSources.byVVLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VVLoose")
849 tauIDSources.byVLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VLoose")
850 tauIDSources.byLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Loose")
851 tauIDSources.byMediumIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Medium")
852 tauIDSources.byTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Tight")
853 tauIDSources.byVTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VTight")
854 tauIDSources.byVVTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VVTight")
856 if "againstElePhase2v1" in self.
toKeep:
857 if self.
debug:
print (
"Adding anti-e Phase2v1 ID")
860 from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6Phase2_cff
import patTauDiscriminationAgainstElectronMVA6Phase2Raw, patTauDiscriminationAgainstElectronMVA6Phase2, mergedSlimmedElectronsForTauId
861 _byElectronRejectionMVA6Phase2v1Raw =
"patTauDiscriminationByElectronRejectionMVA6Phase2v1Raw"+self.
postfix 862 setattr(self.
process,_byElectronRejectionMVA6Phase2v1Raw,patTauDiscriminationAgainstElectronMVA6Phase2Raw.clone(
864 Prediscriminants = noPrediscriminants
867 _byElectronRejectionMVA6Phase2v1 =
"patTauDiscriminationByElectronRejectionMVA6Phase2v1"+self.
postfix 868 setattr(self.
process,_byElectronRejectionMVA6Phase2v1,patTauDiscriminationAgainstElectronMVA6Phase2.clone(
870 Prediscriminants = noPrediscriminants,
871 toMultiplex = _byElectronRejectionMVA6Phase2v1Raw
874 if not hasattr(self.
process,
"mergedSlimmedElectronsForTauId"):
875 self.
process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
876 _patTauDiscriminationByElectronRejectionMVA6Phase2v1Task = cms.Task(
877 self.
process.mergedSlimmedElectronsForTauId,
878 getattr(self.
process,_byElectronRejectionMVA6Phase2v1Raw),
879 getattr(self.
process,_byElectronRejectionMVA6Phase2v1)
881 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
882 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
884 _againstElectronTauIDPhase2v1Sources = cms.PSet(
885 againstElectronMVA6RawPhase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"raw"),
886 againstElectronMVA6categoryPhase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"category"),
887 againstElectronVLooseMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_VLoose"),
888 againstElectronLooseMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Loose"),
889 againstElectronMediumMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Medium"),
890 againstElectronTightMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Tight"),
891 againstElectronVTightMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_VTight")
893 _tauIDSourcesWithAgainistElePhase2v1 = cms.PSet(
894 tauIDSources.clone(),
895 _againstElectronTauIDPhase2v1Sources
897 tauIDSources =_tauIDSourcesWithAgainistElePhase2v1.clone()
901 embedID = cms.EDProducer(
"PATTauIDEmbedder",
903 tauIDSources = tauIDSources
907 tauIDSources = cms.PSet(
911 if not hasattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix):
912 setattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix,_rerunMvaIsolationTask)
914 _updatedRerunMvaIsolationTask = getattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix)
915 _updatedRerunMvaIsolationTask.add(_rerunMvaIsolationTask)
916 setattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix,_updatedRerunMvaIsolationTask)
917 if not hasattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix):
918 setattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix,_rerunMvaIsolationSequence)
920 _updatedRerunMvaIsolationSequence = getattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix)
921 _updatedRerunMvaIsolationSequence += _rerunMvaIsolationSequence
922 setattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix,_updatedRerunMvaIsolationSequence)
926 for target,points
in workingPoints_.items():
927 setattr(tauIDSources,
'by{}VS{}raw'.
format(producer_name[0].upper()+producer_name[1:], target),
928 cms.PSet(inputTag = cms.InputTag(producer_name+self.
postfix,
'VS{}'.
format(target)), workingPointIndex = cms.int32(-1)))
931 for index, (point,cut)
in enumerate(points.items()):
932 cut_expressions.append(
str(cut))
934 setattr(tauIDSources,
'by{}{}VS{}'.
format(point, producer_name[0].upper()+producer_name[1:], target),
935 cms.PSet(inputTag = cms.InputTag(producer_name+self.
postfix,
'VS{}'.
format(target)), workingPointIndex = cms.int32(index)))
936 if len(cut_expressions) > 0:
937 setattr(getattr(self.
process, producer_name+self.
postfix),
'VS{}WP'.
format(target), cms.vstring(*cut_expressions))
941 """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \ 942 (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \ 943 {year}v{version}p{subversion}""" 944 version_search = re.search(
'(20[1,2][125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
945 if not version_search:
946 raise RuntimeError(
'File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \ 947 Unable to extract version number.'.
format(file_name))
948 year = version_search.group(1)
949 version = version_search.group(2)
950 subversion = version_search.group(3)
951 if len(subversion) > 0:
952 subversion = subversion[1:]
955 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)