Belle II Software development
packers.py
1#!/usr/bin/env python3
2
3
10
11import multiprocessing as mp
12import sys
13from ROOT import Belle2
14import rawdata as raw
15import simulation as sim
16import reconstruction as rec
17import basf2 as b2
18
19
20path_to_output = 'rawdata/tests/digits.root'
21b2.set_random_seed("L1V0RN0")
22b2.set_log_level(b2.LogLevel.WARNING)
23# Disable tag replay, we want to test current packers
24# independent of when the digits were created
25b2.conditions.disable_globaltag_replay()
26
27
28def create_digits():
29 """Create the file 'digits.root' needed for testing the packers if it does not exist"""
30 child_path = b2.create_path()
31 child_path.add_module('EventInfoSetter',
32 evtNumList=[10])
33 child_path.add_module('EvtGenInput')
34 sim.add_simulation(path=child_path)
35 child_path.add_module(
36 'RootOutput',
37 outputFileName='${BELLE2_LOCAL_DIR}/' +
38 path_to_output,
39 branchNames=list(rec.DIGITS_OBJECTS))
40 child_path.add_module('Progress')
41 b2.process(child_path)
42 print(b2.statistics)
43
44
45if Belle2.FileSystem.findFile(path_to_output, True) == '':
46 # Execute create_digits() in a child process to avoid side effects
47 child = mp.Process(target=create_digits)
48 child.start()
49 # Wait for simulation to finish
50 child.join()
51 # And exit if it had an error
52 if child.exitcode != 0:
53 sys.exit(child.exitcode)
54
55# Here starts the main path
56main_path = b2.create_path()
57main_path.add_module('RootInput',
58 inputFileNames=Belle2.FileSystem.findFile(path_to_output))
59raw.add_packers(path=main_path)
60main_path.add_module('Progress')
61b2.process(main_path)
62print(b2.statistics)
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:151