def test_csv_multitrajectory_writer(tmp_path): detector, trackingGeometry, decorators = GenericDetector.create() field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) from truth_tracking import runTruthTracking s = Sequencer(numThreads=1, events=10) runTruthTracking( trackingGeometry, field, digiConfigFile=Path( str( Path(__file__).parent.parent.parent.parent / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json" )), outputDir=tmp_path, s=s, ) csv_dir = tmp_path / "csv" csv_dir.mkdir() s.addWriter( CsvMultiTrajectoryWriter( level=acts.logging.INFO, inputTrajectories="trajectories", inputMeasurementParticlesMap="measurement_particles_map", outputDir=str(csv_dir), )) s.run() del s assert len([f for f in csv_dir.iterdir() if f.is_file()]) == 10 assert all(f.stat().st_size > 20 for f in csv_dir.iterdir())
def test_truth_tracking(tmp_path, assert_root_hash, revFiltMomThresh): from truth_tracking import runTruthTracking detector, trackingGeometry, _ = getOpenDataDetector() field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) seq = Sequencer(events=10, numThreads=1) root_files = [ ("trackstates_fitter.root", "trackstates", 19), ("tracksummary_fitter.root", "tracksummary", 10), ("performance_track_finder.root", "track_finder_tracks", 19), ("performance_track_fitter.root", None, -1), ] for fn, _, _ in root_files: fp = tmp_path / fn assert not fp.exists() runTruthTracking( trackingGeometry, field, digiConfigFile=Path( "thirdparty/OpenDataDetector/config/odd-digi-smearing-config.json", ), outputDir=tmp_path, reverseFilteringMomThreshold=revFiltMomThresh, s=seq, ) seq.run() del seq for fn, tn, ee in root_files: fp = tmp_path / fn assert fp.exists() assert fp.stat().st_size > 1024 if tn is not None: assert_entries(fp, tn, ee) assert_root_hash(fn, fp)
def test_vertex_fitting_reading( tmp_path, ptcl_gun, rng, finder, inputTracks, entries, assert_root_hash ): ptcl_file = tmp_path / "particles.root" detector, trackingGeometry, decorators = GenericDetector.create() field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) from vertex_fitting import runVertexFitting, VertexFinder inputTrackSummary = None if inputTracks: from truth_tracking import runTruthTracking s2 = Sequencer(numThreads=1, events=100) runTruthTracking( trackingGeometry, field, digiConfigFile=Path( Path(__file__).parent.parent.parent.parent / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json" ), outputDir=tmp_path, s=s2, ) s2.run() del s2 inputTrackSummary = tmp_path / "tracksummary_fitter.root" assert inputTrackSummary.exists() assert ptcl_file.exists() else: s0 = Sequencer(events=100, numThreads=1) evGen = ptcl_gun(s0) s0.addWriter( RootParticleWriter( level=acts.logging.INFO, inputParticles=evGen.config.outputParticles, filePath=str(ptcl_file), ) ) s0.run() del s0 assert ptcl_file.exists() finder = VertexFinder[finder] s3 = Sequencer(numThreads=1) runVertexFitting( field, inputParticlePath=ptcl_file, inputTrackSummary=inputTrackSummary, outputDir=tmp_path, vertexFinder=finder, s=s3, ) alg = AssertCollectionExistsAlg(["fittedVertices"], name="check_alg") s3.addAlgorithm(alg) s3.run() vertexing_file = tmp_path / "performance_vertexing.root" assert vertexing_file.exists() assert_entries(vertexing_file, "vertexing", entries) assert_root_hash(vertexing_file.name, vertexing_file)
from pathlib import Path import acts import acts.examples from truth_tracking import runTruthTracking u = acts.UnitConstants if "__main__" == __name__: srcdir = Path(__file__).resolve().parent.parent.parent.parent # detector, trackingGeometry, _ = getOpenDataDetector() # detector, trackingGeometry, decorators = acts.examples.GenericDetector.create() detector, trackingGeometry, decorators = acts.examples.TelescopeDetector.create( bounds=[200, 200], positions=[30, 60, 90, 120, 150, 180, 210, 240, 270] ) field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) runTruthTracking( trackingGeometry, field, digiConfigFile=srcdir / "Examples/Algorithms/Digitization/share/default-smearing-config-telescope.json", # / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json", # "thirdparty/OpenDataDetector/config/odd-digi-smearing-config.json", outputDir=Path.cwd(), ).run()
digiConfig = srcdir / "thirdparty/OpenDataDetector/config/odd-digi-smearing-config.json" geoSel = srcdir / "thirdparty/OpenDataDetector/config/odd-seeding-config.json" field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) s = acts.examples.Sequencer( events=args.events, numThreads=-1, logLevel=acts.logging.INFO, skip=0 ) with tempfile.TemporaryDirectory() as temp: tp = Path(temp) runTruthTracking( trackingGeometry, field, digiConfigFile=digiConfig, outputDir=tp, s=s, ) s.run() del s perf_file = tp / "performance_track_fitter.root" assert perf_file.exists(), "Performance file not found" shutil.copy(perf_file, outdir / "performance_truth_tracking.root") for truthSmeared, truthEstimated, label in [ (True, False, "truth_smeared"), # if first is true, second is ignored (False, True, "truth_estimated"),