File indexing completed on 2024-11-25 02:30:00
0001 import FWCore.ParameterSet.Config as cms
0002 from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
0003 from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import patDiscriminationByIsolationMVArun2v1raw, patDiscriminationByIsolationMVArun2v1
0004 from RecoTauTag.RecoTau.DeepTau_cfi import DeepTau
0005 from RecoTauTag.RecoTau.DeepTauIdSonicProducer_cfi import DeepTauIdSonicProducer
0006 from RecoTauTag.RecoTau.tauIdWPsDefs import WORKING_POINTS_v2p1, WORKING_POINTS_v2p5, WORKING_POINTS_PHASEII_v2p5, WORKING_POINTS_BOOSTED_v2p0
0007
0008 import os
0009 import re
0010
0011 class TauIDEmbedder(object):
0012 """class to rerun the tau seq and acces trainings from the database"""
0013 experimentalDiscriminators = [
0014 "2017v1", "2017v2", "newDM2017v2", "dR0p32017v2", "2016v1", "newDM2016v1",
0015 "againstEle2018"
0016 ]
0017 availableDiscriminators = experimentalDiscriminators.copy()
0018 availableDiscriminators.extend([
0019 "mvaIso", "mvaIsoNewDM", "mvaIsoDR0p3",
0020 "againstEle",
0021 "newDMPhase2v1",
0022 "againstElePhase2v1",
0023 "deepTau2017v2", "deepTau2017v2p1", "deepTau2018v2p5", "boostedDeepTauRunIIv2p0", "deepTau2026v2p5"
0024 ])
0025
0026 def __init__(self, process, debug = False,
0027 originalTauName = "slimmedTaus",
0028 updatedTauName = "slimmedTausNewID",
0029 postfix = "",
0030 toKeep = ["deepTau2017v2p1", "deepTau2018v2p5", "deepTau2026v2p5"],
0031 conditionDB = ""
0032 ):
0033 super(TauIDEmbedder, self).__init__()
0034 self.process = process
0035 self.debug = debug
0036 self.originalTauName = originalTauName
0037 self.updatedTauName = updatedTauName
0038 self.postfix = postfix
0039
0040 for discr in toKeep:
0041 if discr not in TauIDEmbedder.availableDiscriminators:
0042 raise RuntimeError('TauIDEmbedder: discriminator "{}" is not supported'.format(discr))
0043 self.toKeep = toKeep
0044 if not set(toKeep).isdisjoint(TauIDEmbedder.experimentalDiscriminators):
0045 print('There are experimental tauIDs not from GT')
0046 self.process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
0047 if len(conditionDB) != 0:
0048 self.process.CondDBTauConnection.connect = cms.string(conditionDB)
0049 self.process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
0050
0051
0052
0053
0054
0055 @staticmethod
0056 def get_cmssw_version(debug = False):
0057 """returns 'CMSSW_X_Y_Z'"""
0058 cmssw_version = os.environ["CMSSW_VERSION"]
0059 if debug: print ("get_cmssw_version:", cmssw_version)
0060 return cmssw_version
0061
0062 @classmethod
0063 def get_cmssw_version_number(klass, debug = False):
0064 """returns '(release, subversion, patch)' (without 'CMSSW_')"""
0065 v = klass.get_cmssw_version().split("CMSSW_")[1].split("_")[0:3]
0066 if debug: print ("get_cmssw_version_number:", v)
0067 try:
0068 patch = int(v[2])
0069 except:
0070 patch = -1
0071 return int(v[0]), int(v[1]), patch
0072
0073 @staticmethod
0074 def versionToInt(release=9, subversion=4, patch=0, debug = False):
0075 version = release * 10000 + subversion * 100 + patch + 1
0076 if debug: print ("versionToInt:", version)
0077 return version
0078
0079
0080 @classmethod
0081 def is_above_cmssw_version(klass, release=9, subversion=4, patch=0, debug = False):
0082 split_cmssw_version = klass.get_cmssw_version_number()
0083 if klass.versionToInt(release, subversion, patch) > klass.versionToInt(split_cmssw_version[0], split_cmssw_version[1], split_cmssw_version[2]):
0084 if debug: print ("is_above_cmssw_version:", False)
0085 return False
0086 else:
0087 if debug: print ("is_above_cmssw_version:", True)
0088 return True
0089
0090 def tauIDMVAinputs(self, module, wp):
0091 return cms.PSet(inputTag = cms.InputTag(module), workingPointIndex = cms.int32(-1 if wp=="raw" else -2 if wp=="category" else getattr(self.process, module).workingPoints.index(wp)))
0092
0093 def loadMVA_WPs_run2_2017(self):
0094 if self.debug: print ("loadMVA_WPs_run2_2017: performed")
0095 global cms
0096 for training, gbrForestName in self.tauIdDiscrMVA_trainings_run2_2017.items():
0097
0098 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
0099 cms.PSet(
0100 record = cms.string('GBRWrapperRcd'),
0101 tag = cms.string("RecoTauTag_%s%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version)),
0102 label = cms.untracked.string("RecoTauTag_%s%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version))
0103 )
0104 )
0105
0106 for WP in self.tauIdDiscrMVA_WPs_run2_2017[training].keys():
0107 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
0108 cms.PSet(
0109 record = cms.string('PhysicsTGraphPayloadRcd'),
0110 tag = cms.string("RecoTauTag_%s%s_WP%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version, WP)),
0111 label = cms.untracked.string("RecoTauTag_%s%s_WP%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version, WP))
0112 )
0113 )
0114
0115 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
0116 cms.PSet(
0117 record = cms.string('PhysicsTFormulaPayloadRcd'),
0118 tag = cms.string("RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, self.tauIdDiscrMVA_2017_version)),
0119 label = cms.untracked.string("RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, self.tauIdDiscrMVA_2017_version))
0120 )
0121 )
0122
0123 def load_againstElectronMVA6(self):
0124 if self.debug: print ("load_againstElectronMVA6: performed")
0125 global cms
0126 antiElectronDiscrMVA6_categories = {
0127 '0' : "gbr_NoEleMatch_woGwoGSF_BL",
0128 '2' : "gbr_NoEleMatch_wGwoGSF_BL",
0129 '5' : "gbr_woGwGSF_BL",
0130 '7' : "gbr_wGwGSF_BL",
0131 '8' : "gbr_NoEleMatch_woGwoGSF_EC",
0132 '10' : "gbr_NoEleMatch_wGwoGSF_EC",
0133 '13' : "gbr_woGwGSF_EC",
0134 '15' : "gbr_wGwGSF_EC"
0135 }
0136 for category, gbrForestName in antiElectronDiscrMVA6_categories.items():
0137 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
0138 cms.PSet(
0139 record = cms.string('GBRWrapperRcd'),
0140 tag = cms.string("RecoTauTag_antiElectronMVA6%s_%s" % (self.antiElectronDiscrMVA6_version, gbrForestName)),
0141 label = cms.untracked.string("RecoTauTag_antiElectronMVA6%s_%s" % (self.antiElectronDiscrMVA6_version, gbrForestName))
0142 )
0143 )
0144 for WP in self.antiElectronDiscrMVA6_WPs:
0145 self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
0146 cms.PSet(
0147 record = cms.string('PhysicsTGraphPayloadRcd'),
0148 tag = cms.string("RecoTauTag_antiElectronMVA6%s_%s_WP%s" % (self.antiElectronDiscrMVA6_version, gbrForestName, WP)),
0149 label = cms.untracked.string("RecoTauTag_antiElectronMVA6%s_%s_WP%s" % (self.antiElectronDiscrMVA6_version, gbrForestName, WP))
0150 )
0151 )
0152
0153 def runTauID(self):
0154 _rerunMvaIsolationTask = cms.Task()
0155 _rerunMvaIsolationSequence = cms.Sequence()
0156 tauIDSources = cms.PSet()
0157
0158
0159 if "mvaIso" in self.toKeep:
0160 _byIsolationOldDMMVAraw = "rerunDiscriminationByIsolationOldDMMVAraw"+self.postfix
0161 setattr(self.process,_byIsolationOldDMMVAraw,patDiscriminationByIsolationMVArun2v1raw.clone(
0162 PATTauProducer = self.originalTauName,
0163 Prediscriminants = noPrediscriminants,
0164 loadMVAfromDB = cms.bool(True),
0165 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"),
0166 mvaOpt = cms.string("DBoldDMwLTwGJ"),
0167 verbosity = cms.int32(0)
0168 ))
0169
0170 _byIsolationOldDMMVA = "rerunDiscriminationByIsolationOldDMMVA"+self.postfix
0171 setattr(self.process,_byIsolationOldDMMVA,patDiscriminationByIsolationMVArun2v1.clone(
0172 PATTauProducer = self.originalTauName,
0173 Prediscriminants = noPrediscriminants,
0174 toMultiplex = _byIsolationOldDMMVAraw,
0175 loadMVAfromDB = cms.bool(True),
0176 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT_mvaOutput_normalization"),
0177 mapping = cms.VPSet(
0178 cms.PSet(
0179 category = cms.uint32(0),
0180 cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"),
0181 variable = cms.string("pt"),
0182 )
0183 ),
0184 workingPoints = cms.vstring(
0185 "_VVLoose",
0186 "_VLoose",
0187 "_Loose",
0188 "_Medium",
0189 "_Tight",
0190 "_VTight",
0191 "_VVTight"
0192 )
0193 ))
0194
0195 _rerunIsolationOldDMMVATask = cms.Task(
0196 getattr(self.process,_byIsolationOldDMMVAraw),
0197 getattr(self.process,_byIsolationOldDMMVA)
0198 )
0199 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVATask)
0200 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVATask)
0201
0202 tauIDSources.byIsolationMVArun2DBoldDMwLTraw = self.tauIDMVAinputs(_byIsolationOldDMMVA, "raw")
0203 tauIDSources.byVVLooseIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VVLoose")
0204 tauIDSources.byVLooseIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VLoose")
0205 tauIDSources.byLooseIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_Loose")
0206 tauIDSources.byMediumIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_Medium")
0207 tauIDSources.byTightIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_Tight")
0208 tauIDSources.byVTightIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VTight")
0209 tauIDSources.byVVTightIsolationMVArun2DBoldDMwLT = self.tauIDMVAinputs(_byIsolationOldDMMVA, "_VVTight")
0210
0211 if "mvaIsoNewDM" in self.toKeep:
0212 _byIsolationNewDMMVAraw = "rerunDiscriminationByIsolationNewDMMVAraw"+self.postfix
0213 setattr(self.process,_byIsolationNewDMMVAraw,patDiscriminationByIsolationMVArun2v1raw.clone(
0214 PATTauProducer = self.originalTauName,
0215 Prediscriminants = noPrediscriminants,
0216 loadMVAfromDB = cms.bool(True),
0217 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"),
0218 mvaOpt = cms.string("DBnewDMwLTwGJ"),
0219 verbosity = cms.int32(0)
0220 ))
0221
0222 _byIsolationNewDMMVA = "rerunDiscriminationByIsolationNewDMMVA"+self.postfix
0223 setattr(self.process,_byIsolationNewDMMVA,patDiscriminationByIsolationMVArun2v1.clone(
0224 PATTauProducer = self.originalTauName,
0225 Prediscriminants = noPrediscriminants,
0226 toMultiplex = _byIsolationNewDMMVAraw,
0227 loadMVAfromDB = cms.bool(True),
0228 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT_mvaOutput_normalization"),
0229 mapping = cms.VPSet(
0230 cms.PSet(
0231 category = cms.uint32(0),
0232 cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"),
0233 variable = cms.string("pt"),
0234 )
0235 ),
0236 workingPoints = cms.vstring(
0237 "_VVLoose",
0238 "_VLoose",
0239 "_Loose",
0240 "_Medium",
0241 "_Tight",
0242 "_VTight",
0243 "_VVTight"
0244 )
0245 ))
0246
0247 _rerunIsolationNewDMMVATask = cms.Task(
0248 getattr(self.process,_byIsolationNewDMMVAraw),
0249 getattr(self.process,_byIsolationNewDMMVA)
0250 )
0251 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVATask)
0252 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVATask)
0253
0254 tauIDSources.byIsolationMVArun2DBnewDMwLTraw = self.tauIDMVAinputs(_byIsolationNewDMMVA, "raw")
0255 tauIDSources.byVVLooseIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VVLoose")
0256 tauIDSources.byVLooseIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VLoose")
0257 tauIDSources.byLooseIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_Loose")
0258 tauIDSources.byMediumIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_Medium")
0259 tauIDSources.byTightIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_Tight")
0260 tauIDSources.byVTightIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VTight")
0261 tauIDSources.byVVTightIsolationMVArun2DBnewDMwLT = self.tauIDMVAinputs(_byIsolationNewDMMVA, "_VVTight")
0262
0263 if "mvaIsoDR0p3" in self.toKeep:
0264 _byIsolationOldDMdR0p3MVAraw = "rerunDiscriminationByIsolationOldDMdR0p3MVAraw"+self.postfix
0265 setattr(self.process,_byIsolationOldDMdR0p3MVAraw,patDiscriminationByIsolationMVArun2v1raw.clone(
0266 PATTauProducer = self.originalTauName,
0267 Prediscriminants = noPrediscriminants,
0268 loadMVAfromDB = cms.bool(True),
0269 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"),
0270 mvaOpt = cms.string("DBoldDMwLTwGJ"),
0271 srcChargedIsoPtSum = cms.string('chargedIsoPtSumdR03'),
0272 srcFootprintCorrection = cms.string('footprintCorrectiondR03'),
0273 srcNeutralIsoPtSum = cms.string('neutralIsoPtSumdR03'),
0274 srcPhotonPtSumOutsideSignalCone = cms.string('photonPtSumOutsideSignalConedR03'),
0275 verbosity = cms.int32(0)
0276 ))
0277
0278 _byIsolationOldDMdR0p3MVA = "rerunDiscriminationByIsolationOldDMdR0p3MVA"+self.postfix
0279 setattr(self.process,_byIsolationOldDMdR0p3MVA,patDiscriminationByIsolationMVArun2v1.clone(
0280 PATTauProducer = self.originalTauName,
0281 Prediscriminants = noPrediscriminants,
0282 toMultiplex = _byIsolationOldDMdR0p3MVAraw,
0283 loadMVAfromDB = cms.bool(True),
0284 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT_mvaOutput_normalization"),
0285 mapping = cms.VPSet(
0286 cms.PSet(
0287 category = cms.uint32(0),
0288 cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"),
0289 variable = cms.string("pt"),
0290 )
0291 ),
0292 workingPoints = cms.vstring(
0293 "_VVLoose",
0294 "_VLoose",
0295 "_Loose",
0296 "_Medium",
0297 "_Tight",
0298 "_VTight",
0299 "_VVTight"
0300 )
0301 ))
0302
0303 _rerunIsolationOldDMdR0p3MVATask = cms.Task(
0304 getattr(self.process,_byIsolationOldDMdR0p3MVAraw),
0305 getattr(self.process,_byIsolationOldDMdR0p3MVA)
0306 )
0307 _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVATask)
0308 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVATask)
0309
0310 tauIDSources.byIsolationMVArun2DBoldDMdR0p3wLTraw = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "raw")
0311 tauIDSources.byVVLooseIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VVLoose")
0312 tauIDSources.byVLooseIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VLoose")
0313 tauIDSources.byLooseIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_Loose")
0314 tauIDSources.byMediumIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_Medium")
0315 tauIDSources.byTightIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_Tight")
0316 tauIDSources.byVTightIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VTight")
0317 tauIDSources.byVVTightIsolationMVArun2DBoldDMdR0p3wLT = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVA, "_VVTight")
0318
0319
0320 if "2017v1" in self.toKeep:
0321 self.tauIdDiscrMVA_2017_version = "v1"
0322 self.tauIdDiscrMVA_trainings_run2_2017 = {
0323 'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
0324 }
0325 self.tauIdDiscrMVA_WPs_run2_2017 = {
0326 'tauIdMVAIsoDBoldDMwLT2017' : {
0327 'Eff95' : "DBoldDMwLTEff95",
0328 'Eff90' : "DBoldDMwLTEff90",
0329 'Eff80' : "DBoldDMwLTEff80",
0330 'Eff70' : "DBoldDMwLTEff70",
0331 'Eff60' : "DBoldDMwLTEff60",
0332 'Eff50' : "DBoldDMwLTEff50",
0333 'Eff40' : "DBoldDMwLTEff40"
0334 }
0335 }
0336
0337 if self.debug: print ("runTauID: Will update the list of available in DB samples to access 2017v1")
0338 self.loadMVA_WPs_run2_2017()
0339
0340 _byIsolationOldDMMVArun2017v1raw = "rerunDiscriminationByIsolationOldDMMVArun2017v1raw"+self.postfix
0341 setattr(self.process,_byIsolationOldDMMVArun2017v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
0342 PATTauProducer = self.originalTauName,
0343 Prediscriminants = noPrediscriminants,
0344 loadMVAfromDB = cms.bool(True),
0345 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
0346 mvaOpt = cms.string("DBoldDMwLTwGJ"),
0347 verbosity = cms.int32(0)
0348 ))
0349
0350 _byIsolationOldDMMVArun2017v1 = "rerunDiscriminationByIsolationOldDMMVArun2017v1"+self.postfix
0351 setattr(self.process,_byIsolationOldDMMVArun2017v1,patDiscriminationByIsolationMVArun2v1.clone(
0352 PATTauProducer = self.originalTauName,
0353 Prediscriminants = noPrediscriminants,
0354 toMultiplex = _byIsolationOldDMMVArun2017v1raw,
0355 loadMVAfromDB = cms.bool(True),
0356 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"),
0357 mapping = cms.VPSet(
0358 cms.PSet(
0359 category = cms.uint32(0),
0360 cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
0361 variable = cms.string("pt"),
0362 )
0363 ),
0364 workingPoints = cms.vstring(
0365 "_WPEff95",
0366 "_WPEff90",
0367 "_WPEff80",
0368 "_WPEff70",
0369 "_WPEff60",
0370 "_WPEff50",
0371 "_WPEff40"
0372 )
0373 ))
0374
0375 _rerunIsolationOldDMMVArun2017v1Task = cms.Task(
0376 getattr(self.process,_byIsolationOldDMMVArun2017v1raw),
0377 getattr(self.process,_byIsolationOldDMMVArun2017v1)
0378 )
0379 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v1Task)
0380 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v1Task)
0381
0382 tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "raw")
0383 tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff95")
0384 tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff90")
0385 tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff80")
0386 tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff70")
0387 tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff60")
0388 tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff50")
0389 tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff40")
0390
0391 if "2017v2" in self.toKeep:
0392 self.tauIdDiscrMVA_2017_version = "v2"
0393 self.tauIdDiscrMVA_trainings_run2_2017 = {
0394 'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
0395 }
0396 self.tauIdDiscrMVA_WPs_run2_2017 = {
0397 'tauIdMVAIsoDBoldDMwLT2017' : {
0398 'Eff95' : "DBoldDMwLTEff95",
0399 'Eff90' : "DBoldDMwLTEff90",
0400 'Eff80' : "DBoldDMwLTEff80",
0401 'Eff70' : "DBoldDMwLTEff70",
0402 'Eff60' : "DBoldDMwLTEff60",
0403 'Eff50' : "DBoldDMwLTEff50",
0404 'Eff40' : "DBoldDMwLTEff40"
0405 }
0406 }
0407
0408 if self.debug: print ("runTauID: Will update the list of available in DB samples to access 2017v2")
0409 self.loadMVA_WPs_run2_2017()
0410
0411 _byIsolationOldDMMVArun2017v2raw = "rerunDiscriminationByIsolationOldDMMVArun2017v2raw"+self.postfix
0412 setattr(self.process,_byIsolationOldDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
0413 PATTauProducer = self.originalTauName,
0414 Prediscriminants = noPrediscriminants,
0415 loadMVAfromDB = cms.bool(True),
0416 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
0417 mvaOpt = cms.string("DBoldDMwLTwGJ"),
0418 verbosity = cms.int32(0)
0419 ))
0420
0421 _byIsolationOldDMMVArun2017v2 = "rerunDiscriminationByIsolationOldDMMVArun2017v2"+self.postfix
0422 setattr(self.process,_byIsolationOldDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
0423 PATTauProducer = self.originalTauName,
0424 Prediscriminants = noPrediscriminants,
0425 toMultiplex = _byIsolationOldDMMVArun2017v2raw,
0426 loadMVAfromDB = cms.bool(True),
0427 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"),
0428 mapping = cms.VPSet(
0429 cms.PSet(
0430 category = cms.uint32(0),
0431 cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
0432 variable = cms.string("pt"),
0433 )
0434 ),
0435 workingPoints = cms.vstring(
0436 "_WPEff95",
0437 "_WPEff90",
0438 "_WPEff80",
0439 "_WPEff70",
0440 "_WPEff60",
0441 "_WPEff50",
0442 "_WPEff40"
0443 ),
0444 verbosity = cms.int32(0)
0445 ))
0446
0447 _rerunIsolationOldDMMVArun2017v2Task = cms.Task(
0448 getattr(self.process,_byIsolationOldDMMVArun2017v2raw),
0449 getattr(self.process,_byIsolationOldDMMVArun2017v2)
0450 )
0451 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v2Task)
0452 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v2Task)
0453
0454 tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "raw")
0455 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff95")
0456 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff90")
0457 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff80")
0458 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff70")
0459 tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff60")
0460 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff50")
0461 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff40")
0462
0463 if "newDM2017v2" in self.toKeep:
0464 self.tauIdDiscrMVA_2017_version = "v2"
0465 self.tauIdDiscrMVA_trainings_run2_2017 = {
0466 'tauIdMVAIsoDBnewDMwLT2017' : "tauIdMVAIsoDBnewDMwLT2017",
0467 }
0468 self.tauIdDiscrMVA_WPs_run2_2017 = {
0469 'tauIdMVAIsoDBnewDMwLT2017' : {
0470 'Eff95' : "DBnewDMwLTEff95",
0471 'Eff90' : "DBnewDMwLTEff90",
0472 'Eff80' : "DBnewDMwLTEff80",
0473 'Eff70' : "DBnewDMwLTEff70",
0474 'Eff60' : "DBnewDMwLTEff60",
0475 'Eff50' : "DBnewDMwLTEff50",
0476 'Eff40' : "DBnewDMwLTEff40"
0477 }
0478 }
0479
0480 if self.debug: print ("runTauID: Will update the list of available in DB samples to access newDM2017v2")
0481 self.loadMVA_WPs_run2_2017()
0482
0483 _byIsolationNewDMMVArun2017v2raw = "rerunDiscriminationByIsolationNewDMMVArun2017v2raw"+self.postfix
0484 setattr(self.process,_byIsolationNewDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
0485 PATTauProducer = self.originalTauName,
0486 Prediscriminants = noPrediscriminants,
0487 loadMVAfromDB = cms.bool(True),
0488 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
0489 mvaOpt = cms.string("DBnewDMwLTwGJ"),
0490 verbosity = cms.int32(0)
0491 ))
0492
0493 _byIsolationNewDMMVArun2017v2 = "rerunDiscriminationByIsolationNewDMMVArun2017v2"+self.postfix
0494 setattr(self.process,_byIsolationNewDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
0495 PATTauProducer = self.originalTauName,
0496 Prediscriminants = noPrediscriminants,
0497 toMultiplex = _byIsolationNewDMMVArun2017v2raw,
0498 loadMVAfromDB = cms.bool(True),
0499 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"),
0500 mapping = cms.VPSet(
0501 cms.PSet(
0502 category = cms.uint32(0),
0503 cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
0504 variable = cms.string("pt"),
0505 )
0506 ),
0507 workingPoints = cms.vstring(
0508 "_WPEff95",
0509 "_WPEff90",
0510 "_WPEff80",
0511 "_WPEff70",
0512 "_WPEff60",
0513 "_WPEff50",
0514 "_WPEff40"
0515 ),
0516 verbosity = cms.int32(0)
0517 ))
0518
0519 _rerunIsolationNewDMMVArun2017v2Task = cms.Task(
0520 getattr(self.process,_byIsolationNewDMMVArun2017v2raw),
0521 getattr(self.process,_byIsolationNewDMMVArun2017v2)
0522 )
0523 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2017v2Task)
0524 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2017v2Task)
0525
0526 tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "raw")
0527 tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff95")
0528 tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff90")
0529 tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff80")
0530 tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff70")
0531 tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff60")
0532 tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff50")
0533 tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff40")
0534
0535 if "dR0p32017v2" in self.toKeep:
0536 self.tauIdDiscrMVA_2017_version = "v2"
0537 self.tauIdDiscrMVA_trainings_run2_2017 = {
0538 'tauIdMVAIsoDBoldDMdR0p3wLT2017' : "tauIdMVAIsoDBoldDMdR0p3wLT2017",
0539 }
0540 self.tauIdDiscrMVA_WPs_run2_2017 = {
0541 'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
0542 'Eff95' : "DBoldDMdR0p3wLTEff95",
0543 'Eff90' : "DBoldDMdR0p3wLTEff90",
0544 'Eff80' : "DBoldDMdR0p3wLTEff80",
0545 'Eff70' : "DBoldDMdR0p3wLTEff70",
0546 'Eff60' : "DBoldDMdR0p3wLTEff60",
0547 'Eff50' : "DBoldDMdR0p3wLTEff50",
0548 'Eff40' : "DBoldDMdR0p3wLTEff40"
0549 }
0550 }
0551
0552 if self.debug: print ("runTauID: Will update the list of available in DB samples to access dR0p32017v2")
0553 self.loadMVA_WPs_run2_2017()
0554
0555 _byIsolationOldDMdR0p3MVArun2017v2raw = "rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw"+self.postfix
0556 setattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
0557 PATTauProducer = self.originalTauName,
0558 Prediscriminants = noPrediscriminants,
0559 loadMVAfromDB = cms.bool(True),
0560 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
0561 mvaOpt = cms.string("DBoldDMwLTwGJ"),
0562 srcChargedIsoPtSum = cms.string('chargedIsoPtSumdR03'),
0563 srcFootprintCorrection = cms.string('footprintCorrectiondR03'),
0564 srcNeutralIsoPtSum = cms.string('neutralIsoPtSumdR03'),
0565 srcPhotonPtSumOutsideSignalCone = cms.string('photonPtSumOutsideSignalConedR03'),
0566 verbosity = cms.int32(0)
0567 ))
0568
0569 _byIsolationOldDMdR0p3MVArun2017v2 = "rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2"+self.postfix
0570 setattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
0571 PATTauProducer = self.originalTauName,
0572 Prediscriminants = noPrediscriminants,
0573 toMultiplex = _byIsolationOldDMdR0p3MVArun2017v2raw,
0574 loadMVAfromDB = cms.bool(True),
0575 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"),
0576 mapping = cms.VPSet(
0577 cms.PSet(
0578 category = cms.uint32(0),
0579 cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
0580 variable = cms.string("pt"),
0581 )
0582 ),
0583 workingPoints = cms.vstring(
0584 "_WPEff95",
0585 "_WPEff90",
0586 "_WPEff80",
0587 "_WPEff70",
0588 "_WPEff60",
0589 "_WPEff50",
0590 "_WPEff40"
0591 ),
0592 verbosity = cms.int32(0)
0593 ))
0594
0595 _rerunIsolationOldDMdR0p3MVArun2017v2Task = cms.Task(
0596 getattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2raw),
0597 getattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2)
0598 )
0599 _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
0600 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
0601
0602 tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "raw")
0603 tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff95")
0604 tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff90")
0605 tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff80")
0606 tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff70")
0607 tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff60")
0608 tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff50")
0609 tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff40")
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638 if "2016v1" in self.toKeep:
0639 _byIsolationOldDMMVArun2016v1raw = "rerunDiscriminationByIsolationOldDMMVArun2v1raw"+self.postfix
0640 setattr(self.process,_byIsolationOldDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
0641 PATTauProducer = self.originalTauName,
0642 Prediscriminants = noPrediscriminants,
0643 loadMVAfromDB = cms.bool(True),
0644 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
0645 mvaOpt = cms.string("DBoldDMwLT"),
0646 verbosity = cms.int32(0)
0647 ))
0648
0649 _byIsolationOldDMMVArun2016v1 = "rerunDiscriminationByIsolationOldDMMVArun2v1"+self.postfix
0650 setattr(self.process,_byIsolationOldDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
0651 PATTauProducer = self.originalTauName,
0652 Prediscriminants = noPrediscriminants,
0653 toMultiplex = _byIsolationOldDMMVArun2016v1raw,
0654 loadMVAfromDB = cms.bool(True),
0655 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
0656 mapping = cms.VPSet(
0657 cms.PSet(
0658 category = cms.uint32(0),
0659 cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
0660 variable = cms.string("pt"),
0661 )
0662 ),
0663 workingPoints = cms.vstring(
0664 "_WPEff90",
0665 "_WPEff80",
0666 "_WPEff70",
0667 "_WPEff60",
0668 "_WPEff50",
0669 "_WPEff40"
0670 )
0671 ))
0672
0673 self.tauIdDiscrMVA_2017_version = "v1"
0674 self.tauIdDiscrMVA_trainings_run2_2017 = {
0675 'tauIdMVAIsoDBoldDMwLT2016' : "tauIdMVAIsoDBoldDMwLT2016",
0676 }
0677 self.tauIdDiscrMVA_WPs_run2_2017 = {
0678 'tauIdMVAIsoDBoldDMwLT2016' : {
0679 'Eff90' : "DBoldDMwLT2016Eff90",
0680 'Eff80' : "DBoldDMwLT2016Eff80",
0681 'Eff70' : "DBoldDMwLT2016Eff70",
0682 'Eff60' : "DBoldDMwLT2016Eff60",
0683 'Eff50' : "DBoldDMwLT2016Eff50",
0684 'Eff40' : "DBoldDMwLT2016Eff40"
0685 }
0686 }
0687 if self.debug: print ("runTauID: Will update the list of available in DB samples to access 2016v1")
0688 self.loadMVA_WPs_run2_2017()
0689
0690 _rerunIsolationOldDMMVArun2016v1Task = cms.Task(
0691 getattr(self.process,_byIsolationOldDMMVArun2016v1raw),
0692 getattr(self.process,_byIsolationOldDMMVArun2016v1)
0693 )
0694 _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2016v1Task)
0695 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2016v1Task)
0696
0697 tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "raw")
0698 tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff90")
0699 tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff80")
0700 tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff70")
0701 tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff60")
0702 tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff50")
0703 tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff40")
0704
0705
0706 if "newDM2016v1" in self.toKeep:
0707 _byIsolationNewDMMVArun2016v1raw = "rerunDiscriminationByIsolationNewDMMVArun2v1raw"+self.postfix
0708 setattr(self.process,_byIsolationNewDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
0709 PATTauProducer = self.originalTauName,
0710 Prediscriminants = noPrediscriminants,
0711 loadMVAfromDB = cms.bool(True),
0712 mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
0713 mvaOpt = cms.string("DBnewDMwLT"),
0714 verbosity = cms.int32(0)
0715 ))
0716
0717 _byIsolationNewDMMVArun2016v1 = "rerunDiscriminationByIsolationNewDMMVArun2v1"+self.postfix
0718 setattr(self.process,_byIsolationNewDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
0719 PATTauProducer = self.originalTauName,
0720 Prediscriminants = noPrediscriminants,
0721 toMultiplex = _byIsolationNewDMMVArun2016v1raw,
0722 loadMVAfromDB = cms.bool(True),
0723 mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
0724 mapping = cms.VPSet(
0725 cms.PSet(
0726 category = cms.uint32(0),
0727 cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
0728 variable = cms.string("pt"),
0729 )
0730 ),
0731 workingPoints = cms.vstring(
0732 "_WPEff90",
0733 "_WPEff80",
0734 "_WPEff70",
0735 "_WPEff60",
0736 "_WPEff50",
0737 "_WPEff40"
0738 )
0739 ))
0740
0741 self.tauIdDiscrMVA_2017_version = "v1"
0742 self.tauIdDiscrMVA_trainings_run2_2017 = {
0743 'tauIdMVAIsoDBnewDMwLT2016' : "tauIdMVAIsoDBnewDMwLT2016",
0744 }
0745 self.tauIdDiscrMVA_WPs_run2_2017 = {
0746 'tauIdMVAIsoDBnewDMwLT2016' : {
0747 'Eff90' : "DBnewDMwLT2016Eff90",
0748 'Eff80' : "DBnewDMwLT2016Eff80",
0749 'Eff70' : "DBnewDMwLT2016Eff70",
0750 'Eff60' : "DBnewDMwLT2016Eff60",
0751 'Eff50' : "DBnewDMwLT2016Eff50",
0752 'Eff40' : "DBnewDMwLT2016Eff40"
0753 }
0754 }
0755 if self.debug: print ("runTauID: Will update the list of available in DB samples to access newDM2016v1")
0756 self.loadMVA_WPs_run2_2017()
0757
0758 _rerunIsolationNewDMMVArun2016v1Task = cms.Task(
0759 getattr(self.process,_byIsolationNewDMMVArun2016v1raw),
0760 getattr(self.process,_byIsolationNewDMMVArun2016v1)
0761 )
0762 _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2016v1Task)
0763 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2016v1Task)
0764
0765 tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "raw")
0766 tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff90")
0767 tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff80")
0768 tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff70")
0769 tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff60")
0770 tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff50")
0771 tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff40")
0772
0773 if "deepTau2017v2" in self.toKeep:
0774 if self.debug: print ("Adding DeepTau v2 IDs")
0775
0776 _deepTauName = "deepTau2017v2"
0777 workingPoints_ = WORKING_POINTS_v2p1
0778
0779 file_names = [
0780 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
0781 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
0782 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
0783 ]
0784 full_version = self.getDeepTauVersion(file_names[0])
0785 setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
0786 Prediscriminants = noPrediscriminants,
0787 taus = self.originalTauName,
0788 graph_file = file_names,
0789 year = full_version[0],
0790 version = full_version[1],
0791 sub_version = 1
0792 ))
0793
0794 _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
0795
0796 from Configuration.ProcessModifiers.deepTauSonicTriton_cff import deepTauSonicTriton
0797 deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
0798 Client = cms.PSet(
0799 mode = cms.string('PseudoAsync'),
0800 allowedTries = cms.untracked.uint32(0),
0801 verbose = cms.untracked.bool(False),
0802 modelName = cms.string("deeptau_2017v2p1"),
0803 modelVersion = cms.string(''),
0804 modelConfigPath = cms.FileInPath("RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2017v2p1/config.pbtxt"),
0805 preferredServer = cms.untracked.string(''),
0806 timeout = cms.untracked.uint32(300),
0807 useSharedMemory = cms.untracked.bool(True),
0808 compression = cms.untracked.string(''),
0809 outputs = cms.untracked.vstring()
0810 ),
0811 Prediscriminants = noPrediscriminants,
0812 taus = self.originalTauName,
0813 year = full_version[0],
0814 version = full_version[1],
0815 sub_version = 1,
0816 ))
0817
0818 self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
0819
0820 _rerunMvaIsolationTask.add(_deepTauProducer)
0821 _rerunMvaIsolationSequence += _deepTauProducer
0822
0823
0824 if "deepTau2017v2p1" in self.toKeep:
0825 if self.debug: print ("Adding DeepTau v2p1 IDs")
0826
0827 _deepTauName = "deepTau2017v2p1"
0828 workingPoints_ = WORKING_POINTS_v2p1
0829
0830 file_names = [
0831 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
0832 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
0833 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
0834 ]
0835 full_version = self.getDeepTauVersion(file_names[0])
0836 setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
0837 Prediscriminants = noPrediscriminants,
0838 taus = self.originalTauName,
0839 graph_file = file_names,
0840 year = full_version[0],
0841 version = full_version[1],
0842 sub_version = 1,
0843 disable_dxy_pca = True
0844 ))
0845
0846 _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
0847
0848 from Configuration.ProcessModifiers.deepTauSonicTriton_cff import deepTauSonicTriton
0849 deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
0850 Client = cms.PSet(
0851 mode = cms.string('PseudoAsync'),
0852 allowedTries = cms.untracked.uint32(0),
0853 verbose = cms.untracked.bool(False),
0854 modelName = cms.string("deeptau_2017v2p1"),
0855 modelVersion = cms.string(''),
0856 modelConfigPath = cms.FileInPath("RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2017v2p1/config.pbtxt"),
0857 preferredServer = cms.untracked.string(''),
0858 timeout = cms.untracked.uint32(300),
0859 useSharedMemory = cms.untracked.bool(True),
0860 compression = cms.untracked.string(''),
0861 outputs = cms.untracked.vstring()
0862 ),
0863 Prediscriminants = noPrediscriminants,
0864 taus = self.originalTauName,
0865 year = full_version[0],
0866 version = full_version[1],
0867 sub_version = 1,
0868 disable_dxy_pca = True
0869 ))
0870
0871 self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
0872
0873 _rerunMvaIsolationTask.add(_deepTauProducer)
0874 _rerunMvaIsolationSequence += _deepTauProducer
0875
0876 if "deepTau2018v2p5" in self.toKeep:
0877 if self.debug: print ("Adding DeepTau v2p5 IDs")
0878
0879 _deepTauName = "deepTau2018v2p5"
0880 workingPoints_ = WORKING_POINTS_v2p5
0881
0882 file_names = [
0883 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_core.pb',
0884 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_inner.pb',
0885 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_outer.pb',
0886 ]
0887 full_version = self.getDeepTauVersion(file_names[0])
0888 setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
0889 Prediscriminants = noPrediscriminants,
0890 taus = self.originalTauName,
0891 graph_file = file_names,
0892 year = full_version[0],
0893 version = full_version[1],
0894 sub_version = full_version[2],
0895 disable_dxy_pca = True,
0896 disable_hcalFraction_workaround = True,
0897 disable_CellIndex_workaround = True
0898 ))
0899
0900 _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
0901
0902 from Configuration.ProcessModifiers.deepTauSonicTriton_cff import deepTauSonicTriton
0903 deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
0904 Client = cms.PSet(
0905 mode = cms.string('PseudoAsync'),
0906 allowedTries = cms.untracked.uint32(0),
0907 verbose = cms.untracked.bool(False),
0908 modelName = cms.string("deeptau_2018v2p5"),
0909 modelVersion = cms.string(''),
0910 modelConfigPath = cms.FileInPath("RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2018v2p5/config.pbtxt"),
0911 preferredServer = cms.untracked.string(''),
0912 timeout = cms.untracked.uint32(300),
0913 useSharedMemory = cms.untracked.bool(True),
0914 compression = cms.untracked.string(''),
0915 outputs = cms.untracked.vstring(),
0916 ),
0917 Prediscriminants = noPrediscriminants,
0918 taus = self.originalTauName,
0919 year = full_version[0],
0920 version = full_version[1],
0921 sub_version = full_version[2],
0922 disable_dxy_pca = True,
0923 disable_hcalFraction_workaround = True,
0924 disable_CellIndex_workaround = True
0925 ))
0926
0927 self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
0928
0929 _rerunMvaIsolationTask.add(_deepTauProducer)
0930 _rerunMvaIsolationSequence += _deepTauProducer
0931
0932 if "boostedDeepTauRunIIv2p0" in self.toKeep:
0933 if self.debug: print ("Adding BoostedDeepTau v2p0 IDs for boostedTaus")
0934
0935 _deepTauName = "boostedDeepTau20161718v2p0"
0936 workingPoints_ = WORKING_POINTS_BOOSTED_v2p0
0937
0938 file_names = [
0939 'core:RecoTauTag/TrainingFiles/data/BoostedDeepTauId/boosteddeepTau_RunIIv2p0_core.pb',
0940 'inner:RecoTauTag/TrainingFiles/data/BoostedDeepTauId/boosteddeepTau_RunIIv2p0_inner.pb',
0941 'outer:RecoTauTag/TrainingFiles/data/BoostedDeepTauId/boosteddeepTau_RunIIv2p0_outer.pb',
0942 ]
0943 full_version = self.getDeepTauVersion(file_names[0])
0944 setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
0945 Prediscriminants = noPrediscriminants,
0946 taus = self.originalTauName,
0947 graph_file = file_names,
0948 year = full_version[0],
0949 version = full_version[1],
0950 sub_version = full_version[2],
0951 disable_dxy_pca = True,
0952 disable_hcalFraction_workaround = True,
0953 save_inputs = False,
0954 disable_CellIndex_workaround = True
0955 ))
0956
0957 self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
0958
0959 _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
0960 _rerunMvaIsolationTask.add(_deepTauProducer)
0961 _rerunMvaIsolationSequence += _deepTauProducer
0962
0963 if "deepTau2026v2p5" in self.toKeep:
0964 if self.debug: print ("Adding Phase2 DeepTau v2p5 IDs")
0965
0966 _deepTauName = "deepTau2026v2p5"
0967 workingPoints_ = WORKING_POINTS_PHASEII_v2p5
0968
0969 file_names = [
0970 'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_core.pb',
0971 'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_inner.pb',
0972 'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_outer.pb',
0973 ]
0974 full_version = self.getDeepTauVersion(file_names[0])
0975 setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
0976 Prediscriminants = noPrediscriminants,
0977 taus = self.originalTauName,
0978 graph_file = file_names,
0979 year = full_version[0],
0980 version = full_version[1],
0981 sub_version = full_version[2],
0982 disable_dxy_pca = True,
0983 disable_hcalFraction_workaround = True,
0984 disable_CellIndex_workaround = True
0985 ))
0986
0987 from RecoTauTag.RecoTau.mergedPhase2SlimmedElectronsForTauId_cff import mergedSlimmedElectronsForTauId
0988 if not hasattr(self.process,"mergedSlimmedElectronsForTauId"):
0989 self.process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
0990 setattr(getattr(self.process, _deepTauName+self.postfix), "electrons", cms.InputTag("mergedSlimmedElectronsForTauId"))
0991 setattr(getattr(self.process, _deepTauName+self.postfix), "vertices", cms.InputTag("offlineSlimmedPrimaryVertices4D"))
0992
0993 self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
0994
0995 _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
0996 _rerunMvaIsolationTask.add(self.process.mergedSlimmedElectronsForTauId)
0997 _rerunMvaIsolationTask.add(_deepTauProducer)
0998 _rerunMvaIsolationSequence += self.process.mergedSlimmedElectronsForTauId
0999 _rerunMvaIsolationSequence += _deepTauProducer
1000
1001 if "againstEle2018" in self.toKeep:
1002 self.antiElectronDiscrMVA6_version = "v3_noeveto"
1003 self.antiElectronDiscrMVA6_WPs = [ "eff98", "eff90", "eff80", "eff70", "eff60" ]
1004
1005
1006 from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
1007 _byElectronRejectionMVA62018Raw = "patTauDiscriminationByElectronRejectionMVA62018Raw"+self.postfix
1008 setattr(self.process,_byElectronRejectionMVA62018Raw,patTauDiscriminationAgainstElectronMVA6.clone(
1009 PATTauProducer = self.originalTauName,
1010 Prediscriminants = noPrediscriminants,
1011 srcElectrons = cms.InputTag('slimmedElectrons'),
1012 vetoEcalCracks = cms.bool(False),
1013 mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL',
1014 mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC',
1015 mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL',
1016 mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC',
1017 mvaName_wGwGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL',
1018 mvaName_wGwGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC',
1019 mvaName_woGwGSF_BL = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL',
1020 mvaName_woGwGSF_EC = 'RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'
1021 ))
1022
1023 from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer
1024 _byElectronRejectionMVA62018 = "patTauDiscriminationByElectronRejectionMVA62018"+self.postfix
1025 setattr(self.process,"patTauDiscriminationByElectronRejectionMVA62018"+self.postfix,patTauDiscriminantCutMultiplexer.clone(
1026 PATTauProducer = self.originalTauName,
1027 Prediscriminants = noPrediscriminants,
1028 toMultiplex = _byElectronRejectionMVA62018Raw,
1029 mapping = cms.VPSet(
1030 cms.PSet(
1031 category = cms.uint32(0),
1032 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL'),
1033 variable = cms.string('pt')
1034 ),
1035 cms.PSet(
1036 category = cms.uint32(2),
1037 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL'),
1038 variable = cms.string('pt')
1039 ),
1040 cms.PSet(
1041 category = cms.uint32(5),
1042 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL'),
1043 variable = cms.string('pt')
1044 ),
1045 cms.PSet(
1046 category = cms.uint32(7),
1047 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL'),
1048 variable = cms.string('pt')
1049 ),
1050 cms.PSet(
1051 category = cms.uint32(8),
1052 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC'),
1053 variable = cms.string('pt')
1054 ),
1055 cms.PSet(
1056 category = cms.uint32(10),
1057 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC'),
1058 variable = cms.string('pt')
1059 ),
1060 cms.PSet(
1061 category = cms.uint32(13),
1062 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'),
1063 variable = cms.string('pt')
1064 ),
1065 cms.PSet(
1066 category = cms.uint32(15),
1067 cut = cms.string('RecoTauTag_antiElectronMVA6'+self.antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC'),
1068 variable = cms.string('pt')
1069 )
1070 ),
1071 workingPoints = cms.vstring(
1072 "_WPeff98",
1073 "_WPeff90",
1074 "_WPeff80",
1075 "_WPeff70",
1076 "_WPeff60"
1077 )
1078 ))
1079
1080 if self.debug: print ("runTauID: Will update the list of available in DB samples to access againstEle 2018")
1081 self.load_againstElectronMVA6()
1082
1083
1084 _patTauDiscriminationByElectronRejectionMVA62018Task = cms.Task(
1085 getattr(self.process,_byElectronRejectionMVA62018Raw),
1086 getattr(self.process,_byElectronRejectionMVA62018)
1087 )
1088 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA62018Task)
1089 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA62018Task)
1090
1091 _againstElectronTauIDSources = cms.PSet(
1092 againstElectronMVA6Raw2018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "raw"),
1093 againstElectronMVA6category2018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "category"),
1094 againstElectronVLooseMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff98"),
1095 againstElectronLooseMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff90"),
1096 againstElectronMediumMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff80"),
1097 againstElectronTightMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff70"),
1098 againstElectronVTightMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff60")
1099 )
1100 _tauIDSourcesWithAgainistEle = cms.PSet(
1101 tauIDSources.clone(),
1102 _againstElectronTauIDSources
1103 )
1104 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
1105
1106 if "againstEle" in self.toKeep:
1107
1108
1109 from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
1110 _byElectronRejectionMVA6Raw = "patTauDiscriminationByElectronRejectionMVA6Raw"+self.postfix
1111 setattr(self.process,_byElectronRejectionMVA6Raw,patTauDiscriminationAgainstElectronMVA6.clone(
1112 PATTauProducer = self.originalTauName,
1113 Prediscriminants = noPrediscriminants,
1114 srcElectrons = cms.InputTag('slimmedElectrons'),
1115 vetoEcalCracks = cms.bool(False),
1116 mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_BL',
1117 mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_EC',
1118 mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_BL',
1119 mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_EC',
1120 mvaName_wGwGSF_BL = 'RecoTauTag_antiElectronMVA_wGwGSF_BL',
1121 mvaName_wGwGSF_EC = 'RecoTauTag_antiElectronMVA_wGwGSF_EC',
1122 mvaName_woGwGSF_BL = 'RecoTauTag_antiElectronMVA_woGwGSF_BL',
1123 mvaName_woGwGSF_EC = 'RecoTauTag_antiElectronMVA_woGwGSF_EC'
1124 ))
1125
1126 from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer
1127 _byElectronRejectionMVA6 = "patTauDiscriminationByElectronRejectionMVA6"+self.postfix
1128 setattr(self.process,"patTauDiscriminationByElectronRejectionMVA6"+self.postfix,patTauDiscriminantCutMultiplexer.clone(
1129 PATTauProducer = self.originalTauName,
1130 Prediscriminants = noPrediscriminants,
1131 toMultiplex = _byElectronRejectionMVA6Raw,
1132 mapping = cms.VPSet(
1133 cms.PSet(
1134 category = cms.uint32(0),
1135 cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_BL'),
1136 variable = cms.string('pt')
1137 ),
1138 cms.PSet(
1139 category = cms.uint32(2),
1140 cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_BL'),
1141 variable = cms.string('pt')
1142 ),
1143 cms.PSet(
1144 category = cms.uint32(5),
1145 cut = cms.string('RecoTauTag_antiElectronMVA_woGwGSF_BL'),
1146 variable = cms.string('pt')
1147 ),
1148 cms.PSet(
1149 category = cms.uint32(7),
1150 cut = cms.string('RecoTauTag_antiElectronMVA_wGwGSF_BL'),
1151 variable = cms.string('pt')
1152 ),
1153 cms.PSet(
1154 category = cms.uint32(8),
1155 cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_woGwoGSF_EC'),
1156 variable = cms.string('pt')
1157 ),
1158 cms.PSet(
1159 category = cms.uint32(10),
1160 cut = cms.string('RecoTauTag_antiElectronMVA_NoEleMatch_wGwoGSF_EC'),
1161 variable = cms.string('pt')
1162 ),
1163 cms.PSet(
1164 category = cms.uint32(13),
1165 cut = cms.string('RecoTauTag_antiElectronMVA_woGwGSF_EC'),
1166 variable = cms.string('pt')
1167 ),
1168 cms.PSet(
1169 category = cms.uint32(15),
1170 cut = cms.string('RecoTauTag_antiElectronMVA_wGwGSF_EC'),
1171 variable = cms.string('pt')
1172 )
1173 ),
1174 workingPoints = cms.vstring(
1175 "_VLoose",
1176 "_Loose",
1177 "_Medium",
1178 "_Tight",
1179 "_VTight"
1180 )
1181 ))
1182
1183 _patTauDiscriminationByElectronRejectionMVA6Task = cms.Task(
1184 getattr(self.process,_byElectronRejectionMVA6Raw),
1185 getattr(self.process,_byElectronRejectionMVA6)
1186 )
1187 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Task)
1188 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Task)
1189
1190 _againstElectronTauIDSources = cms.PSet(
1191 againstElectronMVA6Raw = self.tauIDMVAinputs(_byElectronRejectionMVA6, "raw"),
1192 againstElectronMVA6category = self.tauIDMVAinputs(_byElectronRejectionMVA6, "category"),
1193 againstElectronVLooseMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_VLoose"),
1194 againstElectronLooseMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_Loose"),
1195 againstElectronMediumMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_Medium"),
1196 againstElectronTightMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_Tight"),
1197 againstElectronVTightMVA6 = self.tauIDMVAinputs(_byElectronRejectionMVA6, "_VTight")
1198 )
1199 _tauIDSourcesWithAgainistEle = cms.PSet(
1200 tauIDSources.clone(),
1201 _againstElectronTauIDSources
1202 )
1203 tauIDSources =_tauIDSourcesWithAgainistEle.clone()
1204
1205 if "newDMPhase2v1" in self.toKeep:
1206 if self.debug: print ("Adding newDMPhase2v1 ID")
1207 def tauIDMVAinputs(module, wp):
1208 return cms.PSet(inputTag = cms.InputTag(module), workingPointIndex = cms.int32(-1 if wp=="raw" else -2 if wp=="category" else getattr(self.process, module).workingPoints.index(wp)))
1209 _byIsolationNewDMMVAPhase2raw = "rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw"+self.postfix
1210 setattr(self.process,_byIsolationNewDMMVAPhase2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
1211 PATTauProducer = self.originalTauName,
1212 Prediscriminants = noPrediscriminants,
1213 loadMVAfromDB = True,
1214 mvaName = 'RecoTauTag_tauIdMVAIsoPhase2',
1215 mvaOpt = 'DBnewDMwLTwGJPhase2',
1216 verbosity = 0
1217 ))
1218
1219 _byIsolationNewDMMVAPhase2 = "rerunDiscriminationByIsolationMVADBnewDMwLTPhase2"+self.postfix
1220 setattr(self.process,_byIsolationNewDMMVAPhase2,patDiscriminationByIsolationMVArun2v1.clone(
1221 PATTauProducer = self.originalTauName,
1222 Prediscriminants = noPrediscriminants,
1223 toMultiplex = _byIsolationNewDMMVAPhase2raw,
1224 loadMVAfromDB = True,
1225 mvaOutput_normalization = 'RecoTauTag_tauIdMVAIsoPhase2_mvaOutput_normalization',
1226 mapping = cms.VPSet(
1227 cms.PSet(
1228 category = cms.uint32(0),
1229 cut = cms.string("RecoTauTag_tauIdMVAIsoPhase2"),
1230 variable = cms.string("pt"),
1231 )
1232 ),
1233 workingPoints = cms.vstring(
1234 "_VVLoose",
1235 "_VLoose",
1236 "_Loose",
1237 "_Medium",
1238 "_Tight",
1239 "_VTight",
1240 "_VVTight"
1241 )
1242 ))
1243 _rerunIsolationMVADBnewDMwLTPhase2Task = cms.Task(
1244 getattr(self.process,_byIsolationNewDMMVAPhase2raw),
1245 getattr(self.process,_byIsolationNewDMMVAPhase2)
1246 )
1247 _rerunMvaIsolationTask.add(_rerunIsolationMVADBnewDMwLTPhase2Task)
1248 _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationMVADBnewDMwLTPhase2Task)
1249
1250 tauIDSources.byIsolationMVADBnewDMwLTPhase2raw = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "raw")
1251 tauIDSources.byVVLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VVLoose")
1252 tauIDSources.byVLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VLoose")
1253 tauIDSources.byLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_Loose")
1254 tauIDSources.byMediumIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_Medium")
1255 tauIDSources.byTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_Tight")
1256 tauIDSources.byVTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VTight")
1257 tauIDSources.byVVTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VVTight")
1258
1259 if "againstElePhase2v1" in self.toKeep:
1260 if self.debug: print ("Adding anti-e Phase2v1 ID")
1261
1262
1263 from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6Phase2_cff import patTauDiscriminationAgainstElectronMVA6Phase2Raw, patTauDiscriminationAgainstElectronMVA6Phase2, mergedSlimmedElectronsForTauId
1264 _byElectronRejectionMVA6Phase2v1Raw = "patTauDiscriminationByElectronRejectionMVA6Phase2v1Raw"+self.postfix
1265 setattr(self.process,_byElectronRejectionMVA6Phase2v1Raw,patTauDiscriminationAgainstElectronMVA6Phase2Raw.clone(
1266 PATTauProducer = self.originalTauName,
1267 Prediscriminants = noPrediscriminants
1268 ))
1269
1270 _byElectronRejectionMVA6Phase2v1 = "patTauDiscriminationByElectronRejectionMVA6Phase2v1"+self.postfix
1271 setattr(self.process,_byElectronRejectionMVA6Phase2v1,patTauDiscriminationAgainstElectronMVA6Phase2.clone(
1272 PATTauProducer = self.originalTauName,
1273 Prediscriminants = noPrediscriminants,
1274 toMultiplex = _byElectronRejectionMVA6Phase2v1Raw
1275 ))
1276
1277 if not hasattr(self.process,"mergedSlimmedElectronsForTauId"):
1278 self.process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
1279 _patTauDiscriminationByElectronRejectionMVA6Phase2v1Task = cms.Task(
1280 self.process.mergedSlimmedElectronsForTauId,
1281 getattr(self.process,_byElectronRejectionMVA6Phase2v1Raw),
1282 getattr(self.process,_byElectronRejectionMVA6Phase2v1)
1283 )
1284 _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
1285 _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
1286
1287 _againstElectronTauIDPhase2v1Sources = cms.PSet(
1288 againstElectronMVA6RawPhase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "raw"),
1289 againstElectronMVA6categoryPhase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "category"),
1290 againstElectronVLooseMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_VLoose"),
1291 againstElectronLooseMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_Loose"),
1292 againstElectronMediumMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_Medium"),
1293 againstElectronTightMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_Tight"),
1294 againstElectronVTightMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_VTight")
1295 )
1296 _tauIDSourcesWithAgainistElePhase2v1 = cms.PSet(
1297 tauIDSources.clone(),
1298 _againstElectronTauIDPhase2v1Sources
1299 )
1300 tauIDSources =_tauIDSourcesWithAgainistElePhase2v1.clone()
1301
1302 if self.debug: print('Embedding new TauIDs into \"'+self.updatedTauName+'\"')
1303 if not hasattr(self.process, self.updatedTauName):
1304 embedID = cms.EDProducer("PATTauIDEmbedder",
1305 src = cms.InputTag(self.originalTauName),
1306 tauIDSources = tauIDSources
1307 )
1308 setattr(self.process, self.updatedTauName, embedID)
1309 else:
1310 tauIDSources = cms.PSet(
1311 getattr(self.process, self.updatedTauName).tauIDSources,
1312 tauIDSources)
1313 getattr(self.process, self.updatedTauName).tauIDSources = tauIDSources
1314 if not hasattr(self.process,"rerunMvaIsolationTask"+self.postfix):
1315 setattr(self.process,"rerunMvaIsolationTask"+self.postfix,_rerunMvaIsolationTask)
1316 else:
1317 _updatedRerunMvaIsolationTask = getattr(self.process,"rerunMvaIsolationTask"+self.postfix)
1318 _updatedRerunMvaIsolationTask.add(_rerunMvaIsolationTask)
1319 setattr(self.process,"rerunMvaIsolationTask"+self.postfix,_updatedRerunMvaIsolationTask)
1320 if not hasattr(self.process,"rerunMvaIsolationSequence"+self.postfix):
1321 setattr(self.process,"rerunMvaIsolationSequence"+self.postfix,_rerunMvaIsolationSequence)
1322 else:
1323 _updatedRerunMvaIsolationSequence = getattr(self.process,"rerunMvaIsolationSequence"+self.postfix)
1324 _updatedRerunMvaIsolationSequence += _rerunMvaIsolationSequence
1325 setattr(self.process,"rerunMvaIsolationSequence"+self.postfix,_updatedRerunMvaIsolationSequence)
1326
1327
1328 def processDeepProducer(self, producer_name, tauIDSources, workingPoints_):
1329 for target,points in workingPoints_.items():
1330 setattr(tauIDSources, 'by{}VS{}raw'.format(producer_name[0].upper()+producer_name[1:], target),
1331 cms.PSet(inputTag = cms.InputTag(producer_name+self.postfix, 'VS{}'.format(target)), workingPointIndex = cms.int32(-1)))
1332
1333 cut_expressions = []
1334 for index, (point,cut) in enumerate(points.items()):
1335 cut_expressions.append(str(cut))
1336
1337 setattr(tauIDSources, 'by{}{}VS{}'.format(point, producer_name[0].upper()+producer_name[1:], target),
1338 cms.PSet(inputTag = cms.InputTag(producer_name+self.postfix, 'VS{}'.format(target)), workingPointIndex = cms.int32(index)))
1339 if len(cut_expressions) > 0:
1340 setattr(getattr(self.process, producer_name+self.postfix), 'VS{}WP'.format(target), cms.vstring(*cut_expressions))
1341
1342
1343 def getDeepTauVersion(self, file_name):
1344 """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \
1345 (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \
1346 {year}v{version}p{subversion}"""
1347 version_search = re.search('(20[1,2][125678]|RunII)v([0-9]+)(p[0-9]+|)[\\._]', file_name)
1348 if not version_search:
1349 raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \
1350 Unable to extract version number.'.format(file_name))
1351 year = version_search.group(1)
1352 if year == 'RunII': year = 20161718
1353 version = version_search.group(2)
1354 subversion = version_search.group(3)
1355 if len(subversion) > 0:
1356 subversion = subversion[1:]
1357 else:
1358 subversion = 0
1359 return int(year), int(version), int(subversion)