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

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

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

Definition at line 115 of file tauTools.py.

00122                                 :
00123     """internal auxiliary function to switch to **any** PFTau collection"""  
00124     print ' Taus: ', pfTauLabelOld, '->', pfTauLabelNew
00125     
00126     applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = pfTauLabelNew
00127     applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = pfTauLabelNew
00128     
00129     applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = pfTauLabelNew
00130     applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00131     applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = pfTauLabelNew
00132     applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00133     applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = pfTauLabelNew
00134     applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00135     applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = pfTauLabelNew
00136     applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
00137     
00138     applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = pfTauLabelNew
00139     applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
00140 
00141     applyPostfix(process, "cleanPatTaus" + patTauLabel, postfix).preselection = \
00142       'tauID("leadingTrackFinding") > 0.5 & tauID("leadingPionPtCut") > 0.5 & tauID("byIsolationUsingLeadingPion") > 0.5' \
00143      + ' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5' \
00144      + ' & (signalPFChargedHadrCands.size() = 1 | signalPFChargedHadrCands.size() = 3)'
00145 
# Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
def tauTools::redoPFTauDiscriminators (   process,
  oldPFTauLabel = cms.InputTag('shrinkingConePFTauProducer'),
  newPFTauLabel = cms.InputTag('shrinkingConePFTauProducer'),
  tauType = 'shrinkingConePFTau',
  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 276 of file tauTools.py.

00277                                 :
00278     switchToPFTauFixedCone(process)
00279     process.cleanPatTaus.preselection = cms.string('tauID("byIsolation") > 0')
    
def tauTools::switchToCaloTau (   process,
  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
  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     ## adapt cleanPatTaus
00104     if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
00105         getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
00106       'tauID("leadingTrackFinding") > 0.5 & tauID("leadingTrackPtCut") > 0.5' \
00107      + ' & 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('shrinkingConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 261 of file tauTools.py.

00267                                       :
00268     mapping = { 'shrinkingConePFTau' : switchToPFTauShrinkingCone,
00269                 'fixedConePFTau' : switchToPFTauFixedCone,
00270                 'hpsPFTau' : switchToPFTauHPS,
00271                 'caloRecoTau' : switchToCaloTau,
00272                 'hpsTancPFTau' : switchToPFTauHPSpTaNC }
00273     mapping[pfTauType](process, pfTauLabelOld = pfTauLabelOld, pfTauLabelNew = pfTauLabelNew,
00274                        patTauLabel = patTauLabel, postfix = postfix)
00275 
# switch to PFTau collection that was default in PAT production in CMSSW_3_1_x release series
def tauTools::switchToPFTauFixedCone (   process,
  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
  pfTauLabelNew = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 205 of file tauTools.py.

00210                                         :
00211     fixedConeIDSources = copy.copy(classicTauIDSources)
00212     fixedConeIDSources.extend(classicPFTauIDSources)
00213 
00214     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'fixedConePFTau', fixedConeIDSources,
00215                    patTauLabel = patTauLabel, postfix = postfix)
00216 
# switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
def tauTools::switchToPFTauHPS (   process,
  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
  pfTauLabelNew = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 231 of file tauTools.py.

00236                                   :
00237     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'hpsPFTau', hpsTauIDSources,
00238                    patTauLabel = patTauLabel, postfix = postfix)
00239     
00240     ## adapt cleanPatTaus
00241     if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
00242         getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
00243       'pt > 15 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseIsolation") > 0.5' \
00244      + ' & tauID("againstMuonTight") > 0.5 & tauID("againstElectronLoose") > 0.5'
00245 
# switch to hadron-plus-strip(s) (HPS) PFTau collection
def tauTools::switchToPFTauHPSpTaNC (   process,
  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
  pfTauLabelNew = cms.InputTag('hpsTancTaus'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 246 of file tauTools.py.

00251                                        :
00252     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'hpsTancTaus', hpsTancTauIDSources,
00253                    patTauLabel = patTauLabel, postfix = postfix)
00254     
00255     ## adapt cleanPatTaus
00256     if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
00257         getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
00258       'pt > 15 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byHPSloose") > 0.5' \
00259      + ' & tauID("againstMuonTight") > 0.5 & tauID("againstElectronLoose") > 0.5'
00260 
# Select switcher by string
def tauTools::switchToPFTauShrinkingCone (   process,
  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
  pfTauLabelNew = cms.InputTag('shrinkingConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 217 of file tauTools.py.

00222                                             :
00223     shrinkingIDSources = copy.copy(classicTauIDSources)
00224     shrinkingIDSources.extend(classicPFTauIDSources)
00225     # Only shrinkingCone has associated TaNC discriminators, so add them here
00226     shrinkingIDSources.extend(tancTauIDSources)
00227     
00228     _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'shrinkingConePFTau', shrinkingIDSources,
00229                    patTauLabel = patTauLabel, postfix = postfix)
00230 
# 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 155 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 146 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 183 of file tauTools.py.

Initial value:
00001 [
00002     ("decayModeFinding", "DiscriminationByDecayModeFinding"),
00003     ("byVLooseIsolation", "DiscriminationByVLooseIsolation"),
00004     ("byLooseIsolation", "DiscriminationByLooseIsolation"),
00005     ("byMediumIsolation", "DiscriminationByMediumIsolation"),
00006     ("byTightIsolation", "DiscriminationByTightIsolation"),
00007     ("againstElectronLoose", "DiscriminationByLooseElectronRejection"),
00008     ("againstElectronMedium", "DiscriminationByMediumElectronRejection"),
00009     ("againstElectronTight", "DiscriminationByTightElectronRejection"),
00010     ("againstMuonLoose", "DiscriminationByLooseMuonRejection"),
00011     ("againstMuonTight", "DiscriminationByTightMuonRejection") ]

Definition at line 170 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 162 of file tauTools.py.