37 event.inclusiveTaus = []
38 event.selectedTaus = []
42 alltaus =
map( Tau, self.handles[
'taus'].product() )
46 tau.associatedVertex = event.goodVertices[0]
if len(event.goodVertices)>0
else event.vertices[0]
48 tau.idDecayMode = tau.tauID(
"decayModeFinding")
49 tau.idDecayModeNewDMs = tau.tauID(
"decayModeFindingNewDMs")
51 if hasattr(self.cfg_ana,
'inclusive_decayModeID')
and self.cfg_ana.inclusive_decayModeID
and not tau.tauID(self.cfg_ana.inclusive_decayModeID):
54 tau.inclusive_lepVeto =
False
55 if self.cfg_ana.inclusive_vetoLeptons:
56 for lep
in event.selectedLeptons:
57 if deltaR(lep.eta(), lep.phi(), tau.eta(), tau.phi()) < self.cfg_ana.inclusive_leptonVetoDR:
58 tau.inclusive_lepVeto =
True
59 if tau.inclusive_lepVeto:
continue
60 if self.cfg_ana.inclusive_vetoLeptonsPOG:
61 if not tau.tauID(self.cfg_ana.inclusive_tauAntiMuonID):
62 tau.inclusive_lepVeto =
True
63 if not tau.tauID(self.cfg_ana.inclusive_tauAntiElectronID):
64 tau.inclusive_lepVeto =
True
65 if tau.inclusive_lepVeto:
continue
67 if tau.pt() < self.cfg_ana.inclusive_ptMin:
continue
68 if abs(tau.eta()) > self.cfg_ana.inclusive_etaMax:
continue
69 if abs(tau.dxy()) > self.cfg_ana.inclusive_dxyMax
or abs(tau.dz()) > self.cfg_ana.inclusive_dzMax:
continue
72 """Create an integer equal to 1-2-3 for (loose,medium,tight)"""
73 return tau.tauID(X%
"Loose") + tau.tauID(X%
"Medium") + tau.tauID(X%
"Tight")
75 """Create an integer equal to 1-2-3-4-5 for (very loose,
76 loose, medium, tight, very tight)"""
77 return id3(tau, X) + tau.tauID(X%
"VLoose") + tau.tauID(X%
"VTight")
79 """Create an integer equal to 1-2-3-4-5-6 for (very loose,
80 loose, medium, tight, very tight, very very tight)"""
81 return id5(tau, X) + tau.tauID(X%
"VVTight")
83 tau.idMVA = id6(tau,
"by%sIsolationMVA3oldDMwLT")
84 tau.idMVANewDM = id6(tau,
"by%sIsolationMVA3newDMwLT")
85 tau.idCI3hit = id3(tau,
"by%sCombinedIsolationDeltaBetaCorr3Hits")
86 tau.idAntiMu = tau.tauID(
"againstMuonLoose3") + tau.tauID(
"againstMuonTight3")
87 tau.idAntiE = id5(tau,
"againstElectron%sMVA5")
90 if tau.tauID(self.cfg_ana.inclusive_tauID):
91 event.inclusiveTaus.append(tau)
93 for tau
in event.inclusiveTaus:
95 tau.loose_lepVeto =
False
96 if self.cfg_ana.loose_vetoLeptons:
97 for lep
in event.selectedLeptons:
98 if deltaR(lep.eta(), lep.phi(), tau.eta(), tau.phi()) < self.cfg_ana.loose_leptonVetoDR:
99 tau.loose_lepVeto =
True
100 if self.cfg_ana.loose_vetoLeptonsPOG:
101 if not tau.tauID(self.cfg_ana.loose_tauAntiMuonID):
102 tau.loose_lepVeto =
True
103 if not tau.tauID(self.cfg_ana.loose_tauAntiElectronID):
104 tau.loose_lepVeto =
True
106 if tau.tauID(self.cfg_ana.loose_decayModeID)
and \
107 tau.pt() > self.cfg_ana.loose_ptMin
and abs(tau.eta()) < self.cfg_ana.loose_etaMax
and \
108 abs(tau.dxy()) < self.cfg_ana.loose_dxyMax
and abs(tau.dz()) < self.cfg_ana.loose_dzMax
and \
109 tau.tauID(self.cfg_ana.loose_tauID)
and not tau.loose_lepVeto:
110 event.selectedTaus.append(tau)
112 event.otherTaus.append(tau)
114 event.inclusiveTaus.sort(key =
lambda l : l.pt(), reverse =
True)
115 event.selectedTaus.sort(key =
lambda l : l.pt(), reverse =
True)
116 event.otherTaus.sort(key =
lambda l : l.pt(), reverse =
True)
117 self.counters.counter(
'events').inc(
'all events')
118 if len(event.inclusiveTaus): self.counters.counter(
'events').inc(
'has >=1 tau at preselection')
119 if len(event.selectedTaus): self.counters.counter(
'events').inc(
'has >=1 selected taus')
120 if len(event.otherTaus): self.counters.counter(
'events').inc(
'has >=1 other taus')