CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def beginLoop
 
def declareHandles
 
def makeTaus
 
def matchTaus
 
def process
 

Static Public Attributes

string decayModeID = "decayModeFindingNewDMs"
 
int dxyMax = 1000
 
float dzMax = 0.2
 
int etaMax = 9999
 
float leptonVetoDR = 0.4
 
int ptMin = 20
 
string tauAntiElectronID = "againstElectronLooseMVA5"
 
string tauAntiMuonID = "againstMuonLoose3"
 
string tauID = "byLooseCombinedIsolationDeltaBetaCorr3Hits"
 
string tauLooseID = "decayModeFinding"
 
 vetoLeptons = True,
 
 vetoLeptonsPOG = False,
 

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 
14  def __init__(self, cfg_ana, cfg_comp, looperName ):
15  super(TauAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName)

Member Function Documentation

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

Definition at line 24 of file TauAnalyzer.py.

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

Definition at line 19 of file TauAnalyzer.py.

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

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

Definition at line 37 of file TauAnalyzer.py.

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

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

37 
38  def makeTaus(self, event):
39  event.selectedTaus = []
40  event.looseTaus = []
41  event.inclusiveTaus = []
42 
43  #get all
44  alltaus = map( Tau, self.handles['taus'].product() )
45 
46  foundTau = False
47  for tau in alltaus:
48  tau.associatedVertex = event.goodVertices[0] if len(event.goodVertices)>0 else event.vertices[0]
49  tau.lepVeto = False
50  tau.idDecayMode = tau.tauID("decayModeFinding")
51  tau.idDecayModeNewDMs = tau.tauID("decayModeFindingNewDMs")
52  if hasattr(self.cfg_ana, 'decayModeID') and self.cfg_ana.decayModeID and not tau.tauID(self.cfg_ana.decayModeID):
53  continue
54 
55  if self.cfg_ana.vetoLeptons:
56  for lep in event.selectedLeptons:
57  if deltaR(lep.eta(), lep.phi(), tau.eta(), tau.phi()) < self.cfg_ana.leptonVetoDR:
58  tau.lepVeto = True
59  if tau.lepVeto: continue
60  if self.cfg_ana.vetoLeptonsPOG:
61  if not tau.tauID(self.cfg_ana.tauAntiMuonID):
62  tau.lepVeto = True
63  if not tau.tauID(self.cfg_ana.tauAntiElectronID):
64  tau.lepVeto = True
65  if tau.lepVeto: continue
66 
67  if tau.pt() < self.cfg_ana.ptMin: continue
68  if abs(tau.eta()) > self.cfg_ana.etaMax: continue
69  if abs(tau.dxy()) > self.cfg_ana.dxyMax or abs(tau.dz()) > self.cfg_ana.dzMax: continue
70 
71  foundTau = True
72  def id3(tau,X):
73  """Create an integer equal to 1-2-3 for (loose,medium,tight)"""
74  return tau.tauID(X%"Loose") + tau.tauID(X%"Medium") + tau.tauID(X%"Tight")
75  def id5(tau,X):
76  """Create an integer equal to 1-2-3-4-5 for (very loose,
77  loose, medium, tight, very tight)"""
78  return id3(tau, X) + tau.tauID(X%"VLoose") + tau.tauID(X%"VTight")
79  def id6(tau,X):
80  """Create an integer equal to 1-2-3-4-5-6 for (very loose,
81  loose, medium, tight, very tight, very very tight)"""
82  return id5(tau, X) + tau.tauID(X%"VVTight")
83 
84  tau.idMVA = id6(tau, "by%sIsolationMVA3oldDMwLT")
85  tau.idMVANewDM = id6(tau, "by%sIsolationMVA3newDMwLT")
86  tau.idCI3hit = id3(tau, "by%sCombinedIsolationDeltaBetaCorr3Hits")
87  tau.idAntiMu = tau.tauID("againstMuonLoose") + tau.tauID("againstMuonTight")
88  tau.idAntiE = id5(tau, "againstElectron%sMVA5")
89  #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))
90  if tau.tauID(self.cfg_ana.tauID):
91  event.selectedTaus.append(tau)
92  event.inclusiveTaus.append(tau)
93  elif tau.tauID(self.cfg_ana.tauLooseID):
94  event.looseTaus.append(tau)
95  event.inclusiveTaus.append(tau)
96 
97  event.selectedTaus.sort(key = lambda l : l.pt(), reverse = True)
98  event.looseTaus.sort(key = lambda l : l.pt(), reverse = True)
99  self.counters.counter('events').inc('all events')
100  if foundTau: self.counters.counter('events').inc('has >=1 tau at preselection')
101  if len(event.selectedTaus): self.counters.counter('events').inc('has >=1 selected taus')
102  if len(event.looseTaus): self.counters.counter('events').inc('has >=1 loose taus')
103  if len(event.inclusiveTaus): self.counters.counter('events').inc('has >=1 inclusive taus')
104 
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 105 of file TauAnalyzer.py.

References deltar.matchObjectCollection3().

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

106  def matchTaus(self, event):
107  match = matchObjectCollection3(event.inclusiveTaus, event.gentaus, deltaRMax = 0.5)
108  for lep in event.inclusiveTaus:
109  gen = match[lep]
110  lep.mcMatchId = 1 if gen else 0
def matchObjectCollection3
Definition: deltar.py:38
def objects.TauAnalyzer.TauAnalyzer.process (   self,
  event 
)

Definition at line 111 of file TauAnalyzer.py.

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

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

112  def process(self, event):
113  self.readCollections( event.input )
114 
115  self.makeTaus(event)
116 
117  if not self.cfg_comp.isMC:
118  return True
119 
120  if hasattr(event, 'gentaus'):
121  self.matchTaus(event)
122 
123  return True
124 
125 # Find the definitions of the tau ID strings here:
126 # http://cmslxr.fnal.gov/lxr/source/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py
127 
setattr(TauAnalyzer,"defaultConfig",cfg.Analyzer(

Member Data Documentation

string objects.TauAnalyzer.TauAnalyzer.decayModeID = "decayModeFindingNewDMs"
static

Definition at line 135 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.dxyMax = 1000
static

Definition at line 131 of file TauAnalyzer.py.

float objects.TauAnalyzer.TauAnalyzer.dzMax = 0.2
static

Definition at line 132 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.etaMax = 9999
static

Definition at line 130 of file TauAnalyzer.py.

float objects.TauAnalyzer.TauAnalyzer.leptonVetoDR = 0.4
static

Definition at line 134 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.ptMin = 20
static

Definition at line 129 of file TauAnalyzer.py.

string objects.TauAnalyzer.TauAnalyzer.tauAntiElectronID = "againstElectronLooseMVA5"
static

Definition at line 139 of file TauAnalyzer.py.

string objects.TauAnalyzer.TauAnalyzer.tauAntiMuonID = "againstMuonLoose3"
static

Definition at line 138 of file TauAnalyzer.py.

string objects.TauAnalyzer.TauAnalyzer.tauID = "byLooseCombinedIsolationDeltaBetaCorr3Hits"
static

Definition at line 136 of file TauAnalyzer.py.

string objects.TauAnalyzer.TauAnalyzer.tauLooseID = "decayModeFinding"
static

Definition at line 140 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.vetoLeptons = True,
static

Definition at line 133 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.vetoLeptonsPOG = False,
static

Definition at line 137 of file TauAnalyzer.py.