CMS 3D CMS Logo

Classes | Functions | Variables
tauTools Namespace Reference

Classes

class  AddTauCollection
 

Functions

def _buildIDSourcePSet (tauType, idSources, postfix="")
 
def _switchToPFTau (process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
 
def applyPostfix (process, label, postfix)
 
def switchToCaloTau (process, tauSource=cms.InputTag('caloRecoTauProducer'), patTauLabel="", postfix="")
 
def switchToPFTauByType (process, pfTauType=None, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", postfix="")
 
def switchToPFTauFixedCone (process, tauSource=cms.InputTag('fixedConePFTauProducer'), patTauLabel="", postfix="")
 
def switchToPFTauHPS (process, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", jecLevels=[], postfix="")
 
def switchToPFTauShrinkingCone (process, tauSource=cms.InputTag('shrinkingConePFTauProducer'), patTauLabel="", postfix="")
 

Variables

 classicPFTauIDSources
 
 classicTauIDSources
 
 hpsTauIDSources
 

Function Documentation

def tauTools._buildIDSourcePSet (   tauType,
  idSources,
  postfix = "" 
)
private
Build a PSet defining the tau ID sources to embed into the pat::Tau 

Definition at line 43 of file tauTools.py.

References _switchToPFTau().

Referenced by _switchToPFTau(), and switchToCaloTau().

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 
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:43
def tauTools._switchToPFTau (   process,
  tauSource,
  pfTauType,
  idSources,
  patTauLabel = "",
  postfix = "" 
)
private
internal auxiliary function to switch to **any** PFTau collection

Definition at line 59 of file tauTools.py.

References _buildIDSourcePSet(), applyPostfix(), and edm.print().

Referenced by _buildIDSourcePSet(), switchToPFTauFixedCone(), switchToPFTauHPS(), and switchToPFTauShrinkingCone().

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 = preselection
82 
83 # Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:43
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def applyPostfix(process, label, postfix)
Definition: tauTools.py:10
def tauTools.applyPostfix (   process,
  label,
  postfix 
)

Definition at line 10 of file tauTools.py.

References switchToCaloTau().

Referenced by _switchToPFTau(), switchToCaloTau(), and switchToPFTauHPS().

10 def applyPostfix(process, label, postfix):
11  result = None
12  if hasattr(process, label+postfix):
13  result = getattr(process, label + postfix)
14  else:
15  raise ValueError("Error in <applyPostfix>: No module of name = %s attached to process !!" % (label + postfix))
16  return result
17 
18 # switch to CaloTau collection
def applyPostfix(process, label, postfix)
Definition: tauTools.py:10
def tauTools.switchToCaloTau (   process,
  tauSource = cms.InputTag('caloRecoTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 22 of file tauTools.py.

References _buildIDSourcePSet(), applyPostfix(), and edm.print().

Referenced by applyPostfix(), and tauTools.AddTauCollection.toolCode().

22  postfix = ""):
23  print(' switching PAT Tau input to: ', tauSource)
24 
25  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
26  applyPostfix(process, "tauGenJetMatch"+ patTauLabel, postfix).src = tauSource
27 
28  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
29  # CV: reconstruction of tau lifetime information not implemented for CaloTaus yet
30  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
31  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet('caloRecoTau', classicTauIDSources, postfix)
32 
33  ## Isolation is somewhat an issue, so we start just by turning it off
34  print("NO PF Isolation will be computed for CaloTau (this could be improved later)")
35  applyPostfix(process, "patTaus" + patTauLabel, postfix).isolation = cms.PSet()
36  applyPostfix(process, "patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
37  applyPostfix(process, "patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
38 
39  ## adapt cleanPatTaus
40  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
41  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
42 
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:43
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def applyPostfix(process, label, postfix)
Definition: tauTools.py:10
def tauTools.switchToPFTauByType (   process,
  pfTauType = None,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 225 of file tauTools.py.

Referenced by pfTools.adaptPFTaus(), switchToPFTauHPS(), and tauTools.AddTauCollection.toolCode().

225  postfix = "" ):
226  mapping = {
227  'shrinkingConePFTau' : switchToPFTauShrinkingCone,
228  'fixedConePFTau' : switchToPFTauFixedCone,
229  'hpsPFTau' : switchToPFTauHPS,
230  'caloRecoTau' : switchToCaloTau
231  }
232  if not pfTauType in mapping.keys():
233  raise ValueError("Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
234 
235  mapping[pfTauType](process, tauSource = tauSource,
236  patTauLabel = patTauLabel, postfix = postfix)
237 
def tauTools.switchToPFTauFixedCone (   process,
  tauSource = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 185 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauShrinkingCone().

185  postfix = ""):
186  fixedConeIDSources = copy.copy(classicTauIDSources)
187  fixedConeIDSources.extend(classicPFTauIDSources)
188 
189  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
190  patTauLabel = patTauLabel, postfix = postfix)
191 
192 # switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
def _switchToPFTau(process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
Definition: tauTools.py:59
def tauTools.switchToPFTauHPS (   process,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 208 of file tauTools.py.

References _switchToPFTau(), applyPostfix(), python.rootplot.root2matplotlib.replace(), and switchToPFTauByType().

Referenced by switchToPFTauShrinkingCone().

208  postfix = ""):
209 
210  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources,
211  patTauLabel = patTauLabel, postfix = postfix)
212 
213  # CV: enable tau lifetime information for HPS PFTaus
214  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().replace("Producer", "TransverseImpactParameters")
215 
216  ## adapt cleanPatTaus
217  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
218  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
219 
220 # Select switcher by string
def replace(string, replacements)
def _switchToPFTau(process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
Definition: tauTools.py:59
def applyPostfix(process, label, postfix)
Definition: tauTools.py:10
def tauTools.switchToPFTauShrinkingCone (   process,
  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 196 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauHPS().

Referenced by switchToPFTauFixedCone().

196  postfix = ""):
197  shrinkingIDSources = copy.copy(classicTauIDSources)
198  shrinkingIDSources.extend(classicPFTauIDSources)
199 
200  _switchToPFTau(process, tauSource, 'shrinkingConePFTau', shrinkingIDSources,
201  patTauLabel = patTauLabel, postfix = postfix)
202 
203 # switch to hadron-plus-strip(s) (HPS) PFTau collection
def _switchToPFTau(process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
Definition: tauTools.py:59

Variable Documentation

tauTools.classicPFTauIDSources

Definition at line 94 of file tauTools.py.

tauTools.classicTauIDSources

Definition at line 84 of file tauTools.py.

tauTools.hpsTauIDSources

Definition at line 102 of file tauTools.py.