File indexing completed on 2026-05-07 07:59:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 import pytest
0010 from pathlib import Path
0011
0012 from helpers import AssertCollectionExistsAlg
0013
0014 import acts
0015 import acts.examples
0016 from acts.examples.uproot import UprootParticleReader, UprootSimHitReader
0017 from acts.examples import Sequencer
0018 from acts.examples.root import RootParticleWriter, RootSimHitWriter
0019
0020
0021 @pytest.mark.root
0022 def test_root_write_uproot_read(tmp_path, fatras, conf_const):
0023 """Full round-trip: simulate with fatras, write ROOT files, read back with uproot readers."""
0024 particle_file = tmp_path / "particles_simulation.root"
0025 hit_file = tmp_path / "hits.root"
0026
0027 s = Sequencer(numThreads=1, events=10, logLevel=acts.logging.INFO)
0028 evGen, simAlg, _ = fatras(s)
0029 s.addWriter(
0030 conf_const(
0031 RootParticleWriter,
0032 acts.logging.INFO,
0033 inputParticles=simAlg.config.outputParticles,
0034 filePath=str(particle_file),
0035 )
0036 )
0037 s.addWriter(
0038 conf_const(
0039 RootSimHitWriter,
0040 acts.logging.INFO,
0041 inputSimHits=simAlg.config.outputSimHits,
0042 filePath=str(hit_file),
0043 )
0044 )
0045 s.run()
0046
0047 s2 = Sequencer(numThreads=1, logLevel=acts.logging.INFO)
0048 s2.addReader(
0049 UprootParticleReader(
0050 filePath=particle_file,
0051 outputParticles="particles_read",
0052 level=acts.logging.INFO,
0053 )
0054 )
0055 s2.addReader(
0056 UprootSimHitReader(
0057 filePath=hit_file,
0058 outputSimHits="simhits_read",
0059 level=acts.logging.INFO,
0060 )
0061 )
0062 alg = AssertCollectionExistsAlg(
0063 ["particles_read", "simhits_read"],
0064 "check_alg",
0065 acts.logging.INFO,
0066 )
0067 s2.addAlgorithm(alg)
0068 s2.run()
0069 assert alg.events_seen == 10