CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes
objects.TauAnalyzer.TauAnalyzer Class Reference
Inheritance diagram for objects.TauAnalyzer.TauAnalyzer:

Public Member Functions

def __init__ (self, cfg_ana, cfg_comp, looperName)
 
def beginLoop (self, setup)
 
def declareHandles (self)
 
def makeTaus (self, event)
 
def matchTaus (self, event)
 
def process (self, event)
 

Static Public Attributes

 class_object
 
 inclusive_decayModeID
 
 inclusive_dxyMax
 
 inclusive_dzMax
 
 inclusive_etaMax
 
 inclusive_leptonVetoDR
 
 inclusive_ptMin
 
 inclusive_tauAntiElectronID
 
 inclusive_tauAntiMuonID
 
 inclusive_tauID
 
 inclusive_vetoLeptons
 
 inclusive_vetoLeptonsPOG
 
 loose_decayModeID
 
 loose_dxyMax
 
 loose_dzMax
 
 loose_etaMax
 
 loose_leptonVetoDR
 
 loose_ptMin
 
 loose_tauAntiElectronID
 
 loose_tauAntiMuonID
 
 loose_tauID
 
 loose_vetoLeptons
 
 loose_vetoLeptonsPOG
 

Detailed Description

Definition at line 10 of file TauAnalyzer.py.

Constructor & Destructor Documentation

def objects.TauAnalyzer.TauAnalyzer.__init__ (   self,
  cfg_ana,
  cfg_comp,
  looperName 
)

Definition at line 13 of file TauAnalyzer.py.

13  def __init__(self, cfg_ana, cfg_comp, looperName ):
14  super(TauAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName)
15 
def __init__(self, cfg_ana, cfg_comp, looperName)
Definition: TauAnalyzer.py:13

Member Function Documentation

def objects.TauAnalyzer.TauAnalyzer.beginLoop (   self,
  setup 
)

Definition at line 23 of file TauAnalyzer.py.

23  def beginLoop(self, setup):
24  super(TauAnalyzer,self).beginLoop(setup)
25  self.counters.addCounter('events')
26  count = self.counters.counter('events')
27  count.register('all events')
28  count.register('has >=1 tau at preselection')
29  count.register('has >=1 selected taus')
30  count.register('has >=1 other taus')
31 
def objects.TauAnalyzer.TauAnalyzer.declareHandles (   self)

Definition at line 19 of file TauAnalyzer.py.

References core.Analyzer.Analyzer.handles, and HTTP.RequestManager.handles.

19  def declareHandles(self):
20  super(TauAnalyzer, self).declareHandles()
21  self.handles['taus'] = AutoHandle( ('slimmedTaus',''),'std::vector<pat::Tau>')
22 
def objects.TauAnalyzer.TauAnalyzer.makeTaus (   self,
  event 
)

Definition at line 35 of file TauAnalyzer.py.

References funct.abs(), analyzer.Analyzer.cfg_ana, deltaR(), core.Analyzer.Analyzer.handles, HTTP.RequestManager.handles, and genParticles_cff.map.

Referenced by objects.TauAnalyzer.TauAnalyzer.process().

