Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
PhysicsTools
HeppyCore
python
statistics
tree_test.py
Go to the documentation of this file.
1
from
__future__
import
absolute_import
2
import
unittest
3
from
ROOT
import
TFile
4
from
.tree
import
Tree
5
6
class
TreeTestCase
(unittest.TestCase):
7
8
def
test_fill
(self):
9
fi = TFile(
'tree.root'
,
'RECREATE'
)
10
tr = Tree(
'test_tree'
,
'A test tree'
)
11
tr.var(
'a'
)
12
tr.var(
'b'
)
13
tr.fill(
'a'
, 3)
14
tr.fill(
'a'
, 4)
15
tr.fill(
'b'
, 5)
16
tr.tree.Fill()
17
fi.Write()
18
fi.Close()
19
20
def
test_read
(self):
21
fi = TFile(
'tree.root'
)
22
tr = fi.Get(
'test_tree'
)
23
self.assertEqual(tr.GetEntries(), 1)
24
tr.GetEntry(0)
25
self.assertEqual(tr.a, 4)
26
27
def
test_iterate
(self):
28
fi = TFile(
'tree.root'
)
29
tr = fi.Get(
'test_tree'
)
30
for
ev
in
tr:
31
self.assertEqual(ev.a, 4)
32
break
33
34
35
if
__name__ ==
'__main__'
:
36
unittest.main()
tree_test.TreeTestCase.test_fill
def test_fill
Definition:
tree_test.py:8
tree_test.TreeTestCase
Definition:
tree_test.py:6
tree_test.TreeTestCase.test_read
def test_read
Definition:
tree_test.py:20
tree_test.TreeTestCase.test_iterate
def test_iterate
Definition:
tree_test.py:27
Generated for CMSSW Reference Manual by
1.8.5