CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes
runTauIdMVA.TauIDEmbedder Class Reference
Inheritance diagram for runTauIdMVA.TauIDEmbedder:

Public Member Functions

def __init__
 
def get_cmssw_version_number (klass, debug=False)
 
def getDeepTauVersion (self, file_name)
 
def is_above_cmssw_version (klass, release=9, subversion=4, patch=0, debug=False)
 
def loadMVA_WPs_run2_2017 (self)
 
def processDeepProducer (self, producer_name, tauIDSources, workingPoints_)
 
def runTauID (self)
 
def tauIDMVAinputs (self, module, wp)
 

Static Public Member Functions

def get_cmssw_version (debug=False)
 
def versionToInt (release=9, subversion=4, patch=0, debug=False)
 

Public Attributes

 debug
 
 originalTauName
 
 postfix
 
 process
 
 tauIdDiscrMVA_2017_version
 
 tauIdDiscrMVA_trainings_run2_2017
 
 tauIdDiscrMVA_WPs_run2_2017
 
 toKeep
 
 updatedTauName
 

Static Public Attributes

 availableDiscriminators
 

Detailed Description

class to rerun the tau seq and acces trainings from the database

Definition at line 12 of file runTauIdMVA.py.

Constructor & Destructor Documentation

◆ __init__()

