src
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.Tree
Definition:
tree.py:5
tree_test.TreeTestCase.test_fill
def test_fill(self)
Definition:
tree_test.py:8
tree_test.TreeTestCase.test_iterate
def test_iterate(self)
Definition:
tree_test.py:27
tree_test.TreeTestCase.test_read
def test_read(self)
Definition:
tree_test.py:20
tree_test.TreeTestCase
Definition:
tree_test.py:6
Generated for CMSSW Reference Manual by
1.8.14