CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
def getDeepTauVersion
 
def getDpfTauVersion
 
def is_above_cmssw_version
 
def loadMVA_WPs_run2_2017
 
def processDeepProducer
 
def runTauID
 
def tauIDMVAinputs
 

Static Public Member Functions

def get_cmssw_version
 
def versionToInt
 

Public Attributes

 debug
 
 originalTauName
 
 postfix
 
 process
 
 tauIdDiscrMVA_2017_version
 
 tauIdDiscrMVA_trainings_run2_2017
 
 tauIdDiscrMVA_WPs_run2_2017
 
 toKeep
 
 updatedTauName
 

Static Public Attributes

list availableDiscriminators
 

Detailed Description

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

Definition at line 8 of file runTauIdMVA.py.

Constructor & Destructor Documentation

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

Definition at line 28 of file runTauIdMVA.py.

28 
29  'Eff90' : "DBoldDMwLTEff90",
30  'Eff80' : "DBoldDMwLTEff80",
31  'Eff70' : "DBoldDMwLTEff70",
32  'Eff60' : "DBoldDMwLTEff60",
33  'Eff50' : "DBoldDMwLTEff50",
34  'Eff40' : "DBoldDMwLTEff40"
35  }
36  },
37  tauIdDiscrMVA_2017_version = "v1",
38  conditionDB = "" # preparational DB: 'frontier://FrontierPrep/CMS_CONDITIONS'
39  ):
40  super(TauIDEmbedder, self).__init__()
41  self.process = process
42  self.debug = debug
43  self.originalTauName = originalTauName
44  self.updatedTauName = updatedTauName
45  self.postfix = postfix
46  self.process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
47  if len(conditionDB) != 0:
48  self.process.CondDBTauConnection.connect = cms.string(conditionDB)
49  self.process.loadRecoTauTagMVAsFromPrepDB.connect = cms.string(conditionDB)
50  # if debug:
51  # print self.process.CondDBTauConnection.connect
52  # print dir(self.process.loadRecoTauTagMVAsFromPrepDB)
53  # print self.process.loadRecoTauTagMVAsFromPrepDB.parameterNames_
54 
55  self.tauIdDiscrMVA_trainings_run2_2017 = tauIdDiscrMVA_trainings_run2_2017
56  self.tauIdDiscrMVA_WPs_run2_2017 = tauIdDiscrMVA_WPs_run2_2017
57  self.tauIdDiscrMVA_2017_version = tauIdDiscrMVA_2017_version
58  for discr in toKeep:
59  if discr not in TauIDEmbedder.availableDiscriminators:
60  raise RuntimeError('TauIDEmbedder: discriminator "{}" is not supported'.format(discr))
61  self.toKeep = toKeep
62 

Member Function Documentation

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

Definition at line 64 of file runTauIdMVA.py.

64 
65  def get_cmssw_version(debug = False):
66  """returns 'CMSSW_X_Y_Z'"""
67  cmssw_version = os.environ["CMSSW_VERSION"]
68  if debug: print ("get_cmssw_version:", cmssw_version)
69  return cmssw_version
def runTauIdMVA.TauIDEmbedder.get_cmssw_version_number (   klass,
  debug = False 
)
returns '(release, subversion, patch)' (without 'CMSSW_')

Definition at line 71 of file runTauIdMVA.py.

References submitPVValidationJobs.split().

71 
72  def get_cmssw_version_number(klass, debug = False):
73  """returns '(release, subversion, patch)' (without 'CMSSW_')"""
74  v = klass.get_cmssw_version().split("CMSSW_")[1].split("_")[0:3]
75  if debug: print ("get_cmssw_version_number:", v)
76  try:
77  patch = int(v[2])
78  except:
79  patch = -1
80  return int(v[0]), int(v[1]), patch
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 1039 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

1040  def getDeepTauVersion(self, file_name):
1041  """returns the DeepTau year, version, subversion. File name should contain a version label with data takig year \
1042  (2011-2, 2015-8), version number (vX) and subversion (pX), e.g. 2017v0p6, in general the following format: \
1043  {year}v{version}p{subversion}"""
1044  version_search = re.search('(201[125678])v([0-9]+)(p[0-9]+|)[\._]', file_name)
1045  if not version_search:
1046  raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}p{subversion}". \
1047  Unable to extract version number.'.format(file_name))
1048  year = version_search.group(1)
1049  version = version_search.group(2)
1050  subversion = version_search.group(3)
1051  if len(subversion) > 0:
1052  subversion = subversion[1:]
1053  else:
1054  subversion = 0
1055  return int(year), int(version), int(subversion)
def runTauIdMVA.TauIDEmbedder.getDpfTauVersion (   self,
  file_name 
)
returns the DNN version. File name should contain a version label with data takig year (2011-2, 2015-8) and \
   version number (vX), e.g. 2017v0, in general the following format: {year}v{version}

Definition at line 1029 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

1030  def getDpfTauVersion(self, file_name):
1031  """returns the DNN version. File name should contain a version label with data takig year (2011-2, 2015-8) and \
1032  version number (vX), e.g. 2017v0, in general the following format: {year}v{version}"""
1033  version_search = re.search('201[125678]v([0-9]+)[\._]', file_name)
1034  if not version_search:
1035  raise RuntimeError('File "{}" has an invalid name pattern, should be in the format "{year}v{version}". \
1036  Unable to extract version number.'.format(file_name))
1037  version = version_search.group(1)
1038  return int(version)
def runTauIdMVA.TauIDEmbedder.is_above_cmssw_version (   klass,
  release = 9,
  subversion = 4,
  patch = 0,
  debug = False 
)

Definition at line 89 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

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

Definition at line 101 of file runTauIdMVA.py.

References InterpolationDebug.debug, DTDigiToRawModule.debug, CSCRPCData.debug, CSCTMBScope.debug, ALIUtils.debug, DTDigiToRaw.debug, magneticfield::eSector.debug, CSCSegAlgoPreClustering.debug, magneticfield::bRod.debug, DTSegment4DT0Corrector.debug, DTRecSegment4DProducer.debug, crabFunctions.CrabController.debug, DTRecHitProducer.debug, RPCPointProducer.debug, DTSegmentsTask.debug, CSCGEMData.debug, runTauIdMVA.TauIDEmbedder.debug, magneticfield::bSector.debug, DTOccupancyEfficiency.debug, MuonSeedProducer.debug, DTTTrigCorrectionFirst.debug, DTDDUUnpacker.debug, pkg.AbstractPkg.debug, JetAnaPythia< Jet >.debug, magneticfield::bSlab.debug, MuScleFitFilter.debug, DTRecSegment2DProducer.debug, CSCDCCEventData.debug, DTT0CalibrationRMS.debug, DTRecSegment2DExtendedProducer.debug, DTTPDeadWriter.debug, DTTTrigWriter.debug, TritonService::FallbackOpts.debug, PPSAlignmentConfigurationESSource.debug, CSCSegAlgoShowering.debug, DTNoiseComputation.debug, magneticfield::bLayer.debug, MuScleFitPlotter.debug, DTOccupancyPoint.debug, GEMCSCSegAlgoRR.debug, PPSAlignmentConfigESSource.debug, DTROS25Unpacker.debug, L1CaloJetHTTProducer.debug, util.rrapi.RRApi.debug, rrapi.RRApi.debug, DTSpyReader.debug, DTT0Calibration.debug, DTTTrigSyncT0Only.debug, ME0SegmentAlgorithm.debug, PythiaFilterEMJetHeep.debug, DTEfficiencyTask.debug, GEMSegmentAlgorithm.debug, DTTTrigCalibration.debug, CSCDDUEventData.debug, DTRunConditionVar.debug, DTChamberEfficiencyTask.debug, HCALResponse.debug, DTClusterer.debug, DTMeantimerPatternReco4D.debug, DTCombinatorialPatternReco4D.debug, DTRefitAndCombineReco4D.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, CSCTMBData.debug, MagGeoBuilderFromDDD.debug, DTTTrigSyncTOFCorr.debug, DTCombinatorialPatternReco.debug, DTTimingExtractor.debug, DTMeantimerPatternReco.debug, MuonSeedBuilder.debug, DTCombinatorialExtendedPatternReco.debug, L1CaloJetProducer.debug, DTSegmentUpdator.debug, CSCSegAlgoDF.debug, DTLinearDriftFromDBAlgo.debug, CSCEventData.debug, MuScleFitUtils.debug, CSCTMBHeader.debug, BaseParticlePropagator.debug, magneticfield::BaseVolumeHandle.debug, CSCSegAlgoST.debug, CSCALCTTrailer.debug, CSCALCTHeader.debug, notcub::CachingHostAllocator.debug, notcub::CachingDeviceAllocator.debug, EcalBoundaryInfoCalculator< EcalDetId >.debug, crabFunctions.CrabTask.debug, Pythia8::PowhegHooksBB4L.debug, HltDiff.debug, relativeConstraints.keys, runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_2017_version, and runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_WPs_run2_2017.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

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

