13 import multiprocessing
16 def 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
22 <LogLevel.FATAL>` error occurs during processing.
24 It will return the exitcode of the child process which should be 0 in case of no error
26 process = multiprocessing.Process(target=basf2.process, args=args, kwargs=kwargs)
29 return process.exitcode
33 shutil.rmtree(
"localdb", ignore_errors=
True)
36 path.add_module(
"EventInfoSetter")
37 path.add_module(
"Gearbox")
38 path.add_module(
"Geometry", createPayloads=
True, payloadIov=[0, 0, -1, -1])
39 for field
in [
"",
"Phase2",
"Phase2QCSoff"]:
40 basf2.set_module_parameters(path,
"Geometry", components=[f
"MagneticField{field}"])
41 basf2.prepend_testing_payloads(f
"localdb/MagneticField{field}.txt")
43 txtfile = open(f
"localdb/MagneticField{field}.txt").readlines()
44 with open(f
"localdb/MagneticField{field}.txt",
"w")
as newfile:
46 if line.find(
"Magnetic") >= 0: