CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleTreeAnalyzer.py
Go to the documentation of this file.
1 from PhysicsTools.Heppy.analyzers.core.TreeAnalyzerNumpy import TreeAnalyzerNumpy
2 
3 
4 class SimpleTreeAnalyzer(TreeAnalyzerNumpy):
5 
6  def beginLoop(self, setup):
7  super(SimpleTreeAnalyzer, self).beginLoop(setup)
8  self.bookJet('jet1')
9  self.bookJet('jet2')
10  self.bookJet('jet1_gen')
11  self.bookJet('jet2_gen')
12 
13  def process(self, event):
14  if len(event.jets)>0:
15  self.fillJet('jet1', event.jets[0])
16  self.fillJet('jet1_gen', event.jets[0].gen)
17  if len(event.jets)>1:
18  self.fillJet('jet2', event.jets[1])
19  self.fillJet('jet2_gen', event.jets[1].gen)
20  self.tree.tree.Fill()
21 
22  def bookJet(self, name):
23  self.tree.var('{name}_pt'.format(name=name) )
24 
25  def fillJet(self, name, jet):
26  if jet:
27  self.tree.fill('{name}_pt'.format(name=name), jet.pt())
28