Definition at line 1014 of file runTauIdMVA.py.

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

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

1015  def processDeepProducer(self, producer_name, tauIDSources, workingPoints_):
1016  for target,points in workingPoints_.items():
1017  setattr(tauIDSources, 'by{}VS{}raw'.format(producer_name[0].upper()+producer_name[1:], target),
1018  cms.PSet(inputTag = cms.InputTag(producer_name+self.postfix, 'VS{}'.format(target)), workingPointIndex = cms.int32(-1)))
1019 
1020  cut_expressions = []
1021  for index, (point,cut) in enumerate(points.items()):
1022  cut_expressions.append(str(cut))
1023 
1024  setattr(tauIDSources, 'by{}{}VS{}'.format(point, producer_name[0].upper()+producer_name[1:], target),
1025  cms.PSet(inputTag = cms.InputTag(producer_name+self.postfix, 'VS{}'.format(target)), workingPointIndex = cms.int32(index)))
1026 
1027  setattr(getattr(self.process, producer_name+self.postfix), 'VS{}WP'.format(target), cms.vstring(*cut_expressions))
1028 
#define str(s)
def runTauIdMVA.TauIDEmbedder.runTauID (   self)

Definition at line 131 of file runTauIdMVA.py.

References InterpolationDebug.debug, DTDigiToRawModule.debug, CSCRPCData.debug, CSCTMBScope.debug, magneticfield::eSector.debug, ALIUtils.debug, DTDigiToRaw.debug, magneticfield::bRod.debug, CSCSegAlgoPreClustering.debug, DTSegment4DT0Corrector.debug, DTRecSegment4DProducer.debug, crabFunctions.CrabController.debug, DTRecHitProducer.debug, DTSegmentsTask.debug, RPCPointProducer.debug, magneticfield::bSector.debug, CSCGEMData.debug, runTauIdMVA.TauIDEmbedder.debug, DTOccupancyEfficiency.debug, MuonSeedProducer.debug, DTTTrigCorrectionFirst.debug, DTDDUUnpacker.debug, pkg.AbstractPkg.debug, magneticfield::bSlab.debug, JetAnaPythia< Jet >.debug, MuScleFitFilter.debug, CSCDCCEventData.debug, DTRecSegment2DProducer.debug, DTT0CalibrationRMS.debug, DTRecSegment2DExtendedProducer.debug, DTTPDeadWriter.debug, TritonService::FallbackOpts.debug, DTTTrigWriter.debug, PPSAlignmentConfigurationESSource.debug, CSCSegAlgoShowering.debug, DTNoiseComputation.debug, magneticfield::bLayer.debug, MuScleFitPlotter.debug, DTOccupancyPoint.debug, GEMCSCSegAlgoRR.debug, PPSAlignmentConfigESSource.debug, DTROS25Unpacker.debug, L1CaloJetHTTProducer.debug, util.rrapi.RRApi.debug, rrapi.RRApi.debug, DTSpyReader.debug, DTTTrigSyncT0Only.debug, DTT0Calibration.debug, ME0SegmentAlgorithm.debug, GEMSegmentAlgorithm.debug, DTTTrigCalibration.debug, PythiaFilterEMJetHeep.debug, DTEfficiencyTask.debug, CSCDDUEventData.debug, DTRunConditionVar.debug, HCALResponse.debug, DTChamberEfficiencyTask.debug, DTClusterer.debug, DTCombinatorialPatternReco4D.debug, DTMeantimerPatternReco4D.debug, DTRefitAndCombineReco4D.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, CSCTMBData.debug, MagGeoBuilderFromDDD.debug, DTTTrigSyncTOFCorr.debug, DTCombinatorialPatternReco.debug, DTTimingExtractor.debug, DTMeantimerPatternReco.debug, MuonSeedBuilder.debug, DTCombinatorialExtendedPatternReco.debug, L1CaloJetProducer.debug, DTSegmentUpdator.debug, CSCSegAlgoDF.debug, DTLinearDriftFromDBAlgo.debug, CSCEventData.debug, MuScleFitUtils.debug, CSCTMBHeader.debug, BaseParticlePropagator.debug, magneticfield::BaseVolumeHandle.debug, CSCSegAlgoST.debug, CSCALCTTrailer.debug, CSCALCTHeader.debug, notcub::CachingHostAllocator.debug, notcub::CachingDeviceAllocator.debug, EcalBoundaryInfoCalculator< EcalDetId >.debug, crabFunctions.CrabTask.debug, Pythia8::PowhegHooksBB4L.debug, HltDiff.debug, runTauIdMVA.TauIDEmbedder.getDeepTauVersion(), runTauIdMVA.TauIDEmbedder.getDpfTauVersion(), runTauIdMVA.TauIDEmbedder.is_above_cmssw_version(), runTauIdMVA.TauIDEmbedder.loadMVA_WPs_run2_2017(), runTauIdMVA.TauIDEmbedder.originalTauName, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.postfix, runTauIdMVA.TauIDEmbedder.postfix, print(), edm::ProductLabels.process, adaptToRunAtMiniAOD.adaptToRunAtMiniAOD.process, DTT0WireWorkflow.DTT0WireWorkflow.process, runTauIdMVA.TauIDEmbedder.process, DTVdriftWorkflow.DTvdriftWorkflow.process, cscdqm::HWStandbyType.process, DTTtrigWorkflow.DTttrigWorkflow.process, EgammaHLTValidationUtils.EgammaDQMModuleMaker.process, Config.Process.process, DTWorkflow.DTWorkflow.process, ConfigBuilder.ConfigBuilder.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, and runTauIdMVA.TauIDEmbedder.updatedTauName.

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

