Belle II Software  release-08-01-10
packers.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import multiprocessing as mp
12 import sys
13 from ROOT import Belle2
14 import rawdata as raw
15 import simulation as sim
16 import reconstruction as rec
17 import basf2 as b2
18 
19 
20 path_to_output = 'rawdata/tests/digits.root'
21 b2.set_random_seed("L1V0RN0")
22 b2.set_log_level(b2.LogLevel.WARNING)
23 # Disable tag replay, we want to test current packers
24 # independent of when the digits were created
25 b2.conditions.disable_globaltag_replay()
26 
27 
28 def 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 
45 if 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
56 main_path = b2.create_path()
57 main_path.add_module('RootInput',
58  inputFileNames=Belle2.FileSystem.findFile(path_to_output))
59 raw.add_packers(path=main_path)
60 main_path.add_module('Progress')
61 b2.process(main_path)
62 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:148