CMS 3D CMS Logo

runTauIdMVA.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
3 from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import patDiscriminationByIsolationMVArun2v1raw, patDiscriminationByIsolationMVArun2v1VLoose
4 import os
5 import re
6 import six
7 
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", "DPFTau_2016_v0", "DPFTau_2016_v1", "againstEle2018"
13  ]
14 
15  def __init__(self, process, cms, debug = False,
16  updatedTauName = "slimmedTausNewID",
17  toKeep = ["deepTau2017v2"],
18  tauIdDiscrMVA_trainings_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017", },
19  tauIdDiscrMVA_WPs_run2_2017 = {
20  'tauIdMVAIsoDBoldDMwLT2017' : {
21  'Eff95' : "DBoldDMwLTEff95",
22  'Eff90' : "DBoldDMwLTEff90",
23  'Eff80' : "DBoldDMwLTEff80",
24  'Eff70' : "DBoldDMwLTEff70",
25  'Eff60' : "DBoldDMwLTEff60",
26  'Eff50' : "DBoldDMwLTEff50",
27  'Eff40' : "DBoldDMwLTEff40"
28  }
29  },
30  tauIdDiscrMVA_2017_version = "v1",
31  conditionDB = "" # preparational DB: 'frontier://FrontierPrep/CMS_CONDITIONS'
32  ):
33  super(TauIDEmbedder, self).__init__()
34  self.process = process
35  self.cms = cms
36  self.debug = debug
37  self.updatedTauName = updatedTauName
38  self.process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
39  if len(conditionDB) != 0:
40  self.process.CondDBTauConnection.connect = cms.string(conditionDB)
41  self.process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
42  # if debug:
43  # print self.process.CondDBTauConnection.connect
44  # print dir(self.process.loadRecoTauTagMVAsFromPrepDB)
45  # print self.process.loadRecoTauTagMVAsFromPrepDB.parameterNames_
46 
47  self.tauIdDiscrMVA_trainings_run2_2017 = tauIdDiscrMVA_trainings_run2_2017
48  self.tauIdDiscrMVA_WPs_run2_2017 = tauIdDiscrMVA_WPs_run2_2017
49  self.tauIdDiscrMVA_2017_version = tauIdDiscrMVA_2017_version
50  for discr in toKeep:
51  if discr not in TauIDEmbedder.availableDiscriminators:
52  raise RuntimeError('TauIDEmbedder: discriminator "{}" is not supported'.format(discr))
53  self.toKeep = toKeep
54 
55 
56  @staticmethod
57  def get_cmssw_version(debug = False):
58  """returns 'CMSSW_X_Y_Z'"""
59  cmssw_version = os.environ["CMSSW_VERSION"]
60  if debug: print ("get_cmssw_version:", cmssw_version)
61  return cmssw_version
62 
63  @classmethod
64  def get_cmssw_version_number(klass, debug = False):
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)
68  if v[2] == "X":
69  patch = -1
70  else:
71  patch = int(v[2])
72  return int(v[0]), int(v[1]), patch
73 
74  @staticmethod
75  def versionToInt(release=9, subversion=4, patch=0, debug = False):
76  version = release * 10000 + subversion * 100 + patch + 1 # shifted by one to account for pre-releases.
77  if debug: print ("versionToInt:", version)
78  return version
79 
80 
81  @classmethod
82  def is_above_cmssw_version(klass, release=9, subversion=4, patch=0, debug = False):
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)
86  return False
87  else:
88  if debug: print ("is_above_cmssw_version:", True)
89  return True
90 
92  if self.debug: print ("loadMVA_WPs_run2_2017: performed")
93  global cms
94  for training, gbrForestName in self.tauIdDiscrMVA_trainings_run2_2017.items():
95 
96  self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
97  self.cms.PSet(
98  record = self.cms.string('GBRWrapperRcd'),
99  tag = self.cms.string("RecoTauTag_%s%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version)),
100  label = self.cms.untracked.string("RecoTauTag_%s%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version))
101  )
102  )
103 
104  for WP in self.tauIdDiscrMVA_WPs_run2_2017[training].keys():
105  self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
106  self.cms.PSet(
107  record = self.cms.string('PhysicsTGraphPayloadRcd'),
108  tag = self.cms.string("RecoTauTag_%s%s_WP%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version, WP)),
109  label = self.cms.untracked.string("RecoTauTag_%s%s_WP%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version, WP))
110  )
111  )
112 
113  self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
114  self.cms.PSet(
115  record = self.cms.string('PhysicsTFormulaPayloadRcd'),
116  tag = self.cms.string("RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, self.tauIdDiscrMVA_2017_version)),
117  label = self.cms.untracked.string("RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, self.tauIdDiscrMVA_2017_version))
118  )
119  )
120 
121  def runTauID(self):
122  self.process.rerunMvaIsolationTask = self.cms.Task()
123  self.process.rerunMvaIsolationSequence = self.cms.Sequence()
124  tauIDSources = self.cms.PSet()
125 
126  # rerun the seq to obtain the 2017 nom training with 0.5 iso cone, old DM, ptph>1, trained on 2017MCv1
127  if "2017v1" in self.toKeep:
128  self.tauIdDiscrMVA_2017_version = "v1"
130  'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
131  }
133  'tauIdMVAIsoDBoldDMwLT2017' : {
134  'Eff95' : "DBoldDMwLTEff95",
135  'Eff90' : "DBoldDMwLTEff90",
136  'Eff80' : "DBoldDMwLTEff80",
137  'Eff70' : "DBoldDMwLTEff70",
138  'Eff60' : "DBoldDMwLTEff60",
139  'Eff50' : "DBoldDMwLTEff50",
140  'Eff40' : "DBoldDMwLTEff40"
141  }
142  }
143  # update the list of available in DB samples
144  if not self.is_above_cmssw_version(9, 4, 4, self.debug):
145  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")
146  self.loadMVA_WPs_run2_2017()
147 
148  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
149  PATTauProducer = self.cms.InputTag('slimmedTaus'),
150  Prediscriminants = noPrediscriminants,
151  loadMVAfromDB = self.cms.bool(True),
152  mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
153  mvaOpt = self.cms.string("DBoldDMwLTwGJ"),
154  verbosity = self.cms.int32(0)
155  )
156 
157  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
158  PATTauProducer = self.cms.InputTag('slimmedTaus'),
159  Prediscriminants = noPrediscriminants,
160  toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1raw'),
161  key = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1raw:category'),#?
162  loadMVAfromDB = self.cms.bool(True),
163  mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
164  mapping = self.cms.VPSet(
165  self.cms.PSet(
166  category = self.cms.uint32(0),
167  cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff90"), #writeTauIdDiscrWPs
168  variable = self.cms.string("pt"),
169  )
170  )
171  )
172 
173  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone()
174  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff95")
175  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone()
176  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff80")
177  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone()
178  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Medium.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff70")
179  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone()
180  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff60")
181  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone()
182  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff50")
183  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone()
184  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff40")
185 
187  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw,
188  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose,
189  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose,
190  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose,
191  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Medium,
192  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight,
193  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VTight,
194  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight
195  )
196  self.process.rerunMvaIsolationTask.add(self.rerunIsolationOldDMMVArun2017v1Task)
197  self.process.rerunMvaIsolationSequence += self.cms.Sequence(self.rerunIsolationOldDMMVArun2017v1Task)
198 
199  tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1raw')
200  tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose')
201  tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose')
202  tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1Loose')
203  tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1Medium')
204  tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1Tight')
205  tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1VTight')
206  tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight')
207 
208 
209  if "2017v2" in self.toKeep:
210  self.tauIdDiscrMVA_2017_version = "v2"
212  'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
213  }
215  'tauIdMVAIsoDBoldDMwLT2017' : {
216  'Eff95' : "DBoldDMwLTEff95",
217  'Eff90' : "DBoldDMwLTEff90",
218  'Eff80' : "DBoldDMwLTEff80",
219  'Eff70' : "DBoldDMwLTEff70",
220  'Eff60' : "DBoldDMwLTEff60",
221  'Eff50' : "DBoldDMwLTEff50",
222  'Eff40' : "DBoldDMwLTEff40"
223  }
224  }
225 
226  if not self.is_above_cmssw_version(9, 4, 5, self.debug):
227  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")
228  self.loadMVA_WPs_run2_2017()
229 
230  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
231  PATTauProducer = self.cms.InputTag('slimmedTaus'),
232  Prediscriminants = noPrediscriminants,
233  loadMVAfromDB = self.cms.bool(True),
234  mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
235  mvaOpt = self.cms.string("DBoldDMwLTwGJ"),
236  verbosity = self.cms.int32(0)
237  )
238 
239  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
240  PATTauProducer = self.cms.InputTag('slimmedTaus'),
241  Prediscriminants = noPrediscriminants,
242  toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2raw'),
243  key = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2raw:category'),#?
244  loadMVAfromDB = self.cms.bool(True),
245  mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
246  mapping = self.cms.VPSet(
247  self.cms.PSet(
248  category = self.cms.uint32(0),
249  cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff90"), #writeTauIdDiscrWPs
250  variable = self.cms.string("pt"),
251  )
252  ),
253  verbosity = self.cms.int32(0)
254  )
255 
256  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
257  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff95")
258  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
259  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff80")
260  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
261  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff70")
262  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
263  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff60")
264  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
265  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff50")
266  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
267  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff40")
268 
270  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw,
271  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose,
272  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose,
273  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose,
274  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium,
275  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight,
276  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight,
277  self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight
278  )
279  self.process.rerunMvaIsolationTask.add(self.rerunIsolationOldDMMVArun2017v2Task)
280  self.process.rerunMvaIsolationSequence += self.cms.Sequence(self.rerunIsolationOldDMMVArun2017v2Task)
281 
282  tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2raw')
283  tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose')
284  tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose')
285  tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2Loose')
286  tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2Medium')
287  tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2Tight')
288  tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VTight')
289  tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight')
290 
291  if "newDM2017v2" in self.toKeep:
292  self.tauIdDiscrMVA_2017_version = "v2"
294  'tauIdMVAIsoDBnewDMwLT2017' : "tauIdMVAIsoDBnewDMwLT2017",
295  }
297  'tauIdMVAIsoDBnewDMwLT2017' : {
298  'Eff95' : "DBnewDMwLTEff95",
299  'Eff90' : "DBnewDMwLTEff90",
300  'Eff80' : "DBnewDMwLTEff80",
301  'Eff70' : "DBnewDMwLTEff70",
302  'Eff60' : "DBnewDMwLTEff60",
303  'Eff50' : "DBnewDMwLTEff50",
304  'Eff40' : "DBnewDMwLTEff40"
305  }
306  }
307 
308  if not self.is_above_cmssw_version(9, 4, 5, self.debug):
309  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")
310  self.loadMVA_WPs_run2_2017()
311 
312  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
313  PATTauProducer = self.cms.InputTag('slimmedTaus'),
314  Prediscriminants = noPrediscriminants,
315  loadMVAfromDB = self.cms.bool(True),
316  mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
317  mvaOpt = self.cms.string("DBnewDMwLTwGJ"),
318  verbosity = self.cms.int32(0)
319  )
320 
321  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
322  PATTauProducer = self.cms.InputTag('slimmedTaus'),
323  Prediscriminants = noPrediscriminants,
324  toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2raw'),
325  key = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2raw:category'),#?
326  loadMVAfromDB = self.cms.bool(True),
327  mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
328  mapping = self.cms.VPSet(
329  self.cms.PSet(
330  category = self.cms.uint32(0),
331  cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff90"), #writeTauIdDiscrWPs
332  variable = self.cms.string("pt"),
333  )
334  ),
335  verbosity = self.cms.int32(0)
336  )
337 
338  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone()
339  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff95")
340  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone()
341  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff80")
342  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Medium = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone()
343  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Medium.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff70")
344  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone()
345  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff60")
346  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone()
347  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff50")
348  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone()
349  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff40")
350 
352  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw,
353  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose,
354  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose,
355  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose,
356  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Medium,
357  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight,
358  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VTight,
359  self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight
360  )
361  self.process.rerunMvaIsolationTask.add(self.rerunIsolationNewDMMVArun2017v2Task)
362  self.process.rerunMvaIsolationSequence += self.cms.Sequence(self.rerunIsolationNewDMMVArun2017v2Task)
363 
364  tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2raw')
365  tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose')
366  tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose')
367  tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2Loose')
368  tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2Medium')
369  tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2Tight')
370  tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2VTight')
371  tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight')
372 
373  if "dR0p32017v2" in self.toKeep:
374  self.tauIdDiscrMVA_2017_version = "v2"
376  'tauIdMVAIsoDBoldDMdR0p3wLT2017' : "tauIdMVAIsoDBoldDMdR0p3wLT2017",
377  }
379  'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
380  'Eff95' : "DBoldDMdR0p3wLTEff95",
381  'Eff90' : "DBoldDMdR0p3wLTEff90",
382  'Eff80' : "DBoldDMdR0p3wLTEff80",
383  'Eff70' : "DBoldDMdR0p3wLTEff70",
384  'Eff60' : "DBoldDMdR0p3wLTEff60",
385  'Eff50' : "DBoldDMdR0p3wLTEff50",
386  'Eff40' : "DBoldDMdR0p3wLTEff40"
387  }
388  }
389 
390  if not self.is_above_cmssw_version(9, 4, 5, self.debug):
391  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")
392  self.loadMVA_WPs_run2_2017()
393 
394  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
395  PATTauProducer = self.cms.InputTag('slimmedTaus'),
396  Prediscriminants = noPrediscriminants,
397  loadMVAfromDB = self.cms.bool(True),
398  mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
399  mvaOpt = self.cms.string("DBoldDMwLTwGJ"),
400  srcChargedIsoPtSum = self.cms.string('chargedIsoPtSumdR03'),
401  srcFootprintCorrection = self.cms.string('footprintCorrectiondR03'),
402  srcNeutralIsoPtSum = self.cms.string('neutralIsoPtSumdR03'),
403  srcPhotonPtSumOutsideSignalCone = self.cms.string('photonPtSumOutsideSignalConedR03'),
404  verbosity = self.cms.int32(0)
405  )
406 
407  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
408  PATTauProducer = self.cms.InputTag('slimmedTaus'),
409  Prediscriminants = noPrediscriminants,
410  toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw'),
411  key = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw:category'),#?
412  loadMVAfromDB = self.cms.bool(True),
413  mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
414  mapping = self.cms.VPSet(
415  self.cms.PSet(
416  category = self.cms.uint32(0),
417  cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff90"), #writeTauIdDiscrWPs
418  variable = self.cms.string("pt"),
419  )
420  ),
421  verbosity = self.cms.int32(0)
422  )
423 
424  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone()
425  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff95")
426  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone()
427  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff80")
428  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone()
429  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff70")
430  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone()
431  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff60")
432  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone()
433  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff50")
434  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone()
435  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff40")
436 
438  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw,
439  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose,
440  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose,
441  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose,
442  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium,
443  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight,
444  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight,
445  self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight
446  )
447  self.process.rerunMvaIsolationTask.add(self.rerunIsolationOldDMdR0p3MVArun2017v2Task)
448  self.process.rerunMvaIsolationSequence += self.cms.Sequence(self.rerunIsolationOldDMdR0p3MVArun2017v2Task)
449 
450  tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw')
451  tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose')
452  tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose')
453  tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose')
454  tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium')
455  tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight')
456  tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight')
457  tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight')
458 
459  # 2016 training strategy(v2) - essentially the same as 2017 training strategy (v1), trained on 2016MC, old DM - currently not implemented in the tau sequence of any release
460  # self.process.rerunDiscriminationByIsolationOldDMMVArun2v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
461  # PATTauProducer = self.cms.InputTag('slimmedTaus'),
462  # Prediscriminants = noPrediscriminants,
463  # loadMVAfromDB = self.cms.bool(True),
464  # mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
465  # mvaOpt = self.cms.string("DBoldDMwLTwGJ"),
466  # verbosity = self.cms.int32(0)
467  # )
468  # #
469  # self.process.rerunDiscriminationByIsolationOldDMMVArun2v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
470  # PATTauProducer = self.cms.InputTag('slimmedTaus'),
471  # Prediscriminants = noPrediscriminants,
472  # toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v2raw'),
473  # key = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v2raw:category'),#?
474  # loadMVAfromDB = self.cms.bool(True),
475  # mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
476  # mapping = self.cms.VPSet(
477  # self.cms.PSet(
478  # category = self.cms.uint32(0),
479  # cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2_WPEff90"), #writeTauIdDiscrWPs
480  # variable = self.cms.string("pt"),
481  # )
482  # )
483  # )
484 
485  # 2016 training strategy(v1), trained on 2016MC, old DM
486  if "2016v1" in self.toKeep:
487  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
488  PATTauProducer = self.cms.InputTag('slimmedTaus'),
489  Prediscriminants = noPrediscriminants,
490  loadMVAfromDB = self.cms.bool(True),
491  mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
492  mvaOpt = self.cms.string("DBoldDMwLT"),
493  verbosity = self.cms.int32(0)
494  )
495 
496  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
497  PATTauProducer = self.cms.InputTag('slimmedTaus'),
498  Prediscriminants = noPrediscriminants,
499  toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1raw'),
500  key = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1raw:category'),
501  loadMVAfromDB = self.cms.bool(True),
502  mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
503  mapping = self.cms.VPSet(
504  self.cms.PSet(
505  category = self.cms.uint32(0),
506  cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff90"),
507  variable = self.cms.string("pt"),
508  )
509  )
510  )
511 
512  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone()
513  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff80")
514  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone()
515  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff70")
516  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone()
517  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff60")
518  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone()
519  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff50")
520  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone()
521  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VVTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff40")
522 
524  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1raw,
525  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose,
526  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose,
527  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium,
528  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight,
529  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight,
530  self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VVTight
531  )
532  self.process.rerunMvaIsolationTask.add(self.rerunIsolationOldDMMVArun2016v1Task)
533  self.process.rerunMvaIsolationSequence += self.cms.Sequence(self.rerunIsolationOldDMMVArun2016v1Task)
534 
535  tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1raw')
536  tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1VLoose')
537  tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1Loose')
538  tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1Medium')
539  tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1Tight')
540  tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1VTight')
541  tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v1VVTight')
542 
543  # 2016 training strategy(v1), trained on 2016MC, new DM
544  if "newDM2016v1" in self.toKeep:
545  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
546  PATTauProducer = self.cms.InputTag('slimmedTaus'),
547  Prediscriminants = noPrediscriminants,
548  loadMVAfromDB = self.cms.bool(True),
549  mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
550  mvaOpt = self.cms.string("DBnewDMwLT"),
551  verbosity = self.cms.int32(0)
552  )
553 
554  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
555  PATTauProducer = self.cms.InputTag('slimmedTaus'),
556  Prediscriminants = noPrediscriminants,
557  toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1raw'),
558  key = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1raw:category'),
559  loadMVAfromDB = self.cms.bool(True),
560  mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
561  mapping = self.cms.VPSet(
562  self.cms.PSet(
563  category = self.cms.uint32(0),
564  cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
565  variable = self.cms.string("pt"),
566  )
567  )
568  )
569 
570  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone()
571  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff80")
572  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone()
573  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff70")
574  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone()
575  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff60")
576  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone()
577  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff50")
578  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VVTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone()
579  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VVTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff40")
580 
582  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1raw,
583  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose,
584  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose,
585  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium,
586  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight,
587  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight,
588  self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VVTight
589  )
590  self.process.rerunMvaIsolationTask.add(self.rerunIsolationNewDMMVArun2016v1Task)
591  self.process.rerunMvaIsolationSequence += self.cms.Sequence(self.rerunIsolationNewDMMVArun2016v1Task)
592 
593  tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1raw')
594  tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1VLoose')
595  tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1Loose')
596  tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1Medium')
597  tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1Tight')
598  tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1VTight')
599  tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag('rerunDiscriminationByIsolationNewDMMVArun2v1VVTight')
600 
601  if "deepTau2017v1" in self.toKeep:
602  if self.debug: print ("Adding DeepTau IDs")
603 
604  workingPoints_ = {
605  "e": {
606  "VVVLoose" : 0.96424,
607  "VVLoose" : 0.98992,
608  "VLoose" : 0.99574,
609  "Loose": 0.99831,
610  "Medium": 0.99868,
611  "Tight": 0.99898,
612  "VTight": 0.99911,
613  "VVTight": 0.99918
614  },
615  "mu": {
616  "VVVLoose" : 0.959619,
617  "VVLoose" : 0.997687,
618  "VLoose" : 0.999392,
619  "Loose": 0.999755,
620  "Medium": 0.999854,
621  "Tight": 0.999886,
622  "VTight": 0.999944,
623  "VVTight": 0.9999971
624  },
625 
626  "jet": {
627  "VVVLoose" : 0.5329,
628  "VVLoose" : 0.7645,
629  "VLoose" : 0.8623,
630  "Loose": 0.9140,
631  "Medium": 0.9464,
632  "Tight": 0.9635,
633  "VTight": 0.9760,
634  "VVTight": 0.9859
635  }
636  }
637  file_names = ['RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v1_20L1024N_quantized.pb']
638  self.process.deepTau2017v1 = self.cms.EDProducer("DeepTauId",
639  electrons = self.cms.InputTag('slimmedElectrons'),
640  muons = self.cms.InputTag('slimmedMuons'),
641  taus = self.cms.InputTag('slimmedTaus'),
642  pfcands = self.cms.InputTag('packedPFCandidates'),
643  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
644  rho = self.cms.InputTag('fixedGridRhoAll'),
645  graph_file = self.cms.vstring(file_names),
646  mem_mapped = self.cms.bool(False),
647  version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1])
648  )
649 
650  self.processDeepProducer('deepTau2017v1', tauIDSources, workingPoints_)
651 
652  self.process.rerunMvaIsolationTask.add(self.process.deepTau2017v1)
653  self.process.rerunMvaIsolationSequence += self.process.deepTau2017v1
654 
655  if "deepTau2017v2" in self.toKeep:
656  if self.debug: print ("Adding DeepTau IDs")
657 
658  workingPoints_ = {
659  "e": {
660  "VVVLoose": 0.0630386,
661  "VVLoose": 0.1686942,
662  "VLoose": 0.3628130,
663  "Loose": 0.6815435,
664  "Medium": 0.8847544,
665  "Tight": 0.9675541,
666  "VTight": 0.9859251,
667  "VVTight": 0.9928449,
668  },
669  "mu": {
670  "VLoose": 0.1058354,
671  "Loose": 0.2158633,
672  "Medium": 0.5551894,
673  "Tight": 0.8754835,
674  },
675  "jet": {
676  "VVVLoose": 0.2599605,
677  "VVLoose": 0.4249705,
678  "VLoose": 0.5983682,
679  "Loose": 0.7848675,
680  "Medium": 0.8834768,
681  "Tight": 0.9308689,
682  "VTight": 0.9573137,
683  "VVTight": 0.9733927,
684  },
685  }
686 
687  file_names = [
688  'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
689  'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
690  'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
691  ]
692  self.process.deepTau2017v2 = self.cms.EDProducer("DeepTauId",
693  electrons = self.cms.InputTag('slimmedElectrons'),
694  muons = self.cms.InputTag('slimmedMuons'),
695  taus = self.cms.InputTag('slimmedTaus'),
696  pfcands = self.cms.InputTag('packedPFCandidates'),
697  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
698  rho = self.cms.InputTag('fixedGridRhoAll'),
699  graph_file = self.cms.vstring(file_names),
700  mem_mapped = self.cms.bool(True),
701  version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1]),
702  debug_level = self.cms.int32(0)
703 
704  )
705 
706  self.processDeepProducer('deepTau2017v2', tauIDSources, workingPoints_)
707 
708  self.process.rerunMvaIsolationTask.add(self.process.deepTau2017v2)
709  self.process.rerunMvaIsolationSequence += self.process.deepTau2017v2
710 
711  if "DPFTau_2016_v0" in self.toKeep:
712  if self.debug: print ("Adding DPFTau isolation (v0)")
713 
714  workingPoints_ = {
715  "all": {
716  "Tight" : "if(decayMode == 0) return (0.898328 - 0.000160992 * pt);" + \
717  "if(decayMode == 1) return (0.910138 - 0.000229923 * pt);" + \
718  "if(decayMode == 10) return (0.873958 - 0.0002328 * pt);" + \
719  "return 99.0;"
720  #"Tight" : "? decayMode == 0 ? (0.898328 - 0.000160992 * pt) : " +
721  # "(? decayMode == 1 ? 0.910138 - 0.000229923 * pt : " +
722  # "(? decayMode == 10 ? (0.873958 - 0.0002328 * pt) : 1))"
723  # "Tight" : "(decayMode == 0) * (0.898328 - 0.000160992 * pt) + \
724  # (decayMode == 1) * (0.910138 - 0.000229923 * pt) + \
725  # (decayMode == 10) * (0.873958 - 0.0002328 * pt) "
726  }
727  }
728  file_names = [ 'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v0_quantized.pb' ]
729  self.process.dpfTau2016v0 = self.cms.EDProducer("DPFIsolation",
730  pfcands = self.cms.InputTag('packedPFCandidates'),
731  taus = self.cms.InputTag('slimmedTaus'),
732  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
733  graph_file = self.cms.vstring(file_names),
734  version = self.cms.uint32(self.getDpfTauVersion(file_names[0])),
735  mem_mapped = self.cms.bool(False)
736  )
737 
738  self.processDeepProducer('dpfTau2016v0', tauIDSources, workingPoints_)
739 
740  self.process.rerunMvaIsolationTask.add(self.process.dpfTau2016v0)
741  self.process.rerunMvaIsolationSequence += self.process.dpfTau2016v0
742 
743 
744  if "DPFTau_2016_v1" in self.toKeep:
745  print ("Adding DPFTau isolation (v1)")
746  print ("WARNING: WPs are not defined for DPFTau_2016_v1")
747  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).")
748 
749  workingPoints_ = {
750  "all": {"Tight" : 0.123} #FIXME: define WP
751  }
752 
753  file_names = [ 'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v1_quantized.pb' ]
754  self.process.dpfTau2016v1 = self.cms.EDProducer("DPFIsolation",
755  pfcands = self.cms.InputTag('packedPFCandidates'),
756  taus = self.cms.InputTag('slimmedTaus'),
757  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
758  graph_file = self.cms.vstring(file_names),
759  version = self.cms.uint32(self.getDpfTauVersion(file_names[0])),
760  mem_mapped = self.cms.bool(False)
761  )
762 
763  self.processDeepProducer('dpfTau2016v1', tauIDSources, workingPoints_)
764 
765  self.process.rerunMvaIsolationTask.add(self.process.dpfTau2016v1)
766  self.process.rerunMvaIsolationSequence += self.process.dpfTau2016v1
767 
768  if "againstEle2018" in self.toKeep:
769  antiElectronDiscrMVA6_version = "MVA6v3_noeveto"
770  ### Define new anti-e discriminants
771  ## Raw
772  from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
773  self.process.patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone(
774  Prediscriminants = noPrediscriminants, #already selected for MiniAOD
775  vetoEcalCracks = self.cms.bool(False), #keep taus in EB-EE cracks
776  mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL',
777  mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC',
778  mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL',
779  mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC',
780  mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL',
781  mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC',
782  mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL',
783  mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'
784  )
785  ## WPs
786  from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer
787  # VLoose
788  self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018 = patTauDiscriminantCutMultiplexer.clone(
789  PATTauProducer = self.process.patTauDiscriminationByElectronRejectionMVA62018Raw.PATTauProducer,
790  Prediscriminants = self.process.patTauDiscriminationByElectronRejectionMVA62018Raw.Prediscriminants,
791  toMultiplex = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"),
792  key = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw","category"),
793  mapping = self.cms.VPSet(
794  self.cms.PSet(
795  category = self.cms.uint32(0),
796  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff98'),
797  variable = self.cms.string('pt')
798  ),
799  self.cms.PSet(
800  category = self.cms.uint32(2),
801  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff98'),
802  variable = self.cms.string('pt')
803  ),
804  self.cms.PSet(
805  category = self.cms.uint32(5),
806  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff98'),
807  variable = self.cms.string('pt')
808  ),
809  self.cms.PSet(
810  category = self.cms.uint32(7),
811  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff98'),
812  variable = self.cms.string('pt')
813  ),
814  self.cms.PSet(
815  category = self.cms.uint32(8),
816  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff98'),
817  variable = self.cms.string('pt')
818  ),
819  self.cms.PSet(
820  category = self.cms.uint32(10),
821  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff98'),
822  variable = self.cms.string('pt')
823  ),
824  self.cms.PSet(
825  category = self.cms.uint32(13),
826  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff98'),
827  variable = self.cms.string('pt')
828  ),
829  self.cms.PSet(
830  category = self.cms.uint32(15),
831  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff98'),
832  variable = self.cms.string('pt')
833  )
834  )
835  )
836  # Loose
837  self.process.patTauDiscriminationByLooseElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
838  mapping = self.cms.VPSet(
839  self.cms.PSet(
840  category = self.cms.uint32(0),
841  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff90'),
842  variable = self.cms.string('pt')
843  ),
844  self.cms.PSet(
845  category = self.cms.uint32(2),
846  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff90'),
847  variable = self.cms.string('pt')
848  ),
849  self.cms.PSet(
850  category = self.cms.uint32(5),
851  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff90'),
852  variable = self.cms.string('pt')
853  ),
854  self.cms.PSet(
855  category = self.cms.uint32(7),
856  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff90'),
857  variable = self.cms.string('pt')
858  ),
859  self.cms.PSet(
860  category = self.cms.uint32(8),
861  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff90'),
862  variable = self.cms.string('pt')
863  ),
864  self.cms.PSet(
865  category = self.cms.uint32(10),
866  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff90'),
867  variable = self.cms.string('pt')
868  ),
869  self.cms.PSet(
870  category = self.cms.uint32(13),
871  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff90'),
872  variable = self.cms.string('pt')
873  ),
874  self.cms.PSet(
875  category = self.cms.uint32(15),
876  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff90'),
877  variable = self.cms.string('pt')
878  )
879  )
880  )
881  # Medium
882  self.process.patTauDiscriminationByMediumElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
883  mapping = self.cms.VPSet(
884  self.cms.PSet(
885  category = self.cms.uint32(0),
886  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff80'),
887  variable = self.cms.string('pt')
888  ),
889  self.cms.PSet(
890  category = self.cms.uint32(2),
891  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff80'),
892  variable = self.cms.string('pt')
893  ),
894  self.cms.PSet(
895  category = self.cms.uint32(5),
896  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff80'),
897  variable = self.cms.string('pt')
898  ),
899  self.cms.PSet(
900  category = self.cms.uint32(7),
901  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff80'),
902  variable = self.cms.string('pt')
903  ),
904  self.cms.PSet(
905  category = self.cms.uint32(8),
906  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff80'),
907  variable = self.cms.string('pt')
908  ),
909  self.cms.PSet(
910  category = self.cms.uint32(10),
911  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff80'),
912  variable = self.cms.string('pt')
913  ),
914  self.cms.PSet(
915  category = self.cms.uint32(13),
916  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff80'),
917  variable = self.cms.string('pt')
918  ),
919  self.cms.PSet(
920  category = self.cms.uint32(15),
921  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff80'),
922  variable = self.cms.string('pt')
923  )
924  )
925  )
926  # Tight
927  self.process.patTauDiscriminationByTightElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
928  mapping = self.cms.VPSet(
929  self.cms.PSet(
930  category = self.cms.uint32(0),
931  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff70'),
932  variable = self.cms.string('pt')
933  ),
934  self.cms.PSet(
935  category = self.cms.uint32(2),
936  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff70'),
937  variable = self.cms.string('pt')
938  ),
939  self.cms.PSet(
940  category = self.cms.uint32(5),
941  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff70'),
942  variable = self.cms.string('pt')
943  ),
944  self.cms.PSet(
945  category = self.cms.uint32(7),
946  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff70'),
947  variable = self.cms.string('pt')
948  ),
949  self.cms.PSet(
950  category = self.cms.uint32(8),
951  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff70'),
952  variable = self.cms.string('pt')
953  ),
954  self.cms.PSet(
955  category = self.cms.uint32(10),
956  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff70'),
957  variable = self.cms.string('pt')
958  ),
959  self.cms.PSet(
960  category = self.cms.uint32(13),
961  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff70'),
962  variable = self.cms.string('pt')
963  ),
964  self.cms.PSet(
965  category = self.cms.uint32(15),
966  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff70'),
967  variable = self.cms.string('pt')
968  )
969  )
970  )
971  # VTight
972  self.process.patTauDiscriminationByVTightElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
973  mapping = self.cms.VPSet(
974  self.cms.PSet(
975  category = self.cms.uint32(0),
976  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff60'),
977  variable = self.cms.string('pt')
978  ),
979  self.cms.PSet(
980  category = self.cms.uint32(2),
981  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff60'),
982  variable = self.cms.string('pt')
983  ),
984  self.cms.PSet(
985  category = self.cms.uint32(5),
986  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff60'),
987  variable = self.cms.string('pt')
988  ),
989  self.cms.PSet(
990  category = self.cms.uint32(7),
991  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff60'),
992  variable = self.cms.string('pt')
993  ),
994  self.cms.PSet(
995  category = self.cms.uint32(8),
996  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff60'),
997  variable = self.cms.string('pt')
998  ),
999  self.cms.PSet(
1000  category = self.cms.uint32(10),
1001  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff60'),
1002  variable = self.cms.string('pt')
1003  ),
1004  self.cms.PSet(
1005  category = self.cms.uint32(13),
1006  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff60'),
1007  variable = self.cms.string('pt')
1008  ),
1009  self.cms.PSet(
1010  category = self.cms.uint32(15),
1011  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff60'),
1012  variable = self.cms.string('pt')
1013  )
1014  )
1015  )
1016  ### Put all new anti-e discrminats to a sequence
1017  self.process.patTauDiscriminationByElectronRejectionMVA62018Task = self.cms.Task(
1018  self.process.patTauDiscriminationByElectronRejectionMVA62018Raw,
1019  self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018,
1020  self.process.patTauDiscriminationByLooseElectronRejectionMVA62018,
1021  self.process.patTauDiscriminationByMediumElectronRejectionMVA62018,
1022  self.process.patTauDiscriminationByTightElectronRejectionMVA62018,
1023  self.process.patTauDiscriminationByVTightElectronRejectionMVA62018
1024  )
1025  self.process.patTauDiscriminationByElectronRejectionMVA62018Seq = self.cms.Sequence(self.process.patTauDiscriminationByElectronRejectionMVA62018Task)
1026  self.process.rerunMvaIsolationTask.add(self.process.patTauDiscriminationByElectronRejectionMVA62018Task)
1027  self.process.rerunMvaIsolationSequence += self.process.patTauDiscriminationByElectronRejectionMVA62018Seq
1028 
1029  _againstElectronTauIDSources = self.cms.PSet(
1030  againstElectronMVA6Raw2018 = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"),
1031  againstElectronMVA6category2018 = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw","category"),
1032  againstElectronVLooseMVA62018 = self.cms.InputTag("patTauDiscriminationByVLooseElectronRejectionMVA62018"),
1033  againstElectronLooseMVA62018 = self.cms.InputTag("patTauDiscriminationByLooseElectronRejectionMVA62018"),
1034  againstElectronMediumMVA62018 = self.cms.InputTag("patTauDiscriminationByMediumElectronRejectionMVA62018"),
1035  againstElectronTightMVA62018 = self.cms.InputTag("patTauDiscriminationByTightElectronRejectionMVA62018"),
1036  againstElectronVTightMVA62018 = self.cms.InputTag("patTauDiscriminationByVTightElectronRejectionMVA62018")
1037  )
1038  _tauIDSourcesWithAgainistEle = self.cms.PSet(
1039  tauIDSources.clone(),
1040  _againstElectronTauIDSources
1041  )
1042  tauIDSources =_tauIDSourcesWithAgainistEle.clone()
1043 
1044 
1045  if self.debug: print('Embedding new TauIDs into \"'+self.updatedTauName+'\"')
1046  if not hasattr(self.process, self.updatedTauName):
1047  embedID = self.cms.EDProducer("PATTauIDEmbedder",
1048  src = self.cms.InputTag('slimmedTaus'),
1049  tauIDSources = tauIDSources
1050  )
1051  setattr(self.process, self.updatedTauName, embedID)
1052  else: #assume same type
1053  tauIDSources = self.cms.PSet(
1054  getattr(self.process, self.updatedTauName).tauIDSources,
1055  tauIDSources)
1056  getattr(self.process, self.updatedTauName).tauIDSources = tauIDSources
1057 
1058 
1059  def processDeepProducer(self, producer_name, tauIDSources, workingPoints_):
1060  for target,points in six.iteritems(workingPoints_):
1061  cuts = self.cms.PSet()
1062  setattr(tauIDSources, 'by{}VS{}raw'.format(producer_name[0].upper()+producer_name[1:], target),
1063  self.cms.InputTag(producer_name, 'VS{}'.format(target)))
1064  for point,cut in six.iteritems(points):
1065  setattr(cuts, point, self.cms.string(str(cut)))
1066 
1067  setattr(tauIDSources, 'by{}{}VS{}'.format(point, producer_name[0].upper()+producer_name[1:], target),
1068  self.cms.InputTag(producer_name, 'VS{}{}'.format(target, point)))
1069 
1070  setattr(getattr(self.process, producer_name), 'VS{}WP'.format(target), cuts)
1071 
1072 
1073  def getDpfTauVersion(self, file_name):
1074  """returns the DNN version. File name should contain a version label with data takig year (2011-2, 2015-8) and \
1075  version number (vX), e.g. 2017v0, in general the following format: {year}v{version}"""
1076  version_search = re.search('201[125678]v([0-9]+)[\._]', file_name)
1077  if not version_search:
1078  raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}". \
1079  Unable to extract version number.'.format(file_name))
1080  version = version_search.group(1)
1081  return int(version)
1082 
1083  def getDeepTauVersion(self, file_name):
1084  """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \
1085  (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \
1086  {year}v{version}p{subversion}"""
1087  version_search = re.search('(201[125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
1088  if not version_search:
1089  raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \
1090  Unable to extract version number.'.format(file_name))
1091  year = version_search.group(1)
1092  version = version_search.group(2)
1093  subversion = version_search.group(3)
1094  if len(subversion) > 0:
1095  subversion = subversion[1:]
1096  else:
1097  subversion = 0
1098  return int(year), int(version), int(subversion)
def is_above_cmssw_version(klass, release=9, subversion=4, patch=0, debug=False)
Definition: runTauIdMVA.py:82
def getDeepTauVersion(self, file_name)
def get_cmssw_version_number(klass, debug=False)
Definition: runTauIdMVA.py:64
def get_cmssw_version(debug=False)
Definition: runTauIdMVA.py:57
def getDpfTauVersion(self, file_name)
def loadMVA_WPs_run2_2017(self)
Definition: runTauIdMVA.py:91
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def processDeepProducer(self, producer_name, tauIDSources, workingPoints_)
def versionToInt(release=9, subversion=4, patch=0, debug=False)
Definition: runTauIdMVA.py:75
#define str(s)
double split
Definition: MVATrainer.cc:139