CMS 3D CMS Logo

Classes | Functions | Variables

tauTools Namespace Reference

Classes

class  AddTauCollection

Functions

def _buildIDSourcePSet
def _switchToPFTau
def redoPFTauDiscriminators
def switchTo31Xdefaults
def switchToCaloTau
def switchToPFTauByType
def switchToPFTauFixedCone
def switchToPFTauHPS
def switchToPFTauHPSpTaNC
def switchToPFTauShrinkingCone

Variables

list classicPFTauIDSources
list classicTauIDSources
list hpsTancTauIDSources
list hpsTauIDSources
tuple pfTauJECpayloadMapping
list tancTauIDSources

Function Documentation

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

Definition at line 112 of file tauTools.py.

00113                                                          :
00114     """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
00115     output = cms.PSet()
00116     for label, discriminator in idSources:
00117         setattr(output, label, cms.InputTag(pfTauType + discriminator + postfix))
00118     return output

def tauTools::_switchToPFTau (   process,
  pfTauLabelOld,
  pfTauLabelNew,
  pfTauType,
  idSources,
  jecLevels,
  jecPayloadMapping,
  patTauLabel = "",
  postfix = "" 
) [private]
internal auxiliary function to switch to **any** PFTau collection

Definition at line 119 of file tauTools.py.

00127                                 :
00128     """internal auxiliary function to switch to **any** PFTau collection"""
00129     print ' Taus: ', pfTauLabelOld, '->', pfTauLabelNew
00130 
00131     applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = pfTauLabelNew
00132     applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = pfTauLabelNew
00133 
00134     applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = pfTauLabelNew
00135     applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00136     applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = pfTauLabelNew
00137     applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00138     applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = pfTauLabelNew
00139     applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00140     applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = pfTauLabelNew
00141     applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00142 
00143 #    applyPostfix(process, "patTauJetCorrFactors" + patTauLabel, postfix).src = pfTauLabelNew
00144 #    if len(jecLevels) > 0:
00145 #        applyPostfix(process, "patTaus" + patTauLabel, postfix).addTauJetCorrFactors = cms.bool(True)
00146 #        applyPostfix(process, "patTauJetCorrFactors" + patTauLabel, postfix).parameters = jecPayloadMapping
00147 #    else:
00148 #        applyPostfix(process, "patTaus" + patTauLabel, postfix).addTauJetCorrFactors = cms.bool(False)
00149 
00150     applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = pfTauLabelNew
00151     applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
00152 
00153     if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
00154         getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
00155           'tauID("leadingTrackFinding") > 0.5 & tauID("leadingPionPtCut") > 0.5 & tauID("byIsolationUsingLeadingPion") > 0.5' \
00156          + ' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5' \
00157          + ' & (signalPFChargedHadrCands.size() = 1 | signalPFChargedHadrCands.size() = 3)'
00158 
# Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
def tauTools::redoPFTauDiscriminators (   process,
  oldPFTauLabel = cms.InputTag('hpsPFTauProducer'),
  newPFTauLabel = cms.InputTag('hpsPFTauProducer'),
  tauType = 'hpsPFTau',
  postfix = "" 
)

Definition at line 9 of file tauTools.py.

00013                                                                :
00014     print 'Tau discriminators: ', oldPFTauLabel, '->', newPFTauLabel
00015     print 'Tau type: ', tauType
00016     #oldPFTauLabel.setModuleLabel(oldPFTauLabel.getModuleLabel()+postfix)
00017     tauSrc = 'PFTauProducer'
00018 
00019     tauDiscriminationSequence = None
00020 
00021     if tauType == 'hpsPFTau':
00022         process.patHPSPFTauDiscrimination = process.produceAndDiscriminateHPSPFTaus.copy()
00023         # remove producers
00024         for iname in process.patHPSPFTauDiscrimination.moduleNames():
00025             if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
00026                 process.patHPSPFTauDiscrimination.remove(getattr(process,iname) )
00027         tauDiscriminationSequence = cloneProcessingSnippet(process, process.patHPSPFTauDiscrimination, postfix)
00028 
00029     elif tauType == 'hpsTancTaus': #to be checked if correct
00030         process.patHPSTaNCPFTauDiscrimination = process.hpsTancTauInitialSequence.copy()
00031         process.patHPSTaNCPFTauDiscrimination *= process.hpsTancTauDiscriminantSequence
00032         # remove producers
00033         for iname in process.patHPSTaNCPFTauDiscrimination.moduleNames():
00034             if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
00035                 process.patHPSTaNCPFTauDiscrimination.remove(getattr(process,iname) )
00036         tauDiscriminationSequence = cloneProcessingSnippet(process, process.patHPSTaNCPFTauDiscrimination, postfix)
00037 
00038     elif tauType == 'fixedConePFTau':
00039         process.patFixedConePFTauDiscrimination = process.produceAndDiscriminateFixedConePFTaus.copy()
00040         # remove producers
00041         for iname in process.patFixedConePFTauDiscrimination.moduleNames():
00042             if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
00043                 process.patFixedConePFTauDiscrimination.remove(getattr(process,iname) )
00044         tauDiscriminationSequence =  cloneProcessingSnippet(process, process.patFixedConePFTauDiscrimination, postfix)
00045 
00046     elif tauType == 'shrinkingConePFTau': #shr cone with TaNC
00047         process.patShrinkingConePFTauDiscrimination = process.produceAndDiscriminateShrinkingConePFTaus.copy()
00048         process.patShrinkingConePFTauDiscrimination *= process.produceShrinkingConeDiscriminationByTauNeuralClassifier
00049         # remove producers
00050         for iname in process.patShrinkingConePFTauDiscrimination.moduleNames():
00051             if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
00052                 process.patShrinkingConePFTauDiscrimination.remove(getattr(process,iname) )
00053         tauDiscriminationSequence =  cloneProcessingSnippet(process, process.patShrinkingConePFTauDiscrimination, postfix)
00054 
00055     elif tauType == 'caloTau':
00056         # fill calo sequence by discriminants
00057         process.patCaloTauDiscrimination = process.tautagging.copy()
00058         # remove producers
00059         for iname in process.patCaloTauDiscrimination.moduleNames():
00060             if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
00061                 process.patCaloTauDiscrimination.remove(getattr(process,iname) )
00062         tauDiscriminationSequence =  cloneProcessingSnippet(process, process.patCaloTauDiscrimination, postfix)
00063         tauSrc = 'CaloTauProducer'
00064     else:
00065         raise StandardError, "Unkown tauType: '%s'"%tauType
00066 
00067     applyPostfix(process,"patDefaultSequence",postfix).replace(
00068         applyPostfix(process,"patTaus",postfix),
00069         tauDiscriminationSequence*applyPostfix(process,"patTaus",postfix)
00070     )
00071 
00072     massSearchReplaceParam(tauDiscriminationSequence, tauSrc, oldPFTauLabel, newPFTauLabel)
00073 
# switch to CaloTau collection
def tauTools::switchTo31Xdefaults (   process)

Definition at line 344 of file tauTools.py.

00345                                 :
00346     switchToPFTauFixedCone(process)
00347     process.cleanPatTaus.preselection = cms.string('tauID("byIsolation") > 0')

def tauTools::switchToCaloTau (   process,
  pfTauLabelOld = cms.InputTag('hpsPFTauProducer'),
  pfTauLabelNew = cms.InputTag('caloRecoTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 74 of file tauTools.py.

00079                                  :
00080     print ' Taus: ', pfTauLabelOld, '->', pfTauLabelNew
00081 
00082     caloTauLabel = pfTauLabelNew
00083     applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = caloTauLabel
00084     applyPostfix(process, "tauGenJetMatch"+ patTauLabel, postfix).src = caloTauLabel
00085 
00086     applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = caloTauLabel
00087     applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet('caloRecoTau', classicTauIDSources, postfix)
00088 #    applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = cms.PSet(
00089 #        leadingTrackFinding = cms.InputTag("caloRecoTauDiscriminationByLeadingTrackFinding" + postfix),
00090 #        leadingTrackPtCut   = cms.InputTag("caloRecoTauDiscriminationByLeadingTrackPtCut" + postfix),
00091 #        trackIsolation      = cms.InputTag("caloRecoTauDiscriminationByTrackIsolation" + postfix),
00092 #        ecalIsolation       = cms.InputTag("caloRecoTauDiscriminationByECALIsolation" + postfix),
00093 #        byIsolation         = cms.InputTag("caloRecoTauDiscriminationByIsolation" + postfix),
00094 #        againstElectron     = cms.InputTag("caloRecoTauDiscriminationAgainstElectron" + postfix),
00095 #        againstMuon         = cms.InputTag("caloRecoTauDiscriminationAgainstMuon" + postfix)
00096 #    )
00097     ## Isolation is somewhat an issue, so we start just by turning it off
00098     print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
00099     applyPostfix(process, "patTaus" + patTauLabel, postfix).isolation   = cms.PSet()
00100     applyPostfix(process, "patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
00101     applyPostfix(process, "patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
00102 
00103     ## no tau-jet energy corrections determined for CaloTaus yet
00104 #    applyPostfix(process, "patTauJetCorrFactors" + patTauLabel, postfix).src = caloTauLabel
00105 #    applyPostfix(process, "patTaus" + patTauLabel, postfix).addTauJetCorrFactors = cms.bool(False)
00106 
00107     ## adapt cleanPatTaus
00108     if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
00109         getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
00110       'tauID("leadingTrackFinding") > 0.5 & tauID("leadingTrackPtCut") > 0.5' \
00111      + ' & tauID("byIsolation") > 0.5 & tauID("againstElectron") > 0.5 & (signalTracks.size() = 1 | signalTracks.size() = 3)'

def tauTools::switchToPFTauByType (   process,
  pfTauType = None,
  pfTauLabelNew = None,
  pfTauLabelOld = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 327 of file tauTools.py.

00334                                       :
00335     mapping = { 'shrinkingConePFTau' : switchToPFTauShrinkingCone,
00336                 'fixedConePFTau' : switchToPFTauFixedCone,
00337                 'hpsPFTau' : switchToPFTauHPS,
00338                 'caloRecoTau' : switchToCaloTau,
00339                 'hpsTancPFTau' : switchToPFTauHPSpTaNC }
00340     mapping[pfTauType](process, pfTauLabelOld = pfTauLabelOld, pfTauLabelNew = pfTauLabelNew,
00341                        jecLevels = jecLevels,
00342                        patTauLabel = patTauLabel, postfix = postfix)
00343 
# switch to PFTau collection that was default in PAT production in CMSSW_3_1_x release series
def tauTools::switchToPFTauFixedCone (   process,
  pfTauLabelOld = cms.InputTag('hpsPFTauProducer'),
  pfTauLabelNew = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 253 of file tauTools.py.

00259                                         :
00260     fixedConeIDSources = copy.copy(classicTauIDSources)
00261     fixedConeIDSources.extend(classicPFTauIDSources)
00262 
00263     fixedConeJECpayloadMapping = pfTauJECpayloadMapping
00264 
00265     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'fixedConePFTau', fixedConeIDSources,
00266                    jecLevels, fixedConeJECpayloadMapping,
00267                    patTauLabel = patTauLabel, postfix = postfix)
00268 
# switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
def tauTools::switchToPFTauHPS (   process,
  pfTauLabelOld = cms.InputTag('hpsPFTauProducer'),
  pfTauLabelNew = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 287 of file tauTools.py.

00293                                   :
00294 
00295     hpsTauJECpayloadMapping = pfTauJECpayloadMapping
00296 
00297     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'hpsPFTau', hpsTauIDSources,
00298                    jecLevels, hpsTauJECpayloadMapping,
00299                    patTauLabel = patTauLabel, postfix = postfix)
00300 
00301     ## adapt cleanPatTaus
00302     if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
00303         getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
00304       'pt > 15 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseIsolation") > 0.5' \
00305      + ' & tauID("againstMuonTight") > 0.5 & tauID("againstElectronLoose") > 0.5'
00306 
# switch to hadron-plus-strip(s) (HPS) PFTau collection
def tauTools::switchToPFTauHPSpTaNC (   process,
  pfTauLabelOld = cms.InputTag('hpsPFTauProducer'),
  pfTauLabelNew = cms.InputTag('hpsTancTaus'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 307 of file tauTools.py.

00313                                        :
00314 
00315     hpsTancTauJECpayloadMapping = pfTauJECpayloadMapping
00316 
00317     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'hpsTancTaus', hpsTancTauIDSources,
00318                    jecLevels, hpsTancTauJECpayloadMapping,
00319                    patTauLabel = patTauLabel, postfix = postfix)
00320 
00321     ## adapt cleanPatTaus
00322     if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
00323         getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
00324       'pt > 15 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byHPSloose") > 0.5' \
00325      + ' & tauID("againstMuonTight") > 0.5 & tauID("againstElectronLoose") > 0.5'
00326 
# Select switcher by string
def tauTools::switchToPFTauShrinkingCone (   process,
  pfTauLabelOld = cms.InputTag('hpsPFTauProducer'),
  pfTauLabelNew = cms.InputTag('shrinkingConePFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 269 of file tauTools.py.

00275                                             :
00276     shrinkingIDSources = copy.copy(classicTauIDSources)
00277     shrinkingIDSources.extend(classicPFTauIDSources)
00278     # Only shrinkingCone has associated TaNC discriminators, so add them here
00279     shrinkingIDSources.extend(tancTauIDSources)
00280 
00281     shrinkingConeJECpayloadMapping = pfTauJECpayloadMapping
00282 
00283     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'shrinkingConePFTau', shrinkingIDSources,
00284                    jecLevels, shrinkingConeJECpayloadMapping,
00285                    patTauLabel = patTauLabel, postfix = postfix)
00286 
# switch to hadron-plus-strip(s) (HPS) PFTau collection

Variable Documentation

Initial value:
00001 [
00002     ("leadingPionPtCut", "DiscriminationByLeadingPionPtCut"),
00003     ("trackIsolationUsingLeadingPion", "DiscriminationByTrackIsolationUsingLeadingPion"),
00004     ("ecalIsolationUsingLeadingPion", "DiscriminationByECALIsolationUsingLeadingPion"),
00005     ("byIsolationUsingLeadingPion", "DiscriminationByIsolationUsingLeadingPion")]

Definition at line 168 of file tauTools.py.

Initial value:
00001 [
00002     ("leadingTrackFinding", "DiscriminationByLeadingTrackFinding"),
00003     ("leadingTrackPtCut", "DiscriminationByLeadingTrackPtCut"),
00004     ("trackIsolation", "DiscriminationByTrackIsolation"),
00005     ("ecalIsolation", "DiscriminationByECALIsolation"),
00006     ("byIsolation", "DiscriminationByIsolation"),
00007     ("againstElectron", "DiscriminationAgainstElectron"),
00008     ("againstMuon", "DiscriminationAgainstMuon") ]

Definition at line 159 of file tauTools.py.

Initial value:
00001 [
00002     ("leadingTrackFinding", "DiscriminationByLeadingTrackFinding"),
00003     ("leadingTrackPtCut", "DiscriminationByLeadingTrackPtCut"),
00004     ("leadingPionPtCut", "DiscriminationByLeadingPionPtCut"),
00005     ("byTaNCraw", "DiscriminationByTancRaw"),
00006     ("byTaNC", "DiscriminationByTanc"),
00007     ("byTaNCvloose", "DiscriminationByTancVLoose"),
00008     ("byTaNCloose", "DiscriminationByTancLoose"),
00009     ("byTaNCmedium", "DiscriminationByTancMedium"),
00010     ("byTaNCtight", "DiscriminationByTancTight"),
00011     ("decayModeFinding", "DiscriminationByDecayModeSelection"),
00012     ("byHPSvloose", "DiscriminationByVLooseIsolation"),
00013     ("byHPSloose", "DiscriminationByLooseIsolation"),
00014     ("byHPSmedium", "DiscriminationByMediumIsolation"),
00015     ("byHPStight", "DiscriminationByTightIsolation"),
00016     ("againstElectronLoose", "DiscriminationByLooseElectronRejection"),
00017     ("againstElectronMedium", "DiscriminationByMediumElectronRejection"),
00018     ("againstElectronTight", "DiscriminationByTightElectronRejection"),
00019     ("againstMuonLoose", "DiscriminationByLooseMuonRejection"),
00020     ("againstMuonTight", "DiscriminationByTightMuonRejection") ]

Definition at line 206 of file tauTools.py.

Initial value:
00001 [
00002     ("decayModeFinding", "DiscriminationByDecayModeFinding"),
00003     ("byVLooseIsolation", "DiscriminationByVLooseIsolation"),
00004     ("byLooseIsolation", "DiscriminationByLooseIsolation"),
00005     ("byMediumIsolation", "DiscriminationByMediumIsolation"),
00006     ("byTightIsolation", "DiscriminationByTightIsolation"),
00007     ("byVLooseIsolationDeltaBetaCorr", "DiscriminationByVLooseIsolationDBSumPtCorr"),
00008     ("byLooseIsolationDeltaBetaCorr", "DiscriminationByLooseIsolationDBSumPtCorr"),
00009     ("byMediumIsolationDeltaBetaCorr", "DiscriminationByMediumIsolationDBSumPtCorr"),
00010     ("byTightIsolationDeltaBetaCorr", "DiscriminationByTightIsolationDBSumPtCorr"),
00011     ("byVLooseCombinedIsolationDeltaBetaCorr", "DiscriminationByVLooseCombinedIsolationDBSumPtCorr"),
00012     ("byLooseCombinedIsolationDeltaBetaCorr", "DiscriminationByLooseCombinedIsolationDBSumPtCorr"),
00013     ("byMediumCombinedIsolationDeltaBetaCorr", "DiscriminationByMediumCombinedIsolationDBSumPtCorr"),
00014     ("byTightCombinedIsolationDeltaBetaCorr", "DiscriminationByTightCombinedIsolationDBSumPtCorr"),
00015     ("againstElectronLoose", "DiscriminationByLooseElectronRejection"),
00016     ("againstElectronMedium", "DiscriminationByMediumElectronRejection"),
00017     ("againstElectronTight", "DiscriminationByTightElectronRejection"),
00018     ("againstElectronMVA", "DiscriminationByMVAElectronRejection"),
00019     ("againstMuonLoose", "DiscriminationByLooseMuonRejection"),
00020     ("againstMuonMedium", "DiscriminationByMediumMuonRejection"),
00021     ("againstMuonTight", "DiscriminationByTightMuonRejection") ]

Definition at line 183 of file tauTools.py.

Initial value:
00001 cms.VPSet(
00002     cms.PSet(
00003         payload    = cms.string('AK5tauHPSlooseCombDBcorrOneProng0Pi0'),
00004         decayModes = cms.vstring('%i' % tauToOneProng0PiZero)
00005     ),
00006     cms.PSet(
00007         payload    = cms.string('AK5tauHPSlooseCombDBcorrOneProng1Pi0'),
00008         decayModes = cms.vstring('%i' % tauToOneProng1PiZero)
00009     ),
00010     cms.PSet(
00011         payload    = cms.string('AK5tauHPSlooseCombDBcorrOneProng2Pi0'),
00012         decayModes = cms.vstring('%i' % tauToOneProng2PiZero)
00013     ),
00014     cms.PSet(
00015         payload    = cms.string('AK5tauHPSlooseCombDBcorrThreeProng0Pi0'),
00016         decayModes = cms.vstring('%i' % tauToThreeProng0PiZero)
00017     ),
00018     cms.PSet(
00019         payload    = cms.string('AK5tauHPSlooseCombDBcorr'),
00020         decayModes = cms.vstring('*')
00021     )
00022 )

Definition at line 229 of file tauTools.py.

Initial value:
00001 [
00002     ("byTaNC", "DiscriminationByTaNC"),
00003     ("byTaNCfrOnePercent", "DiscriminationByTaNCfrOnePercent"),
00004     ("byTaNCfrHalfPercent", "DiscriminationByTaNCfrHalfPercent"),
00005     ("byTaNCfrQuarterPercent", "DiscriminationByTaNCfrQuarterPercent"),
00006     ("byTaNCfrTenthPercent", "DiscriminationByTaNCfrTenthPercent") ]

Definition at line 175 of file tauTools.py.