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