CMS 3D CMS Logo

tauTools.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
7 
8 # applyPostFix function adapted to unscheduled mode
9 def applyPostfix(process, label, postfix):
10  result = None
11  if hasattr(process, label+postfix):
12  result = getattr(process, label + postfix)
13  else:
14  raise ValueError("Error in <applyPostfix>: No module of name = %s attached to process !!" % (label + postfix))
15  return result
16 
17 # switch to CaloTau collection
18 def switchToCaloTau(process,
19  tauSource = cms.InputTag('caloRecoTauProducer'),
20  patTauLabel = "",
21  postfix = ""):
22  print ' switching PAT Tau input to: ', tauSource
23 
24  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
25  applyPostfix(process, "tauGenJetMatch"+ patTauLabel, postfix).src = tauSource
26 
27  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
28  # CV: reconstruction of tau lifetime information not implemented for CaloTaus yet
29  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
30  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet('caloRecoTau', classicTauIDSources, postfix)
31 
32  ## Isolation is somewhat an issue, so we start just by turning it off
33  print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
34  applyPostfix(process, "patTaus" + patTauLabel, postfix).isolation = cms.PSet()
35  applyPostfix(process, "patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
36  applyPostfix(process, "patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
37 
38  ## adapt cleanPatTaus
39  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
40  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
41 
42 def _buildIDSourcePSet(tauType, idSources, postfix =""):
43  """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
44  output = cms.PSet()
45  for label, discriminator in idSources:
46  if ":" in discriminator:
47  discr = discriminator.split(":")
48  setattr(output, label, cms.InputTag(tauType + discr[0] + postfix + ":" + discr[1]))
49  else:
50  setattr(output, label, cms.InputTag(tauType + discriminator + postfix))
51  return output
52 
53 def _switchToPFTau(process,
54  tauSource,
55  pfTauType,
56  idSources,
57  patTauLabel = "",
58  postfix = ""):
59  """internal auxiliary function to switch to **any** PFTau collection"""
60  print ' switching PAT Tau input to: ', tauSource
61 
62  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
63  applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = tauSource
64 
65  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
66  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
67  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
68  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
69  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
70  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
71  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
72  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
73 
74  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
75  # CV: reconstruction of tau lifetime information not enabled for tau collections other than 'hpsPFTauProducer' yet
76  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
77  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
78 
79  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
80  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
81 
82 # Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
83 classicTauIDSources = [
84  ("leadingTrackFinding", "DiscriminationByLeadingTrackFinding"),
85  ("leadingTrackPtCut", "DiscriminationByLeadingTrackPtCut"),
86  ("trackIsolation", "DiscriminationByTrackIsolation"),
87  ("ecalIsolation", "DiscriminationByECALIsolation"),
88  ("byIsolation", "DiscriminationByIsolation"),
89  ("againstElectron", "DiscriminationAgainstElectron"),
90  ("againstMuon", "DiscriminationAgainstMuon")
91 ]
92 
93 classicPFTauIDSources = [
94  ("leadingPionPtCut", "DiscriminationByLeadingPionPtCut"),
95  ("trackIsolationUsingLeadingPion", "DiscriminationByTrackIsolationUsingLeadingPion"),
96  ("ecalIsolationUsingLeadingPion", "DiscriminationByECALIsolationUsingLeadingPion"),
97  ("byIsolationUsingLeadingPion", "DiscriminationByIsolationUsingLeadingPion")
98 ]
99 
100 # Hadron-plus-strip(s) (HPS) Tau Discriminators
101 hpsTauIDSources = [
102  ("decayModeFindingNewDMs", "DiscriminationByDecayModeFindingNewDMs"),
103  ("decayModeFinding", "DiscriminationByDecayModeFinding"), # CV: kept for backwards compatibility
104  ("byLooseCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),
105  ("byMediumCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"),
106  ("byTightCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"),
107  ("byCombinedIsolationDeltaBetaCorrRaw3Hits", "DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"),
108  ("byLooseCombinedIsolationDeltaBetaCorr3HitsdR03", "DiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03"),
109  ("byMediumCombinedIsolationDeltaBetaCorr3HitsdR03", "DiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03"),
110  ("byTightCombinedIsolationDeltaBetaCorr3HitsdR03", "DiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03"),
111  ("byPhotonPtSumOutsideSignalCone", "DiscriminationByPhotonPtSumOutsideSignalCone"),
112  ("chargedIsoPtSum", "ChargedIsoPtSum"),
113  ("neutralIsoPtSum", "NeutralIsoPtSum"),
114  ("puCorrPtSum", "PUcorrPtSum"),
115  ("neutralIsoPtSumWeight", "NeutralIsoPtSumWeight"),
116  ("footprintCorrection", "FootprintCorrection"),
117  ("photonPtSumOutsideSignalCone", "PhotonPtSumOutsideSignalCone"),
118  ("againstMuonLoose3", "DiscriminationByLooseMuonRejection3"),
119  ("againstMuonTight3", "DiscriminationByTightMuonRejection3"),
120  ("byIsolationMVArun2v1DBoldDMwLTraw", "DiscriminationByIsolationMVArun2v1DBoldDMwLTraw"),
121  ("byVLooseIsolationMVArun2v1DBoldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1DBoldDMwLT"),
122  ("byLooseIsolationMVArun2v1DBoldDMwLT", "DiscriminationByLooseIsolationMVArun2v1DBoldDMwLT"),
123  ("byMediumIsolationMVArun2v1DBoldDMwLT", "DiscriminationByMediumIsolationMVArun2v1DBoldDMwLT"),
124  ("byTightIsolationMVArun2v1DBoldDMwLT", "DiscriminationByTightIsolationMVArun2v1DBoldDMwLT"),
125  ("byVTightIsolationMVArun2v1DBoldDMwLT", "DiscriminationByVTightIsolationMVArun2v1DBoldDMwLT"),
126  ("byVVTightIsolationMVArun2v1DBoldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1DBoldDMwLT"),
127  ("byIsolationMVArun2v1DBnewDMwLTraw", "DiscriminationByIsolationMVArun2v1DBnewDMwLTraw"),
128  ("byVLooseIsolationMVArun2v1DBnewDMwLT", "DiscriminationByVLooseIsolationMVArun2v1DBnewDMwLT"),
129  ("byLooseIsolationMVArun2v1DBnewDMwLT", "DiscriminationByLooseIsolationMVArun2v1DBnewDMwLT"),
130  ("byMediumIsolationMVArun2v1DBnewDMwLT", "DiscriminationByMediumIsolationMVArun2v1DBnewDMwLT"),
131  ("byTightIsolationMVArun2v1DBnewDMwLT", "DiscriminationByTightIsolationMVArun2v1DBnewDMwLT"),
132  ("byVTightIsolationMVArun2v1DBnewDMwLT", "DiscriminationByVTightIsolationMVArun2v1DBnewDMwLT"),
133  ("byVVTightIsolationMVArun2v1DBnewDMwLT", "DiscriminationByVVTightIsolationMVArun2v1DBnewDMwLT"),
134  ("byIsolationMVArun2v1PWoldDMwLTraw", "DiscriminationByIsolationMVArun2v1PWoldDMwLTraw"),
135  ("byVLooseIsolationMVArun2v1PWoldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1PWoldDMwLT"),
136  ("byLooseIsolationMVArun2v1PWoldDMwLT", "DiscriminationByLooseIsolationMVArun2v1PWoldDMwLT"),
137  ("byMediumIsolationMVArun2v1PWoldDMwLT", "DiscriminationByMediumIsolationMVArun2v1PWoldDMwLT"),
138  ("byTightIsolationMVArun2v1PWoldDMwLT", "DiscriminationByTightIsolationMVArun2v1PWoldDMwLT"),
139  ("byVTightIsolationMVArun2v1PWoldDMwLT", "DiscriminationByVTightIsolationMVArun2v1PWoldDMwLT"),
140  ("byVVTightIsolationMVArun2v1PWoldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1PWoldDMwLT"),
141  ("byIsolationMVArun2v1PWnewDMwLTraw", "DiscriminationByIsolationMVArun2v1PWnewDMwLTraw"),
142  ("byVLooseIsolationMVArun2v1PWnewDMwLT", "DiscriminationByVLooseIsolationMVArun2v1PWnewDMwLT"),
143  ("byLooseIsolationMVArun2v1PWnewDMwLT", "DiscriminationByLooseIsolationMVArun2v1PWnewDMwLT"),
144  ("byMediumIsolationMVArun2v1PWnewDMwLT", "DiscriminationByMediumIsolationMVArun2v1PWnewDMwLT"),
145  ("byTightIsolationMVArun2v1PWnewDMwLT", "DiscriminationByTightIsolationMVArun2v1PWnewDMwLT"),
146  ("byVTightIsolationMVArun2v1PWnewDMwLT", "DiscriminationByVTightIsolationMVArun2v1PWnewDMwLT"),
147  ("byVVTightIsolationMVArun2v1PWnewDMwLT", "DiscriminationByVVTightIsolationMVArun2v1PWnewDMwLT"),
148  ("chargedIsoPtSumdR03", "ChargedIsoPtSumdR03"),
149  ("neutralIsoPtSumdR03", "NeutralIsoPtSumdR03"),
150  ("neutralIsoPtSumWeightdR03", "NeutralIsoPtSumWeightdR03"),
151  ("footprintCorrectiondR03", "FootprintCorrectiondR03"),
152  ("photonPtSumOutsideSignalConedR03", "PhotonPtSumOutsideSignalConedR03"),
153  ("byIsolationMVArun2v1DBdR03oldDMwLTraw", "DiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw"),
154  ("byVLooseIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT"),
155  ("byLooseIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByLooseIsolationMVArun2v1DBdR03oldDMwLT"),
156  ("byMediumIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByMediumIsolationMVArun2v1DBdR03oldDMwLT"),
157  ("byTightIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByTightIsolationMVArun2v1DBdR03oldDMwLT"),
158  ("byVTightIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByVTightIsolationMVArun2v1DBdR03oldDMwLT"),
159  ("byVVTightIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1DBdR03oldDMwLT"),
160  ("byIsolationMVArun2v1PWdR03oldDMwLTraw", "DiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw"),
161  ("byVLooseIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1PWdR03oldDMwLT"),
162  ("byLooseIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByLooseIsolationMVArun2v1PWdR03oldDMwLT"),
163  ("byMediumIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByMediumIsolationMVArun2v1PWdR03oldDMwLT"),
164  ("byTightIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByTightIsolationMVArun2v1PWdR03oldDMwLT"),
165  ("byVTightIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByVTightIsolationMVArun2v1PWdR03oldDMwLT"),
166  ("byVVTightIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1PWdR03oldDMwLT"),
167  ("againstElectronMVA6Raw", "DiscriminationByMVA6rawElectronRejection"),
168  ("againstElectronMVA6category", "DiscriminationByMVA6rawElectronRejection:category"),
169  ("againstElectronVLooseMVA6", "DiscriminationByMVA6VLooseElectronRejection"),
170  ("againstElectronLooseMVA6", "DiscriminationByMVA6LooseElectronRejection"),
171  ("againstElectronMediumMVA6", "DiscriminationByMVA6MediumElectronRejection"),
172  ("againstElectronTightMVA6", "DiscriminationByMVA6TightElectronRejection"),
173  ("againstElectronVTightMVA6", "DiscriminationByMVA6VTightElectronRejection"),
174 ]
175 
176 # switch to PFTau collection produced for fixed dR = 0.07 signal cone size
177 def switchToPFTauFixedCone(process,
178  tauSource = cms.InputTag('fixedConePFTauProducer'),
179  patTauLabel = "",
180  postfix = ""):
181  fixedConeIDSources = copy.copy(classicTauIDSources)
182  fixedConeIDSources.extend(classicPFTauIDSources)
183 
184  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
185  patTauLabel = patTauLabel, postfix = postfix)
186 
187 # switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
188 def switchToPFTauShrinkingCone(process,
189  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
190  patTauLabel = "",
191  postfix = ""):
192  shrinkingIDSources = copy.copy(classicTauIDSources)
193  shrinkingIDSources.extend(classicPFTauIDSources)
194 
195  _switchToPFTau(process, tauSource, 'shrinkingConePFTau', shrinkingIDSources,
196  patTauLabel = patTauLabel, postfix = postfix)
197 
198 # switch to hadron-plus-strip(s) (HPS) PFTau collection
199 def switchToPFTauHPS(process,
200  tauSource = cms.InputTag('hpsPFTauProducer'),
201  patTauLabel = "",
202  jecLevels = [],
203  postfix = ""):
204 
205  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources,
206  patTauLabel = patTauLabel, postfix = postfix)
207 
208  # CV: enable tau lifetime information for HPS PFTaus
209  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().replace("Producer", "TransverseImpactParameters")
210 
211  ## adapt cleanPatTaus
212  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
213  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
214 
215  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
216  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
217  for era in [ run2_miniAOD_80XLegacy, run2_miniAOD_94XFall17]:
218  _patTaus = getattr(process, "patTaus"+patTauLabel+postfix)
219  _extTauIDSources = _patTaus.tauIDSources.clone()
220  _extTauIDSources.byVVLooseIsolationMVArun2v1DBoldDMwLT = cms.InputTag("hpsPFTauDiscriminationByVVLooseIsolationMVArun2v1DBoldDMwLT")
221  era.toModify(_patTaus, tauIDSources = _extTauIDSources)
222 
223 # Select switcher by string
224 def switchToPFTauByType(process,
225  pfTauType = None,
226  tauSource = cms.InputTag('hpsPFTauProducer'),
227  patTauLabel = "",
228  postfix = "" ):
229  mapping = {
230  'shrinkingConePFTau' : switchToPFTauShrinkingCone,
231  'fixedConePFTau' : switchToPFTauFixedCone,
232  'hpsPFTau' : switchToPFTauHPS,
233  'caloRecoTau' : switchToCaloTau
234  }
235  if not pfTauType in mapping.keys():
236  raise ValueError("Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
237 
238  mapping[pfTauType](process, tauSource = tauSource,
239  patTauLabel = patTauLabel, postfix = postfix)
240 
242 
243  """ Add a new collection of taus. Takes the configuration from the
244  already configured standard tau collection as starting point;
245  replaces before calling addTauCollection will also affect the
246  new tau collections
247  """
248  _label='addTauCollection'
249  _defaultParameters=dicttypes.SortedKeysDict()
250  def __init__(self):
251  ConfigToolBase.__init__(self)
252  self.addParameter(self._defaultParameters, 'tauCollection',
253  self._defaultValue, 'Input tau collection', cms.InputTag)
254  self.addParameter(self._defaultParameters, 'algoLabel',
255  self._defaultValue, "label to indicate the tau algorithm (e.g.'hps')", str)
256  self.addParameter(self._defaultParameters, 'typeLabel',
257  self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
258  self.addParameter(self._defaultParameters, 'doPFIsoDeposits',
259  True, "run sequence for computing particle-flow based IsoDeposits")
260  self.addParameter(self._defaultParameters, 'standardAlgo',
261  "hps", "standard algorithm label of the collection from which the clones " \
262  + "for the new tau collection will be taken from " \
263  + "(note that this tau collection has to be available in the event before hand)")
264  self.addParameter(self._defaultParameters, 'standardType',
265  "PFTau", "standard constituent type label of the collection from which the clones " \
266  + " for the new tau collection will be taken from "\
267  + "(note that this tau collection has to be available in the event before hand)")
268 
269  self._parameters=copy.deepcopy(self._defaultParameters)
270  self._comment = ""
271 
273  return self._defaultParameters
274 
275  def __call__(self,process,
276  tauCollection = None,
277  algoLabel = None,
278  typeLabel = None,
279  doPFIsoDeposits = None,
280  jetCorrLabel = None,
281  standardAlgo = None,
282  standardType = None):
283 
284  if tauCollection is None:
285  tauCollection = self._defaultParameters['tauCollection'].value
286  if algoLabel is None:
287  algoLabel = self._defaultParameters['algoLabel'].value
288  if typeLabel is None:
289  typeLabel = self._defaultParameters['typeLabel'].value
290  if doPFIsoDeposits is None:
291  doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value
292  if standardAlgo is None:
293  standardAlgo = self._defaultParameters['standardAlgo'].value
294  if standardType is None:
295  standardType = self._defaultParameters['standardType'].value
296 
297  self.setParameter('tauCollection', tauCollection)
298  self.setParameter('algoLabel', algoLabel)
299  self.setParameter('typeLabel', typeLabel)
300  self.setParameter('doPFIsoDeposits', doPFIsoDeposits)
301  self.setParameter('standardAlgo', standardAlgo)
302  self.setParameter('standardType', standardType)
303 
304  self.apply(process)
305 
306  def toolCode(self, process):
307  tauCollection = self._parameters['tauCollection'].value
308  algoLabel = self._parameters['algoLabel'].value
309  typeLabel = self._parameters['typeLabel'].value
310  doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value
311  standardAlgo = self._parameters['standardAlgo'].value
312  standardType = self._parameters['standardType'].value
313 
314  ## disable computation of particle-flow based IsoDeposits
315  ## in case tau is of CaloTau type
316  if typeLabel == 'Tau':
317  print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
318  doPFIsoDeposits = False
319 
320  ## create old module label from standardAlgo
321  ## and standardType and return
322  def oldLabel(prefix = ''):
323  if prefix == '':
324  return "patTaus"
325  else:
326  return prefix + "PatTaus"
327 
328  ## capitalize first character of appended part
329  ## when creating new module label
330  ## (giving e.g. "patTausCaloRecoTau")
331  def capitalize(label):
332  return label[0].capitalize() + label[1:]
333 
334  ## create new module label from old module
335  ## label and return
336  def newLabel(oldLabel):
337  newLabel = oldLabel
338  if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ):
339  oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel)
340  else:
341  oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
342  return oldLabel
343 
344  ## clone module and add it to the patDefaultSequence
345  def addClone(hook, **replaceStatements):
346  ## create a clone of the hook with corresponding
347  ## parameter replacements
348  newModule = getattr(process, hook).clone(**replaceStatements)
349 
350  ## clone module for computing particle-flow IsoDeposits
351  def addPFIsoDepositClone(hook, **replaceStatements):
352  newModule = getattr(process, hook).clone(**replaceStatements)
353  newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet")
354  setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src"))
355 
356  ## add a clone of patTaus
357  addClone(oldLabel(), tauSource = tauCollection)
358 
359  ## add a clone of selectedPatTaus
360  addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel())))
361 
362  ## add a clone of cleanPatTaus
363  addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected'))))
364 
365  ## get attributes of new module
366  newTaus = getattr(process, newLabel(oldLabel()))
367 
368  ## add a clone of gen tau matching
369  addClone('tauMatch', src = tauCollection)
370  addClone('tauGenJetMatch', src = tauCollection)
371 
372  ## add a clone of IsoDeposits computed based on particle-flow
373  if doPFIsoDeposits:
374  addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection)
375  addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection)
376  addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection)
377  addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection)
378 
379  ## fix label for input tag
380  def fixInputTag(x):
381  x.setModuleLabel(newLabel(x.moduleLabel))
382 
383  ## provide patTau inputs with individual labels
384  fixInputTag(newTaus.genParticleMatch)
385  fixInputTag(newTaus.genJetMatch)
386  fixInputTag(newTaus.isoDeposits.pfAllParticles)
387  fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
388  fixInputTag(newTaus.isoDeposits.pfChargedHadron)
389  fixInputTag(newTaus.isoDeposits.pfGamma)
390  fixInputTag(newTaus.userIsolation.pfAllParticles.src)
391  fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
392  fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
393  fixInputTag(newTaus.userIsolation.pfGamma.src)
394 
395  ## set discriminators
396  ## (using switchTauCollection functions)
397  oldTaus = getattr(process, oldLabel())
398  if typeLabel == 'Tau':
399  switchToCaloTau(process,
400  tauSource = getattr(newTaus, "tauSource"),
401  patTauLabel = capitalize(algoLabel + typeLabel))
402  else:
403  switchToPFTauByType(process, pfTauType = algoLabel + typeLabel,
404  tauSource = getattr(newTaus, "tauSource"),
405  patTauLabel = capitalize(algoLabel + typeLabel))
406 
407 addTauCollection=AddTauCollection()
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:42
def replace(string, replacements)
def switchToPFTauShrinkingCone(process, tauSource=cms.InputTag('shrinkingConePFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:191
def switchToCaloTau(process, tauSource=cms.InputTag('caloRecoTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:21
def __call__(self, process, tauCollection=None, algoLabel=None, typeLabel=None, doPFIsoDeposits=None, jetCorrLabel=None, standardAlgo=None, standardType=None)
Definition: tauTools.py:282
def switchToPFTauByType(process, pfTauType=None, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:228
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def switchToPFTauHPS(process, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", jecLevels=[], postfix="")
Definition: tauTools.py:203
def toolCode(self, process)
Definition: tauTools.py:306
def getDefaultParameters(self)
Definition: tauTools.py:272
def _switchToPFTau(process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
Definition: tauTools.py:58
def switchToPFTauFixedCone(process, tauSource=cms.InputTag('fixedConePFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:180
def applyPostfix(process, label, postfix)
Definition: tauTools.py:9