Belle II Software development
v2nt_multiple_trees_samename.py
1#!/usr/bin/env python3
2
3
10
11import ROOT
12import b2test_utils
13from basf2 import create_path, set_random_seed
14from b2test_utils import configure_logging_for_tests
15from modularAnalysis import variablesToNtuple
16
17set_random_seed("1337")
18# make logging a bit less verbose and more reproducible
19configure_logging_for_tests()
20
21
23testpath = create_path()
24testpath.add_module('EventInfoSetter', evtNumList=[10], runList=[0], expList=[0])
25testpath.add_module('ParticleLoader', decayStrings=['e+'])
26variablesToNtuple("e+:all", ['electronID', 'p', 'isSignal'], path=testpath)
27variablesToNtuple("e+:all", ['electronID', 'p', 'isSignal'], path=testpath)
29 b2test_utils.safe_process(testpath) # throws B2FATAL, *this* script needs to exit happily
30
31
33testpath = create_path()
34testpath.add_module('EventInfoSetter', evtNumList=[10], runList=[0], expList=[0])
35variablesToNtuple("e+", ['electronID', 'p', 'isSignal'], path=testpath)
38
39
41testpath = create_path()
42testpath.add_module('EventInfoSetter', evtNumList=[10], runList=[0], expList=[0])
43testpath.add_module('ParticleLoader', decayStrings=['e+'])
44testpath.add_module('ParticleLoader', decayStrings=['pi+'])
45variablesToNtuple("e+:all", ['electronID', 'p', 'isSignal'], treename='firsttree',
46 filename="firstfile.root", path=testpath)
47
48variablesToNtuple("", ['nTracks'], treename='intermediate',
49 filename="secondfile.root", path=testpath)
50
51variablesToNtuple("pi+:all", ['electronID', 'p', 'isSignal'], treename='secondtree',
52 filename="firstfile.root", path=testpath)
53
56 f1 = ROOT.TFile('firstfile.root')
57 t1 = f1.Get('firsttree')
58 t2 = f1.Get('secondtree')
59 assert bool(t1), "firsttree isn't contained in file"
60 assert bool(t2), "secondtree isn't contained in file"
61
62 f2 = ROOT.TFile('secondfile.root')
63 t = f2.Get('intermediate')
64 assert bool(t), "intermediate isn't contained in file"
def clean_working_directory()
Definition: __init__.py:189
def safe_process(*args, **kwargs)
Definition: __init__.py:236