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