Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
material_validation_itk.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file material_validation_itk.py
1 #!/usr/bin/env python3
2 import os
3 import argparse
4 from pathlib import Path
5 
6 from acts.examples import Sequencer, RootMaterialTrackWriter
7 
8 import acts
9 from acts import (
10  UnitConstants as u,
11 )
12 
13 
15  trackingGeometry,
16  decorators,
17  field,
18  outputDir,
19  outputName="propagation-material",
20  dumpPropagationSteps=False,
21  s=None,
22 ):
23  s = s or Sequencer(events=1000, numThreads=-1)
24 
25  for decorator in decorators:
26  s.addContextDecorator(decorator)
27 
28  nav = acts.Navigator(
29  trackingGeometry=trackingGeometry,
30  resolveSensitive=True,
31  resolveMaterial=True,
32  resolvePassive=True,
33  )
34 
35  # stepper = acts.StraightLineStepper()
36  stepper = acts.EigenStepper(field)
37 
39 
40  alg = acts.examples.PropagationAlgorithm(
41  propagatorImpl=prop,
42  level=acts.logging.INFO,
43  randomNumberSvc=acts.examples.RandomNumbers(),
44  ntests=1000,
45  sterileLogger=False,
46  recordMaterialInteractions=True,
47  d0Sigma=0,
48  z0Sigma=0,
49  )
50 
51  s.addAlgorithm(alg)
52 
53  s.addWriter(
54  RootMaterialTrackWriter(
55  level=acts.logging.INFO,
56  collection=alg.config.propagationMaterialCollection,
57  filePath=os.path.join(outputDir, (outputName + ".root")),
58  storeSurface=True,
59  storeVolume=True,
60  )
61  )
62 
63  if dumpPropagationSteps:
64  s.addWriter(
65  acts.examples.RootPropagationStepsWriter(
66  level=acts.logging.INFO,
67  collection=alg.config.propagationStepCollection,
68  filePath=outputDir + "/propagation_steps.root",
69  )
70  )
71 
72  return s
73 
74 
75 if "__main__" == __name__:
76  p = argparse.ArgumentParser(
77  description="Script to run material validation on ITk geometry"
78  )
79  p.add_argument(
80  "geo_dir",
81  help="Input directory containing the ITk standalone geometry. Get in touch if you don't have this.",
82  )
83  p.add_argument("--material", type=str, default="", help="Material file")
84 
85  args = p.parse_args()
86 
87  geo_example_dir = Path(args.geo_dir)
88  assert geo_example_dir.exists(), "Detector example input directory missing"
89  assert os.path.exists(
90  args.material
91  ), "Invalid file path/name in --material. Please check your input!"
92 
93  from acts.examples.itk import buildITkGeometry
94 
95  detector, trackingGeometry, decorators = buildITkGeometry(
96  geo_example_dir, customMaterialFile=args.material
97  )
98 
99  field = acts.ConstantBField(acts.Vector3(0, 0, 2 * acts.UnitConstants.T))
100 
102  trackingGeometry, decorators, field, outputDir=os.getcwd()
103  ).run()