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 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

◆ _buildIDSourcePSet()

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

Definition at line 18 of file tauTools.py.

18 def _buildIDSourcePSet(tauType, idSources, postfix =""):
19  """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
20  output = cms.PSet()
21  for label, discriminator in idSources:
22  wp = -99
23  if ";" in discriminator: #read from PFTauDiscriminatorContainer
24  discriminator, wp_str = discriminator.split(";")
25  wp = int(wp_str)
26  id = cms.PSet()
27  id.inputTag = cms.InputTag(discriminator.replace(":", postfix + ":"))
28  id.provenanceConfigLabel=cms.string("")
29  id.idLabel=cms.string("")
30  setattr(output, label, id)
31  return output
32 

References createfilelist.int.

Referenced by _switchToPFTau().

◆ _switchToPFTau()

def tauTools._switchToPFTau (   process,
  tauSource,
  pfTauType,
  idSources,
  patTauLabel = "",
  postfix = "" 
)
private
internal auxiliary function to switch to **any** PFTau collection

Definition at line 33 of file tauTools.py.

33 def _switchToPFTau(process,
34  tauSource,
35  pfTauType,
36  idSources,
37  patTauLabel = "",
38  postfix = ""):
39  """internal auxiliary function to switch to **any** PFTau collection"""
40  print(' switching PAT Tau input to: ', tauSource)
41 
42  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
43  applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = tauSource
44 
45  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
46  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
47  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
48  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
49  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
50  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
51  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
52  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
53 
54  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
55  # CV: reconstruction of tau lifetime information not enabled for tau collections other than 'hpsPFTauProducer' yet
56  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
57  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
58 
59  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
60  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
61 
62 # Name mapping for classic tau ID sources (present for fixed and shrinkingCones)

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

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

◆ applyPostfix()

def tauTools.applyPostfix (   process,
  label,
  postfix 
)

Definition at line 10 of file tauTools.py.

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 

Referenced by _switchToPFTau(), and switchToPFTauHPS().

◆ switchToPFTauByType()

def tauTools.switchToPFTauByType (   process,
  pfTauType = None,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 200 of file tauTools.py.

200 def switchToPFTauByType(process,
201  pfTauType = None,
202  tauSource = cms.InputTag('hpsPFTauProducer'),
203  patTauLabel = "",
204  postfix = "" ):
205  mapping = {
206  'shrinkingConePFTau' : switchToPFTauShrinkingCone,
207  'fixedConePFTau' : switchToPFTauFixedCone,
208  'hpsPFTau' : switchToPFTauHPS
209  }
210  if not pfTauType in mapping.keys():
211  raise ValueError("Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
212 
213  mapping[pfTauType](process, tauSource = tauSource,
214  patTauLabel = patTauLabel, postfix = postfix)
215 

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

◆ switchToPFTauFixedCone()

def tauTools.switchToPFTauFixedCone (   process,
  tauSource = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 161 of file tauTools.py.

161 def switchToPFTauFixedCone(process,
162  tauSource = cms.InputTag('fixedConePFTauProducer'),
163  patTauLabel = "",
164  postfix = ""):
165  fixedConeIDSources = copy.copy(classicTauIDSources)
166  fixedConeIDSources.extend(classicPFTauIDSources)
167 
168  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
169  patTauLabel = patTauLabel, postfix = postfix)
170 
171 # switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)

References _switchToPFTau().

◆ switchToPFTauHPS()

def tauTools.switchToPFTauHPS (   process,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 183 of file tauTools.py.

183 def switchToPFTauHPS(process,
184  tauSource = cms.InputTag('hpsPFTauProducer'),
185  patTauLabel = "",
186  jecLevels = [],
187  postfix = ""):
188 
189  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources,
190  patTauLabel = patTauLabel, postfix = postfix)
191 
192  # CV: enable tau lifetime information for HPS PFTaus
193  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().replace("Producer", "TransverseImpactParameters")
194 
195 
196  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
197  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
198 
199 # Select switcher by string

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

◆ switchToPFTauShrinkingCone()

def tauTools.switchToPFTauShrinkingCone (   process,
  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 172 of file tauTools.py.

172 def switchToPFTauShrinkingCone(process,
173  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
174  patTauLabel = "",
175  postfix = ""):
176  shrinkingIDSources = copy.copy(classicTauIDSources)
177  shrinkingIDSources.extend(classicPFTauIDSources)
178 
179  _switchToPFTau(process, tauSource, 'shrinkingConePFTau', shrinkingIDSources,
180  patTauLabel = patTauLabel, postfix = postfix)
181 
182 # switch to hadron-plus-strip(s) (HPS) PFTau collection

References _switchToPFTau().

Variable Documentation

◆ classicPFTauIDSources

tauTools.classicPFTauIDSources

Definition at line 73 of file tauTools.py.

◆ classicTauIDSources

tauTools.classicTauIDSources

Definition at line 63 of file tauTools.py.

◆ hpsTauIDSources

tauTools.hpsTauIDSources

Definition at line 81 of file tauTools.py.

tauTools._buildIDSourcePSet
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:18
tauTools.switchToPFTauHPS
def switchToPFTauHPS(process, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", jecLevels=[], postfix="")
Definition: tauTools.py:183
tauTools.switchToPFTauFixedCone
def switchToPFTauFixedCone(process, tauSource=cms.InputTag('fixedConePFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:161
tauTools._switchToPFTau
def _switchToPFTau(process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
Definition: tauTools.py:33
tauTools.applyPostfix
def applyPostfix(process, label, postfix)
Definition: tauTools.py:10
createfilelist.int
int
Definition: createfilelist.py:10
tauTools.switchToPFTauByType
def switchToPFTauByType(process, pfTauType=None, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:200
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
tauTools.switchToPFTauShrinkingCone
def switchToPFTauShrinkingCone(process, tauSource=cms.InputTag('shrinkingConePFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:172
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444