4 from pathlib
import Path
9 GaussianVertexGenerator,
10 ParametricParticleGenerator,
11 FixedMultiplicityGenerator,
19 from common
import getOpenDataDetectorDirectory
23 u = acts.UnitConstants
25 _material_recording_executed =
False
29 detectorConstructionFactory,
35 global _material_recording_executed
36 if _material_recording_executed:
37 warnings.warn(
"Material recording already ran in this process. Expect crashes")
38 _material_recording_executed =
True
40 rnd = RandomNumbers(seed=228)
42 evGen = EventGenerator(
43 level=acts.logging.INFO,
45 EventGenerator.Generator(
46 multiplicity=FixedMultiplicityGenerator(n=1),
47 vertex=GaussianVertexGenerator(
48 stddev=acts.Vector4(0, 0, 0, 0),
49 mean=acts.Vector4(0, 0, 0, 0),
51 particles=ParametricParticleGenerator(
52 pdg=acts.PdgParticle.eInvalid,
54 randomizeCharge=
False,
56 p=(1 * u.GeV, 10 * u.GeV),
58 numParticles=tracksPerEvent,
63 outputParticles=
"particles_initial",
69 g4Alg = acts.examples.geant4.Geant4MaterialRecording(
70 level=acts.logging.INFO,
71 detectorConstructionFactory=detectorConstructionFactory,
73 inputParticles=evGen.config.outputParticles,
74 outputMaterialTracks=
"material_tracks",
80 acts.examples.RootMaterialTrackWriter(
82 recalculateTotals=
True,
83 collection=
"material_tracks",
84 filePath=os.path.join(outputDir,
"geant4_material_tracks.root"),
85 level=acts.logging.INFO,
94 p = argparse.ArgumentParser()
96 "-n",
"--events", type=int, default=1000, help=
"Number of events to generate"
99 "-t",
"--tracks", type=int, default=100, help=
"Particle tracks per event"
102 "-i",
"--input", type=str, default=
"", help=
"GDML input file (optional)"
105 args = p.parse_args()
107 detectorConstructionFactory =
None
109 detectorConstructionFactory = (
110 acts.examples.geant4.GdmlDetectorConstructionFactory(args.input)
117 detectorConstructionFactory = (
118 acts.examples.geant4.dd4hep.DDG4DetectorConstructionFactory(detector)
122 detectorConstructionFactory=detectorConstructionFactory,
123 tracksPerEvent=args.tracks,
124 outputDir=os.getcwd(),
129 if "__main__" == __name__: