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 42 of file tauTools.py.

References _switchToPFTau().

Referenced by _switchToPFTau(), and switchToCaloTau().

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

Definition at line 58 of file tauTools.py.

References _buildIDSourcePSet(), and applyPostfix().

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

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)
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:42
def applyPostfix(process, label, postfix)
Definition: tauTools.py:9
def tauTools.applyPostfix (   process,
  label,
  postfix 
)

Definition at line 9 of file tauTools.py.

References switchToCaloTau().

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

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
def applyPostfix(process, label, postfix)
Definition: tauTools.py:9
def tauTools.switchToCaloTau (   process,
  tauSource = cms.InputTag('caloRecoTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 21 of file tauTools.py.

References _buildIDSourcePSet(), and applyPostfix().

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

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 
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:42
def applyPostfix(process, label, postfix)
Definition: tauTools.py:9
def tauTools.switchToPFTauByType (   process,
  pfTauType = None,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 222 of file tauTools.py.

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

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

Definition at line 182 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauShrinkingCone().

182  postfix = ""):
183  fixedConeIDSources = copy.copy(classicTauIDSources)
184  fixedConeIDSources.extend(classicPFTauIDSources)
185 
186  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
187  patTauLabel = patTauLabel, postfix = postfix)
188 
189 # 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:58
def tauTools.switchToPFTauHPS (   process,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 205 of file tauTools.py.

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

Referenced by switchToPFTauShrinkingCone().

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

Definition at line 193 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauHPS().

Referenced by switchToPFTauFixedCone().

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

Variable Documentation

tauTools.classicPFTauIDSources

Definition at line 93 of file tauTools.py.

tauTools.classicTauIDSources

Definition at line 83 of file tauTools.py.

tauTools.hpsTauIDSources

Definition at line 101 of file tauTools.py.