Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
check_smearing_config.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file check_smearing_config.py
1 #!/usr/bin/env python3
2 
3 # This file is part of the Acts project.
4 #
5 # Copyright (C) 2021 CERN for the benefit of the Acts project
6 #
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http:#mozilla.org/MPL/2.0/.
10 
11 # Configuration taken from: https://arxiv.org/pdf/1904.06778.pdf
12 # See also https://github.com/acts-project/acts/issues/946
13 
14 import argparse
15 import math
16 import subprocess
17 
18 args = argparse.ArgumentParser()
19 args.add_argument("sourcedir")
20 args = args.parse_args()
21 
22 volumes = [7, 8, 9, 12, 13, 14, 16, 17, 18]
23 
24 
25 base_cli = [
26  "python",
27  args.sourcedir + "/Examples/Algorithms/Digitization/scripts/smearing-config.py",
28 ]
29 
30 for vid in volumes:
31  # 50μm×50μmand further out two different strip detectors withshort80μm×1200μmand long strips0.12 mm×10.8 mmare placed.
32  if vid in [7, 8, 9]: # Pixel
33  resx, resy = 0.05, 0.05
34  elif vid in [12, 13, 14]: # Short strip
35  resx, resy = 0.08, 1.2
36  elif vid in [16, 17, 18]: # Long strip
37  resx, resy = 0.12, 10.8
38  else:
39  raise RuntimeError("Invalid volume id")
40 
41  resx /= math.sqrt(12)
42  resy /= math.sqrt(12)
43 
44  base_cli += [
45  "--digi-smear-volume={}".format(vid),
46  "--digi-smear-indices=0:1",
47  "--digi-smear-types=0:0",
48  "--digi-smear-parameters={}:{}".format(resx, resy),
49  ]
50 
51 output = subprocess.check_output(base_cli).decode("utf-8")
52 
53 ref_path = (
54  args.sourcedir
55  + "/Examples/Algorithms/Digitization/share/default-smearing-config-generic.json"
56 )
57 
58 with open(ref_path, "r") as ifile:
59  ref = ifile.read()
60 
61 for i, (line_ref, line_gen) in enumerate(zip(ref.split("\n"), output.split("\n"))):
62 
63  lhs = line_ref.strip()
64  rhs = line_gen.strip()
65 
66  if lhs != rhs:
67  raise RuntimeError(f"Mismatched line #{i}: Ref=<{lhs}>, Gen=<{rhs}>")