test
CMS 3D CMS Logo

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