def runTauIdMVA.TauIDEmbedder.__init__ (   self,
  process,
  debug = False,
  originalTauName = "slimmedTaus",
  updatedTauName = "slimmedTausNewID",
  postfix = "",
  toKeep = ["deepTau2017v2p1",
  deepTau2018v2p5,
  deepTau2026v2p5,
  tauIdDiscrMVA_trainings_run2_2017 = { 'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
  tauIdDiscrMVA_WPs_run2_2017 = {                     'tauIdMVAIsoDBoldDMwLT2017' : {                         'Eff95' : "DBoldDMwLTEff95",
  Eff90 
)

Definition at line 31 of file runTauIdMVA.py.

31  'Eff90' : "DBoldDMwLTEff90",
32  'Eff80' : "DBoldDMwLTEff80",
33  'Eff70' : "DBoldDMwLTEff70",
34  'Eff60' : "DBoldDMwLTEff60",
35  'Eff50' : "DBoldDMwLTEff50",
36  'Eff40' : "DBoldDMwLTEff40"
37  }
38  },
39  tauIdDiscrMVA_2017_version = "v1",
40  conditionDB = "" # preparational DB: 'frontier://FrontierPrep/CMS_CONDITIONS'
41  ):
42  super(TauIDEmbedder, self).__init__()
43  self.process = process
44  self.debug = debug
45  self.originalTauName = originalTauName
46  self.updatedTauName = updatedTauName
47  self.postfix = postfix
48  self.process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
49  if len(conditionDB) != 0:
50  self.process.CondDBTauConnection.connect = cms.string(conditionDB)
51  self.process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
52  # if debug:
53  # print self.process.CondDBTauConnection.connect
54  # print dir(self.process.loadRecoTauTagMVAsFromPrepDB)
55  # print self.process.loadRecoTauTagMVAsFromPrepDB.parameterNames_
56 
57  self.tauIdDiscrMVA_trainings_run2_2017 = tauIdDiscrMVA_trainings_run2_2017
58  self.tauIdDiscrMVA_WPs_run2_2017 = tauIdDiscrMVA_WPs_run2_2017
59  self.tauIdDiscrMVA_2017_version = tauIdDiscrMVA_2017_version
60  for discr in toKeep:
61  if discr not in TauIDEmbedder.availableDiscriminators:
62  raise RuntimeError('TauIDEmbedder: discriminator "{}" is not supported'.format(discr))
63  self.toKeep = toKeep
64 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def load(fileName)
Definition: svgfig.py:547

Member Function Documentation

◆ get_cmssw_version()

def runTauIdMVA.TauIDEmbedder.get_cmssw_version (   debug = False)
static
returns 'CMSSW_X_Y_Z'

Definition at line 66 of file runTauIdMVA.py.

66  def get_cmssw_version(debug = False):
67  """returns 'CMSSW_X_Y_Z'"""
68  cmssw_version = os.environ["CMSSW_VERSION"]
69  if debug: print ("get_cmssw_version:", cmssw_version)
70  return cmssw_version
71 

◆ get_cmssw_version_number()

def runTauIdMVA.TauIDEmbedder.get_cmssw_version_number (   klass,
  debug = False 
)
returns '(release, subversion, patch)' (without 'CMSSW_')

Definition at line 73 of file runTauIdMVA.py.

References createfilelist.int, and submitPVValidationJobs.split().

73  def get_cmssw_version_number(klass, debug = False):
74  """returns '(release, subversion, patch)' (without 'CMSSW_')"""
75  v = klass.get_cmssw_version().split("CMSSW_")[1].split("_")[0:3]
76  if debug: print ("get_cmssw_version_number:", v)
77  try:
78  patch = int(v[2])
79  except:
80  patch = -1
81  return int(v[0]), int(v[1]), patch
82 

◆ getDeepTauVersion()

def runTauIdMVA.TauIDEmbedder.getDeepTauVersion (   self,
  file_name 
)
returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \
(2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \
{year}v{version}p{subversion}

Definition at line 998 of file runTauIdMVA.py.

References createfilelist.int.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

998  def getDeepTauVersion(self, file_name):
999  """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \
1000  (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \
1001  {year}v{version}p{subversion}"""
1002  version_search = re.search('(20[1,2][125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
1003  if not version_search:
1004  raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \
1005  Unable to extract version number.'.format(file_name))
1006  year = version_search.group(1)
1007  version = version_search.group(2)
1008  subversion = version_search.group(3)
1009  if len(subversion) > 0:
1010  subversion = subversion[1:]
1011  else:
1012  subversion = 0
1013  return int(year), int(version), int(subversion)

◆ is_above_cmssw_version()

def runTauIdMVA.TauIDEmbedder.is_above_cmssw_version (   klass,
  release = 9,
  subversion = 4,
  patch = 0,
  debug = False 
)

Definition at line 91 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

91  def is_above_cmssw_version(klass, release=9, subversion=4, patch=0, debug = False):
92  split_cmssw_version = klass.get_cmssw_version_number()
93  if klass.versionToInt(release, subversion, patch) > klass.versionToInt(split_cmssw_version[0], split_cmssw_version[1], split_cmssw_version[2]):
94  if debug: print ("is_above_cmssw_version:", False)
95  return False
96  else:
97  if debug: print ("is_above_cmssw_version:", True)
98  return True
99 

◆ loadMVA_WPs_run2_2017()

def runTauIdMVA.TauIDEmbedder.loadMVA_WPs_run2_2017 (   self)

Definition at line 103 of file runTauIdMVA.py.

References InterpolationDebug.debug, l1ct::EGInputSelectorEmuConfig.debug, Cordic.debug, DTDigiToRawModule.debug, CSCRPCData.debug, CSCTMBScope.debug, DTDigiToRaw.debug, magneticfield::eSector.debug, ALIUtils.debug, CSCSegAlgoPreClustering.debug, magneticfield::bRod.debug, DTSegment4DT0Corrector.debug, DTRecSegment4DProducer.debug, L1SeedConePFJetProducer.debug, crabFunctions.CrabController.debug, DTRecHitProducer.debug, DTSegmentsTask.debug, magneticfield::bSector.debug, DTOccupancyEfficiency.debug, RPCPointProducer.debug, runTauIdMVA.TauIDEmbedder.debug, MuonSeedProducer.debug, CSCGEMData.debug, DTDDUUnpacker.debug, pkg.AbstractPkg.debug, DTTTrigCorrectionFirst.debug, MuScleFitFilter.debug, JetAnaPythia< Jet >.debug, magneticfield::bSlab.debug, DTRecSegment2DProducer.debug, CSCDCCEventData.debug, DTRecSegment2DExtendedProducer.debug, DTT0CalibrationRMS.debug, DTTTrigWriter.debug, DTTPDeadWriter.debug, PPSAlignmentConfigurationESSource.debug, CSCSegAlgoShowering.debug, TritonService::FallbackOpts.debug, magneticfield::bLayer.debug, MuScleFitPlotter.debug, DTOccupancyPoint.debug, GEMCSCSegAlgoRR.debug, DTNoiseComputation.debug, DTROS25Unpacker.debug, L1CaloJetHTTProducer.debug, util.rrapi.RRApi.debug, rrapi.RRApi.debug, DTSpyReader.debug, DTT0Calibration.debug, DTTTrigSyncT0Only.debug, ME0SegmentAlgorithm.debug, DTEfficiencyTask.debug, PythiaFilterEMJetHeep.debug, GEMSegmentAlgorithm.debug, DTTTrigCalibration.debug, CSCDDUEventData.debug, DTRunConditionVar.debug, DTChamberEfficiencyTask.debug, HCALResponse.debug, DTMeantimerPatternReco4D.debug, DTCombinatorialPatternReco4D.debug, DTRefitAndCombineReco4D.debug, DTClusterer.debug, l1ct::PFTkEGAlgoEmuConfig.debug, DTChamberEfficiency.debug, CSCDCCUnpacker.debug, CSCComparatorData.debug, MuonSeedCreator.debug, DTTMax.debug, L1TowerCalibrator.debug, DTLinearDriftAlgo.debug, CSCTimingExtractor.debug, MuonSeedCleaner.debug, DTVDriftCalibration.debug, DTNoDriftAlgo.debug, DTParametrizedDriftAlgo.debug, DTTTrigSyncFromDB.debug, MagGeoBuilderFromDDD.debug, CSCTMBData.debug, DTTTrigSyncTOFCorr.debug, DTCombinatorialPatternReco.debug, DTTimingExtractor.debug, DTMeantimerPatternReco.debug, MuonSeedBuilder.debug, DTCombinatorialExtendedPatternReco.debug, L1CaloJetProducer.debug, DTSegmentUpdator.debug, CSCSegAlgoDF.debug, DTLinearDriftFromDBAlgo.debug, MuScleFitUtils.debug, CSCEventData.debug, BaseParticlePropagator.debug, magneticfield::BaseVolumeHandle.debug, CSCTMBHeader.debug, CSCSegAlgoST.debug, CSCALCTTrailer.debug, notcub::CachingHostAllocator.debug, notcub::CachingDeviceAllocator.debug, CSCALCTHeader.debug, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.debug, EcalBoundaryInfoCalculator< EcalDetId >.debug, PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >.debug, crabFunctions.CrabTask.debug, Pythia8::PowhegHooksBB4L.debug, HltDiff.debug, mps_monitormerge.items, relativeConstraints.keys, edm::ProductLabels.process, DTT0WireWorkflow.DTT0WireWorkflow.process, runTauIdMVA.TauIDEmbedder.process, DTVdriftWorkflow.DTvdriftWorkflow.process, cscdqm::HWStandbyType.process, DTTtrigWorkflow.DTttrigWorkflow.process, edmTracerCompactLogViewer.Activity.process, EgammaHLTValidationUtils.EgammaDQMModuleMaker.process, Config.Process.process, DTWorkflow.DTWorkflow.process, ConfigBuilder.ConfigBuilder.process, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.process, JsonOutputProducer::JsonConfigurationBlock.process, Config.TestModuleCommand.process, runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_2017_version, runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_trainings_run2_2017, and runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_WPs_run2_2017.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

103  def loadMVA_WPs_run2_2017(self):
104  if self.debug: print ("loadMVA_WPs_run2_2017: performed")
105  global cms
106  for training, gbrForestName in self.tauIdDiscrMVA_trainings_run2_2017.items():
107 
108  self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
109  cms.PSet(
110  record = cms.string('GBRWrapperRcd'),
111  tag = cms.string("RecoTauTag_%s%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version)),
112  label = cms.untracked.string("RecoTauTag_%s%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version))
113  )
114  )
115 
116  for WP in self.tauIdDiscrMVA_WPs_run2_2017[training].keys():
117  self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
118  cms.PSet(
119  record = cms.string('PhysicsTGraphPayloadRcd'),
120  tag = cms.string("RecoTauTag_%s%s_WP%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version, WP)),
121  label = cms.untracked.string("RecoTauTag_%s%s_WP%s" % (gbrForestName, self.tauIdDiscrMVA_2017_version, WP))
122  )
123  )
124 
125  self.process.loadRecoTauTagMVAsFromPrepDB.toGet.append(
126  cms.PSet(
127  record = cms.string('PhysicsTFormulaPayloadRcd'),
128  tag = cms.string("RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, self.tauIdDiscrMVA_2017_version)),
129  label = cms.untracked.string("RecoTauTag_%s%s_mvaOutput_normalization" % (gbrForestName, self.tauIdDiscrMVA_2017_version))
130  )
131  )
132 

◆ processDeepProducer()

def runTauIdMVA.TauIDEmbedder.processDeepProducer (   self,
  producer_name,
  tauIDSources,
  workingPoints_ 
)

Definition at line 983 of file runTauIdMVA.py.

References postprocessor.PostProcessor.postfix, runTauIdMVA.TauIDEmbedder.postfix, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.postfix, edm::ProductLabels.process, DTT0WireWorkflow.DTT0WireWorkflow.process, runTauIdMVA.TauIDEmbedder.process, DTVdriftWorkflow.DTvdriftWorkflow.process, cscdqm::HWStandbyType.process, DTTtrigWorkflow.DTttrigWorkflow.process, edmTracerCompactLogViewer.Activity.process, EgammaHLTValidationUtils.EgammaDQMModuleMaker.process, Config.Process.process, DTWorkflow.DTWorkflow.process, ConfigBuilder.ConfigBuilder.process, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.process, JsonOutputProducer::JsonConfigurationBlock.process, Config.TestModuleCommand.process, and str.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

983  def processDeepProducer(self, producer_name, tauIDSources, workingPoints_):
984  for target,points in workingPoints_.items():
985  setattr(tauIDSources, 'by{}VS{}raw'.format(producer_name[0].upper()+producer_name[1:], target),
986  cms.PSet(inputTag = cms.InputTag(producer_name+self.postfix, 'VS{}'.format(target)), workingPointIndex = cms.int32(-1)))
987 
988  cut_expressions = []
989  for index, (point,cut) in enumerate(points.items()):
990  cut_expressions.append(str(cut))
991 
992  setattr(tauIDSources, 'by{}{}VS{}'.format(point, producer_name[0].upper()+producer_name[1:], target),
993  cms.PSet(inputTag = cms.InputTag(producer_name+self.postfix, 'VS{}'.format(target)), workingPointIndex = cms.int32(index)))
994  if len(cut_expressions) > 0:
995  setattr(getattr(self.process, producer_name+self.postfix), 'VS{}WP'.format(target), cms.vstring(*cut_expressions))
996 
997 
#define str(s)

◆ runTauID()

def runTauIdMVA.TauIDEmbedder.runTauID (   self)

Definition at line 133 of file runTauIdMVA.py.

References InterpolationDebug.debug, l1ct::EGInputSelectorEmuConfig.debug, Cordic.debug, DTDigiToRawModule.debug, CSCRPCData.debug, CSCTMBScope.debug, DTDigiToRaw.debug, magneticfield::eSector.debug, ALIUtils.debug, magneticfield::bRod.debug, CSCSegAlgoPreClustering.debug, DTSegment4DT0Corrector.debug, DTRecSegment4DProducer.debug, L1SeedConePFJetProducer.debug, crabFunctions.CrabController.debug, DTRecHitProducer.debug, DTSegmentsTask.debug, magneticfield::bSector.debug, DTOccupancyEfficiency.debug, RPCPointProducer.debug, runTauIdMVA.TauIDEmbedder.debug, MuonSeedProducer.debug, CSCGEMData.debug, DTDDUUnpacker.debug, pkg.AbstractPkg.debug, DTTTrigCorrectionFirst.debug, magneticfield::bSlab.debug, MuScleFitFilter.debug, JetAnaPythia< Jet >.debug, CSCDCCEventData.debug, DTRecSegment2DProducer.debug, DTRecSegment2DExtendedProducer.debug, DTT0CalibrationRMS.debug, DTTTrigWriter.debug, DTTPDeadWriter.debug, magneticfield::bLayer.debug, CSCSegAlgoShowering.debug, PPSAlignmentConfigurationESSource.debug, TritonService::FallbackOpts.debug, MuScleFitPlotter.debug, DTOccupancyPoint.debug, DTNoiseComputation.debug, GEMCSCSegAlgoRR.debug, DTROS25Unpacker.debug, L1CaloJetHTTProducer.debug, util.rrapi.RRApi.debug, rrapi.RRApi.debug, DTSpyReader.debug, DTT0Calibration.debug, DTTTrigSyncT0Only.debug, ME0SegmentAlgorithm.debug, DTEfficiencyTask.debug, GEMSegmentAlgorithm.debug, PythiaFilterEMJetHeep.debug, CSCDDUEventData.debug, DTTTrigCalibration.debug, DTRunConditionVar.debug, DTChamberEfficiencyTask.debug, HCALResponse.debug, DTCombinatorialPatternReco4D.debug, DTMeantimerPatternReco4D.debug, DTRefitAndCombineReco4D.debug, DTClusterer.debug, l1ct::PFTkEGAlgoEmuConfig.debug, DTChamberEfficiency.debug, CSCComparatorData.debug, CSCDCCUnpacker.debug, MuonSeedCreator.debug, DTTMax.debug, L1TowerCalibrator.debug, DTLinearDriftAlgo.debug, CSCTimingExtractor.debug, MuonSeedCleaner.debug, DTVDriftCalibration.debug, DTNoDriftAlgo.debug, DTTTrigSyncFromDB.debug, DTParametrizedDriftAlgo.debug, MagGeoBuilderFromDDD.debug, CSCTMBData.debug, DTTTrigSyncTOFCorr.debug, DTCombinatorialPatternReco.debug, DTTimingExtractor.debug, DTMeantimerPatternReco.debug, MuonSeedBuilder.debug, DTCombinatorialExtendedPatternReco.debug, L1CaloJetProducer.debug, DTSegmentUpdator.debug, CSCSegAlgoDF.debug, DTLinearDriftFromDBAlgo.debug, MuScleFitUtils.debug, CSCEventData.debug, BaseParticlePropagator.debug, magneticfield::BaseVolumeHandle.debug, CSCTMBHeader.debug, CSCSegAlgoST.debug, CSCALCTTrailer.debug, notcub::CachingHostAllocator.debug, notcub::CachingDeviceAllocator.debug, CSCALCTHeader.debug, EcalBoundaryInfoCalculator< EcalDetId >.debug, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.debug, PFHCALDenseIdNavigator< DET, TOPO, ownsTopo >.debug, crabFunctions.CrabTask.debug, Pythia8::PowhegHooksBB4L.debug, HltDiff.debug, runTauIdMVA.TauIDEmbedder.getDeepTauVersion(), runTauIdMVA.TauIDEmbedder.is_above_cmssw_version(), runTauIdMVA.TauIDEmbedder.loadMVA_WPs_run2_2017(), runTauIdMVA.TauIDEmbedder.originalTauName, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.originalTauName, postprocessor.PostProcessor.postfix, runTauIdMVA.TauIDEmbedder.postfix, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.postfix, print(), edm::ProductLabels.process, DTT0WireWorkflow.DTT0WireWorkflow.process, runTauIdMVA.TauIDEmbedder.process, DTVdriftWorkflow.DTvdriftWorkflow.process, cscdqm::HWStandbyType.process, DTTtrigWorkflow.DTttrigWorkflow.process, edmTracerCompactLogViewer.Activity.process, EgammaHLTValidationUtils.EgammaDQMModuleMaker.process, Config.Process.process, DTWorkflow.DTWorkflow.process, ConfigBuilder.ConfigBuilder.process, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.process, JsonOutputProducer::JsonConfigurationBlock.process, Config.TestModuleCommand.process, runTauIdMVA.TauIDEmbedder.processDeepProducer(), runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_2017_version, runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_trainings_run2_2017, runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_WPs_run2_2017, runTauIdMVA.TauIDEmbedder.tauIDMVAinputs(), runTauIdMVA.TauIDEmbedder.toKeep, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.toKeep, runTauIdMVA.TauIDEmbedder.updatedTauName, and adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.updatedTauName.

133  def runTauID(self):
134  _rerunMvaIsolationTask = cms.Task()
135  _rerunMvaIsolationSequence = cms.Sequence()
136  tauIDSources = cms.PSet()
137 
138  # rerun the seq to obtain the 2017 nom training with 0.5 iso cone, old DM, ptph>1, trained on 2017MCv1
139  if "2017v1" in self.toKeep:
140  self.tauIdDiscrMVA_2017_version = "v1"
141  self.tauIdDiscrMVA_trainings_run2_2017 = {
142  'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
143  }
144  self.tauIdDiscrMVA_WPs_run2_2017 = {
145  'tauIdMVAIsoDBoldDMwLT2017' : {
146  'Eff95' : "DBoldDMwLTEff95",
147  'Eff90' : "DBoldDMwLTEff90",
148  'Eff80' : "DBoldDMwLTEff80",
149  'Eff70' : "DBoldDMwLTEff70",
150  'Eff60' : "DBoldDMwLTEff60",
151  'Eff50' : "DBoldDMwLTEff50",
152  'Eff40' : "DBoldDMwLTEff40"
153  }
154  }
155  # update the list of available in DB samples
156  if not self.is_above_cmssw_version(9, 4, 4, self.debug):
157  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")
158  self.loadMVA_WPs_run2_2017()
159 
160  _byIsolationOldDMMVArun2017v1raw = "rerunDiscriminationByIsolationOldDMMVArun2017v1raw"+self.postfix
161  setattr(self.process,_byIsolationOldDMMVArun2017v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
162  PATTauProducer = self.originalTauName,
163  Prediscriminants = noPrediscriminants,
164  loadMVAfromDB = cms.bool(True),
165  mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),
166  mvaOpt = cms.string("DBoldDMwLTwGJ"),
167  verbosity = cms.int32(0)
168  ))
169 
170  _byIsolationOldDMMVArun2017v1 = "rerunDiscriminationByIsolationOldDMMVArun2017v1"+self.postfix
171  setattr(self.process,_byIsolationOldDMMVArun2017v1,patDiscriminationByIsolationMVArun2v1.clone(
172  PATTauProducer = self.originalTauName,
173  Prediscriminants = noPrediscriminants,
174  toMultiplex = _byIsolationOldDMMVArun2017v1raw,
175  loadMVAfromDB = cms.bool(True),
176  mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
177  mapping = cms.VPSet(
178  cms.PSet(
179  category = cms.uint32(0),
180  cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"), #writeTauIdDiscrWPs
181  variable = cms.string("pt"),
182  )
183  ),
184  workingPoints = cms.vstring(
185  "_WPEff95",
186  "_WPEff90",
187  "_WPEff80",
188  "_WPEff70",
189  "_WPEff60",
190  "_WPEff50",
191  "_WPEff40"
192  )
193  ))
194 
195  _rerunIsolationOldDMMVArun2017v1Task = cms.Task(
196  getattr(self.process,_byIsolationOldDMMVArun2017v1raw),
197  getattr(self.process,_byIsolationOldDMMVArun2017v1)
198  )
199  _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v1Task)
200  _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v1Task)
201 
202  tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "raw")
203  tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff95")
204  tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff90")
205  tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff80")
206  tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff70")
207  tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff60")
208  tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff50")
209  tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v1, "_WPEff40")
210 
211 
212  if "2017v2" in self.toKeep:
213  self.tauIdDiscrMVA_2017_version = "v2"
214  self.tauIdDiscrMVA_trainings_run2_2017 = {
215  'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
216  }
217  self.tauIdDiscrMVA_WPs_run2_2017 = {
218  'tauIdMVAIsoDBoldDMwLT2017' : {
219  'Eff95' : "DBoldDMwLTEff95",
220  'Eff90' : "DBoldDMwLTEff90",
221  'Eff80' : "DBoldDMwLTEff80",
222  'Eff70' : "DBoldDMwLTEff70",
223  'Eff60' : "DBoldDMwLTEff60",
224  'Eff50' : "DBoldDMwLTEff50",
225  'Eff40' : "DBoldDMwLTEff40"
226  }
227  }
228 
229  if not self.is_above_cmssw_version(9, 4, 5, self.debug):
230  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")
231  self.loadMVA_WPs_run2_2017()
232 
233  _byIsolationOldDMMVArun2017v2raw = "rerunDiscriminationByIsolationOldDMMVArun2017v2raw"+self.postfix
234  setattr(self.process,_byIsolationOldDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
235  PATTauProducer = self.originalTauName,
236  Prediscriminants = noPrediscriminants,
237  loadMVAfromDB = cms.bool(True),
238  mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),
239  mvaOpt = cms.string("DBoldDMwLTwGJ"),
240  verbosity = cms.int32(0)
241  ))
242 
243  _byIsolationOldDMMVArun2017v2 = "rerunDiscriminationByIsolationOldDMMVArun2017v2"+self.postfix
244  setattr(self.process,_byIsolationOldDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
245  PATTauProducer = self.originalTauName,
246  Prediscriminants = noPrediscriminants,
247  toMultiplex = _byIsolationOldDMMVArun2017v2raw,
248  loadMVAfromDB = cms.bool(True),
249  mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
250  mapping = cms.VPSet(
251  cms.PSet(
252  category = cms.uint32(0),
253  cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"), #writeTauIdDiscrWPs
254  variable = cms.string("pt"),
255  )
256  ),
257  workingPoints = cms.vstring(
258  "_WPEff95",
259  "_WPEff90",
260  "_WPEff80",
261  "_WPEff70",
262  "_WPEff60",
263  "_WPEff50",
264  "_WPEff40"
265  ),
266  verbosity = cms.int32(0)
267  ))
268 
269  _rerunIsolationOldDMMVArun2017v2Task = cms.Task(
270  getattr(self.process,_byIsolationOldDMMVArun2017v2raw),
271  getattr(self.process,_byIsolationOldDMMVArun2017v2)
272  )
273  _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2017v2Task)
274  _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2017v2Task)
275 
276  tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "raw")
277  tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff95")
278  tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff90")
279  tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff80")
280  tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff70")
281  tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff60")
282  tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff50")
283  tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2017v2, "_WPEff40")
284 
285  if "newDM2017v2" in self.toKeep:
286  self.tauIdDiscrMVA_2017_version = "v2"
287  self.tauIdDiscrMVA_trainings_run2_2017 = {
288  'tauIdMVAIsoDBnewDMwLT2017' : "tauIdMVAIsoDBnewDMwLT2017",
289  }
290  self.tauIdDiscrMVA_WPs_run2_2017 = {
291  'tauIdMVAIsoDBnewDMwLT2017' : {
292  'Eff95' : "DBnewDMwLTEff95",
293  'Eff90' : "DBnewDMwLTEff90",
294  'Eff80' : "DBnewDMwLTEff80",
295  'Eff70' : "DBnewDMwLTEff70",
296  'Eff60' : "DBnewDMwLTEff60",
297  'Eff50' : "DBnewDMwLTEff50",
298  'Eff40' : "DBnewDMwLTEff40"
299  }
300  }
301 
302  if not self.is_above_cmssw_version(9, 4, 5, self.debug):
303  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")
304  self.loadMVA_WPs_run2_2017()
305 
306  _byIsolationNewDMMVArun2017v2raw = "rerunDiscriminationByIsolationNewDMMVArun2017v2raw"+self.postfix
307  setattr(self.process,_byIsolationNewDMMVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
308  PATTauProducer = self.originalTauName,
309  Prediscriminants = noPrediscriminants,
310  loadMVAfromDB = cms.bool(True),
311  mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),
312  mvaOpt = cms.string("DBnewDMwLTwGJ"),
313  verbosity = cms.int32(0)
314  ))
315 
316  _byIsolationNewDMMVArun2017v2 = "rerunDiscriminationByIsolationNewDMMVArun2017v2"+self.postfix
317  setattr(self.process,_byIsolationNewDMMVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
318  PATTauProducer = self.originalTauName,
319  Prediscriminants = noPrediscriminants,
320  toMultiplex = _byIsolationNewDMMVArun2017v2raw,
321  loadMVAfromDB = cms.bool(True),
322  mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
323  mapping = cms.VPSet(
324  cms.PSet(
325  category = cms.uint32(0),
326  cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"), #writeTauIdDiscrWPs
327  variable = cms.string("pt"),
328  )
329  ),
330  workingPoints = cms.vstring(
331  "_WPEff95",
332  "_WPEff90",
333  "_WPEff80",
334  "_WPEff70",
335  "_WPEff60",
336  "_WPEff50",
337  "_WPEff40"
338  ),
339  verbosity = cms.int32(0)
340  ))
341 
342  _rerunIsolationNewDMMVArun2017v2Task = cms.Task(
343  getattr(self.process,_byIsolationNewDMMVArun2017v2raw),
344  getattr(self.process,_byIsolationNewDMMVArun2017v2)
345  )
346  _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2017v2Task)
347  _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2017v2Task)
348 
349  tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "raw")
350  tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff95")
351  tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff90")
352  tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff80")
353  tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff70")
354  tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff60")
355  tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff50")
356  tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2017v2, "_WPEff40")
357 
358  if "dR0p32017v2" in self.toKeep:
359  self.tauIdDiscrMVA_2017_version = "v2"
360  self.tauIdDiscrMVA_trainings_run2_2017 = {
361  'tauIdMVAIsoDBoldDMdR0p3wLT2017' : "tauIdMVAIsoDBoldDMdR0p3wLT2017",
362  }
363  self.tauIdDiscrMVA_WPs_run2_2017 = {
364  'tauIdMVAIsoDBoldDMdR0p3wLT2017' : {
365  'Eff95' : "DBoldDMdR0p3wLTEff95",
366  'Eff90' : "DBoldDMdR0p3wLTEff90",
367  'Eff80' : "DBoldDMdR0p3wLTEff80",
368  'Eff70' : "DBoldDMdR0p3wLTEff70",
369  'Eff60' : "DBoldDMdR0p3wLTEff60",
370  'Eff50' : "DBoldDMdR0p3wLTEff50",
371  'Eff40' : "DBoldDMdR0p3wLTEff40"
372  }
373  }
374 
375  if not self.is_above_cmssw_version(9, 4, 5, self.debug):
376  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")
377  self.loadMVA_WPs_run2_2017()
378 
379  _byIsolationOldDMdR0p3MVArun2017v2raw = "rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw"+self.postfix
380  setattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
381  PATTauProducer = self.originalTauName,
382  Prediscriminants = noPrediscriminants,
383  loadMVAfromDB = cms.bool(True),
384  mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
385  mvaOpt = cms.string("DBoldDMwLTwGJ"),
386  srcChargedIsoPtSum = cms.string('chargedIsoPtSumdR03'),
387  srcFootprintCorrection = cms.string('footprintCorrectiondR03'),
388  srcNeutralIsoPtSum = cms.string('neutralIsoPtSumdR03'),
389  srcPhotonPtSumOutsideSignalCone = cms.string('photonPtSumOutsideSignalConedR03'),
390  verbosity = cms.int32(0)
391  ))
392 
393  _byIsolationOldDMdR0p3MVArun2017v2 = "rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2"+self.postfix
394  setattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2,patDiscriminationByIsolationMVArun2v1.clone(
395  PATTauProducer = self.originalTauName,
396  Prediscriminants = noPrediscriminants,
397  toMultiplex = _byIsolationOldDMdR0p3MVArun2017v2raw,
398  loadMVAfromDB = cms.bool(True),
399  mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
400  mapping = cms.VPSet(
401  cms.PSet(
402  category = cms.uint32(0),
403  cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"), #writeTauIdDiscrWPs
404  variable = cms.string("pt"),
405  )
406  ),
407  workingPoints = cms.vstring(
408  "_WPEff95",
409  "_WPEff90",
410  "_WPEff80",
411  "_WPEff70",
412  "_WPEff60",
413  "_WPEff50",
414  "_WPEff40"
415  ),
416  verbosity = cms.int32(0)
417  ))
418 
419  _rerunIsolationOldDMdR0p3MVArun2017v2Task = cms.Task(
420  getattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2raw),
421  getattr(self.process,_byIsolationOldDMdR0p3MVArun2017v2)
422  )
423  _rerunMvaIsolationTask.add(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
424  _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMdR0p3MVArun2017v2Task)
425 
426  tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "raw")
427  tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff95")
428  tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff90")
429  tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff80")
430  tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff70")
431  tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff60")
432  tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff50")
433  tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.tauIDMVAinputs(_byIsolationOldDMdR0p3MVArun2017v2, "_WPEff40")
434 
435  # 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
436  # self.process.rerunDiscriminationByIsolationOldDMMVArun2v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
437  # PATTauProducer = self.originalTauName,
438  # Prediscriminants = noPrediscriminants,
439  # loadMVAfromDB = cms.bool(True),
440  # mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2"),
441  # mvaOpt = cms.string("DBoldDMwLTwGJ"),
442  # verbosity = cms.int32(0)
443  # )
444  # #
445  # self.process.rerunDiscriminationByIsolationOldDMMVArun2v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
446  # PATTauProducer = self.originalTauName,
447  # Prediscriminants = noPrediscriminants,
448  # toMultiplex = 'rerunDiscriminationByIsolationOldDMMVArun2v2raw',
449  # key = cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v2raw:category'),#?
450  # loadMVAfromDB = cms.bool(True),
451  # mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
452  # mapping = cms.VPSet(
453  # cms.PSet(
454  # category = cms.uint32(0),
455  # cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2_WPEff90"), #writeTauIdDiscrWPs
456  # variable = cms.string("pt"),
457  # )
458  # )
459  # )
460 
461  # 2016 training strategy(v1), trained on 2016MC, old DM
462  if "2016v1" in self.toKeep:
463  _byIsolationOldDMMVArun2016v1raw = "rerunDiscriminationByIsolationOldDMMVArun2v1raw"+self.postfix
464  setattr(self.process,_byIsolationOldDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
465  PATTauProducer = self.originalTauName,
466  Prediscriminants = noPrediscriminants,
467  loadMVAfromDB = cms.bool(True),
468  mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
469  mvaOpt = cms.string("DBoldDMwLT"),
470  verbosity = cms.int32(0)
471  ))
472 
473  _byIsolationOldDMMVArun2016v1 = "rerunDiscriminationByIsolationOldDMMVArun2v1"+self.postfix
474  setattr(self.process,_byIsolationOldDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
475  PATTauProducer = self.originalTauName,
476  Prediscriminants = noPrediscriminants,
477  toMultiplex = _byIsolationOldDMMVArun2016v1raw,
478  loadMVAfromDB = cms.bool(True),
479  mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"),
480  mapping = cms.VPSet(
481  cms.PSet(
482  category = cms.uint32(0),
483  cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
484  variable = cms.string("pt"),
485  )
486  ),
487  workingPoints = cms.vstring(
488  "_WPEff90",
489  "_WPEff80",
490  "_WPEff70",
491  "_WPEff60",
492  "_WPEff50",
493  "_WPEff40"
494  )
495  ))
496 
497  _rerunIsolationOldDMMVArun2016v1Task = cms.Task(
498  getattr(self.process,_byIsolationOldDMMVArun2016v1raw),
499  getattr(self.process,_byIsolationOldDMMVArun2016v1)
500  )
501  _rerunMvaIsolationTask.add(_rerunIsolationOldDMMVArun2016v1Task)
502  _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationOldDMMVArun2016v1Task)
503 
504  tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "raw")
505  tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff90")
506  tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff80")
507  tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff70")
508  tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff60")
509  tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff50")
510  tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.tauIDMVAinputs(_byIsolationOldDMMVArun2016v1, "_WPEff40")
511 
512  # 2016 training strategy(v1), trained on 2016MC, new DM
513  if "newDM2016v1" in self.toKeep:
514  _byIsolationNewDMMVArun2016v1raw = "rerunDiscriminationByIsolationNewDMMVArun2v1raw"+self.postfix
515  setattr(self.process,_byIsolationNewDMMVArun2016v1raw,patDiscriminationByIsolationMVArun2v1raw.clone(
516  PATTauProducer = self.originalTauName,
517  Prediscriminants = noPrediscriminants,
518  loadMVAfromDB = cms.bool(True),
519  mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
520  mvaOpt = cms.string("DBnewDMwLT"),
521  verbosity = cms.int32(0)
522  ))
523 
524  _byIsolationNewDMMVArun2016v1 = "rerunDiscriminationByIsolationNewDMMVArun2v1"+self.postfix
525  setattr(self.process,_byIsolationNewDMMVArun2016v1,patDiscriminationByIsolationMVArun2v1.clone(
526  PATTauProducer = self.originalTauName,
527  Prediscriminants = noPrediscriminants,
528  toMultiplex = _byIsolationNewDMMVArun2016v1raw,
529  loadMVAfromDB = cms.bool(True),
530  mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"),
531  mapping = cms.VPSet(
532  cms.PSet(
533  category = cms.uint32(0),
534  cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
535  variable = cms.string("pt"),
536  )
537  ),
538  workingPoints = cms.vstring(
539  "_WPEff90",
540  "_WPEff80",
541  "_WPEff70",
542  "_WPEff60",
543  "_WPEff50",
544  "_WPEff40"
545  )
546  ))
547 
548  _rerunIsolationNewDMMVArun2016v1Task = cms.Task(
549  getattr(self.process,_byIsolationNewDMMVArun2016v1raw),
550  getattr(self.process,_byIsolationNewDMMVArun2016v1)
551  )
552  _rerunMvaIsolationTask.add(_rerunIsolationNewDMMVArun2016v1Task)
553  _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationNewDMMVArun2016v1Task)
554 
555  tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "raw")
556  tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff90")
557  tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff80")
558  tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff70")
559  tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff60")
560  tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff50")
561  tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.tauIDMVAinputs(_byIsolationNewDMMVArun2016v1, "_WPEff40")
562 
563  if "deepTau2017v2" in self.toKeep:
564  if self.debug: print ("Adding DeepTau v2 IDs")
565 
566  _deepTauName = "deepTau2017v2"
567  workingPoints_ = WORKING_POINTS_v2p1
568 
569  file_names = [
570  'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
571  'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
572  'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
573  ]
574  full_version = self.getDeepTauVersion(file_names[0])
575  setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
576  Prediscriminants = noPrediscriminants,
577  taus = self.originalTauName,
578  graph_file = file_names,
579  year = full_version[0],
580  version = full_version[1],
581  sub_version = 1 #MB: subversion cannot be properly deduced from file names; it should be 1 also for v2
582  ))
583 
584  _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
585 
586  from Configuration.ProcessModifiers.deepTauSonicTriton_cff import deepTauSonicTriton
587  deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
588  Client = cms.PSet(
589  mode = cms.string('PseudoAsync'),
590  allowedTries = cms.untracked.uint32(0),
591  verbose = cms.untracked.bool(False),
592  modelName = cms.string("deeptau_2017v2p1"),
593  modelVersion = cms.string(''),
594  modelConfigPath = cms.FileInPath("RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2017v2p1/config.pbtxt"),
595  preferredServer = cms.untracked.string(''),
596  timeout = cms.untracked.uint32(300),
597  useSharedMemory = cms.untracked.bool(True),
598  compression = cms.untracked.string(''),
599  outputs = cms.untracked.vstring()
600  ),
601  Prediscriminants = noPrediscriminants,
602  taus = self.originalTauName,
603  year = full_version[0],
604  version = full_version[1],
605  sub_version = 1, #MB: subversion cannot be properly deduced from file names
606  ))
607 
608  self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
609 
610  _rerunMvaIsolationTask.add(_deepTauProducer)
611  _rerunMvaIsolationSequence += _deepTauProducer
612 
613 
614  if "deepTau2017v2p1" in self.toKeep:
615  if self.debug: print ("Adding DeepTau v2p1 IDs")
616 
617  _deepTauName = "deepTau2017v2p1"
618  workingPoints_ = WORKING_POINTS_v2p1
619 
620  file_names = [
621  'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
622  'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
623  'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
624  ]
625  full_version = self.getDeepTauVersion(file_names[0])
626  setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
627  Prediscriminants = noPrediscriminants,
628  taus = self.originalTauName,
629  graph_file = file_names,
630  year = full_version[0],
631  version = full_version[1],
632  sub_version = 1, #MB: subversion cannot be properly deduced from file names
633  disable_dxy_pca = True
634  ))
635 
636  _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
637 
638  from Configuration.ProcessModifiers.deepTauSonicTriton_cff import deepTauSonicTriton
639  deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
640  Client = cms.PSet(
641  mode = cms.string('PseudoAsync'),
642  allowedTries = cms.untracked.uint32(0),
643  verbose = cms.untracked.bool(False),
644  modelName = cms.string("deeptau_2017v2p1"),
645  modelVersion = cms.string(''),
646  modelConfigPath = cms.FileInPath("RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2017v2p1/config.pbtxt"),
647  preferredServer = cms.untracked.string(''),
648  timeout = cms.untracked.uint32(300),
649  useSharedMemory = cms.untracked.bool(True),
650  compression = cms.untracked.string(''),
651  outputs = cms.untracked.vstring()
652  ),
653  Prediscriminants = noPrediscriminants,
654  taus = self.originalTauName,
655  year = full_version[0],
656  version = full_version[1],
657  sub_version = 1, #MB: subversion cannot be properly deduced from file names
658  disable_dxy_pca = True
659  ))
660 
661  self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
662 
663  _rerunMvaIsolationTask.add(_deepTauProducer)
664  _rerunMvaIsolationSequence += _deepTauProducer
665 
666  if "deepTau2018v2p5" in self.toKeep:
667  if self.debug: print ("Adding DeepTau v2p5 IDs")
668 
669  _deepTauName = "deepTau2018v2p5"
670  workingPoints_ = WORKING_POINTS_v2p5
671 
672  file_names = [
673  'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_core.pb',
674  'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_inner.pb',
675  'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2018v2p5_outer.pb',
676  ]
677  full_version = self.getDeepTauVersion(file_names[0])
678  setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
679  Prediscriminants = noPrediscriminants,
680  taus = self.originalTauName,
681  graph_file = file_names,
682  year = full_version[0],
683  version = full_version[1],
684  sub_version = full_version[2],
685  disable_dxy_pca = True,
686  disable_hcalFraction_workaround = True,
687  disable_CellIndex_workaround = True
688  ))
689 
690  _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
691 
692  from Configuration.ProcessModifiers.deepTauSonicTriton_cff import deepTauSonicTriton
693  deepTauSonicTriton.toReplaceWith(_deepTauProducer, DeepTauIdSonicProducer.clone(
694  Client = cms.PSet(
695  mode = cms.string('PseudoAsync'),
696  allowedTries = cms.untracked.uint32(0),
697  verbose = cms.untracked.bool(False),
698  modelName = cms.string("deeptau_2018v2p5"),
699  modelVersion = cms.string(''),
700  modelConfigPath = cms.FileInPath("RecoTauTag/TrainingFiles/data/DeepTauIdSONIC/deeptau_2018v2p5/config.pbtxt"),
701  preferredServer = cms.untracked.string(''),
702  timeout = cms.untracked.uint32(300),
703  useSharedMemory = cms.untracked.bool(True),
704  compression = cms.untracked.string(''),
705  outputs = cms.untracked.vstring(),
706  ),
707  Prediscriminants = noPrediscriminants,
708  taus = self.originalTauName,
709  year = full_version[0],
710  version = full_version[1],
711  sub_version = full_version[2],
712  disable_dxy_pca = True,
713  disable_hcalFraction_workaround = True,
714  disable_CellIndex_workaround = True
715  ))
716 
717  self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
718 
719  _rerunMvaIsolationTask.add(_deepTauProducer)
720  _rerunMvaIsolationSequence += _deepTauProducer
721 
722  if "deepTau2026v2p5" in self.toKeep:
723  if self.debug: print ("Adding Phase2 DeepTau v2p5 IDs")
724 
725  _deepTauName = "deepTau2026v2p5"
726  workingPoints_ = WORKING_POINTS_PHASEII_v2p5
727 
728  file_names = [
729  'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_core.pb',
730  'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_inner.pb',
731  'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2026v2p5_outer.pb',
732  ]
733  full_version = self.getDeepTauVersion(file_names[0])
734  setattr(self.process,_deepTauName+self.postfix,DeepTau.clone(
735  Prediscriminants = noPrediscriminants,
736  taus = self.originalTauName,
737  graph_file = file_names,
738  year = full_version[0],
739  version = full_version[1],
740  sub_version = full_version[2],
741  disable_dxy_pca = True,
742  disable_hcalFraction_workaround = True,
743  disable_CellIndex_workaround = True
744  ))
745 
746  from RecoTauTag.RecoTau.mergedPhase2SlimmedElectronsForTauId_cff import mergedSlimmedElectronsForTauId
747  if not hasattr(self.process,"mergedSlimmedElectronsForTauId"):
748  self.process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
749  setattr(getattr(self.process, _deepTauName+self.postfix), "electrons", cms.InputTag("mergedSlimmedElectronsForTauId"))
750  setattr(getattr(self.process, _deepTauName+self.postfix), "vertices", cms.InputTag("offlineSlimmedPrimaryVertices4D"))
751 
752  self.processDeepProducer(_deepTauName, tauIDSources, workingPoints_)
753 
754  _deepTauProducer = getattr(self.process,_deepTauName+self.postfix)
755  _rerunMvaIsolationTask.add(self.process.mergedSlimmedElectronsForTauId)
756  _rerunMvaIsolationTask.add(_deepTauProducer)
757  _rerunMvaIsolationSequence += self.process.mergedSlimmedElectronsForTauId
758  _rerunMvaIsolationSequence += _deepTauProducer
759 
760  if "againstEle2018" in self.toKeep:
761  antiElectronDiscrMVA6_version = "MVA6v3_noeveto"
762 
764  from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
765  _byElectronRejectionMVA62018Raw = "patTauDiscriminationByElectronRejectionMVA62018Raw"+self.postfix
766  setattr(self.process,_byElectronRejectionMVA62018Raw,patTauDiscriminationAgainstElectronMVA6.clone(
767  PATTauProducer = self.originalTauName,
768  Prediscriminants = noPrediscriminants, #already selected for MiniAOD
769  srcElectrons = cms.InputTag('slimmedElectrons'),
770  vetoEcalCracks = cms.bool(False), #keep taus in EB-EE cracks
771  mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL',
772  mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC',
773  mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL',
774  mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC',
775  mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL',
776  mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC',
777  mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL',
778  mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'
779  ))
780 
781  from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer
782  _byElectronRejectionMVA62018 = "patTauDiscriminationByElectronRejectionMVA62018"+self.postfix
783  setattr(self.process,"patTauDiscriminationByElectronRejectionMVA62018"+self.postfix,patTauDiscriminantCutMultiplexer.clone(
784  PATTauProducer = self.originalTauName,
785  Prediscriminants = noPrediscriminants,
786  toMultiplex = _byElectronRejectionMVA62018Raw,
787  mapping = cms.VPSet(
788  cms.PSet(
789  category = cms.uint32(0),
790  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL'),
791  variable = cms.string('pt')
792  ),
793  cms.PSet(
794  category = cms.uint32(2),
795  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL'),
796  variable = cms.string('pt')
797  ),
798  cms.PSet(
799  category = cms.uint32(5),
800  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL'),
801  variable = cms.string('pt')
802  ),
803  cms.PSet(
804  category = cms.uint32(7),
805  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL'),
806  variable = cms.string('pt')
807  ),
808  cms.PSet(
809  category = cms.uint32(8),
810  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC'),
811  variable = cms.string('pt')
812  ),
813  cms.PSet(
814  category = cms.uint32(10),
815  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC'),
816  variable = cms.string('pt')
817  ),
818  cms.PSet(
819  category = cms.uint32(13),
820  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC'),
821  variable = cms.string('pt')
822  ),
823  cms.PSet(
824  category = cms.uint32(15),
825  cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC'),
826  variable = cms.string('pt')
827  )
828  ),
829  workingPoints = cms.vstring(
830  "_WPeff98",
831  "_WPeff90",
832  "_WPeff80",
833  "_WPeff70",
834  "_WPeff60"
835  )
836  ))
837 
838  _patTauDiscriminationByElectronRejectionMVA62018Task = cms.Task(
839  getattr(self.process,_byElectronRejectionMVA62018Raw),
840  getattr(self.process,_byElectronRejectionMVA62018)
841  )
842  _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA62018Task)
843  _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA62018Task)
844 
845  _againstElectronTauIDSources = cms.PSet(
846  againstElectronMVA6Raw2018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "raw"),
847  againstElectronMVA6category2018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "category"),
848  againstElectronVLooseMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff98"),
849  againstElectronLooseMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff90"),
850  againstElectronMediumMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff80"),
851  againstElectronTightMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff70"),
852  againstElectronVTightMVA62018 = self.tauIDMVAinputs(_byElectronRejectionMVA62018, "_WPeff60")
853  )
854  _tauIDSourcesWithAgainistEle = cms.PSet(
855  tauIDSources.clone(),
856  _againstElectronTauIDSources
857  )
858  tauIDSources =_tauIDSourcesWithAgainistEle.clone()
859 
860  if "newDMPhase2v1" in self.toKeep:
861  if self.debug: print ("Adding newDMPhase2v1 ID")
862  def tauIDMVAinputs(module, wp):
863  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)))
864  _byIsolationNewDMMVAPhase2raw = "rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw"+self.postfix
865  setattr(self.process,_byIsolationNewDMMVAPhase2raw,patDiscriminationByIsolationMVArun2v1raw.clone(
866  PATTauProducer = self.originalTauName,
867  Prediscriminants = noPrediscriminants,
868  loadMVAfromDB = True,
869  mvaName = 'RecoTauTag_tauIdMVAIsoPhase2',
870  mvaOpt = 'DBnewDMwLTwGJPhase2',
871  verbosity = 0
872  ))
873 
874  _byIsolationNewDMMVAPhase2 = "rerunDiscriminationByIsolationMVADBnewDMwLTPhase2"+self.postfix
875  setattr(self.process,_byIsolationNewDMMVAPhase2,patDiscriminationByIsolationMVArun2v1.clone(
876  PATTauProducer = self.originalTauName,
877  Prediscriminants = noPrediscriminants,
878  toMultiplex = _byIsolationNewDMMVAPhase2raw,
879  loadMVAfromDB = True,
880  mvaOutput_normalization = 'RecoTauTag_tauIdMVAIsoPhase2_mvaOutput_normalization',
881  mapping = cms.VPSet(
882  cms.PSet(
883  category = cms.uint32(0),
884  cut = cms.string("RecoTauTag_tauIdMVAIsoPhase2"),
885  variable = cms.string("pt"),
886  )
887  ),
888  workingPoints = cms.vstring(
889  "_VVLoose",
890  "_VLoose",
891  "_Loose",
892  "_Medium",
893  "_Tight",
894  "_VTight",
895  "_VVTight"
896  )
897  ))
898  _rerunIsolationMVADBnewDMwLTPhase2Task = cms.Task(
899  getattr(self.process,_byIsolationNewDMMVAPhase2raw),
900  getattr(self.process,_byIsolationNewDMMVAPhase2)
901  )
902  _rerunMvaIsolationTask.add(_rerunIsolationMVADBnewDMwLTPhase2Task)
903  _rerunMvaIsolationSequence += cms.Sequence(_rerunIsolationMVADBnewDMwLTPhase2Task)
904 
905  tauIDSources.byIsolationMVADBnewDMwLTPhase2raw = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "raw")
906  tauIDSources.byVVLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VVLoose")
907  tauIDSources.byVLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VLoose")
908  tauIDSources.byLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_Loose")
909  tauIDSources.byMediumIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_Medium")
910  tauIDSources.byTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_Tight")
911  tauIDSources.byVTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VTight")
912  tauIDSources.byVVTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs(_byIsolationNewDMMVAPhase2, "_VVTight")
913 
914  if "againstElePhase2v1" in self.toKeep:
915  if self.debug: print ("Adding anti-e Phase2v1 ID")
916 
918  from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6Phase2_cff import patTauDiscriminationAgainstElectronMVA6Phase2Raw, patTauDiscriminationAgainstElectronMVA6Phase2, mergedSlimmedElectronsForTauId
919  _byElectronRejectionMVA6Phase2v1Raw = "patTauDiscriminationByElectronRejectionMVA6Phase2v1Raw"+self.postfix
920  setattr(self.process,_byElectronRejectionMVA6Phase2v1Raw,patTauDiscriminationAgainstElectronMVA6Phase2Raw.clone(
921  PATTauProducer = self.originalTauName,
922  Prediscriminants = noPrediscriminants #already selected for MiniAOD
923  ))
924 
925  _byElectronRejectionMVA6Phase2v1 = "patTauDiscriminationByElectronRejectionMVA6Phase2v1"+self.postfix
926  setattr(self.process,_byElectronRejectionMVA6Phase2v1,patTauDiscriminationAgainstElectronMVA6Phase2.clone(
927  PATTauProducer = self.originalTauName,
928  Prediscriminants = noPrediscriminants,
929  toMultiplex = _byElectronRejectionMVA6Phase2v1Raw
930  ))
931 
932  if not hasattr(self.process,"mergedSlimmedElectronsForTauId"):
933  self.process.mergedSlimmedElectronsForTauId = mergedSlimmedElectronsForTauId
934  _patTauDiscriminationByElectronRejectionMVA6Phase2v1Task = cms.Task(
935  self.process.mergedSlimmedElectronsForTauId,
936  getattr(self.process,_byElectronRejectionMVA6Phase2v1Raw),
937  getattr(self.process,_byElectronRejectionMVA6Phase2v1)
938  )
939  _rerunMvaIsolationTask.add(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
940  _rerunMvaIsolationSequence += cms.Sequence(_patTauDiscriminationByElectronRejectionMVA6Phase2v1Task)
941 
942  _againstElectronTauIDPhase2v1Sources = cms.PSet(
943  againstElectronMVA6RawPhase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "raw"),
944  againstElectronMVA6categoryPhase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "category"),
945  againstElectronVLooseMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_VLoose"),
946  againstElectronLooseMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_Loose"),
947  againstElectronMediumMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_Medium"),
948  againstElectronTightMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_Tight"),
949  againstElectronVTightMVA6Phase2v1 = self.tauIDMVAinputs(_byElectronRejectionMVA6Phase2v1, "_VTight")
950  )
951  _tauIDSourcesWithAgainistElePhase2v1 = cms.PSet(
952  tauIDSources.clone(),
953  _againstElectronTauIDPhase2v1Sources
954  )
955  tauIDSources =_tauIDSourcesWithAgainistElePhase2v1.clone()
956 
957  if self.debug: print('Embedding new TauIDs into \"'+self.updatedTauName+'\"')
958  if not hasattr(self.process, self.updatedTauName):
959  embedID = cms.EDProducer("PATTauIDEmbedder",
960  src = cms.InputTag(self.originalTauName),
961  tauIDSources = tauIDSources
962  )
963  setattr(self.process, self.updatedTauName, embedID)
964  else: #assume same type
965  tauIDSources = cms.PSet(
966  getattr(self.process, self.updatedTauName).tauIDSources,
967  tauIDSources)
968  getattr(self.process, self.updatedTauName).tauIDSources = tauIDSources
969  if not hasattr(self.process,"rerunMvaIsolationTask"+self.postfix):
970  setattr(self.process,"rerunMvaIsolationTask"+self.postfix,_rerunMvaIsolationTask)
971  else:
972  _updatedRerunMvaIsolationTask = getattr(self.process,"rerunMvaIsolationTask"+self.postfix)
973  _updatedRerunMvaIsolationTask.add(_rerunMvaIsolationTask)
974  setattr(self.process,"rerunMvaIsolationTask"+self.postfix,_updatedRerunMvaIsolationTask)
975  if not hasattr(self.process,"rerunMvaIsolationSequence"+self.postfix):
976  setattr(self.process,"rerunMvaIsolationSequence"+self.postfix,_rerunMvaIsolationSequence)
977  else:
978  _updatedRerunMvaIsolationSequence = getattr(self.process,"rerunMvaIsolationSequence"+self.postfix)
979  _updatedRerunMvaIsolationSequence += _rerunMvaIsolationSequence
980  setattr(self.process,"rerunMvaIsolationSequence"+self.postfix,_updatedRerunMvaIsolationSequence)
981 
982 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ tauIDMVAinputs()

