File indexing completed on 2025-10-31 08:15:59
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 = args.sourcedir + "/Examples/Configs/generic-digi-smearing-config.json"
0054 
0055 with open(ref_path, "r") as ifile:
0056     ref = ifile.read()
0057 
0058 for i, (line_ref, line_gen) in enumerate(zip(ref.split("\n"), output.split("\n"))):
0059     lhs = line_ref.strip()
0060     rhs = line_gen.strip()
0061 
0062     if lhs != rhs:
0063         raise RuntimeError(f"Mismatched line #{i}: Ref=<{lhs}>, Gen=<{rhs}>")