Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:31

0001 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer
0002 from PhysicsTools.HeppyCore.statistics.tree import Tree
0003 from ROOT import TFile
0004 
0005 class SimpleTreeProducer(Analyzer):
0006 
0007     def beginLoop(self, setup):
0008         super(SimpleTreeProducer, self).beginLoop(setup)
0009         self.rootfile = TFile('/'.join([self.dirName,
0010                                         'simple_tree.root']),
0011                               'recreate')
0012         self.tree = Tree( self.cfg_ana.tree_name,
0013                           self.cfg_ana.tree_title )
0014         self.tree.var('test_variable')
0015 
0016     def process(self, event):
0017         self.tree.fill('test_variable', event.input.var1)
0018         self.tree.tree.Fill()
0019 
0020     def write(self, setup):
0021         self.rootfile.Write()
0022         self.rootfile.Close()
0023