1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
4 from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff
import patDiscriminationByIsolationMVArun2v1raw, patDiscriminationByIsolationMVArun2v1
6 from RecoTauTag.RecoTau.DeepTauIdSonicProducer_cfi
import DeepTauIdSonicProducer
7 from RecoTauTag.RecoTau.tauIdWPsDefs
import WORKING_POINTS_v2p1, WORKING_POINTS_v2p5, WORKING_POINTS_PHASEII_v2p5
13 """class to rerun the tau seq and acces trainings from the database""" 14 experimentalDiscriminators = [
15 "2017v1",
"2017v2",
"newDM2017v2",
"dR0p32017v2",
"2016v1",
"newDM2016v1",
18 availableDiscriminators = experimentalDiscriminators.copy()
19 availableDiscriminators.extend([
20 "mvaIso",
"mvaIsoNewDM",
"mvaIsoDR0p3",
24 "deepTau2017v2",
"deepTau2017v2p1",
"deepTau2018v2p5",
"deepTau2026v2p5" 27 def __init__(self, process, debug = False,
28 originalTauName = "slimmedTaus",
29 updatedTauName = "slimmedTausNewID",
31 toKeep = ["deepTau2017v2p1", "deepTau2018v2p5", "deepTau2026v2p5"],
34 super(TauIDEmbedder, self).
__init__()
42 if discr
not in TauIDEmbedder.availableDiscriminators:
43 raise RuntimeError(
'TauIDEmbedder: discriminator "{}" is not supported'.
format(discr))
45 if not set(toKeep).isdisjoint(TauIDEmbedder.experimentalDiscriminators):
46 print(
'There are experimental tauIDs not from GT')
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)
58 """returns 'CMSSW_X_Y_Z'""" 59 cmssw_version = os.environ[
"CMSSW_VERSION"]
60 if debug:
print (
"get_cmssw_version:", cmssw_version)
65 """returns '(release, subversion, patch)' (without 'CMSSW_')""" 66 v = klass.get_cmssw_version().
split(
"CMSSW_")[1].
split(
"_")[0:3]
67 if debug:
print (
"get_cmssw_version_number:", v)
72 return int(v[0]),
int(v[1]), patch
76 version = release * 10000 + subversion * 100 + patch + 1
77 if debug:
print (
"versionToInt:", version)
83 split_cmssw_version = klass.get_cmssw_version_number()
84 if klass.versionToInt(release, subversion, patch) > klass.versionToInt(split_cmssw_version[0], split_cmssw_version[1], split_cmssw_version[2]):
85 if debug:
print (
"is_above_cmssw_version:",
False)
88 if debug:
print (
"is_above_cmssw_version:",
True)
92 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)))
95 if self.
debug:
print (
"loadMVA_WPs_run2_2017: performed")
99 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
101 record = cms.string(
'GBRWrapperRcd'),
108 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
110 record = cms.string(
'PhysicsTGraphPayloadRcd'),
116 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
118 record = cms.string(
'PhysicsTFormulaPayloadRcd'),
125 if self.
debug:
print (
"load_againstElectronMVA6: performed")
127 antiElectronDiscrMVA6_categories = {
128 '0' :
"gbr_NoEleMatch_woGwoGSF_BL",
129 '2' :
"gbr_NoEleMatch_wGwoGSF_BL",
130 '5' :
"gbr_woGwGSF_BL",
131 '7' :
"gbr_wGwGSF_BL",
132 '8' :
"gbr_NoEleMatch_woGwoGSF_EC",
133 '10' :
"gbr_NoEleMatch_wGwoGSF_EC",
134 '13' :
"gbr_woGwGSF_EC",
135 '15' :
"gbr_wGwGSF_EC" 137 for category, gbrForestName
in antiElectronDiscrMVA6_categories.items():
138 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
140 record = cms.string(
'GBRWrapperRcd'),
146 self.
process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
148 record = cms.string(
'PhysicsTGraphPayloadRcd'),
155 _rerunMvaIsolationTask = cms.Task()
156 _rerunMvaIsolationSequence = cms.Sequence()
157 tauIDSources = cms.PSet()
160 if "mvaIso" in self.
toKeep:
161 _byIsolationOldDMMVAraw =
"rerunDiscriminationByIsolationOldDMMVAraw"+self.
postfix 162 setattr(self.
process,_byIsolationOldDMMVAraw,patDiscriminationByIsolationMVArun2v1raw.clone(
164 Prediscriminants = noPrediscriminants,
165 loadMVAfromDB = cms.bool(
True),
166 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT"),
167 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
168 verbosity = cms.int32(0)
171 _byIsolationOldDMMVA =
"rerunDiscriminationByIsolationOldDMMVA"+self.
postfix 172 setattr(self.
process,_byIsolationOldDMMVA,patDiscriminationByIsolationMVArun2v1.clone(
174 Prediscriminants = noPrediscriminants,
175 toMultiplex = _byIsolationOldDMMVAraw,
176 loadMVAfromDB = cms.bool(
True),
177 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT_mvaOutput_normalization"),
180 category = cms.uint32(0),
181 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT"),
182 variable = cms.string(
"pt"),
185 workingPoints = cms.vstring(
196 _rerunIsolationOldDMMVATask = cms.Task(
197 getattr(self.
process,_byIsolationOldDMMVAraw),
198 getattr(self.
process,_byIsolationOldDMMVA)
200 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVATask)
201 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVATask)
203 tauIDSources.byIsolationMVArun2DBoldDMwLTraw = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"raw")
204 tauIDSources.byVVLooseIsolationMVArun2DBoldDMwLT = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"_VVLoose")
205 tauIDSources.byVLooseIsolationMVArun2DBoldDMwLT = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"_VLoose")
206 tauIDSources.byLooseIsolationMVArun2DBoldDMwLT = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"_Loose")
207 tauIDSources.byMediumIsolationMVArun2DBoldDMwLT = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"_Medium")
208 tauIDSources.byTightIsolationMVArun2DBoldDMwLT = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"_Tight")
209 tauIDSources.byVTightIsolationMVArun2DBoldDMwLT = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"_VTight")
210 tauIDSources.byVVTightIsolationMVArun2DBoldDMwLT = self.
tauIDMVAinputs(_byIsolationOldDMMVA,
"_VVTight")
212 if "mvaIsoNewDM" in self.
toKeep:
213 _byIsolationNewDMMVAraw =
"rerunDiscriminationByIsolationNewDMMVAraw"+self.
postfix 214 setattr(self.
process,_byIsolationNewDMMVAraw,patDiscriminationByIsolationMVArun2v1raw.clone(
216 Prediscriminants = noPrediscriminants,
217 loadMVAfromDB = cms.bool(
True),
218 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT"),
219 mvaOpt = cms.string(
"DBnewDMwLTwGJ"),
220 verbosity = cms.int32(0)
223 _byIsolationNewDMMVA =
"rerunDiscriminationByIsolationNewDMMVA"+self.
postfix 224 setattr(self.
process,_byIsolationNewDMMVA,patDiscriminationByIsolationMVArun2v1.clone(
226 Prediscriminants = noPrediscriminants,
227 toMultiplex = _byIsolationNewDMMVAraw,
228 loadMVAfromDB = cms.bool(
True),
229 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT_mvaOutput_normalization"),
232 category = cms.uint32(0),
233 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT"),
234 variable = cms.string(
"pt"),
237 workingPoints = cms.vstring(
248 _rerunIsolationNewDMMVATask = cms.Task(
249 getattr(self.
process,_byIsolationNewDMMVAraw),
250 getattr(self.
process,_byIsolationNewDMMVA)
252 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVATask)
253 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVATask)
255 tauIDSources.byIsolationMVArun2DBnewDMwLTraw = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"raw")
256 tauIDSources.byVVLooseIsolationMVArun2DBnewDMwLT = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"_VVLoose")
257 tauIDSources.byVLooseIsolationMVArun2DBnewDMwLT = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"_VLoose")
258 tauIDSources.byLooseIsolationMVArun2DBnewDMwLT = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"_Loose")
259 tauIDSources.byMediumIsolationMVArun2DBnewDMwLT = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"_Medium")
260 tauIDSources.byTightIsolationMVArun2DBnewDMwLT = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"_Tight")
261 tauIDSources.byVTightIsolationMVArun2DBnewDMwLT = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"_VTight")
262 tauIDSources.byVVTightIsolationMVArun2DBnewDMwLT = self.
tauIDMVAinputs(_byIsolationNewDMMVA,
"_VVTight")
264 if "mvaIsoDR0p3" in self.
toKeep:
265 _byIsolationOldDMdR0p3MVAraw =
"rerunDiscriminationByIsolationOldDMdR0p3MVAraw"+self.
postfix 266 setattr(self.
process,_byIsolationOldDMdR0p3MVAraw,patDiscriminationByIsolationMVArun2v1raw.clone(
268 Prediscriminants = noPrediscriminants,
269 loadMVAfromDB = cms.bool(
True),
270 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"),
271 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
272 srcChargedIsoPtSum = cms.string(
'chargedIsoPtSumdR03'),
273 srcFootprintCorrection = cms.string(
'footprintCorrectiondR03'),
274 srcNeutralIsoPtSum = cms.string(
'neutralIsoPtSumdR03'),
275 srcPhotonPtSumOutsideSignalCone = cms.string(
'photonPtSumOutsideSignalConedR03'),
276 verbosity = cms.int32(0)
279 _byIsolationOldDMdR0p3MVA =
"rerunDiscriminationByIsolationOldDMdR0p3MVA"+self.
postfix 280 setattr(self.
process,_byIsolationOldDMdR0p3MVA,patDiscriminationByIsolationMVArun2v1.clone(
282 Prediscriminants = noPrediscriminants,
283 toMultiplex = _byIsolationOldDMdR0p3MVAraw,
284 loadMVAfromDB = cms.bool(
True),
285 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT_mvaOutput_normalization"),
288 category = cms.uint32(0),
289 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"),
290 variable = cms.string(
"pt"),
293 workingPoints = cms.vstring(
304 _rerunIsolationOldDMdR0p3MVATask = cms.Task(
305 getattr(self.
process,_byIsolationOldDMdR0p3MVAraw),
306 getattr(self.
process,_byIsolationOldDMdR0p3MVA)
308 _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVATask)
309 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVATask)
311 tauIDSources.byIsolationMVArun2DBoldDMdR0p3wLTraw = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"raw")
312 tauIDSources.byVVLooseIsolationMVArun2DBoldDMdR0p3wLT = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"_VVLoose")
313 tauIDSources.byVLooseIsolationMVArun2DBoldDMdR0p3wLT = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"_VLoose")
314 tauIDSources.byLooseIsolationMVArun2DBoldDMdR0p3wLT = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"_Loose")
315 tauIDSources.byMediumIsolationMVArun2DBoldDMdR0p3wLT = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"_Medium")
316 tauIDSources.byTightIsolationMVArun2DBoldDMdR0p3wLT = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"_Tight")
317 tauIDSources.byVTightIsolationMVArun2DBoldDMdR0p3wLT = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"_VTight")
318 tauIDSources.byVVTightIsolationMVArun2DBoldDMdR0p3wLT = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVA,
"_VVTight")
321 if "2017v1" in self.
toKeep:
324 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
327 'tauIdMVAIsoDBoldDMwLT2017' : {
328 'Eff95' :
"DBoldDMwLTEff95",
329 'Eff90' :
"DBoldDMwLTEff90",
330 'Eff80' :
"DBoldDMwLTEff80",
331 'Eff70' :
"DBoldDMwLTEff70",
332 'Eff60' :
"DBoldDMwLTEff60",
333 'Eff50' :
"DBoldDMwLTEff50",
334 'Eff40' :
"DBoldDMwLTEff40" 338 if self.
debug:
print (
"runTauID: Will update the list of available in DB samples to access 2017v1")
341 _byIsolationOldDMMVArun2017v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v1raw"+self.
postfix 342 setattr(self.
process,_byIsolationOldDMMVArun2017v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
344 Prediscriminants = noPrediscriminants,
345 loadMVAfromDB = cms.bool(
True),
346 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
347 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
348 verbosity = cms.int32(0)
351 _byIsolationOldDMMVArun2017v1 =
"rerunDiscriminationByIsolationOldDMMVArun2017v1"+self.
postfix 352 setattr(self.
process,_byIsolationOldDMMVArun2017v1,patDiscriminationByIsolationMVArun2v1.clone(
354 Prediscriminants = noPrediscriminants,
355 toMultiplex = _byIsolationOldDMMVArun2017v1raw,
356 loadMVAfromDB = cms.bool(
True),
357 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"),
360 category = cms.uint32(0),
361 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
362 variable = cms.string(
"pt"),
365 workingPoints = cms.vstring(
376 _rerunIsolationOldDMMVArun2017v1Task = cms.Task(
377 getattr(self.
process,_byIsolationOldDMMVArun2017v1raw),
378 getattr(self.
process,_byIsolationOldDMMVArun2017v1)
380 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v1Task)
381 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v1Task)
383 tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"raw")
384 tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff95")
385 tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff90")
386 tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff80")
387 tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff70")
388 tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff60")
389 tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff50")
390 tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v1,
"_WPEff40")
392 if "2017v2" in self.
toKeep:
395 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
398 'tauIdMVAIsoDBoldDMwLT2017' : {
399 'Eff95' :
"DBoldDMwLTEff95",
400 'Eff90' :
"DBoldDMwLTEff90",
401 'Eff80' :
"DBoldDMwLTEff80",
402 'Eff70' :
"DBoldDMwLTEff70",
403 'Eff60' :
"DBoldDMwLTEff60",
404 'Eff50' :
"DBoldDMwLTEff50",
405 'Eff40' :
"DBoldDMwLTEff40" 409 if self.
debug:
print (
"runTauID: Will update the list of available in DB samples to access 2017v2")
412 _byIsolationOldDMMVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v2raw"+self.
postfix 413 setattr(self.
process,_byIsolationOldDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
415 Prediscriminants = noPrediscriminants,
416 loadMVAfromDB = cms.bool(
True),
417 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
418 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
419 verbosity = cms.int32(0)
422 _byIsolationOldDMMVArun2017v2 =
"rerunDiscriminationByIsolationOldDMMVArun2017v2"+self.
postfix 423 setattr(self.
process,_byIsolationOldDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
425 Prediscriminants = noPrediscriminants,
426 toMultiplex = _byIsolationOldDMMVArun2017v2raw,
427 loadMVAfromDB = cms.bool(
True),
428 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"),
431 category = cms.uint32(0),
432 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
433 variable = cms.string(
"pt"),
436 workingPoints = cms.vstring(
445 verbosity = cms.int32(0)
448 _rerunIsolationOldDMMVArun2017v2Task = cms.Task(
449 getattr(self.
process,_byIsolationOldDMMVArun2017v2raw),
450 getattr(self.
process,_byIsolationOldDMMVArun2017v2)
452 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v2Task)
453 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v2Task)
455 tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"raw")
456 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff95")
457 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff90")
458 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff80")
459 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff70")
460 tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff60")
461 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff50")
462 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2017v2,
"_WPEff40")
464 if "newDM2017v2" in self.
toKeep:
467 'tauIdMVAIsoDBnewDMwLT2017' :
"tauIdMVAIsoDBnewDMwLT2017",
470 'tauIdMVAIsoDBnewDMwLT2017' : {
471 'Eff95' :
"DBnewDMwLTEff95",
472 'Eff90' :
"DBnewDMwLTEff90",
473 'Eff80' :
"DBnewDMwLTEff80",
474 'Eff70' :
"DBnewDMwLTEff70",
475 'Eff60' :
"DBnewDMwLTEff60",
476 'Eff50' :
"DBnewDMwLTEff50",
477 'Eff40' :
"DBnewDMwLTEff40" 481 if self.
debug:
print (
"runTauID: Will update the list of available in DB samples to access newDM2017v2")
484 _byIsolationNewDMMVArun2017v2raw =
"rerunDiscriminationByIsolationNewDMMVArun2017v2raw"+self.
postfix 485 setattr(self.
process,_byIsolationNewDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
487 Prediscriminants = noPrediscriminants,
488 loadMVAfromDB = cms.bool(
True),
489 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
490 mvaOpt = cms.string(
"DBnewDMwLTwGJ"),
491 verbosity = cms.int32(0)
494 _byIsolationNewDMMVArun2017v2 =
"rerunDiscriminationByIsolationNewDMMVArun2017v2"+self.
postfix 495 setattr(self.
process,_byIsolationNewDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
497 Prediscriminants = noPrediscriminants,
498 toMultiplex = _byIsolationNewDMMVArun2017v2raw,
499 loadMVAfromDB = cms.bool(
True),
500 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"),
503 category = cms.uint32(0),
504 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
505 variable = cms.string(
"pt"),
508 workingPoints = cms.vstring(
517 verbosity = cms.int32(0)
520 _rerunIsolationNewDMMVArun2017v2Task = cms.Task(
521 getattr(self.
process,_byIsolationNewDMMVArun2017v2raw),
522 getattr(self.
process,_byIsolationNewDMMVArun2017v2)
524 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2017v2Task)
525 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2017v2Task)
527 tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"raw")
528 tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff95")
529 tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff90")
530 tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff80")
531 tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff70")
532 tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff60")
533 tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff50")
534 tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2017v2,
"_WPEff40")
536 if "dR0p32017v2" in self.
toKeep:
539 'tauIdMVAIsoDBoldDMdR0p3wLT2017' :
"tauIdMVAIsoDBoldDMdR0p3wLT2017",
542 'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
543 'Eff95' :
"DBoldDMdR0p3wLTEff95",
544 'Eff90' :
"DBoldDMdR0p3wLTEff90",
545 'Eff80' :
"DBoldDMdR0p3wLTEff80",
546 'Eff70' :
"DBoldDMdR0p3wLTEff70",
547 'Eff60' :
"DBoldDMdR0p3wLTEff60",
548 'Eff50' :
"DBoldDMdR0p3wLTEff50",
549 'Eff40' :
"DBoldDMdR0p3wLTEff40" 553 if self.
debug:
print (
"runTauID: Will update the list of available in DB samples to access dR0p32017v2")
556 _byIsolationOldDMdR0p3MVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw"+self.
postfix 557 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
559 Prediscriminants = noPrediscriminants,
560 loadMVAfromDB = cms.bool(
True),
561 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
562 mvaOpt = cms.string(
"DBoldDMwLTwGJ"),
563 srcChargedIsoPtSum = cms.string(
'chargedIsoPtSumdR03'),
564 srcFootprintCorrection = cms.string(
'footprintCorrectiondR03'),
565 srcNeutralIsoPtSum = cms.string(
'neutralIsoPtSumdR03'),
566 srcPhotonPtSumOutsideSignalCone = cms.string(
'photonPtSumOutsideSignalConedR03'),
567 verbosity = cms.int32(0)
570 _byIsolationOldDMdR0p3MVArun2017v2 =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2"+self.
postfix 571 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
573 Prediscriminants = noPrediscriminants,
574 toMultiplex = _byIsolationOldDMdR0p3MVArun2017v2raw,
575 loadMVAfromDB = cms.bool(
True),
576 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"),
579 category = cms.uint32(0),
580 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
581 variable = cms.string(
"pt"),
584 workingPoints = cms.vstring(
593 verbosity = cms.int32(0)
596 _rerunIsolationOldDMdR0p3MVArun2017v2Task = cms.Task(
597 getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw),
598 getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2)
600 _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
601 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
603 tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"raw")
604 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff95")
605 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff90")
606 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff80")
607 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff70")
608 tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff60")
609 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff50")
610 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.
tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2,
"_WPEff40")
639 if "2016v1" in self.
toKeep:
640 _byIsolationOldDMMVArun2016v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2v1raw"+self.
postfix 641 setattr(self.
process,_byIsolationOldDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
643 Prediscriminants = noPrediscriminants,
644 loadMVAfromDB = cms.bool(
True),
645 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
646 mvaOpt = cms.string(
"DBoldDMwLT"),
647 verbosity = cms.int32(0)
650 _byIsolationOldDMMVArun2016v1 =
"rerunDiscriminationByIsolationOldDMMVArun2v1"+self.
postfix 651 setattr(self.
process,_byIsolationOldDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
653 Prediscriminants = noPrediscriminants,
654 toMultiplex = _byIsolationOldDMMVArun2016v1raw,
655 loadMVAfromDB = cms.bool(
True),
656 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
659 category = cms.uint32(0),
660 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
661 variable = cms.string(
"pt"),
664 workingPoints = cms.vstring(
676 'tauIdMVAIsoDBoldDMwLT2016' :
"tauIdMVAIsoDBoldDMwLT2016",
679 'tauIdMVAIsoDBoldDMwLT2016' : {
680 'Eff90' :
"DBoldDMwLT2016Eff90",
681 'Eff80' :
"DBoldDMwLT2016Eff80",
682 'Eff70' :
"DBoldDMwLT2016Eff70",
683 'Eff60' :
"DBoldDMwLT2016Eff60",
684 'Eff50' :
"DBoldDMwLT2016Eff50",
685 'Eff40' :
"DBoldDMwLT2016Eff40" 688 if self.
debug:
print (
"runTauID: Will update the list of available in DB samples to access 2016v1")
691 _rerunIsolationOldDMMVArun2016v1Task = cms.Task(
692 getattr(self.
process,_byIsolationOldDMMVArun2016v1raw),
693 getattr(self.
process,_byIsolationOldDMMVArun2016v1)
695 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2016v1Task)
696 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2016v1Task)
698 tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"raw")
699 tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff90")
700 tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff80")
701 tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff70")
702 tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff60")
703 tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff50")
704 tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.
tauIDMVAinputs(_byIsolationOldDMMVArun2016v1,
"_WPEff40")
707 if "newDM2016v1" in self.
toKeep:
708 _byIsolationNewDMMVArun2016v1raw =
"rerunDiscriminationByIsolationNewDMMVArun2v1raw"+self.
postfix 709 setattr(self.
process,_byIsolationNewDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
711 Prediscriminants = noPrediscriminants,
712 loadMVAfromDB = cms.bool(
True),
713 mvaName = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
714 mvaOpt = cms.string(
"DBnewDMwLT"),
715 verbosity = cms.int32(0)
718 _byIsolationNewDMMVArun2016v1 =
"rerunDiscriminationByIsolationNewDMMVArun2v1"+self.
postfix 719 setattr(self.
process,_byIsolationNewDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
721 Prediscriminants = noPrediscriminants,
722 toMultiplex = _byIsolationNewDMMVArun2016v1raw,
723 loadMVAfromDB = cms.bool(
True),
724 mvaOutput_normalization = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
727 category = cms.uint32(0),
728 cut = cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
729 variable = cms.string(
"pt"),
732 workingPoints = cms.vstring(
744 'tauIdMVAIsoDBnewDMwLT2016' :
"tauIdMVAIsoDBnewDMwLT2016",
747 'tauIdMVAIsoDBnewDMwLT2016' : {
748 'Eff90' :
"DBnewDMwLT2016Eff90",
749 'Eff80' :
"DBnewDMwLT2016Eff80",
750 'Eff70' :
"DBnewDMwLT2016Eff70",
751 'Eff60' :
"DBnewDMwLT2016Eff60",
752 'Eff50' :
"DBnewDMwLT2016Eff50",
753 'Eff40' :
"DBnewDMwLT2016Eff40" 756 if self.
debug:
print (
"runTauID: Will update the list of available in DB samples to access newDM2016v1")
759 _rerunIsolationNewDMMVArun2016v1Task = cms.Task(
760 getattr(self.
process,_byIsolationNewDMMVArun2016v1raw),
761 getattr(self.
process,_byIsolationNewDMMVArun2016v1)
763 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2016v1Task)
764 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2016v1Task)
766 tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"raw")
767 tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff90")
768 tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff80")
769 tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff70")
770 tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff60")
771 tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff50")
772 tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.
tauIDMVAinputs(_byIsolationNewDMMVArun2016v1,
"_WPEff40")
774 if "deepTau2017v2" in self.
toKeep:
775 if self.
debug:
print (
"Adding DeepTau v2 IDs")
777 _deepTauName =
"deepTau2017v2" 778 workingPoints_ = WORKING_POINTS_v2p1
781 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
782 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
783 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
787 Prediscriminants = noPrediscriminants,
789 graph_file = file_names,
790 year = full_version[0],
791 version = full_version[1],
795 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
797 from Configuration.ProcessModifiers.deepTauSonicTriton_cff
import deepTauSonicTriton
798 deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
800 mode = cms.string(
'PseudoAsync'),
801 allowedTries = cms.untracked.uint32(0),
802 verbose = cms.untracked.bool(
False),
803 modelName = cms.string(
"deeptau_2017v2p1"),
804 modelVersion = cms.string(
''),
805 modelConfigPath = cms.FileInPath(
"RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2017v2p1/config.pbtxt"),
806 preferredServer = cms.untracked.string(
''),
807 timeout = cms.untracked.uint32(300),
808 useSharedMemory = cms.untracked.bool(
True),
809 compression = cms.untracked.string(
''),
810 outputs = cms.untracked.vstring()
812 Prediscriminants = noPrediscriminants,
814 year = full_version[0],
815 version = full_version[1],
821 _rerunMvaIsolationTask.add(_deepTauProducer)
822 _rerunMvaIsolationSequence += _deepTauProducer
825 if "deepTau2017v2p1" in self.
toKeep:
826 if self.
debug:
print (
"Adding DeepTau v2p1 IDs")
828 _deepTauName =
"deepTau2017v2p1" 829 workingPoints_ = WORKING_POINTS_v2p1
832 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
833 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
834 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
838 Prediscriminants = noPrediscriminants,
840 graph_file = file_names,
841 year = full_version[0],
842 version = full_version[1],
844 disable_dxy_pca =
True 847 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
849 from Configuration.ProcessModifiers.deepTauSonicTriton_cff
import deepTauSonicTriton
850 deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
852 mode = cms.string(
'PseudoAsync'),
853 allowedTries = cms.untracked.uint32(0),
854 verbose = cms.untracked.bool(
False),
855 modelName = cms.string(
"deeptau_2017v2p1"),
856 modelVersion = cms.string(
''),
857 modelConfigPath = cms.FileInPath(
"RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2017v2p1/config.pbtxt"),
858 preferredServer = cms.untracked.string(
''),
859 timeout = cms.untracked.uint32(300),
860 useSharedMemory = cms.untracked.bool(
True),
861 compression = cms.untracked.string(
''),
862 outputs = cms.untracked.vstring()
864 Prediscriminants = noPrediscriminants,
866 year = full_version[0],
867 version = full_version[1],
869 disable_dxy_pca =
True 874 _rerunMvaIsolationTask.add(_deepTauProducer)
875 _rerunMvaIsolationSequence += _deepTauProducer
877 if "deepTau2018v2p5" in self.
toKeep:
878 if self.
debug:
print (
"Adding DeepTau v2p5 IDs")
880 _deepTauName =
"deepTau2018v2p5" 881 workingPoints_ = WORKING_POINTS_v2p5
884 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_core.pb',
885 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_inner.pb',
886 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_outer.pb',
890 Prediscriminants = noPrediscriminants,
892 graph_file = file_names,
893 year = full_version[0],
894 version = full_version[1],
895 sub_version = full_version[2],
896 disable_dxy_pca =
True,
897 disable_hcalFraction_workaround =
True,
898 disable_CellIndex_workaround =
True 901 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
903 from Configuration.ProcessModifiers.deepTauSonicTriton_cff
import deepTauSonicTriton
904 deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
906 mode = cms.string(
'PseudoAsync'),
907 allowedTries = cms.untracked.uint32(0),
908 verbose = cms.untracked.bool(
False),
909 modelName = cms.string(
"deeptau_2018v2p5"),
910 modelVersion = cms.string(
''),
911 modelConfigPath = cms.FileInPath(
"RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2018v2p5/config.pbtxt"),
912 preferredServer = cms.untracked.string(
''),
913 timeout = cms.untracked.uint32(300),
914 useSharedMemory = cms.untracked.bool(
True),
915 compression = cms.untracked.string(
''),
916 outputs = cms.untracked.vstring(),
918 Prediscriminants = noPrediscriminants,
920 year = full_version[0],
921 version = full_version[1],
922 sub_version = full_version[2],
923 disable_dxy_pca =
True,
924 disable_hcalFraction_workaround =
True,
925 disable_CellIndex_workaround =
True 930 _rerunMvaIsolationTask.add(_deepTauProducer)
931 _rerunMvaIsolationSequence += _deepTauProducer
933 if "deepTau2026v2p5" in self.
toKeep:
934 if self.
debug:
print (
"Adding Phase2 DeepTau v2p5 IDs")
936 _deepTauName =
"deepTau2026v2p5" 937 workingPoints_ = WORKING_POINTS_PHASEII_v2p5
940 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_core.pb',
941 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_inner.pb',
942 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_outer.pb',
946 Prediscriminants = noPrediscriminants,
948 graph_file = file_names,
949 year = full_version[0],
950 version = full_version[1],
951 sub_version = full_version[2],
952 disable_dxy_pca =
True,
953 disable_hcalFraction_workaround =
True,
954 disable_CellIndex_workaround =
True 957 from RecoTauTag.RecoTau.mergedPhase2SlimmedElectronsForTauId_cff
import mergedSlimmedElectronsForTauId
958 if not hasattr(self.
process,
"mergedSlimmedElectronsForTauId"):
959 self.
process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
960 setattr(getattr(self.
process, _deepTauName+self.
postfix),
"electrons", cms.InputTag(
"mergedSlimmedElectronsForTauId"))
961 setattr(getattr(self.
process, _deepTauName+self.
postfix),
"vertices", cms.InputTag(
"offlineSlimmedPrimaryVertices4D"))
965 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
966 _rerunMvaIsolationTask.add(self.
process.mergedSlimmedElectronsForTauId)
967 _rerunMvaIsolationTask.add(_deepTauProducer)
968 _rerunMvaIsolationSequence += self.
process.mergedSlimmedElectronsForTauId
969 _rerunMvaIsolationSequence += _deepTauProducer
971 if "againstEle2018" in self.
toKeep:
977 _byElectronRejectionMVA62018Raw =
"patTauDiscriminationByElectronRejectionMVA62018Raw"+self.
postfix 978 setattr(self.
process,_byElectronRejectionMVA62018Raw,patTauDiscriminationAgainstElectronMVA6.clone(
980 Prediscriminants = noPrediscriminants,
981 srcElectrons = cms.InputTag(
'slimmedElectrons'),
982 vetoEcalCracks = cms.bool(
False),
994 _byElectronRejectionMVA62018 =
"patTauDiscriminationByElectronRejectionMVA62018"+self.
postfix 995 setattr(self.
process,
"patTauDiscriminationByElectronRejectionMVA62018"+self.
postfix,patTauDiscriminantCutMultiplexer.clone(
997 Prediscriminants = noPrediscriminants,
998 toMultiplex = _byElectronRejectionMVA62018Raw,
1001 category = cms.uint32(0),
1003 variable = cms.string(
'pt')
1006 category = cms.uint32(2),
1008 variable = cms.string(
'pt')
1011 category = cms.uint32(5),
1013 variable = cms.string(
'pt')
1016 category = cms.uint32(7),
1018 variable = cms.string(
'pt')
1021 category = cms.uint32(8),
1023 variable = cms.string(
'pt')
1026 category = cms.uint32(10),
1028 variable = cms.string(
'pt')
1031 category = cms.uint32(13),
1033 variable = cms.string(
'pt')
1036 category = cms.uint32(15),
1038 variable = cms.string(
'pt')
1041 workingPoints = cms.vstring(
1050 if self.
debug:
print (
"runTauID: Will update the list of available in DB samples to access againstEle 2018")
1054 _patTauDiscriminationByElectronRejectionMVA62018Task = cms.Task(
1055 getattr(self.
process,_byElectronRejectionMVA62018Raw),
1056 getattr(self.
process,_byElectronRejectionMVA62018)
1058 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA62018Task)
1059 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA62018Task)
1061 _againstElectronTauIDSources = cms.PSet(
1062 againstElectronMVA6Raw2018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"raw"),
1063 againstElectronMVA6category2018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"category"),
1064 againstElectronVLooseMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff98"),
1065 againstElectronLooseMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff90"),
1066 againstElectronMediumMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff80"),
1067 againstElectronTightMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff70"),
1068 againstElectronVTightMVA62018 = self.
tauIDMVAinputs(_byElectronRejectionMVA62018,
"_WPeff60")
1070 _tauIDSourcesWithAgainistEle = cms.PSet(
1071 tauIDSources.clone(),
1072 _againstElectronTauIDSources
1074 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
1076 if "againstEle" in self.
toKeep:
1080 _byElectronRejectionMVA6Raw =
"patTauDiscriminationByElectronRejectionMVA6Raw"+self.
postfix 1081 setattr(self.
process,_byElectronRejectionMVA6Raw,patTauDiscriminationAgainstElectronMVA6.clone(
1083 Prediscriminants = noPrediscriminants,
1084 srcElectrons = cms.InputTag(
'slimmedElectrons'),
1085 vetoEcalCracks = cms.bool(
False),
1086 mvaName_NoEleMatch_wGwoGSF_BL =
'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_BL',
1087 mvaName_NoEleMatch_wGwoGSF_EC =
'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_EC',
1088 mvaName_NoEleMatch_woGwoGSF_BL =
'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_BL',
1089 mvaName_NoEleMatch_woGwoGSF_EC =
'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_EC',
1090 mvaName_wGwGSF_BL =
'RecoTauTag_antiElectronMVA_wGwGSF_BL',
1091 mvaName_wGwGSF_EC =
'RecoTauTag_antiElectronMVA_wGwGSF_EC',
1092 mvaName_woGwGSF_BL =
'RecoTauTag_antiElectronMVA_woGwGSF_BL',
1093 mvaName_woGwGSF_EC =
'RecoTauTag_antiElectronMVA_woGwGSF_EC' 1097 _byElectronRejectionMVA6 =
"patTauDiscriminationByElectronRejectionMVA6"+self.
postfix 1098 setattr(self.
process,
"patTauDiscriminationByElectronRejectionMVA6"+self.
postfix,patTauDiscriminantCutMultiplexer.clone(
1100 Prediscriminants = noPrediscriminants,
1101 toMultiplex = _byElectronRejectionMVA6Raw,
1102 mapping = cms.VPSet(
1104 category = cms.uint32(0),
1105 cut = cms.string(
'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_BL'),
1106 variable = cms.string(
'pt')
1109 category = cms.uint32(2),
1110 cut = cms.string(
'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_BL'),
1111 variable = cms.string(
'pt')
1114 category = cms.uint32(5),
1115 cut = cms.string(
'RecoTauTag_antiElectronMVA_woGwGSF_BL'),
1116 variable = cms.string(
'pt')
1119 category = cms.uint32(7),
1120 cut = cms.string(
'RecoTauTag_antiElectronMVA_wGwGSF_BL'),
1121 variable = cms.string(
'pt')
1124 category = cms.uint32(8),
1125 cut = cms.string(
'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_EC'),
1126 variable = cms.string(
'pt')
1129 category = cms.uint32(10),
1130 cut = cms.string(
'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_EC'),
1131 variable = cms.string(
'pt')
1134 category = cms.uint32(13),
1135 cut = cms.string(
'RecoTauTag_antiElectronMVA_woGwGSF_EC'),
1136 variable = cms.string(
'pt')
1139 category = cms.uint32(15),
1140 cut = cms.string(
'RecoTauTag_antiElectronMVA_wGwGSF_EC'),
1141 variable = cms.string(
'pt')
1144 workingPoints = cms.vstring(
1153 _patTauDiscriminationByElectronRejectionMVA6Task = cms.Task(
1154 getattr(self.
process,_byElectronRejectionMVA6Raw),
1155 getattr(self.
process,_byElectronRejectionMVA6)
1157 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Task)
1158 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Task)
1160 _againstElectronTauIDSources = cms.PSet(
1161 againstElectronMVA6Raw = self.
tauIDMVAinputs(_byElectronRejectionMVA6,
"raw"),
1162 againstElectronMVA6category = self.
tauIDMVAinputs(_byElectronRejectionMVA6,
"category"),
1163 againstElectronVLooseMVA6 = self.
tauIDMVAinputs(_byElectronRejectionMVA6,
"_VLoose"),
1164 againstElectronLooseMVA6 = self.
tauIDMVAinputs(_byElectronRejectionMVA6,
"_Loose"),
1165 againstElectronMediumMVA6 = self.
tauIDMVAinputs(_byElectronRejectionMVA6,
"_Medium"),
1166 againstElectronTightMVA6 = self.
tauIDMVAinputs(_byElectronRejectionMVA6,
"_Tight"),
1167 againstElectronVTightMVA6 = self.
tauIDMVAinputs(_byElectronRejectionMVA6,
"_VTight")
1169 _tauIDSourcesWithAgainistEle = cms.PSet(
1170 tauIDSources.clone(),
1171 _againstElectronTauIDSources
1173 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
1175 if "newDMPhase2v1" in self.
toKeep:
1176 if self.
debug:
print (
"Adding newDMPhase2v1 ID")
1178 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)))
1179 _byIsolationNewDMMVAPhase2raw =
"rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw"+self.
postfix 1180 setattr(self.
process,_byIsolationNewDMMVAPhase2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
1182 Prediscriminants = noPrediscriminants,
1183 loadMVAfromDB =
True,
1184 mvaName =
'RecoTauTag_tauIdMVAIsoPhase2',
1185 mvaOpt =
'DBnewDMwLTwGJPhase2',
1189 _byIsolationNewDMMVAPhase2 =
"rerunDiscriminationByIsolationMVADBnewDMwLTPhase2"+self.
postfix 1190 setattr(self.
process,_byIsolationNewDMMVAPhase2,patDiscriminationByIsolationMVArun2v1.clone(
1192 Prediscriminants = noPrediscriminants,
1193 toMultiplex = _byIsolationNewDMMVAPhase2raw,
1194 loadMVAfromDB =
True,
1195 mvaOutput_normalization =
'RecoTauTag_tauIdMVAIsoPhase2_mvaOutput_normalization',
1196 mapping = cms.VPSet(
1198 category = cms.uint32(0),
1199 cut = cms.string(
"RecoTauTag_tauIdMVAIsoPhase2"),
1200 variable = cms.string(
"pt"),
1203 workingPoints = cms.vstring(
1213 _rerunIsolationMVADBnewDMwLTPhase2Task = cms.Task(
1214 getattr(self.
process,_byIsolationNewDMMVAPhase2raw),
1215 getattr(self.
process,_byIsolationNewDMMVAPhase2)
1217 _rerunMvaIsolationTask.add(_rerunIsolationMVADBnewDMwLTPhase2Task)
1218 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationMVADBnewDMwLTPhase2Task)
1220 tauIDSources.byIsolationMVADBnewDMwLTPhase2raw =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"raw")
1221 tauIDSources.byVVLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VVLoose")
1222 tauIDSources.byVLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VLoose")
1223 tauIDSources.byLooseIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Loose")
1224 tauIDSources.byMediumIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Medium")
1225 tauIDSources.byTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_Tight")
1226 tauIDSources.byVTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VTight")
1227 tauIDSources.byVVTightIsolationMVADBnewDMwLTPhase2 =
tauIDMVAinputs(_byIsolationNewDMMVAPhase2,
"_VVTight")
1229 if "againstElePhase2v1" in self.
toKeep:
1230 if self.
debug:
print (
"Adding anti-e Phase2v1 ID")
1233 from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6Phase2_cff
import patTauDiscriminationAgainstElectronMVA6Phase2Raw, patTauDiscriminationAgainstElectronMVA6Phase2, mergedSlimmedElectronsForTauId
1234 _byElectronRejectionMVA6Phase2v1Raw =
"patTauDiscriminationByElectronRejectionMVA6Phase2v1Raw"+self.
postfix 1235 setattr(self.
process,_byElectronRejectionMVA6Phase2v1Raw,patTauDiscriminationAgainstElectronMVA6Phase2Raw.clone(
1237 Prediscriminants = noPrediscriminants
1240 _byElectronRejectionMVA6Phase2v1 =
"patTauDiscriminationByElectronRejectionMVA6Phase2v1"+self.
postfix 1241 setattr(self.
process,_byElectronRejectionMVA6Phase2v1,patTauDiscriminationAgainstElectronMVA6Phase2.clone(
1243 Prediscriminants = noPrediscriminants,
1244 toMultiplex = _byElectronRejectionMVA6Phase2v1Raw
1247 if not hasattr(self.
process,
"mergedSlimmedElectronsForTauId"):
1248 self.
process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
1249 _patTauDiscriminationByElectronRejectionMVA6Phase2v1Task = cms.Task(
1250 self.
process.mergedSlimmedElectronsForTauId,
1251 getattr(self.
process,_byElectronRejectionMVA6Phase2v1Raw),
1252 getattr(self.
process,_byElectronRejectionMVA6Phase2v1)
1254 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
1255 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
1257 _againstElectronTauIDPhase2v1Sources = cms.PSet(
1258 againstElectronMVA6RawPhase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"raw"),
1259 againstElectronMVA6categoryPhase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"category"),
1260 againstElectronVLooseMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_VLoose"),
1261 againstElectronLooseMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Loose"),
1262 againstElectronMediumMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Medium"),
1263 againstElectronTightMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_Tight"),
1264 againstElectronVTightMVA6Phase2v1 = self.
tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1,
"_VTight")
1266 _tauIDSourcesWithAgainistElePhase2v1 = cms.PSet(
1267 tauIDSources.clone(),
1268 _againstElectronTauIDPhase2v1Sources
1270 tauIDSources =_tauIDSourcesWithAgainistElePhase2v1.clone()
1274 embedID = cms.EDProducer(
"PATTauIDEmbedder",
1276 tauIDSources = tauIDSources
1280 tauIDSources = cms.PSet(
1284 if not hasattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix):
1285 setattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix,_rerunMvaIsolationTask)
1287 _updatedRerunMvaIsolationTask = getattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix)
1288 _updatedRerunMvaIsolationTask.add(_rerunMvaIsolationTask)
1289 setattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix,_updatedRerunMvaIsolationTask)
1290 if not hasattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix):
1291 setattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix,_rerunMvaIsolationSequence)
1293 _updatedRerunMvaIsolationSequence = getattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix)
1294 _updatedRerunMvaIsolationSequence += _rerunMvaIsolationSequence
1295 setattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix,_updatedRerunMvaIsolationSequence)
1299 for target,points
in workingPoints_.items():
1300 setattr(tauIDSources,
'by{}VS{}raw'.
format(producer_name[0].upper()+producer_name[1:], target),
1301 cms.PSet(inputTag = cms.InputTag(producer_name+self.
postfix,
'VS{}'.
format(target)), workingPointIndex = cms.int32(-1)))
1303 cut_expressions = []
1304 for index, (point,cut)
in enumerate(points.items()):
1305 cut_expressions.append(
str(cut))
1307 setattr(tauIDSources,
'by{}{}VS{}'.
format(point, producer_name[0].upper()+producer_name[1:], target),
1308 cms.PSet(inputTag = cms.InputTag(producer_name+self.
postfix,
'VS{}'.
format(target)), workingPointIndex = cms.int32(index)))
1309 if len(cut_expressions) > 0:
1310 setattr(getattr(self.
process, producer_name+self.
postfix),
'VS{}WP'.
format(target), cms.vstring(*cut_expressions))
1314 """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \ 1315 (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \ 1316 {year}v{version}p{subversion}""" 1317 version_search = re.search(
'(20[1,2][125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
1318 if not version_search:
1319 raise RuntimeError(
'File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \ 1320 Unable to extract version number.'.
format(file_name))
1321 year = version_search.group(1)
1322 version = version_search.group(2)
1323 subversion = version_search.group(3)
1324 if len(subversion) > 0:
1325 subversion = subversion[1:]
1328 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_)
def __init__(self, process, debug=False, originalTauName="slimmedTaus", updatedTauName="slimmedTausNewID", postfix="", toKeep=["deepTau2017v2p1", deepTau2018v2p5, deepTau2026v2p5, conditionDB="" # preparational DB:'frontier://FrontierPrep/CMS_CONDITIONS')
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
def load_againstElectronMVA6(self)
def tauIDMVAinputs(self, module, wp)
def versionToInt(release=9, subversion=4, patch=0, debug=False)
antiElectronDiscrMVA6_WPs
antiElectronDiscrMVA6_version