7 from ROOT
import TLorentzVector
9 from PhysicsTools.Heppy.analyzers.core.Analyzer
import Analyzer
10 from PhysicsTools.HeppyCore.framework.event
import Event
11 from PhysicsTools.HeppyCore.statistics.counter
import Counter, Counters
12 from PhysicsTools.Heppy.analyzers.core.AutoHandle
import AutoHandle
13 from PhysicsTools.Heppy.physicsobjects.Lepton
import Lepton
14 from PhysicsTools.Heppy.physicsobjects.Tau
import Tau
24 def __init__(self, cfg_ana, cfg_comp, looperName ):
25 super(TauAnalyzer,self).
__init__(cfg_ana,cfg_comp,looperName)
32 self.handles[
'taus'] =
AutoHandle( (
'slimmedTaus',
''),
'std::vector<pat::Tau>')
37 self.counters.addCounter(
'events')
38 count = self.counters.counter(
'events')
39 count.register(
'all events')
40 count.register(
'has >=1 tau at preselection')
41 count.register(
'has >=1 selected taus')
42 count.register(
'has >=1 loose taus')
43 count.register(
'has >=1 inclusive taus')
49 event.selectedTaus = []
51 event.inclusiveTaus = []
54 alltaus =
map( Tau, self.handles[
'taus'].product() )
58 tau.associatedVertex = event.goodVertices[0]
60 if self.cfg_ana.vetoLeptons:
61 for lep
in event.selectedLeptons:
62 if deltaR(lep.eta(), lep.phi(), tau.eta(), tau.phi()) < self.cfg_ana.leptonVetoDR:
64 if tau.lepVeto:
continue
65 if self.cfg_ana.vetoLeptonsPOG:
66 if not tau.tauID(
"againstMuonTight"):
68 if not tau.tauID(
"againstElectronLoose"):
70 if tau.lepVeto:
continue
71 if tau.pt() < self.cfg_ana.ptMin:
continue
72 if abs(tau.eta()) > self.cfg_ana.etaMax:
continue
77 """Create an integer equal to 1-2-3 for (loose,medium,tight)"""
78 return tau.tauID(X%
"Loose") + tau.tauID(X%
"Medium") + tau.tauID(X%
"Tight")
80 tau.idCI3hit =
id3(tau,
"by%sCombinedIsolationDeltaBetaCorr3Hits")
82 if tau.tauID(self.cfg_ana.tauID):
83 event.selectedTaus.append(tau)
84 event.inclusiveTaus.append(tau)
85 elif tau.tauID(self.cfg_ana.tauLooseID):
86 event.looseTaus.append(tau)
87 event.inclusiveTaus.append(tau)
89 event.selectedTaus.sort(key =
lambda l : l.pt(), reverse =
True)
90 event.looseTaus.sort(key =
lambda l : l.pt(), reverse =
True)
91 self.counters.counter(
'events').inc(
'all events')
92 if foundTau: self.counters.counter(
'events').inc(
'has >=1 tau at preselection')
93 if len(event.selectedTaus): self.counters.counter(
'events').inc(
'has >=1 selected taus')
94 if len(event.looseTaus): self.counters.counter(
'events').inc(
'has >=1 loose taus')
95 if len(event.inclusiveTaus): self.counters.counter(
'events').inc(
'has >=1 inclusive taus')
97 self.readCollections( event.input )
101 setattr(TauAnalyzer,
"defaultConfig",cfg.Analyzer(
102 class_object=TauAnalyzer,
109 vetoLeptonsPOG =
False,
110 tauID =
"byLooseCombinedIsolationDeltaBetaCorr3Hits",
111 tauLooseID =
"decayModeFinding",
Abs< T >::type abs(const T &t)
double deltaR(double eta1, double eta2, double phi1, double phi2)