◆ versionToInt()

def runTauIdMVA.TauIDEmbedder.versionToInt (   release = 9,
  subversion = 4,
  patch = 0,
  debug = False 
)
static

Definition at line 84 of file runTauIdMVA.py.

84  def versionToInt(release=9, subversion=4, patch=0, debug = False):
85  version = release * 10000 + subversion * 100 + patch + 1 # shifted by one to account for pre-releases.
86  if debug: print ("versionToInt:", version)
87  return version
88 
89 

Member Data Documentation

◆ availableDiscriminators

runTauIdMVA.TauIDEmbedder.availableDiscriminators
static

Definition at line 14 of file runTauIdMVA.py.

◆ debug

runTauIdMVA.TauIDEmbedder.debug

◆ originalTauName

runTauIdMVA.TauIDEmbedder.originalTauName

Definition at line 45 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

◆ postfix

runTauIdMVA.TauIDEmbedder.postfix

◆ process

◆ tauIdDiscrMVA_2017_version

runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_2017_version

◆ tauIdDiscrMVA_trainings_run2_2017

runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_trainings_run2_2017

◆ tauIdDiscrMVA_WPs_run2_2017

runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_WPs_run2_2017

◆ toKeep

runTauIdMVA.TauIDEmbedder.toKeep

Definition at line 63 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

◆ updatedTauName

runTauIdMVA.TauIDEmbedder.updatedTauName

Definition at line 46 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().