Definition at line 98 of file runTauIdMVA.py.

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

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

98 
99  def tauIDMVAinputs(self, module, wp):
100  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)))
def runTauIdMVA.TauIDEmbedder.versionToInt (   release = 9,
  subversion = 4,
  patch = 0,
  debug = False 
)
static

Definition at line 82 of file runTauIdMVA.py.

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

Member Data Documentation

list runTauIdMVA.TauIDEmbedder.availableDiscriminators
static
Initial value:
1 = [
2  "2017v1", "2017v2", "newDM2017v2", "dR0p32017v2", "2016v1", "newDM2016v1",
3  "deepTau2017v1", "deepTau2017v2", "deepTau2017v2p1",
4  "DPFTau_2016_v0", "DPFTau_2016_v1",
5  "againstEle2018",
6  "newDMPhase2v1",
7  "againstElePhase2v1"
8  ]

Definition at line 10 of file runTauIdMVA.py.

runTauIdMVA.TauIDEmbedder.debug

Definition at line 41 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.loadMVA_WPs_run2_2017(), and runTauIdMVA.TauIDEmbedder.runTauID().

runTauIdMVA.TauIDEmbedder.originalTauName

Definition at line 42 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

runTauIdMVA.TauIDEmbedder.postfix

Definition at line 44 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.processDeepProducer(), and runTauIdMVA.TauIDEmbedder.runTauID().

runTauIdMVA.TauIDEmbedder.process

Definition at line 40 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.processDeepProducer(), runTauIdMVA.TauIDEmbedder.runTauID(), and runTauIdMVA.TauIDEmbedder.tauIDMVAinputs().

runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_2017_version

Definition at line 56 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.loadMVA_WPs_run2_2017(), and runTauIdMVA.TauIDEmbedder.runTauID().

runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_trainings_run2_2017

Definition at line 54 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

runTauIdMVA.TauIDEmbedder.tauIdDiscrMVA_WPs_run2_2017

Definition at line 55 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.loadMVA_WPs_run2_2017(), and runTauIdMVA.TauIDEmbedder.runTauID().

runTauIdMVA.TauIDEmbedder.toKeep

Definition at line 60 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().

runTauIdMVA.TauIDEmbedder.updatedTauName

Definition at line 43 of file runTauIdMVA.py.

Referenced by runTauIdMVA.TauIDEmbedder.runTauID().