(False, True, "truth_estimated"), (False, False, "seeded"), ]: s = acts.examples.Sequencer(events=args.events, numThreads=1, logLevel=acts.logging.INFO, skip=args.skip) with tempfile.TemporaryDirectory() as temp: tp = Path(temp) runCKFTracks( trackingGeometry, decorators=decorators, field=field, digiConfigFile=digiConfig, geometrySelection=geoSel, outputDir=tp, outputCsv=False, truthSmearedSeeded=truthSmeared, truthEstimatedSeeded=truthEstimated, s=s, ) s.run() del s perf_file = tp / "performance_ckf.root" assert perf_file.exists(), "Performance file not found" shutil.copy(perf_file, outdir / f"performance_ckf_tracks_{label}.root") if not truthSmeared and not truthEstimated: residual_app = srcdir / "build/bin/ActsAnalysisResidualsAndPulls"
def test_ckf_tracks_example( tmp_path, assert_root_hash, truthSmeared, truthEstimated, detector ): csv = tmp_path / "csv" assert not csv.exists() srcdir = Path(__file__).resolve().parent.parent.parent.parent if detector == "generic": detector, trackingGeometry, decorators = GenericDetector.create() geometrySelection = ( srcdir / "Examples/Algorithms/TrackFinding/share/geoSelection-genericDetector.json" ) digiConfigFile = ( srcdir / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json" ) elif detector == "odd": matDeco = acts.IMaterialDecorator.fromFile( srcdir / "thirdparty/OpenDataDetector/data/odd-material-maps.root", level=acts.logging.INFO, ) detector, trackingGeometry, decorators = getOpenDataDetector(matDeco) digiConfigFile = ( srcdir / "thirdparty/OpenDataDetector/config/odd-digi-smearing-config.json" ) geometrySelection = ( srcdir / "thirdparty/OpenDataDetector/config/odd-seeding-config.json" ) else: raise ValueError(f"Invalid detector {detector}") field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) events = 100 s = Sequencer(events=events, numThreads=1) # Digitization is not thread-safe root_files = [ ( "performance_ckf.root", None, ), ( "trackstates_ckf.root", "trackstates", ), ( "tracksummary_ckf.root", "tracksummary", ), ] if not truthSmeared: root_files += [ ( "performance_seeding_trees.root", "track_finder_tracks", ), ] for rf, _ in root_files: assert not (tmp_path / rf).exists() from ckf_tracks import runCKFTracks runCKFTracks( trackingGeometry, decorators, field=field, outputCsv=True, outputDir=tmp_path, geometrySelection=geometrySelection, digiConfigFile=digiConfigFile, truthSmearedSeeded=truthSmeared, truthEstimatedSeeded=truthEstimated, s=s, ) s.run() del s # files are closed in destructors, not great assert csv.exists() for rf, tn in root_files: rp = tmp_path / rf assert rp.exists() if tn is not None: assert_root_hash(rf, rp) assert len([f for f in csv.iterdir() if f.name.endswith("CKFtracks.csv")]) == events assert all([f.stat().st_size > 300 for f in csv.iterdir()])
def test_ckf_tracks_example_truth_smeared(tmp_path, assert_root_hash): # the example as written is only compatible with the generic detector detector, trackingGeometry, decorators = GenericDetector.create() field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) events = 10 s = Sequencer(events=events, numThreads=1) # Digitization is not thread-safe root_files = [ ("performance_ckf.root", None, None), ( "trackstates_ckf.root", "trackstates", 80, ), ( "tracksummary_ckf.root", "tracksummary", 10, ), ] csv = tmp_path / "csv" assert not csv.exists() for rf, _, _ in root_files: assert not (tmp_path / rf).exists() from ckf_tracks import runCKFTracks runCKFTracks( trackingGeometry, decorators, field=field, geometrySelection=Path( Path(__file__).parent.parent.parent.parent / "Examples/Algorithms/TrackFinding/share/geoSelection-genericDetector.json" ), digiConfigFile=Path( Path(__file__).parent.parent.parent.parent / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json" ), outputCsv=True, outputDir=tmp_path, truthSmearedSeeded=True, truthEstimatedSeeded=False, s=s, ) s.run() del s # files are closed in destructors, not great assert csv.exists() for rf, tn, nume in root_files: rp = tmp_path / rf assert rp.exists() if tn is not None and nume is not None: assert_entries(rp, tn, nume) assert_root_hash(rf, rp) assert len([f for f in csv.iterdir() if f.name.endswith("CKFtracks.csv")]) == events assert all([f.stat().st_size > 300 for f in csv.iterdir()])