1 from __future__
import print_function
9 """class to rerun the tau seq and acces trainings from the database""" 10 availableDiscriminators = [
11 "2017v1",
"2017v2",
"newDM2017v2",
"dR0p32017v2",
"2016v1",
"newDM2016v1",
12 "deepTau2017v1",
"deepTau2017v2",
"deepTau2017v2p1",
13 "DPFTau_2016_v0",
"DPFTau_2016_v1",
17 def __init__(self, process, cms, debug = False,
18 originalTauName =
"slimmedTaus",
19 updatedTauName =
"slimmedTausNewID",
21 toKeep = [
"deepTau2017v2p1"],
22 tauIdDiscrMVA_trainings_run2_2017 = {
'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017", },
23 tauIdDiscrMVA_WPs_run2_2017 = {
24 'tauIdMVAIsoDBoldDMwLT2017' : {
25 'Eff95' :
"DBoldDMwLTEff95",
26 'Eff90' :
"DBoldDMwLTEff90",
27 'Eff80' :
"DBoldDMwLTEff80",
28 'Eff70' :
"DBoldDMwLTEff70",
29 'Eff60' :
"DBoldDMwLTEff60",
30 'Eff50' :
"DBoldDMwLTEff50",
31 'Eff40' :
"DBoldDMwLTEff40" 34 tauIdDiscrMVA_2017_version =
"v1",
37 super(TauIDEmbedder, self).
__init__()
44 self.process.load(
'RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
45 if len(conditionDB) != 0:
46 self.process.CondDBTauConnection.connect = cms.string(conditionDB)
47 self.process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
57 if discr
not in TauIDEmbedder.availableDiscriminators:
58 raise RuntimeError(
'TauIDEmbedder: discriminator "{}" is not supported'.
format(discr))
64 """returns 'CMSSW_X_Y_Z'""" 65 cmssw_version = os.environ[
"CMSSW_VERSION"]
66 if debug:
print (
"get_cmssw_version:", cmssw_version)
71 """returns '(release, subversion, patch)' (without 'CMSSW_')""" 72 v = klass.get_cmssw_version().
split(
"CMSSW_")[1].
split(
"_")[0:3]
73 if debug:
print (
"get_cmssw_version_number:", v)
78 return int(v[0]),
int(v[1]), patch
82 version = release * 10000 + subversion * 100 + patch + 1
83 if debug:
print (
"versionToInt:", version)
89 split_cmssw_version = klass.get_cmssw_version_number()
90 if klass.versionToInt(release, subversion, patch) > klass.versionToInt(split_cmssw_version[0], split_cmssw_version[1], split_cmssw_version[2]):
91 if debug:
print (
"is_above_cmssw_version:",
False)
94 if debug:
print (
"is_above_cmssw_version:",
True)
98 if self.
debug:
print (
"loadMVA_WPs_run2_2017: performed")
100 for training, gbrForestName
in self.tauIdDiscrMVA_trainings_run2_2017.items():
102 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
104 record = self.cms.string(
'GBRWrapperRcd'),
111 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
113 record = self.cms.string(
'PhysicsTGraphPayloadRcd'),
119 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
121 record = self.cms.string(
'PhysicsTFormulaPayloadRcd'),
123 label = self.cms.untracked.string(
"RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, self.
tauIdDiscrMVA_2017_version))
128 _rerunMvaIsolationTask = self.cms.Task()
129 _rerunMvaIsolationSequence = self.cms.Sequence()
130 tauIDSources = self.cms.PSet()
133 if "2017v1" in self.
toKeep:
136 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
139 'tauIdMVAIsoDBoldDMwLT2017' : {
140 'Eff95' :
"DBoldDMwLTEff95",
141 'Eff90' :
"DBoldDMwLTEff90",
142 'Eff80' :
"DBoldDMwLTEff80",
143 'Eff70' :
"DBoldDMwLTEff70",
144 'Eff60' :
"DBoldDMwLTEff60",
145 'Eff50' :
"DBoldDMwLTEff50",
146 'Eff40' :
"DBoldDMwLTEff40" 151 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")
154 _byIsolationOldDMMVArun2017v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v1raw"+self.
postfix 155 setattr(self.
process,_byIsolationOldDMMVArun2017v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
157 Prediscriminants = noPrediscriminants,
158 loadMVAfromDB = self.cms.bool(
True),
159 mvaName = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
160 mvaOpt = self.cms.string(
"DBoldDMwLTwGJ"),
161 verbosity = self.cms.int32(0)
164 _byIsolationOldDMMVArun2017v1VLoose =
"rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose"+self.
postfix 165 setattr(self.
process,_byIsolationOldDMMVArun2017v1VLoose,patDiscriminationByIsolationMVArun2v1VLoose.clone(
167 Prediscriminants = noPrediscriminants,
168 toMultiplex = _byIsolationOldDMMVArun2017v1raw,
169 key = _byIsolationOldDMMVArun2017v1raw+
':category',
170 loadMVAfromDB = self.cms.bool(
True),
171 mvaOutput_normalization = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"),
172 mapping = self.cms.VPSet(
174 category = self.cms.uint32(0),
175 cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff90"),
176 variable = self.cms.string(
"pt"),
180 _byIsolationOldDMMVArun2017v1VLooseProd = getattr(self.
process,_byIsolationOldDMMVArun2017v1VLoose)
182 _rerunIsolationOldDMMVArun2017v1Task = self.cms.Task(
183 getattr(self.
process,_byIsolationOldDMMVArun2017v1raw),
184 _byIsolationOldDMMVArun2017v1VLooseProd
186 tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.cms.InputTag(_byIsolationOldDMMVArun2017v1raw)
187 tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(_byIsolationOldDMMVArun2017v1VLoose)
190 "VVLoose" :
"WPEff95",
192 "Medium" :
"WPEff70",
194 "VTight" :
"WPEff50",
195 "VVTight" :
"WPEff40" 197 for wp,wpEff
in wp_to_eff_match.items():
198 _aWP =
"rerunDiscriminationByIsolationOldDMMVArun2017v1"+wp+self.
postfix 199 setattr(self.
process,_aWP,_byIsolationOldDMMVArun2017v1VLooseProd.clone())
200 _aWPProd = getattr(self.
process,_aWP)
201 _aWPProd.mapping[0].cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_"+wpEff)
202 _rerunIsolationOldDMMVArun2017v1Task.add(_aWPProd)
203 setattr(tauIDSources,
"by"+wp+
"IsolationMVArun2017v1DBoldDMwLT2017",self.cms.InputTag(_aWP))
205 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v1Task)
206 _rerunMvaIsolationSequence += self.cms.Sequence(_rerunIsolationOldDMMVArun2017v1Task)
208 if "2017v2" in self.
toKeep:
211 'tauIdMVAIsoDBoldDMwLT2017' :
"tauIdMVAIsoDBoldDMwLT2017",
214 'tauIdMVAIsoDBoldDMwLT2017' : {
215 'Eff95' :
"DBoldDMwLTEff95",
216 'Eff90' :
"DBoldDMwLTEff90",
217 'Eff80' :
"DBoldDMwLTEff80",
218 'Eff70' :
"DBoldDMwLTEff70",
219 'Eff60' :
"DBoldDMwLTEff60",
220 'Eff50' :
"DBoldDMwLTEff50",
221 'Eff40' :
"DBoldDMwLTEff40" 226 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")
229 _byIsolationOldDMMVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMMVArun2017v2raw"+self.
postfix 230 setattr(self.
process,_byIsolationOldDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
232 Prediscriminants = noPrediscriminants,
233 loadMVAfromDB = self.cms.bool(
True),
234 mvaName = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
235 mvaOpt = self.cms.string(
"DBoldDMwLTwGJ"),
236 verbosity = self.cms.int32(0)
239 _byIsolationOldDMMVArun2017v2VLoose =
"rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose"+self.
postfix 240 setattr(self.
process,_byIsolationOldDMMVArun2017v2VLoose,patDiscriminationByIsolationMVArun2v1VLoose.clone(
242 Prediscriminants = noPrediscriminants,
243 toMultiplex = _byIsolationOldDMMVArun2017v2raw,
244 key = _byIsolationOldDMMVArun2017v2raw+
':category',
245 loadMVAfromDB = self.cms.bool(
True),
246 mvaOutput_normalization = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"),
247 mapping = self.cms.VPSet(
249 category = self.cms.uint32(0),
250 cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff90"),
251 variable = self.cms.string(
"pt"),
254 verbosity = self.cms.int32(0)
256 _byIsolationOldDMMVArun2017v2VLooseProd = getattr(self.
process,_byIsolationOldDMMVArun2017v2VLoose)
258 _rerunIsolationOldDMMVArun2017v2Task = self.cms.Task(
259 getattr(self.
process,_byIsolationOldDMMVArun2017v2raw),
260 _byIsolationOldDMMVArun2017v2VLooseProd
262 tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.cms.InputTag(_byIsolationOldDMMVArun2017v2raw)
263 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(_byIsolationOldDMMVArun2017v2VLoose)
266 "VVLoose" :
"WPEff95",
268 "Medium" :
"WPEff70",
270 "VTight" :
"WPEff50",
271 "VVTight" :
"WPEff40" 273 for wp,wpEff
in wp_to_eff_match.items():
274 _aWP =
"rerunDiscriminationByIsolationOldDMMVArun2017v2"+wp+self.
postfix 275 setattr(self.
process,_aWP,_byIsolationOldDMMVArun2017v2VLooseProd.clone())
276 _aWPProd = getattr(self.
process,_aWP)
277 _aWPProd.mapping[0].cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_"+wpEff)
278 _rerunIsolationOldDMMVArun2017v2Task.add(_aWPProd)
279 setattr(tauIDSources,
"by"+wp+
"IsolationMVArun2017v2DBoldDMwLT2017",self.cms.InputTag(_aWP))
281 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v2Task)
282 _rerunMvaIsolationSequence += self.cms.Sequence(_rerunIsolationOldDMMVArun2017v2Task)
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 = self.cms.bool(
True),
310 mvaName = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
311 mvaOpt = self.cms.string(
"DBnewDMwLTwGJ"),
312 verbosity = self.cms.int32(0)
315 _byIsolationNewDMMVArun2017v2VLoose =
"rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose"+self.
postfix 316 setattr(self.
process,_byIsolationNewDMMVArun2017v2VLoose,patDiscriminationByIsolationMVArun2v1VLoose.clone(
318 Prediscriminants = noPrediscriminants,
319 toMultiplex = _byIsolationNewDMMVArun2017v2raw,
320 key = _byIsolationNewDMMVArun2017v2raw+
':category',
321 loadMVAfromDB = self.cms.bool(
True),
322 mvaOutput_normalization = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"),
323 mapping = self.cms.VPSet(
325 category = self.cms.uint32(0),
326 cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff90"),
327 variable = self.cms.string(
"pt"),
330 verbosity = self.cms.int32(0)
332 _byIsolationNewDMMVArun2017v2VLooseProd = getattr(self.
process,_byIsolationNewDMMVArun2017v2VLoose)
334 _rerunIsolationNewDMMVArun2017v2Task = self.cms.Task(
335 getattr(self.
process,_byIsolationNewDMMVArun2017v2raw),
336 _byIsolationNewDMMVArun2017v2VLooseProd
338 tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.cms.InputTag(_byIsolationNewDMMVArun2017v2raw)
339 tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(_byIsolationNewDMMVArun2017v2VLoose)
342 "VVLoose" :
"WPEff95",
344 "Medium" :
"WPEff70",
346 "VTight" :
"WPEff50",
347 "VVTight" :
"WPEff40" 349 for wp,wpEff
in wp_to_eff_match.items():
350 _aWP =
"rerunDiscriminationByIsolationNewDMMVArun2017v2"+wp+self.
postfix 351 setattr(self.
process,_aWP,_byIsolationNewDMMVArun2017v2VLooseProd.clone())
352 _aWPProd = getattr(self.
process,_aWP)
353 _aWPProd.mapping[0].cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_"+wpEff)
354 _rerunIsolationNewDMMVArun2017v2Task.add(_aWPProd)
355 setattr(tauIDSources,
"by"+wp+
"IsolationMVArun2017v2DBnewDMwLT2017",self.cms.InputTag(_aWP))
357 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2017v2Task)
358 _rerunMvaIsolationSequence += self.cms.Sequence(_rerunIsolationNewDMMVArun2017v2Task)
360 if "dR0p32017v2" in self.
toKeep:
363 'tauIdMVAIsoDBoldDMdR0p3wLT2017' :
"tauIdMVAIsoDBoldDMdR0p3wLT2017",
366 'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
367 'Eff95' :
"DBoldDMdR0p3wLTEff95",
368 'Eff90' :
"DBoldDMdR0p3wLTEff90",
369 'Eff80' :
"DBoldDMdR0p3wLTEff80",
370 'Eff70' :
"DBoldDMdR0p3wLTEff70",
371 'Eff60' :
"DBoldDMdR0p3wLTEff60",
372 'Eff50' :
"DBoldDMdR0p3wLTEff50",
373 'Eff40' :
"DBoldDMdR0p3wLTEff40" 378 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")
381 _byIsolationOldDMdR0p3MVArun2017v2raw =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw"+self.
postfix 382 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
384 Prediscriminants = noPrediscriminants,
385 loadMVAfromDB = self.cms.bool(
True),
386 mvaName = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
387 mvaOpt = self.cms.string(
"DBoldDMwLTwGJ"),
388 srcChargedIsoPtSum = self.cms.string(
'chargedIsoPtSumdR03'),
389 srcFootprintCorrection = self.cms.string(
'footprintCorrectiondR03'),
390 srcNeutralIsoPtSum = self.cms.string(
'neutralIsoPtSumdR03'),
391 srcPhotonPtSumOutsideSignalCone = self.cms.string(
'photonPtSumOutsideSignalConedR03'),
392 verbosity = self.cms.int32(0)
395 _byIsolationOldDMdR0p3MVArun2017v2VLoose =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose"+self.
postfix 396 setattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2VLoose,patDiscriminationByIsolationMVArun2v1VLoose.clone(
398 Prediscriminants = noPrediscriminants,
399 toMultiplex = _byIsolationOldDMdR0p3MVArun2017v2raw,
400 key = _byIsolationOldDMdR0p3MVArun2017v2raw+
':category',
401 loadMVAfromDB = self.cms.bool(
True),
402 mvaOutput_normalization = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"),
403 mapping = self.cms.VPSet(
405 category = self.cms.uint32(0),
406 cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff90"),
407 variable = self.cms.string(
"pt"),
410 verbosity = self.cms.int32(0)
412 _byIsolationOldDMdR0p3MVArun2017v2VLooseProd = getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2VLoose)
414 _rerunIsolationOldDMdR0p3MVArun2017v2Task = self.cms.Task(
415 getattr(self.
process,_byIsolationOldDMdR0p3MVArun2017v2raw),
416 _byIsolationOldDMdR0p3MVArun2017v2VLooseProd
418 tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.cms.InputTag(_byIsolationOldDMdR0p3MVArun2017v2raw)
419 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(_byIsolationOldDMdR0p3MVArun2017v2VLoose)
422 "VVLoose" :
"WPEff95",
424 "Medium" :
"WPEff70",
426 "VTight" :
"WPEff50",
427 "VVTight" :
"WPEff40" 429 for wp,wpEff
in wp_to_eff_match.items():
430 _aWP =
"rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2"+wp+self.
postfix 431 setattr(self.
process,_aWP,_byIsolationOldDMdR0p3MVArun2017v2VLooseProd.clone())
432 _aWPProd = getattr(self.
process,_aWP)
433 _aWPProd.mapping[0].cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_"+wpEff)
434 _rerunIsolationOldDMdR0p3MVArun2017v2Task.add(_aWPProd)
435 setattr(tauIDSources,
"by"+wp+
"IsolationMVArun2017v2DBoldDMdR0p3wLT2017",self.cms.InputTag(_aWP))
437 _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
438 _rerunMvaIsolationSequence += self.cms.Sequence(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
467 if "2016v1" in self.
toKeep:
468 _byIsolationOldDMMVArun2016v1raw =
"rerunDiscriminationByIsolationOldDMMVArun2v1raw"+self.
postfix 469 setattr(self.
process,_byIsolationOldDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
471 Prediscriminants = noPrediscriminants,
472 loadMVAfromDB = self.cms.bool(
True),
473 mvaName = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
474 mvaOpt = self.cms.string(
"DBoldDMwLT"),
475 verbosity = self.cms.int32(0)
478 _byIsolationOldDMMVArun2016v1VLoose =
"rerunDiscriminationByIsolationOldDMMVArun2v1VLoose"+self.
postfix 479 setattr(self.
process,_byIsolationOldDMMVArun2016v1VLoose,patDiscriminationByIsolationMVArun2v1VLoose.clone(
481 Prediscriminants = noPrediscriminants,
482 toMultiplex = _byIsolationOldDMMVArun2016v1raw,
483 key = _byIsolationOldDMMVArun2016v1raw+
':category',
484 loadMVAfromDB = self.cms.bool(
True),
485 mvaOutput_normalization = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
486 mapping = self.cms.VPSet(
488 category = self.cms.uint32(0),
489 cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff90"),
490 variable = self.cms.string(
"pt"),
494 _byIsolationOldDMMVArun2016v1VLooseProd = getattr(self.
process,_byIsolationOldDMMVArun2016v1VLoose)
496 _rerunIsolationOldDMMVArun2016v1Task = self.cms.Task(
497 getattr(self.
process,_byIsolationOldDMMVArun2016v1raw),
498 _byIsolationOldDMMVArun2016v1VLooseProd
500 tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.cms.InputTag(_byIsolationOldDMMVArun2016v1raw)
501 tauIDSources.byVLooseIsolationMVArun2v2DBoldDMwLT2016 = self.cms.InputTag(_byIsolationOldDMMVArun2016v1VLoose)
505 "Medium" :
"WPEff70",
507 "VTight" :
"WPEff50",
508 "VVTight" :
"WPEff40" 510 for wp,wpEff
in wp_to_eff_match.items():
511 _aWP =
"rerunDiscriminationByIsolationOldDMMVArun2v1"+wp+self.
postfix 512 setattr(self.
process,_aWP,_byIsolationOldDMMVArun2016v1VLooseProd.clone())
513 _aWPProd = getattr(self.
process,_aWP)
514 _aWPProd.mapping[0].cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_"+wpEff)
515 _rerunIsolationOldDMMVArun2016v1Task.add(_aWPProd)
516 setattr(tauIDSources,
"by"+wp+
"IsolationMVArun2v1DBoldDMwLT2016",self.cms.InputTag(_aWP))
518 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2016v1Task)
519 _rerunMvaIsolationSequence += self.cms.Sequence(_rerunIsolationOldDMMVArun2016v1Task)
522 if "newDM2016v1" in self.
toKeep:
523 _byIsolationNewDMMVArun2016v1raw =
"rerunDiscriminationByIsolationNewDMMVArun2v1raw"+self.
postfix 524 setattr(self.
process,_byIsolationNewDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
526 Prediscriminants = noPrediscriminants,
527 loadMVAfromDB = self.cms.bool(
True),
528 mvaName = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
529 mvaOpt = self.cms.string(
"DBnewDMwLT"),
530 verbosity = self.cms.int32(0)
533 _byIsolationNewDMMVArun2016v1VLoose =
"rerunDiscriminationByIsolationNewDMMVArun2v1VLoose"+self.
postfix 534 setattr(self.
process,_byIsolationNewDMMVArun2016v1VLoose,patDiscriminationByIsolationMVArun2v1VLoose.clone(
536 Prediscriminants = noPrediscriminants,
537 toMultiplex = _byIsolationNewDMMVArun2016v1raw,
538 key = _byIsolationNewDMMVArun2016v1raw+
':category',
539 loadMVAfromDB = self.cms.bool(
True),
540 mvaOutput_normalization = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
541 mapping = self.cms.VPSet(
543 category = self.cms.uint32(0),
544 cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
545 variable = self.cms.string(
"pt"),
549 _byIsolationNewDMMVArun2016v1VLooseProd = getattr(self.
process,_byIsolationNewDMMVArun2016v1VLoose)
551 _rerunIsolationNewDMMVArun2016v1Task = self.cms.Task(
552 getattr(self.
process,_byIsolationNewDMMVArun2016v1raw),
553 _byIsolationNewDMMVArun2016v1VLooseProd
555 tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.cms.InputTag(_byIsolationNewDMMVArun2016v1raw)
556 tauIDSources.byVLooseIsolationMVArun2v2DBnewDMwLT2016 = self.cms.InputTag(_byIsolationNewDMMVArun2016v1VLoose)
560 "Medium" :
"WPEff70",
562 "VTight" :
"WPEff50",
563 "VVTight" :
"WPEff40" 565 for wp,wpEff
in wp_to_eff_match.items():
566 _aWP =
"rerunDiscriminationByIsolationNewDMMVArun2v1"+wp+self.
postfix 567 setattr(self.
process,_aWP,_byIsolationNewDMMVArun2016v1VLooseProd.clone())
568 _aWPProd = getattr(self.
process,_aWP)
569 _aWPProd.mapping[0].cut = self.cms.string(
"RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_"+wpEff)
570 _rerunIsolationNewDMMVArun2016v1Task.add(_aWPProd)
571 setattr(tauIDSources,
"by"+wp+
"IsolationMVArun2v1DBnewDMwLT2016",self.cms.InputTag(_aWP))
573 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2016v1Task)
574 _rerunMvaIsolationSequence += self.cms.Sequence(_rerunIsolationNewDMMVArun2016v1Task)
576 if "deepTau2017v1" in self.
toKeep:
577 if self.
debug:
print (
"Adding DeepTau IDs")
579 _deepTauName =
"deepTau2017v1" 582 "VVVLoose" : 0.96424,
592 "VVVLoose" : 0.959619,
593 "VVLoose" : 0.997687,
613 file_names = [
'RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v1_20L1024N_quantized.pb']
614 setattr(self.
process,_deepTauName+self.
postfix,self.cms.EDProducer(
"DeepTauId",
615 electrons = self.cms.InputTag(
'slimmedElectrons'),
616 muons = self.cms.InputTag(
'slimmedMuons'),
618 pfcands = self.cms.InputTag(
'packedPFCandidates'),
619 vertices = self.cms.InputTag(
'offlineSlimmedPrimaryVertices'),
620 rho = self.cms.InputTag(
'fixedGridRhoAll'),
621 graph_file = self.cms.vstring(file_names),
622 mem_mapped = self.cms.bool(
False),
624 debug_level = self.cms.int32(0),
625 disable_dxy_pca = self.cms.bool(
False)
631 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
632 _rerunMvaIsolationTask.add(_deepTauProducer)
633 _rerunMvaIsolationSequence += _deepTauProducer
635 if "deepTau2017v2" in self.
toKeep:
636 if self.
debug:
print (
"Adding DeepTau IDs")
638 _deepTauName =
"deepTau2017v2" 641 "VVVLoose": 0.0630386,
642 "VVLoose": 0.1686942,
648 "VVTight": 0.9928449,
657 "VVVLoose": 0.2599605,
658 "VVLoose": 0.4249705,
664 "VVTight": 0.9733927,
669 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
670 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
671 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
673 setattr(self.
process,_deepTauName+self.
postfix,self.cms.EDProducer(
"DeepTauId",
674 electrons = self.cms.InputTag(
'slimmedElectrons'),
675 muons = self.cms.InputTag(
'slimmedMuons'),
677 pfcands = self.cms.InputTag(
'packedPFCandidates'),
678 vertices = self.cms.InputTag(
'offlineSlimmedPrimaryVertices'),
679 rho = self.cms.InputTag(
'fixedGridRhoAll'),
680 graph_file = self.cms.vstring(file_names),
681 mem_mapped = self.cms.bool(
True),
683 debug_level = self.cms.int32(0),
684 disable_dxy_pca = self.cms.bool(
False)
690 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
691 _rerunMvaIsolationTask.add(_deepTauProducer)
692 _rerunMvaIsolationSequence += _deepTauProducer
694 if "deepTau2017v2p1" in self.
toKeep:
695 if self.
debug:
print (
"Adding DeepTau IDs")
697 _deepTauName =
"deepTau2017v2p1" 700 "VVVLoose": 0.0630386,
701 "VVLoose": 0.1686942,
707 "VVTight": 0.9928449,
716 "VVVLoose": 0.2599605,
717 "VVLoose": 0.4249705,
723 "VVTight": 0.9733927,
728 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
729 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
730 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
732 setattr(self.
process,_deepTauName+self.
postfix,self.cms.EDProducer(
"DeepTauId",
733 electrons = self.cms.InputTag(
'slimmedElectrons'),
734 muons = self.cms.InputTag(
'slimmedMuons'),
736 pfcands = self.cms.InputTag(
'packedPFCandidates'),
737 vertices = self.cms.InputTag(
'offlineSlimmedPrimaryVertices'),
738 rho = self.cms.InputTag(
'fixedGridRhoAll'),
739 graph_file = self.cms.vstring(file_names),
740 mem_mapped = self.cms.bool(
True),
742 debug_level = self.cms.int32(0),
743 disable_dxy_pca = self.cms.bool(
True)
749 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
750 _rerunMvaIsolationTask.add(_deepTauProducer)
751 _rerunMvaIsolationSequence += _deepTauProducer
753 if "DPFTau_2016_v0" in self.
toKeep:
754 if self.
debug:
print (
"Adding DPFTau isolation (v0)")
756 _deepTauName =
"DPFTau_2016_v0" 759 "Tight" :
"if(decayMode == 0) return (0.898328 - 0.000160992 * pt);" + \
760 "if(decayMode == 1) return (0.910138 - 0.000229923 * pt);" + \
761 "if(decayMode == 10) return (0.873958 - 0.0002328 * pt);" + \
771 file_names = [
'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v0_quantized.pb' ]
772 setattr(self.
process,_deepTauName+self.
postfix,self.cms.EDProducer(
"DPFIsolation",
773 pfcands = self.cms.InputTag(
'packedPFCandidates'),
775 vertices = self.cms.InputTag(
'offlineSlimmedPrimaryVertices'),
776 graph_file = self.cms.vstring(file_names),
778 mem_mapped = self.cms.bool(
False)
783 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
784 _rerunMvaIsolationTask.add(_deepTauProducer)
785 _rerunMvaIsolationSequence += _deepTauProducer
787 if "DPFTau_2016_v1" in self.
toKeep:
788 print (
"Adding DPFTau isolation (v1)")
789 print (
"WARNING: WPs are not defined for DPFTau_2016_v1")
790 print (
"WARNING: The score of DPFTau_2016_v1 is inverted: i.e. for Sig->0, for Bkg->1 with -1 for undefined input (preselection not passed).")
792 _deepTauName =
"DPFTau_2016_v1" 794 "all": {
"Tight" : 0.123}
797 file_names = [
'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v1_quantized.pb' ]
798 setattr(self.
process,_deepTauName+self.
postfix,self.cms.EDProducer(
"DPFIsolation",
799 pfcands = self.cms.InputTag(
'packedPFCandidates'),
801 vertices = self.cms.InputTag(
'offlineSlimmedPrimaryVertices'),
802 graph_file = self.cms.vstring(file_names),
804 mem_mapped = self.cms.bool(
False)
809 _deepTauProducer = getattr(self.
process,_deepTauName+self.
postfix)
810 _rerunMvaIsolationTask.add(_deepTauProducer)
811 _rerunMvaIsolationSequence += _deepTauProducer
813 if "againstEle2018" in self.
toKeep:
814 antiElectronDiscrMVA6_version =
"MVA6v3_noeveto" 817 from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6_cfi
import patTauDiscriminationAgainstElectronMVA6
818 _byElectronRejectionMVA62018Raw =
"patTauDiscriminationByElectronRejectionMVA62018Raw"+self.
postfix 819 setattr(self.
process,_byElectronRejectionMVA62018Raw,patTauDiscriminationAgainstElectronMVA6.clone(
821 Prediscriminants = noPrediscriminants,
822 vetoEcalCracks = self.cms.bool(
False),
823 mvaName_NoEleMatch_wGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL',
824 mvaName_NoEleMatch_wGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC',
825 mvaName_NoEleMatch_woGwoGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL',
826 mvaName_NoEleMatch_woGwoGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC',
827 mvaName_wGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL',
828 mvaName_wGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC',
829 mvaName_woGwGSF_BL =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL',
830 mvaName_woGwGSF_EC =
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC' 835 _byElectronRejectionMVA62018VLoose =
"patTauDiscriminationByVLooseElectronRejectionMVA62018"+self.
postfix 836 setattr(self.
process,_byElectronRejectionMVA62018VLoose,patTauDiscriminantCutMultiplexer.clone(
838 Prediscriminants = noPrediscriminants,
839 toMultiplex = _byElectronRejectionMVA62018Raw,
840 key = _byElectronRejectionMVA62018Raw+
":category",
841 mapping = self.cms.VPSet(
843 category = self.cms.uint32(0),
844 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL_WPeff98'),
845 variable = self.cms.string(
'pt')
848 category = self.cms.uint32(2),
849 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL_WPeff98'),
850 variable = self.cms.string(
'pt')
853 category = self.cms.uint32(5),
854 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL_WPeff98'),
855 variable = self.cms.string(
'pt')
858 category = self.cms.uint32(7),
859 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL_WPeff98'),
860 variable = self.cms.string(
'pt')
863 category = self.cms.uint32(8),
864 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC_WPeff98'),
865 variable = self.cms.string(
'pt')
868 category = self.cms.uint32(10),
869 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC_WPeff98'),
870 variable = self.cms.string(
'pt')
873 category = self.cms.uint32(13),
874 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC_WPeff98'),
875 variable = self.cms.string(
'pt')
878 category = self.cms.uint32(15),
879 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC_WPeff98'),
880 variable = self.cms.string(
'pt')
884 _byElectronRejectionMVA62018VLooseProd = getattr(self.
process,_byElectronRejectionMVA62018VLoose)
886 _patTauDiscriminationByElectronRejectionMVA62018Task = self.cms.Task(
887 getattr(self.
process,_byElectronRejectionMVA62018Raw),
888 _byElectronRejectionMVA62018VLooseProd
890 _againstElectronTauIDSources = self.cms.PSet(
891 againstElectronMVA6Raw2018 = self.cms.InputTag(_byElectronRejectionMVA62018Raw),
892 againstElectronMVA6category2018 = self.cms.InputTag(_byElectronRejectionMVA62018Raw,
"category"),
893 againstElectronVLooseMVA62018 = self.cms.InputTag(_byElectronRejectionMVA62018VLoose)
898 "Medium" :
"WPeff80",
900 "VTight" :
"WPeff60",
902 for wp,wpEff
in wp_to_eff_match.items():
903 _aWP =
"patTauDiscriminationBy"+wp+
"ElectronRejectionMVA62018"+self.
postfix 904 setattr(self.
process,_aWP,_byElectronRejectionMVA62018VLooseProd.clone(
905 mapping = self.cms.VPSet(
907 category = self.cms.uint32(0),
908 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_BL_'+wpEff),
909 variable = self.cms.string(
'pt')
912 category = self.cms.uint32(2),
913 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_BL_'+wpEff),
914 variable = self.cms.string(
'pt')
917 category = self.cms.uint32(5),
918 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_BL_'+wpEff),
919 variable = self.cms.string(
'pt')
922 category = self.cms.uint32(7),
923 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_BL_'+wpEff),
924 variable = self.cms.string(
'pt')
927 category = self.cms.uint32(8),
928 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_woGwoGSF_EC_'+wpEff),
929 variable = self.cms.string(
'pt')
932 category = self.cms.uint32(10),
933 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_NoEleMatch_wGwoGSF_EC_'+wpEff),
934 variable = self.cms.string(
'pt')
937 category = self.cms.uint32(13),
938 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_woGwGSF_EC_'+wpEff),
939 variable = self.cms.string(
'pt')
942 category = self.cms.uint32(15),
943 cut = self.cms.string(
'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+
'_gbr_wGwGSF_EC_'+wpEff),
944 variable = self.cms.string(
'pt')
948 _patTauDiscriminationByElectronRejectionMVA62018Task.add(getattr(self.
process,_aWP))
949 setattr(_againstElectronTauIDSources,
"againstElectron"+wp+
"MVA62018",self.cms.InputTag(_aWP))
951 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA62018Task)
952 _rerunMvaIsolationSequence += self.cms.Sequence(_patTauDiscriminationByElectronRejectionMVA62018Task)
954 _tauIDSourcesWithAgainistEle = self.cms.PSet(
955 tauIDSources.clone(),
956 _againstElectronTauIDSources
958 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
963 embedID = self.cms.EDProducer(
"PATTauIDEmbedder",
965 tauIDSources = tauIDSources
969 tauIDSources = self.cms.PSet(
973 setattr(self.
process,
"rerunMvaIsolationTask"+self.
postfix,_rerunMvaIsolationTask)
974 setattr(self.
process,
"rerunMvaIsolationSequence"+self.
postfix,_rerunMvaIsolationSequence)
978 for target,points
in six.iteritems(workingPoints_):
979 cuts = self.cms.PSet()
980 setattr(tauIDSources,
'by{}VS{}raw'.
format(producer_name[0].
upper()+producer_name[1:], target),
981 self.cms.InputTag(producer_name+self.
postfix,
'VS{}'.
format(target)))
982 for point,cut
in six.iteritems(points):
983 setattr(cuts, point, self.cms.string(
str(cut)))
985 setattr(tauIDSources,
'by{}{}VS{}'.
format(point, producer_name[0].
upper()+producer_name[1:], target),
986 self.cms.InputTag(producer_name+self.
postfix,
'VS{}{}'.
format(target, point)))
992 """returns the DNN version. File name should contain a version label with data takig year (2011-2, 2015-8) and \ 993 version number (vX), e.g. 2017v0, in general the following format: {year}v{version}""" 994 version_search = re.search(
'201[125678]v([0-9]+)[\._]', file_name)
995 if not version_search:
996 raise RuntimeError(
'File "{}" has an invalid name pattern, should be in the format "{year}v{version}". \ 997 Unable to extract version number.'.
format(file_name))
998 version = version_search.group(1)
1002 """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \ 1003 (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \ 1004 {year}v{version}p{subversion}""" 1005 version_search = re.search(
'(201[125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
1006 if not version_search:
1007 raise RuntimeError(
'File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \ 1008 Unable to extract version number.'.
format(file_name))
1009 year = version_search.group(1)
1010 version = version_search.group(2)
1011 subversion = version_search.group(3)
1012 if len(subversion) > 0:
1013 subversion = subversion[1:]
1016 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 getDpfTauVersion(self, file_name)
def loadMVA_WPs_run2_2017(self)
S & print(S &os, JobReport::InputFile const &f)
def processDeepProducer(self, producer_name, tauIDSources, workingPoints_)
def versionToInt(release=9, subversion=4, patch=0, debug=False)