File indexing completed on 2025-01-18 09:10:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 import argparse
0015 import math
0016 import subprocess
0017
0018 args = argparse.ArgumentParser()
0019 args.add_argument("sourcedir")
0020 args = args.parse_args()
0021
0022 volumes = [7, 8, 9, 12, 13, 14, 16, 17, 18]
0023
0024
0025 base_cli = [
0026 "python",
0027 args.sourcedir + "/Examples/Algorithms/Digitization/scripts/smearing-config.py",
0028 ]
0029
0030 for vid in volumes:
0031
0032 if vid in [7, 8, 9]:
0033 resx, resy = 0.05, 0.05
0034 elif vid in [12, 13, 14]:
0035 resx, resy = 0.08, 1.2
0036 elif vid in [16, 17, 18]:
0037 resx, resy = 0.12, 10.8
0038 else:
0039 raise RuntimeError("Invalid volume id")
0040
0041 resx /= math.sqrt(12)
0042 resy /= math.sqrt(12)
0043
0044 base_cli += [
0045 "--digi-smear-volume={}".format(vid),
0046 "--digi-smear-indices=0:1",
0047 "--digi-smear-types=0:0",
0048 "--digi-smear-parameters={}:{}".format(resx, resy),
0049 ]
0050
0051 output = subprocess.check_output(base_cli).decode("utf-8")
0052
0053 ref_path = (
0054 args.sourcedir
0055 + "/Examples/Algorithms/Digitization/share/default-smearing-config-generic.json"
0056 )
0057
0058 with open(ref_path, "r") as ifile:
0059 ref = ifile.read()
0060
0061 for i, (line_ref, line_gen) in enumerate(zip(ref.split("\n"), output.split("\n"))):
0062 lhs = line_ref.strip()
0063 rhs = line_gen.strip()
0064
0065 if lhs != rhs:
0066 raise RuntimeError(f"Mismatched line #{i}: Ref=<{lhs}>, Gen=<{rhs}>")