CMS 3D CMS Logo

taus_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 from PhysicsTools.JetMCAlgos.TauGenJets_cfi import tauGenJets
4 from PhysicsTools.JetMCAlgos.TauGenJetsDecayModeSelectorAllHadrons_cfi import tauGenJetsSelectorAllHadrons
5 
6 
7 ##################### User floats producers, selectors ##########################
8 
9 
10 finalTaus = cms.EDFilter("PATTauRefSelector",
11  src = cms.InputTag("slimmedTaus"),
12  cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))")
13 )
14 
15 ##################### Tables for final output and docs ##########################
16 def _tauIdWPMask(pattern, choices, doc=""):
17  return Var(" + ".join(["%d * tauID('%s')" % (pow(2,i), pattern % c) for (i,c) in enumerate(choices)]), "uint8",
18  doc=doc+": bitmask "+", ".join(["%d = %s" % (pow(2,i),c) for (i,c) in enumerate(choices)]))
19 def _tauId2WPMask(pattern,doc):
20  return _tauIdWPMask(pattern,choices=("Loose","Tight"),doc=doc)
21 def _tauId5WPMask(pattern,doc):
22  return _tauIdWPMask(pattern,choices=("VLoose","Loose","Medium","Tight","VTight"),doc=doc)
23 def _tauId6WPMask(pattern,doc):
24  return _tauIdWPMask(pattern,choices=("VLoose","Loose","Medium","Tight","VTight","VVTight"),doc=doc)
25 
26 
27 tauTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
28  src = cms.InputTag("linkedObjects","taus"),
29  cut = cms.string(""), #we should not filter on cross linked collections
30  name= cms.string("Tau"),
31  doc = cms.string("slimmedTaus after basic selection (" + finalTaus.cut.value()+")"),
32  singleton = cms.bool(False), # the number of entries is variable
33  extension = cms.bool(False), # this is the main table for the taus
34  variables = cms.PSet(P4Vars,
35  charge = Var("charge", int, doc="electric charge"),
36  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
37  decayMode = Var("decayMode()",int),
38  idDecayMode = Var("tauID('decayModeFinding')", bool),
39  idDecayModeNewDMs = Var("tauID('decayModeFindingNewDMs')", bool),
40 
41  leadTkPtOverTauPt = Var("leadChargedHadrCand.pt/pt ",float, doc="pt of the leading track divided by tau pt",precision=10),
42  leadTkDeltaEta = Var("leadChargedHadrCand.eta - eta ",float, doc="eta of the leading track, minus tau eta",precision=8),
43  leadTkDeltaPhi = Var("deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc="phi of the leading track, minus tau phi",precision=8),
44 
45  dxy = Var("leadChargedHadrCand().dxy()",float, doc="d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10),
46  dz = Var("leadChargedHadrCand().dz()",float, doc="d_{z} of lead track with respect to PV, in cm (with sign)",precision=14),
47 
48  # these are too many, we may have to suppress some
49  rawIso = Var( "tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc = "combined isolation (deltaBeta corrections)", precision=10),
50  chargedIso = Var( "tauID('chargedIsoPtSum')", float, doc = "charged isolation", precision=10),
51  neutralIso = Var( "tauID('neutralIsoPtSum')", float, doc = "neutral (photon) isolation", precision=10),
52  puCorr = Var( "tauID('puCorrPtSum')", float, doc = "pileup correction", precision=10),
53  footprintCorr = Var( "tauID('footprintCorrection')", float, doc = "footprint correction", precision=10),
54  photonsOutsideSignalCone = Var( "tauID('photonPtSumOutsideSignalCone')", float, doc = "sum of photons outside signal cone", precision=10),
55 
56  rawMVAnewDM = Var( "tauID('byIsolationMVArun2v1DBnewDMwLTraw')",float, doc="byIsolationMVArun2v1DBnewDMwLT raw output discriminator",precision=10),
57  rawMVAoldDM = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator",precision=10),
58  rawMVAoldDMdR03 = Var( "tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw')",float, doc="byIsolationMVArun2v1DBdR03oldDMwLT raw output discriminator",precision=10),
59  rawAntiEle = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator", precision=10),
60  rawAntiEleCat = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category"),
61 
62  idAntiMu = _tauId2WPMask("againstMuon%s3", doc= "Anti-muon discriminator V3: "),
63  idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6"),
64  idMVAnewDM = _tauId6WPMask( "by%sIsolationMVArun2v1DBnewDMwLT", doc="IsolationMVArun2v1DBnewDMwLT ID working point"),
65  idMVAoldDM = _tauId6WPMask( "by%sIsolationMVArun2v1DBoldDMwLT", doc="IsolationMVArun2v1DBoldDMwLT ID working point"),
66  idMVAoldDMdR03 = _tauId6WPMask( "by%sIsolationMVArun2v1DBdR03oldDMwLT", doc="IsolationMVArun2v1DBdR03oldDMwLT ID working point"),
67 
68 
69 # isoCI3hit = Var( "tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits")" doc="byCombinedIsolationDeltaBetaCorrRaw3Hits raw output discriminator"),
70 # photonOutsideSigCone = Var( "tauID("photonPtSumOutsideSignalCone")" doc="photonPtSumOutsideSignalCone raw output discriminator"),
71 
72 
73  )
74 )
75 
76 tauGenJets.GenParticles = cms.InputTag("prunedGenParticles")
77 tauGenJets.includeNeutrinos = cms.bool(False)
78 
79 genVisTaus = cms.EDProducer("GenVisTauProducer",
80  src = cms.InputTag("tauGenJetsSelectorAllHadrons"),
81  srcGenParticles = cms.InputTag("prunedGenParticles")
82 )
83 
84 genVisTauTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
85  src = cms.InputTag("genVisTaus"),
86  cut = cms.string("pt > 10."),
87  name = cms.string("GenVisTau"),
88  doc = cms.string("gen hadronic taus "),
89  singleton = cms.bool(False), # the number of entries is variable
90  extension = cms.bool(False), # this is the main table for generator level hadronic tau decays
91  variables = cms.PSet(
92  pt = Var("pt", float,precision=8),
93  phi = Var("phi", float,precision=8),
94  eta = Var("eta", float,precision=8),
95  mass = Var("mass", float,precision=8),
96  charge = Var("charge", int),
97  status = Var("status", int, doc="Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
98  genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", int, doc="index of the mother particle"),
99  )
100 )
101 
102 tausMCMatchLepTauForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
103  src = tauTable.src, # final reco collection
104  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
105  mcPdgId = cms.vint32(11,13), # one or more PDG ID (11 = electron, 13 = muon); absolute values (see below)
106  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
107  mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
108  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
109  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
110  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
111  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
112 )
113 
114 tausMCMatchHadTauForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
115  src = tauTable.src, # final reco collection
116  matched = cms.InputTag("genVisTaus"), # generator level hadronic tau decays
117  mcPdgId = cms.vint32(15), # one or more PDG ID (15 = tau); absolute values (see below)
118  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
119  mcStatus = cms.vint32(), # CV: no *not* require certain status code for matching (status code corresponds to decay mode for hadronic tau decays)
120  maxDeltaR = cms.double(0.3), # Maximum deltaR for the match
121  maxDPtRel = cms.double(1.), # Maximum deltaPt/Pt for the match
122  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
123  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
124 )
125 
126 tauMCTable = cms.EDProducer("CandMCMatchTableProducer",
127  src = tauTable.src,
128  mcMap = cms.InputTag("tausMCMatchLepTauForTable"),
129  mcMapVisTau = cms.InputTag("tausMCMatchHadTauForTable"),
130  objName = tauTable.name,
131  objType = tauTable.name, #cms.string("Tau"),
132  branchName = cms.string("genPart"),
133  docString = cms.string("MC matching to status==2 taus"),
134 )
135 
136 
137 tauSequence = cms.Sequence(finalTaus)
138 tauTables = cms.Sequence(tauTable)
139 tauMC = cms.Sequence(tauGenJets + tauGenJetsSelectorAllHadrons + genVisTaus + genVisTauTable + tausMCMatchLepTauForTable + tausMCMatchHadTauForTable + tauMCTable)
140 
def _tauId5WPMask(pattern, doc)
Definition: taus_cff.py:21
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
def _tauId6WPMask(pattern, doc)
Definition: taus_cff.py:23
def _tauIdWPMask(pattern, choices, doc="")
Tables for final output and docs ##########################.
Definition: taus_cff.py:16
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _tauId2WPMask(pattern, doc)
Definition: taus_cff.py:19
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40