16def safe_process(*args, **kwargs):
17 """Run `basf2.process` with the given path in a child process using
18 `multiprocessing.Process`
20 This avoids side effects (`safe_process` can be safely called multiple times)
21 and doesn
't kill this script even if a segmentation violation or a `FATAL <LogLevel.FATAL>` error occurs during processing.
23 It will return the exitcode of the child process which should be 0
in case of no error
25 process = multiprocessing.Process(target=basf2.process, args=args, kwargs=kwargs)
28 return process.exitcode
32shutil.rmtree(
"localdb", ignore_errors=
True)
35path.add_module(
"EventInfoSetter")
36path.add_module(
"Gearbox")
37path.add_module(
"Geometry", createPayloads=
True, payloadIov=[0, 0, -1, -1])
38for field
in [
"",
"Phase2",
"Phase2QCSoff"]:
39 basf2.set_module_parameters(path,
"Geometry", components=[f
"MagneticField{field}"])
40 basf2.prepend_testing_payloads(f
"localdb/MagneticField{field}.txt")
42 txtfile = open(f
"localdb/MagneticField{field}.txt").readlines()
43 with open(f
"localdb/MagneticField{field}.txt",
"w")
as newfile:
45 if line.find(
"Magnetic") >= 0: