CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  self.processDeepProducer('deepTau2017v1', tauIDSources, workingPoints_)
655 
656  self.process.rerunMvaIsolationTask.add(self.process.deepTau2017v1)
657  self.process.rerunMvaIsolationSequence += self.process.deepTau2017v1
658 
659  if "deepTau2017v2" in self.toKeep:
660  if self.debug: print ("Adding DeepTau IDs")
661 
662  workingPoints_ = {
663  "e": {
664  "VVVLoose": 0.0630386,
665  "VVLoose": 0.1686942,
666  "VLoose": 0.3628130,
667  "Loose": 0.6815435,
668  "Medium": 0.8847544,
669  "Tight": 0.9675541,
670  "VTight": 0.9859251,
671  "VVTight": 0.9928449,
672  },
673  "mu": {
674  "VLoose": 0.1058354,
675  "Loose": 0.2158633,
676  "Medium": 0.5551894,
677  "Tight": 0.8754835,
678  },
679  "jet": {
680  "VVVLoose": 0.2599605,
681  "VVLoose": 0.4249705,
682  "VLoose": 0.5983682,
683  "Loose": 0.7848675,
684  "Medium": 0.8834768,
685  "Tight": 0.9308689,
686  "VTight": 0.9573137,
687  "VVTight": 0.9733927,
688  },
689  }
690 
691  file_names = [
692  'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
693  'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
694  'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
695  ]
696  self.process.deepTau2017v2 = self.cms.EDProducer("DeepTauId",
697  electrons = self.cms.InputTag('slimmedElectrons'),
698  muons = self.cms.InputTag('slimmedMuons'),
699  taus = self.cms.InputTag('slimmedTaus'),
700  pfcands = self.cms.InputTag('packedPFCandidates'),
701  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
702  rho = self.cms.InputTag('fixedGridRhoAll'),
703  graph_file = self.cms.vstring(file_names),
704  mem_mapped = self.cms.bool(True),
705  version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1]),
706  debug_level = self.cms.int32(0),
707  disable_dxy_pca = self.cms.bool(False)
708  )
709 
710  self.processDeepProducer('deepTau2017v2', tauIDSources, workingPoints_)
711 
712  self.process.rerunMvaIsolationTask.add(self.process.deepTau2017v2)
713  self.process.rerunMvaIsolationSequence += self.process.deepTau2017v2
714 
715  if "deepTau2017v2p1" in self.toKeep:
716  if self.debug: print ("Adding DeepTau IDs")
717 
718  workingPoints_ = {
719  "e": {
720  "VVVLoose": 0.0630386,
721  "VVLoose": 0.1686942,
722  "VLoose": 0.3628130,
723  "Loose": 0.6815435,
724  "Medium": 0.8847544,
725  "Tight": 0.9675541,
726  "VTight": 0.9859251,
727  "VVTight": 0.9928449,
728  },
729  "mu": {
730  "VLoose": 0.1058354,
731  "Loose": 0.2158633,
732  "Medium": 0.5551894,
733  "Tight": 0.8754835,
734  },
735  "jet": {
736  "VVVLoose": 0.2599605,
737  "VVLoose": 0.4249705,
738  "VLoose": 0.5983682,
739  "Loose": 0.7848675,
740  "Medium": 0.8834768,
741  "Tight": 0.9308689,
742  "VTight": 0.9573137,
743  "VVTight": 0.9733927,
744  },
745  }
746 
747  file_names = [
748  'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
749  'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
750  'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
751  ]
752  self.process.deepTau2017v2p1 = self.cms.EDProducer("DeepTauId",
753  electrons = self.cms.InputTag('slimmedElectrons'),
754  muons = self.cms.InputTag('slimmedMuons'),
755  taus = self.cms.InputTag('slimmedTaus'),
756  pfcands = self.cms.InputTag('packedPFCandidates'),
757  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
758  rho = self.cms.InputTag('fixedGridRhoAll'),
759  graph_file = self.cms.vstring(file_names),
760  mem_mapped = self.cms.bool(True),
761  version = self.cms.uint32(self.getDeepTauVersion(file_names[0])[1]),
762  debug_level = self.cms.int32(0),
763  disable_dxy_pca = self.cms.bool(True)
764  )
765 
766  self.processDeepProducer('deepTau2017v2p1', tauIDSources, workingPoints_)
767 
768  self.process.rerunMvaIsolationTask.add(self.process.deepTau2017v2p1)
769  self.process.rerunMvaIsolationSequence += self.process.deepTau2017v2p1
770 
771  if "DPFTau_2016_v0" in self.toKeep:
772  if self.debug: print ("Adding DPFTau isolation (v0)")
773 
774  workingPoints_ = {
775  "all": {
776  "Tight" : "if(decayMode == 0) return (0.898328 - 0.000160992 * pt);" + \
777  "if(decayMode == 1) return (0.910138 - 0.000229923 * pt);" + \
778  "if(decayMode == 10) return (0.873958 - 0.0002328 * pt);" + \
779  "return 99.0;"
780  #"Tight" : "? decayMode == 0 ? (0.898328 - 0.000160992 * pt) : " +
781  # "(? decayMode == 1 ? 0.910138 - 0.000229923 * pt : " +
782  # "(? decayMode == 10 ? (0.873958 - 0.0002328 * pt) : 1))"
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) "
786  }
787  }
788  file_names = [ 'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v0_quantized.pb' ]
789  self.process.dpfTau2016v0 = self.cms.EDProducer("DPFIsolation",
790  pfcands = self.cms.InputTag('packedPFCandidates'),
791  taus = self.cms.InputTag('slimmedTaus'),
792  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
793  graph_file = self.cms.vstring(file_names),
794  version = self.cms.uint32(self.getDpfTauVersion(file_names[0])),
795  mem_mapped = self.cms.bool(False)
796  )
797 
798  self.processDeepProducer('dpfTau2016v0', tauIDSources, workingPoints_)
799 
800  self.process.rerunMvaIsolationTask.add(self.process.dpfTau2016v0)
801  self.process.rerunMvaIsolationSequence += self.process.dpfTau2016v0
802 
803 
804  if "DPFTau_2016_v1" in self.toKeep:
805  print ("Adding DPFTau isolation (v1)")
806  print ("WARNING: WPs are not defined for DPFTau_2016_v1")
807  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).")
808 
809  workingPoints_ = {
810  "all": {"Tight" : 0.123} #FIXME: define WP
811  }
812 
813  file_names = [ 'RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v1_quantized.pb' ]
814  self.process.dpfTau2016v1 = self.cms.EDProducer("DPFIsolation",
815  pfcands = self.cms.InputTag('packedPFCandidates'),
816  taus = self.cms.InputTag('slimmedTaus'),
817  vertices = self.cms.InputTag('offlineSlimmedPrimaryVertices'),
818  graph_file = self.cms.vstring(file_names),
819  version = self.cms.uint32(self.getDpfTauVersion(file_names[0])),
820  mem_mapped = self.cms.bool(False)
821  )
822 
823  self.processDeepProducer('dpfTau2016v1', tauIDSources, workingPoints_)
824 
825  self.process.rerunMvaIsolationTask.add(self.process.dpfTau2016v1)
826  self.process.rerunMvaIsolationSequence += self.process.dpfTau2016v1
827 
828  if "againstEle2018" in self.toKeep:
829  antiElectronDiscrMVA6_version = "MVA6v3_noeveto"
830  ### Define new anti-e discriminants
831  ## Raw
832  from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
833  self.process.patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone(
834  Prediscriminants = noPrediscriminants, #already selected for MiniAOD
835  vetoEcalCracks = self.cms.bool(False), #keep taus in EB-EE cracks
836  mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL',
837  mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC',
838  mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL',
839  mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC',
840  mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL',
841  mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC',
842  mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL',
843  mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'
844  )
845  ## WPs
846  from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer
847  # VLoose
848  self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018 = patTauDiscriminantCutMultiplexer.clone(
849  PATTauProducer = self.process.patTauDiscriminationByElectronRejectionMVA62018Raw.PATTauProducer,
850  Prediscriminants = self.process.patTauDiscriminationByElectronRejectionMVA62018Raw.Prediscriminants,
851  toMultiplex = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"),
852  key = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw","category"),
853  mapping = self.cms.VPSet(
854  self.cms.PSet(
855  category = self.cms.uint32(0),
856  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff98'),
857  variable = self.cms.string('pt')
858  ),
859  self.cms.PSet(
860  category = self.cms.uint32(2),
861  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff98'),
862  variable = self.cms.string('pt')
863  ),
864  self.cms.PSet(
865  category = self.cms.uint32(5),
866  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff98'),
867  variable = self.cms.string('pt')
868  ),
869  self.cms.PSet(
870  category = self.cms.uint32(7),
871  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff98'),
872  variable = self.cms.string('pt')
873  ),
874  self.cms.PSet(
875  category = self.cms.uint32(8),
876  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff98'),
877  variable = self.cms.string('pt')
878  ),
879  self.cms.PSet(
880  category = self.cms.uint32(10),
881  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff98'),
882  variable = self.cms.string('pt')
883  ),
884  self.cms.PSet(
885  category = self.cms.uint32(13),
886  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff98'),
887  variable = self.cms.string('pt')
888  ),
889  self.cms.PSet(
890  category = self.cms.uint32(15),
891  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff98'),
892  variable = self.cms.string('pt')
893  )
894  )
895  )
896  # Loose
897  self.process.patTauDiscriminationByLooseElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
898  mapping = self.cms.VPSet(
899  self.cms.PSet(
900  category = self.cms.uint32(0),
901  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff90'),
902  variable = self.cms.string('pt')
903  ),
904  self.cms.PSet(
905  category = self.cms.uint32(2),
906  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff90'),
907  variable = self.cms.string('pt')
908  ),
909  self.cms.PSet(
910  category = self.cms.uint32(5),
911  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff90'),
912  variable = self.cms.string('pt')
913  ),
914  self.cms.PSet(
915  category = self.cms.uint32(7),
916  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff90'),
917  variable = self.cms.string('pt')
918  ),
919  self.cms.PSet(
920  category = self.cms.uint32(8),
921  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff90'),
922  variable = self.cms.string('pt')
923  ),
924  self.cms.PSet(
925  category = self.cms.uint32(10),
926  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff90'),
927  variable = self.cms.string('pt')
928  ),
929  self.cms.PSet(
930  category = self.cms.uint32(13),
931  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff90'),
932  variable = self.cms.string('pt')
933  ),
934  self.cms.PSet(
935  category = self.cms.uint32(15),
936  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff90'),
937  variable = self.cms.string('pt')
938  )
939  )
940  )
941  # Medium
942  self.process.patTauDiscriminationByMediumElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
943  mapping = self.cms.VPSet(
944  self.cms.PSet(
945  category = self.cms.uint32(0),
946  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff80'),
947  variable = self.cms.string('pt')
948  ),
949  self.cms.PSet(
950  category = self.cms.uint32(2),
951  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff80'),
952  variable = self.cms.string('pt')
953  ),
954  self.cms.PSet(
955  category = self.cms.uint32(5),
956  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff80'),
957  variable = self.cms.string('pt')
958  ),
959  self.cms.PSet(
960  category = self.cms.uint32(7),
961  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff80'),
962  variable = self.cms.string('pt')
963  ),
964  self.cms.PSet(
965  category = self.cms.uint32(8),
966  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff80'),
967  variable = self.cms.string('pt')
968  ),
969  self.cms.PSet(
970  category = self.cms.uint32(10),
971  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff80'),
972  variable = self.cms.string('pt')
973  ),
974  self.cms.PSet(
975  category = self.cms.uint32(13),
976  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff80'),
977  variable = self.cms.string('pt')
978  ),
979  self.cms.PSet(
980  category = self.cms.uint32(15),
981  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff80'),
982  variable = self.cms.string('pt')
983  )
984  )
985  )
986  # Tight
987  self.process.patTauDiscriminationByTightElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
988  mapping = self.cms.VPSet(
989  self.cms.PSet(
990  category = self.cms.uint32(0),
991  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff70'),
992  variable = self.cms.string('pt')
993  ),
994  self.cms.PSet(
995  category = self.cms.uint32(2),
996  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff70'),
997  variable = self.cms.string('pt')
998  ),
999  self.cms.PSet(
1000  category = self.cms.uint32(5),
1001  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff70'),
1002  variable = self.cms.string('pt')
1003  ),
1004  self.cms.PSet(
1005  category = self.cms.uint32(7),
1006  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff70'),
1007  variable = self.cms.string('pt')
1008  ),
1009  self.cms.PSet(
1010  category = self.cms.uint32(8),
1011  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff70'),
1012  variable = self.cms.string('pt')
1013  ),
1014  self.cms.PSet(
1015  category = self.cms.uint32(10),
1016  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff70'),
1017  variable = self.cms.string('pt')
1018  ),
1019  self.cms.PSet(
1020  category = self.cms.uint32(13),
1021  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff70'),
1022  variable = self.cms.string('pt')
1023  ),
1024  self.cms.PSet(
1025  category = self.cms.uint32(15),
1026  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff70'),
1027  variable = self.cms.string('pt')
1028  )
1029  )
1030  )
1031  # VTight
1032  self.process.patTauDiscriminationByVTightElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
1033  mapping = self.cms.VPSet(
1034  self.cms.PSet(
1035  category = self.cms.uint32(0),
1036  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff60'),
1037  variable = self.cms.string('pt')
1038  ),
1039  self.cms.PSet(
1040  category = self.cms.uint32(2),
1041  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff60'),
1042  variable = self.cms.string('pt')
1043  ),
1044  self.cms.PSet(
1045  category = self.cms.uint32(5),
1046  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff60'),
1047  variable = self.cms.string('pt')
1048  ),
1049  self.cms.PSet(
1050  category = self.cms.uint32(7),
1051  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff60'),
1052  variable = self.cms.string('pt')
1053  ),
1054  self.cms.PSet(
1055  category = self.cms.uint32(8),
1056  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff60'),
1057  variable = self.cms.string('pt')
1058  ),
1059  self.cms.PSet(
1060  category = self.cms.uint32(10),
1061  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff60'),
1062  variable = self.cms.string('pt')
1063  ),
1064  self.cms.PSet(
1065  category = self.cms.uint32(13),
1066  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff60'),
1067  variable = self.cms.string('pt')
1068  ),
1069  self.cms.PSet(
1070  category = self.cms.uint32(15),
1071  cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff60'),
1072  variable = self.cms.string('pt')
1073  )
1074  )
1075  )
1076  ### Put all new anti-e discrminats to a sequence
1077  self.process.patTauDiscriminationByElectronRejectionMVA62018Task = self.cms.Task(
1078  self.process.patTauDiscriminationByElectronRejectionMVA62018Raw,
1079  self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018,
1080  self.process.patTauDiscriminationByLooseElectronRejectionMVA62018,
1081  self.process.patTauDiscriminationByMediumElectronRejectionMVA62018,
1082  self.process.patTauDiscriminationByTightElectronRejectionMVA62018,
1083  self.process.patTauDiscriminationByVTightElectronRejectionMVA62018
1084  )
1085  self.process.patTauDiscriminationByElectronRejectionMVA62018Seq = self.cms.Sequence(self.process.patTauDiscriminationByElectronRejectionMVA62018Task)
1086  self.process.rerunMvaIsolationTask.add(self.process.patTauDiscriminationByElectronRejectionMVA62018Task)
1087  self.process.rerunMvaIsolationSequence += self.process.patTauDiscriminationByElectronRejectionMVA62018Seq
1088 
1089  _againstElectronTauIDSources = self.cms.PSet(
1090  againstElectronMVA6Raw2018 = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"),
1091  againstElectronMVA6category2018 = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw","category"),
1092  againstElectronVLooseMVA62018 = self.cms.InputTag("patTauDiscriminationByVLooseElectronRejectionMVA62018"),
1093  againstElectronLooseMVA62018 = self.cms.InputTag("patTauDiscriminationByLooseElectronRejectionMVA62018"),
1094  againstElectronMediumMVA62018 = self.cms.InputTag("patTauDiscriminationByMediumElectronRejectionMVA62018"),
1095  againstElectronTightMVA62018 = self.cms.InputTag("patTauDiscriminationByTightElectronRejectionMVA62018"),
1096  againstElectronVTightMVA62018 = self.cms.InputTag("patTauDiscriminationByVTightElectronRejectionMVA62018")
1097  )
1098  _tauIDSourcesWithAgainistEle = self.cms.PSet(
1099  tauIDSources.clone(),
1100  _againstElectronTauIDSources
1101  )
1102  tauIDSources =_tauIDSourcesWithAgainistEle.clone()
1103 
1104 
1105  if self.debug: print('Embedding new TauIDs into \"'+self.updatedTauName+'\"')
1106  if not hasattr(self.process, self.updatedTauName):
1107  embedID = self.cms.EDProducer("PATTauIDEmbedder",
1108  src = self.cms.InputTag('slimmedTaus'),
1109  tauIDSources = tauIDSources
1110  )
1111  setattr(self.process, self.updatedTauName, embedID)
1112  else: #assume same type
1113  tauIDSources = self.cms.PSet(
1114  getattr(self.process, self.updatedTauName).tauIDSources,
1115  tauIDSources)
1116  getattr(self.process, self.updatedTauName).tauIDSources = tauIDSources
1117 
1118 
1119  def processDeepProducer(self, producer_name, tauIDSources, workingPoints_):
1120  for target,points in six.iteritems(workingPoints_):
1121  cuts = self.cms.PSet()
1122  setattr(tauIDSources, 'by{}VS{}raw'.format(producer_name[0].upper()+producer_name[1:], target),
1123  self.cms.InputTag(producer_name, 'VS{}'.format(target)))
1124  for point,cut in six.iteritems(points):
1125  setattr(cuts, point, self.cms.string(str(cut)))
1126 
1127  setattr(tauIDSources, 'by{}{}VS{}'.format(point, producer_name[0].upper()+producer_name[1:], target),
1128  self.cms.InputTag(producer_name, 'VS{}{}'.format(target, point)))
1129 
1130  setattr(getattr(self.process, producer_name), 'VS{}WP'.format(target), cuts)
1131 
1132 
1133  def getDpfTauVersion(self, file_name):
1134  """returns the DNN version. File name should contain a version label with data takig year (2011-2, 2015-8) and \
1135  version number (vX), e.g. 2017v0, in general the following format: {year}v{version}"""
1136  version_search = re.search('201[125678]v([0-9]+)[\._]', file_name)
1137  if not version_search:
1138  raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}". \
1139  Unable to extract version number.'.format(file_name))
1140  version = version_search.group(1)
1141  return int(version)
1142 
1143  def getDeepTauVersion(self, file_name):
1144  """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \
1145  (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \
1146  {year}v{version}p{subversion}"""
1147  version_search = re.search('(201[125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
1148  if not version_search:
1149  raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \
1150  Unable to extract version number.'.format(file_name))
1151  year = version_search.group(1)
1152  version = version_search.group(2)
1153  subversion = version_search.group(3)
1154  if len(subversion) > 0:
1155  subversion = subversion[1:]
1156  else:
1157  subversion = 0
1158  return int(year), int(version), int(subversion)
std::vector< std::string_view > split(std::string_view, const char *)
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)