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