3 from pathlib
import Path
4 from typing
import Optional
13 trackingGeometry: acts.TrackingGeometry,
14 field: acts.MagneticFieldProvider,
17 inputParticlePath: Optional[Path] =
None,
38 events=100, numThreads=-1, logLevel=acts.logging.INFO
42 s.addContextDecorator(d)
44 rnd = acts.examples.RandomNumbers(seed=42)
45 outputDir = Path(outputDir)
47 if inputParticlePath
is None:
50 ParticleConfig(num=1, pdg=acts.PdgParticle.eElectron, randomizeCharge=
True),
54 vtxGen=acts.examples.GaussianVertexGenerator(
55 mean=acts.Vector4(0, 0, 0, 0),
56 stddev=acts.Vector4(0, 0, 0, 0),
62 acts.logging.getLogger(
"GSF Example").info(
63 "Reading particles from %s", inputParticlePath.resolve()
65 assert inputParticlePath.exists()
67 acts.examples.RootParticleReader(
68 level=acts.logging.INFO,
69 filePath=
str(inputParticlePath.resolve()),
70 particleCollection=
"particles_input",
80 enableInteractions=
True,
87 digiConfigFile=digiConfigFile,
96 inputParticles=
"particles_input",
97 seedingAlgorithm=SeedingAlgorithm.TruthSmeared,
98 particleHypothesis=acts.ParticleHypothesis.electron,
100 pt=(1 * u.GeV,
None),
112 acts.examples.TrackSelectorAlgorithm(
113 level=acts.logging.INFO,
114 inputTracks=
"tracks",
115 outputTracks=
"selected-tracks",
116 selectorConfig=acts.TrackSelector.Config(
122 acts.examples.TracksToTrajectories(
123 level=acts.logging.INFO,
124 inputTracks=
"selected-tracks",
125 outputTrajectories=
"trajectories-from-tracks",
128 s.addWhiteboardAlias(
"trajectories",
"trajectories-from-tracks")
131 acts.examples.RootTrajectoryStatesWriter(
132 level=acts.logging.INFO,
133 inputTrajectories=
"gsf_trajectories",
134 inputParticles=
"truth_seeds_selected",
135 inputSimHits=
"simhits",
136 inputMeasurementParticlesMap=
"measurement_particles_map",
137 inputMeasurementSimHitsMap=
"measurement_simhits_map",
138 filePath=
str(outputDir /
"trackstates_gsf.root"),
143 acts.examples.RootTrajectorySummaryWriter(
144 level=acts.logging.INFO,
145 inputTrajectories=
"gsf_trajectories",
146 inputParticles=
"truth_seeds_selected",
147 inputMeasurementParticlesMap=
"measurement_particles_map",
148 filePath=
str(outputDir /
"tracksummary_gsf.root"),
153 acts.examples.TrackFitterPerformanceWriter(
154 level=acts.logging.INFO,
155 inputTrajectories=
"gsf_trajectories",
156 inputParticles=
"truth_seeds_selected",
157 inputMeasurementParticlesMap=
"measurement_particles_map",
158 filePath=
str(outputDir /
"performance_gsf.root"),
165 if "__main__" == __name__:
166 srcdir = Path(__file__).resolve().parent.parent.parent.parent
168 detector, trackingGeometry, decorators = acts.examples.GenericDetector.create()
170 field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T))
172 inputParticlePath = Path(
"particles.root")
173 if not inputParticlePath.exists():
174 inputParticlePath =
None
177 trackingGeometry=trackingGeometry,
179 digiConfigFile=srcdir
180 /
"Examples/Algorithms/Digitization/share/default-smearing-config-generic.json",
181 inputParticlePath=inputParticlePath,
182 outputDir=Path.cwd(),