CMS 3D CMS Logo

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