コード例 #1
0
def test_ckf_tracks_example_truth_estimate(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),
        (
            "performance_seeding_trees.root",
            "track_finder_tracks",
            80,
        ),
        (
            "performance_seeding_trees.root",
            "track_finder_particles",
            80,
        ),
        (
            "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=False,
        truthEstimatedSeeded=True,
        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 > 100 for f in csv.iterdir()])
コード例 #2
0
def test_material_mapping(material_recording, tmp_path, assert_root_hash):
    map_file = tmp_path / "material-maps_tracks.root"
    assert not map_file.exists()

    s = Sequencer(numThreads=1)

    detector, trackingGeometry, decorators = getOpenDataDetector()

    from material_mapping import runMaterialMapping

    runMaterialMapping(
        trackingGeometry,
        decorators,
        outputDir=str(tmp_path),
        inputDir=material_recording,
        s=s,
    )

    s.run()

    # MaterialMapping alg only writes on destruct.
    # See https://github.com/acts-project/acts/issues/881
    del s

    mat_file = tmp_path / "material-map.json"

    assert mat_file.exists()
    assert mat_file.stat().st_size > 10

    with mat_file.open() as fh:
        assert json.load(fh)

    assert map_file.exists()
    assert_entries(map_file, "material-tracks", 200)
    assert_root_hash(map_file.name, map_file)

    val_file = tmp_path / "propagation-material.root"
    assert not val_file.exists()

    # test the validation as well

    # we need to destroy the ODD to reload with material
    # del trackingGeometry
    # del detector

    detector, trackingGeometry, decorators = getOpenDataDetector(
        mdecorator=acts.IMaterialDecorator.fromFile(mat_file))

    from material_validation import runMaterialValidation

    s = Sequencer(events=10, numThreads=1)

    field = acts.NullBField()

    runMaterialValidation(trackingGeometry,
                          decorators,
                          field,
                          outputDir=str(tmp_path),
                          s=s)

    s.run()

    assert val_file.exists()
    assert_entries(val_file, "material-tracks", 10000)
    assert_root_hash(val_file.name, val_file)