35  def makeTaus(self, event):
36  event.inclusiveTaus = []
37  event.selectedTaus = []
38  event.otherTaus = []
39 
40  #get all
41  alltaus = map( Tau, self.handles['taus'].product() )
42 
43  #make inclusive taus
44  for tau in alltaus:
45  tau.associatedVertex = event.goodVertices[0] if len(event.goodVertices)>0 else event.vertices[0]
46  tau.lepVeto = False
47  tau.idDecayMode = tau.tauID("decayModeFinding")
48  tau.idDecayModeNewDMs = tau.tauID("decayModeFindingNewDMs")
49 
50  if hasattr(self.cfg_ana, 'inclusive_decayModeID') and self.cfg_ana.inclusive_decayModeID and not tau.tauID(self.cfg_ana.inclusive_decayModeID):
51  continue
52 
53  tau.inclusive_lepVeto = False
54  if self.cfg_ana.inclusive_vetoLeptons:
55  for lep in event.selectedLeptons:
56  if deltaR(lep.eta(), lep.phi(), tau.eta(), tau.phi()) < self.cfg_ana.inclusive_leptonVetoDR:
57  tau.inclusive_lepVeto = True
58  if tau.inclusive_lepVeto: continue
59  if self.cfg_ana.inclusive_vetoLeptonsPOG:
60  if not tau.tauID(self.cfg_ana.inclusive_tauAntiMuonID):
61  tau.inclusive_lepVeto = True
62  if not tau.tauID(self.cfg_ana.inclusive_tauAntiElectronID):
63  tau.inclusive_lepVeto = True
64  if tau.inclusive_lepVeto: continue
65 
66  if tau.pt() < self.cfg_ana.inclusive_ptMin: continue
67  if abs(tau.eta()) > self.cfg_ana.inclusive_etaMax: continue
68  if abs(tau.dxy()) > self.cfg_ana.inclusive_dxyMax or abs(tau.dz()) > self.cfg_ana.inclusive_dzMax: continue
69 
70  def id3(tau,X):
71  """Create an integer equal to 1-2-3 for (loose,medium,tight)"""
72  return tau.tauID(X%"Loose") + tau.tauID(X%"Medium") + tau.tauID(X%"Tight")
73  def id5(tau,X):
74  """Create an integer equal to 1-2-3-4-5 for (very loose,
75  loose, medium, tight, very tight)"""
76  return id3(tau, X) + tau.tauID(X%"VLoose") + tau.tauID(X%"VTight")
77  def id6(tau,X):
78  """Create an integer equal to 1-2-3-4-5-6 for (very loose,
79  loose, medium, tight, very tight, very very tight)"""
80  return id5(tau, X) + tau.tauID(X%"VVTight")
81 
82  tau.idMVA = id6(tau, "by%sIsolationMVArun2v1DBoldDMwLT")
83  tau.idMVANewDM = id6(tau, "by%sIsolationMVArun2v1DBnewDMwLT")
84  tau.idCI3hit = id3(tau, "by%sCombinedIsolationDeltaBetaCorr3Hits")
85  tau.idAntiMu = tau.tauID("againstMuonLoose3") + tau.tauID("againstMuonTight3")
86  tau.idAntiE = id5(tau, "againstElectron%sMVA6")
87  #print "Tau pt %5.1f: idMVA2 %d, idCI3hit %d, %s, %s" % (tau.pt(), tau.idMVA2, tau.idCI3hit, tau.tauID(self.cfg_ana.tauID), tau.tauID(self.cfg_ana.tauLooseID))
88 
89  if tau.tauID(self.cfg_ana.inclusive_tauID):
90  event.inclusiveTaus.append(tau)
91 
92  for tau in event.inclusiveTaus:
93 
94  tau.loose_lepVeto = False
95  if self.cfg_ana.loose_vetoLeptons:
96  for lep in event.selectedLeptons:
97  if deltaR(lep.eta(), lep.phi(), tau.eta(), tau.phi()) < self.cfg_ana.loose_leptonVetoDR:
98  tau.loose_lepVeto = True
99  if self.cfg_ana.loose_vetoLeptonsPOG:
100  if not tau.tauID(self.cfg_ana.loose_tauAntiMuonID):
101  tau.loose_lepVeto = True
102  if not tau.tauID(self.cfg_ana.loose_tauAntiElectronID):
103  tau.loose_lepVeto = True
104 
105  if tau.tauID(self.cfg_ana.loose_decayModeID) and \
106  tau.pt() > self.cfg_ana.loose_ptMin and abs(tau.eta()) < self.cfg_ana.loose_etaMax and \
107  abs(tau.dxy()) < self.cfg_ana.loose_dxyMax and abs(tau.dz()) < self.cfg_ana.loose_dzMax and \
108  tau.tauID(self.cfg_ana.loose_tauID) and not tau.loose_lepVeto:
109  event.selectedTaus.append(tau)
110  else:
111  event.otherTaus.append(tau)
112 
113  event.inclusiveTaus.sort(key = lambda l : l.pt(), reverse = True)
114  event.selectedTaus.sort(key = lambda l : l.pt(), reverse = True)
115  event.otherTaus.sort(key = lambda l : l.pt(), reverse = True)
116  self.counters.counter('events').inc('all events')
117  if len(event.inclusiveTaus): self.counters.counter('events').inc('has >=1 tau at preselection')
118  if len(event.selectedTaus): self.counters.counter('events').inc('has >=1 selected taus')
119  if len(event.otherTaus): self.counters.counter('events').inc('has >=1 other taus')
120 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
def objects.TauAnalyzer.TauAnalyzer.matchTaus (   self,
  event 
)

Definition at line 121 of file TauAnalyzer.py.

References deltar.matchObjectCollection3().

Referenced by objects.TauAnalyzer.TauAnalyzer.process().

121  def matchTaus(self, event):
122  match = matchObjectCollection3(event.inclusiveTaus, event.gentaus, deltaRMax = 0.5)
123  for lep in event.inclusiveTaus:
124  gen = match[lep]
125  lep.mcMatchId = 1 if gen else 0
126  lep.genp = gen
127 
def matchObjectCollection3
Definition: deltar.py:41
def objects.TauAnalyzer.TauAnalyzer.process (   self,
  event 
)

Definition at line 128 of file TauAnalyzer.py.

References objects.TauAnalyzer.TauAnalyzer.makeTaus(), objects.TauAnalyzer.TauAnalyzer.matchTaus(), and core.Analyzer.Analyzer.readCollections().

Referenced by ConfigBuilder.ConfigBuilder.addExtraStream(), ConfigBuilder.ConfigBuilder.completeInputCommand(), ConfigBuilder.ConfigBuilder.doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules.leave(), ConfigBuilder.ConfigBuilder.prepare(), ConfigBuilder.ConfigBuilder.prepare_ALCA(), ConfigBuilder.ConfigBuilder.prepare_DQM(), ConfigBuilder.ConfigBuilder.prepare_HLT(), ConfigBuilder.ConfigBuilder.prepare_LHE(), ConfigBuilder.ConfigBuilder.prepare_PATFILTER(), ConfigBuilder.ConfigBuilder.prepare_VALIDATION(), ConfigBuilder.ConfigBuilder.renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder.renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder.scheduleSequence().

128  def process(self, event):
129  self.readCollections( event.input )
130 
131  self.makeTaus(event)
132 
133  if not self.cfg_comp.isMC:
134  return True
135 
136  if hasattr(event, 'gentaus'):
137  self.matchTaus(event)
138 
139  return True
140 
141 # Find the definitions of the tau ID strings here:
142 # http://cmslxr.fnal.gov/lxr/source/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py
143 
144 setattr(TauAnalyzer,"defaultConfig",cfg.Analyzer(

Member Data Documentation

objects.TauAnalyzer.TauAnalyzer.class_object
static

Definition at line 145 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_decayModeID
static

Definition at line 153 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_dxyMax
static

Definition at line 149 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_dzMax
static

Definition at line 150 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_etaMax
static

Definition at line 148 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_leptonVetoDR
static

Definition at line 152 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_ptMin
static

Definition at line 147 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_tauAntiElectronID
static

Definition at line 157 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_tauAntiMuonID
static

Definition at line 156 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_tauID
static

Definition at line 154 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_vetoLeptons
static

Definition at line 151 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_vetoLeptonsPOG
static

Definition at line 155 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_decayModeID
static

Definition at line 165 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_dxyMax
static

Definition at line 161 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_dzMax
static

Definition at line 162 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_etaMax
static

Definition at line 160 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_leptonVetoDR
static

Definition at line 164 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_ptMin
static

Definition at line 159 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_tauAntiElectronID
static

Definition at line 169 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_tauAntiMuonID
static

Definition at line 168 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_tauID
static

Definition at line 166 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_vetoLeptons
static

Definition at line 163 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_vetoLeptonsPOG
static

Definition at line 167 of file TauAnalyzer.py.