3 from pathlib
import Path
9 AssertCollectionExistsAlg,
11 from common
import getOpenDataDetectorDirectory
16 from acts
import PlanarModuleStepper, UnitConstants
as u
20 RootMaterialTrackReader,
21 RootTrajectorySummaryReader,
28 CsvPlanarClusterWriter,
29 CsvPlanarClusterReader,
30 PlanarSteppingAlgorithm,
38 s = Sequencer(numThreads=1, events=10, logLevel=acts.logging.WARNING)
41 file = tmp_path /
"particles.root"
46 inputParticles=evGen.config.outputParticles,
57 s2 = Sequencer(numThreads=1, logLevel=acts.logging.WARNING)
63 particleCollection=
"input_particles",
68 alg = AssertCollectionExistsAlg(
69 "input_particles",
"check_alg", acts.logging.WARNING
75 assert alg.events_seen == 10
80 s = Sequencer(numThreads=1, events=10, logLevel=acts.logging.WARNING)
83 out = tmp_path /
"csv"
91 inputParticles=evGen.config.outputParticles,
92 outputStem=
"particle",
100 s = Sequencer(numThreads=1, logLevel=acts.logging.WARNING)
105 acts.logging.WARNING,
107 inputStem=
"particle",
108 outputParticles=
"input_particles",
112 alg = AssertCollectionExistsAlg(
113 "input_particles",
"check_alg", acts.logging.WARNING
120 assert alg.events_seen == 10
123 @pytest.mark.parametrize(
125 [RootParticleReader, RootTrajectorySummaryReader],
129 assert hasattr(reader,
"Config")
131 config = reader.Config
133 assert hasattr(config,
"filePath")
135 kw = {
"level": acts.logging.INFO,
"filePath":
str(tmp_path /
"file.root")}
143 @pytest.mark.skipif(
not geant4Enabled, reason=
"Geant4 not set up")
146 input_tracks = material_recording /
"geant4_material_tracks.root"
147 assert input_tracks.exists()
149 s = Sequencer(numThreads=1)
152 RootMaterialTrackReader(
153 level=acts.logging.INFO,
154 fileList=[
str(input_tracks)],
158 alg = AssertCollectionExistsAlg(
159 "material-tracks",
"check_alg", acts.logging.WARNING
165 assert alg.events_seen == 2
170 s = Sequencer(numThreads=1, events=10)
171 evGen, simAlg, digiAlg =
fatras(s)
173 out = tmp_path /
"csv"
177 CsvMeasurementWriter(
178 level=acts.logging.INFO,
179 inputMeasurements=digiAlg.config.outputMeasurements,
180 inputClusters=digiAlg.config.outputClusters,
181 inputMeasurementSimHitsMap=digiAlg.config.outputMeasurementSimHitsMap,
189 level=acts.logging.INFO,
190 inputSimHits=simAlg.config.outputSimHits,
199 s = Sequencer(numThreads=1)
203 level=acts.logging.INFO,
204 outputSimHits=simAlg.config.outputSimHits,
212 CsvMeasurementReader,
213 level=acts.logging.WARNING,
214 outputMeasurements=
"measurements",
215 outputMeasurementSimHitsMap=
"simhitsmap",
216 outputSourceLinks=
"sourcelinks",
217 outputMeasurementParticlesMap=
"meas_ptcl_map",
218 inputSimHits=simAlg.config.outputSimHits,
224 AssertCollectionExistsAlg(k, f
"check_alg_{k}", acts.logging.WARNING)
225 for k
in (
"measurements",
"simhitsmap",
"sourcelinks",
"meas_ptcl_map")
233 assert alg.events_seen == 10
238 s = Sequencer(numThreads=1, events=10)
239 evGen, simAlg, digiAlg =
fatras(s)
241 out = tmp_path /
"csv"
246 level=acts.logging.INFO,
247 inputSimHits=simAlg.config.outputSimHits,
255 s = Sequencer(numThreads=1)
260 level=acts.logging.INFO,
263 outputSimHits=
"simhits",
267 alg = AssertCollectionExistsAlg(
"simhits",
"check_alg", acts.logging.WARNING)
272 assert alg.events_seen == 10
277 s = Sequencer(numThreads=1, events=10)
278 evGen, simAlg, _ =
fatras(s)
279 s = Sequencer(numThreads=1, events=10)
281 s.addAlgorithm(simAlg)
282 digiAlg = PlanarSteppingAlgorithm(
283 level=acts.logging.WARNING,
284 inputSimHits=simAlg.config.outputSimHits,
285 outputClusters=
"clusters",
286 outputSourceLinks=
"sourcelinks",
287 outputDigiSourceLinks=
"digiSourceLink",
288 outputMeasurements=
"measurements",
289 outputMeasurementParticlesMap=
"meas_ptcl_map",
290 outputMeasurementSimHitsMap=
"meas_sh_map",
291 trackingGeometry=trk_geo,
293 planarModuleStepper=PlanarModuleStepper(),
295 s.addAlgorithm(digiAlg)
297 out = tmp_path /
"csv"
301 CsvPlanarClusterWriter(
302 level=acts.logging.WARNING,
304 inputSimHits=simAlg.config.outputSimHits,
305 inputClusters=digiAlg.config.outputClusters,
306 trackingGeometry=trk_geo,
312 s = Sequencer(numThreads=1)
316 CsvPlanarClusterReader,
317 level=acts.logging.WARNING,
318 outputClusters=
"clusters",
321 outputMeasurementParticlesMap=
"meas_ptcl_map",
322 outputSimHits=
"simhits",
323 trackingGeometry=trk_geo,
328 AssertCollectionExistsAlg(k, f
"check_alg_{k}", acts.logging.WARNING)
329 for k
in (
"clusters",
"simhits",
"meas_ptcl_map")
337 assert alg.events_seen == 10
341 from DDSim.DD4hepSimulation
import DD4hepSimulation
343 ddsim = DD4hepSimulation()
344 if isinstance(ddsim.compactFile, list):
345 ddsim.compactFile = [input]
347 ddsim.compactFile = input
348 ddsim.enableGun =
True
349 ddsim.gun.direction = (1, 0, 0)
350 ddsim.gun.distribution =
"eta"
351 ddsim.numberOfEvents = 10
352 ddsim.outputFile = output
358 @pytest.mark.skipif(
not edm4hepEnabled, reason=
"EDM4hep is not set up")
362 tmp_file =
str(tmp_path /
"output_edm4hep.root")
365 with multiprocessing.get_context(
"spawn").Pool()
as pool:
366 pool.apply(generate_input_test_edm4hep_simhit_reader, (odd_xml_file, tmp_file))
368 assert os.path.exists(tmp_file)
374 s = Sequencer(numThreads=1)
378 level=acts.logging.INFO,
380 outputSimHits=
"simhits",
381 dd4hepDetector=detector,
385 alg = AssertCollectionExistsAlg(
"simhits",
"check_alg", acts.logging.WARNING)
390 assert alg.events_seen == 10
394 @pytest.mark.skipif(
not edm4hepEnabled, reason=
"EDM4hep is not set up")
397 EDM4hepMeasurementWriter,
398 EDM4hepMeasurementReader,
401 s = Sequencer(numThreads=1, events=10)
402 _, simAlg, digiAlg =
fatras(s)
404 out = tmp_path /
"measurements_edm4hep.root"
406 config = EDM4hepMeasurementWriter.Config(
407 inputMeasurements=digiAlg.config.outputMeasurements,
408 inputClusters=digiAlg.config.outputClusters,
411 s.addWriter(EDM4hepMeasurementWriter(level=acts.logging.INFO, config=config))
415 s = Sequencer(numThreads=1)
419 EDM4hepMeasurementReader,
420 level=acts.logging.WARNING,
421 outputMeasurements=
"measurements",
422 outputMeasurementSimHitsMap=
"simhitsmap",
423 outputSourceLinks=
"sourcelinks",
429 AssertCollectionExistsAlg(k, f
"check_alg_{k}", acts.logging.WARNING)
430 for k
in (
"measurements",
"simhitsmap",
"sourcelinks")
438 assert alg.events_seen == 10
442 @pytest.mark.skipif(
not edm4hepEnabled, reason=
"EDM4hep is not set up")
445 EDM4hepParticleWriter,
446 EDM4hepParticleReader,
449 s = Sequencer(numThreads=1, events=10, logLevel=acts.logging.WARNING)
452 out = tmp_path /
"particles_edm4hep.root"
458 EDM4hepParticleWriter,
459 acts.logging.WARNING,
460 inputParticles=evGen.config.outputParticles,
468 s = Sequencer(numThreads=1, logLevel=acts.logging.WARNING)
472 EDM4hepParticleReader,
473 acts.logging.WARNING,
475 outputParticles=
"input_particles",
479 alg = AssertCollectionExistsAlg(
480 "input_particles",
"check_alg", acts.logging.WARNING
487 assert alg.events_seen == 10
491 @pytest.mark.skipif(
not edm4hepEnabled, reason=
"EDM4hep is not set up")
495 detector, trackingGeometry, decorators = acts.examples.GenericDetector.create()
496 field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T))
498 from truth_tracking_kalman
import runTruthTrackingKalman
500 s = Sequencer(numThreads=1, events=10)
506 Path(__file__).parent.parent.parent.parent
507 /
"Examples/Algorithms/Digitization/share/default-smearing-config-generic.json"
514 out = tmp_path /
"tracks_edm4hep.root"
518 level=acts.logging.VERBOSE,
519 inputTracks=
"kfTracks",
529 s = Sequencer(numThreads=1)
532 level=acts.logging.VERBOSE,
533 outputTracks=
"kfTracks",