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

 class_object = TauAnalyzer,
 
string inclusive_decayModeID = "decayModeFindingNewDMs"
 
int inclusive_dxyMax = 1000
 
float inclusive_dzMax = 0.4
 
int inclusive_etaMax = 9999
 
float inclusive_leptonVetoDR = 0.4
 
int inclusive_ptMin = 18
 
string inclusive_tauAntiElectronID = ""
 
string inclusive_tauAntiMuonID = ""
 
string inclusive_tauID = "decayModeFindingNewDMs"
 
 inclusive_vetoLeptons = False,
 
 inclusive_vetoLeptonsPOG = False,
 
string loose_decayModeID = "decayModeFindingNewDMs"
 
int loose_dxyMax = 1000
 
float loose_dzMax = 0.2
 
int loose_etaMax = 9999
 
float loose_leptonVetoDR = 0.4
 
int loose_ptMin = 18
 
string loose_tauAntiElectronID = "againstElectronLooseMVA5"
 
string loose_tauAntiMuonID = "againstMuonLoose3"
 
string loose_tauID = "byLooseCombinedIsolationDeltaBetaCorr3Hits"
 
 loose_vetoLeptons = True,
 
 loose_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 23 of file TauAnalyzer.py.

23 
24  def beginLoop(self, setup):
25  super(TauAnalyzer,self).beginLoop(setup)
26  self.counters.addCounter('events')
27  count = self.counters.counter('events')
28  count.register('all events')
29  count.register('has >=1 tau at preselection')
30  count.register('has >=1 selected taus')
31  count.register('has >=1 other 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>')
def objects.TauAnalyzer.TauAnalyzer.makeTaus (   self,
  event 
)

Definition at line 35 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().

35 
36  def makeTaus(self, event):
37  event.inclusiveTaus = []
38  event.selectedTaus = []
39  event.otherTaus = []
40 
41  #get all
42  alltaus = map( Tau, self.handles['taus'].product() )
43 
44  #make inclusive taus
45  for tau in alltaus:
46  tau.associatedVertex = event.goodVertices[0] if len(event.goodVertices)>0 else event.vertices[0]
47  tau.lepVeto = False
48  tau.idDecayMode = tau.tauID("decayModeFinding")
49  tau.idDecayModeNewDMs = tau.tauID("decayModeFindingNewDMs")
50 
51  if hasattr(self.cfg_ana, 'inclusive_decayModeID') and self.cfg_ana.inclusive_decayModeID and not tau.tauID(self.cfg_ana.inclusive_decayModeID):
52  continue
53 
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
66 
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
70 
71  def id3(tau,X):
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")
74  def id5(tau,X):
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")
78  def id6(tau,X):
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")
82 
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")
88  #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))
89 
90  if tau.tauID(self.cfg_ana.inclusive_tauID):
91  event.inclusiveTaus.append(tau)
92 
93  for tau in event.inclusiveTaus:
94 
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
105 
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)
111  else:
112  event.otherTaus.append(tau)
113 
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')
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().

122  def matchTaus(self, event):
123  match = matchObjectCollection3(event.inclusiveTaus, event.gentaus, deltaRMax = 0.5)
124  for lep in event.inclusiveTaus:
125  gen = match[lep]
126  lep.mcMatchId = 1 if gen else 0
127  lep.genp = gen
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_HLT(), ConfigBuilder.ConfigBuilder.prepare_LHE(), ConfigBuilder.ConfigBuilder.prepare_PATFILTER(), ConfigBuilder.ConfigBuilder.prepare_VALIDATION(), ConfigBuilder.ConfigBuilder.renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder.renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder.scheduleSequence().

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

Member Data Documentation

objects.TauAnalyzer.TauAnalyzer.class_object = TauAnalyzer,
static

Definition at line 145 of file TauAnalyzer.py.

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

Definition at line 153 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.inclusive_dxyMax = 1000
static

Definition at line 149 of file TauAnalyzer.py.

float objects.TauAnalyzer.TauAnalyzer.inclusive_dzMax = 0.4
static

Definition at line 150 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.inclusive_etaMax = 9999
static

Definition at line 148 of file TauAnalyzer.py.

float objects.TauAnalyzer.TauAnalyzer.inclusive_leptonVetoDR = 0.4
static

Definition at line 152 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.inclusive_ptMin = 18
static

Definition at line 147 of file TauAnalyzer.py.

string objects.TauAnalyzer.TauAnalyzer.inclusive_tauAntiElectronID = ""
static

Definition at line 157 of file TauAnalyzer.py.

string objects.TauAnalyzer.TauAnalyzer.inclusive_tauAntiMuonID = ""
static

Definition at line 156 of file TauAnalyzer.py.

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

Definition at line 154 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_vetoLeptons = False,
static

Definition at line 151 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.inclusive_vetoLeptonsPOG = False,
static

Definition at line 155 of file TauAnalyzer.py.

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

Definition at line 165 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.loose_dxyMax = 1000
static

Definition at line 161 of file TauAnalyzer.py.

float objects.TauAnalyzer.TauAnalyzer.loose_dzMax = 0.2
static

Definition at line 162 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.loose_etaMax = 9999
static

Definition at line 160 of file TauAnalyzer.py.

float objects.TauAnalyzer.TauAnalyzer.loose_leptonVetoDR = 0.4
static

Definition at line 164 of file TauAnalyzer.py.

int objects.TauAnalyzer.TauAnalyzer.loose_ptMin = 18
static

Definition at line 159 of file TauAnalyzer.py.

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

Definition at line 169 of file TauAnalyzer.py.

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

Definition at line 168 of file TauAnalyzer.py.

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

Definition at line 166 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_vetoLeptons = True,
static

Definition at line 163 of file TauAnalyzer.py.

objects.TauAnalyzer.TauAnalyzer.loose_vetoLeptonsPOG = False,
static

Definition at line 167 of file TauAnalyzer.py.