コード例 #1
0
def material_recording_session():
    if not helpers.geant4Enabled:
        pytest.skip("Geantino recording requested, but Geant4 is not set up")

    if not helpers.dd4hepEnabled:
        pytest.skip("DD4hep recording requested, but Geant4 is not set up")

    from material_recording import runMaterialRecording

    dd4hepSvc = acts.examples.dd4hep.DD4hepGeometryService(xmlFileNames=[
        str(getOpenDataDetectorDirectory() / "xml/OpenDataDetector.xml")
    ])
    dd4hepG4Construction = acts.examples.geant4.dd4hep.DDG4DetectorConstruction(
        dd4hepSvc)

    with tempfile.TemporaryDirectory() as d:

        s = acts.examples.Sequencer(events=2, numThreads=1)

        runMaterialRecording(dd4hepG4Construction,
                             str(d),
                             tracksPerEvent=100,
                             s=s)
        s.run()

        del s
        del dd4hepSvc
        del dd4hepG4Construction

        yield Path(d)
コード例 #2
0
def test_json_material_writer(tmp_path, fmt):
    from acts.examples.dd4hep import DD4hepDetector

    detector, trackingGeometry, _ = DD4hepDetector.create(xmlFileNames=[
        str(getOpenDataDetectorDirectory() / "xml/OpenDataDetector.xml")
    ])

    out = (tmp_path / "material").with_suffix("." + fmt.name.lower())

    assert not out.exists()

    jmw = JsonMaterialWriter(level=acts.logging.WARNING,
                             fileName=str(out.with_suffix("")),
                             writeFormat=fmt)
    assert not out.exists()
    jmw.write(trackingGeometry)

    assert out.stat().st_size > 1000
コード例 #3
0
def test_root_material_writer(tmp_path, assert_root_hash):
    from acts.examples.dd4hep import DD4hepDetector

    detector, trackingGeometry, _ = DD4hepDetector.create(xmlFileNames=[
        str(getOpenDataDetectorDirectory() / "xml/OpenDataDetector.xml")
    ])

    out = tmp_path / "material.root"

    assert not out.exists()

    rmw = RootMaterialWriter(level=acts.logging.WARNING, filePath=str(out))
    assert out.exists()
    assert out.stat().st_size > 0 and out.stat().st_size < 500
    rmw.write(trackingGeometry)

    assert out.stat().st_size > 1000
    assert_root_hash(out.name, out)
コード例 #4
0
ファイル: test_detectors.py プロジェクト: hrzhao76/acts
def test_odd():
    from acts.examples.dd4hep import DD4hepGeometryService, DD4hepDetector

    dd4hepConfig = DD4hepGeometryService.Config(xmlFileNames=[
        str(getOpenDataDetectorDirectory() / "xml/OpenDataDetector.xml")
    ])
    detector = DD4hepDetector()

    config = acts.MaterialMapJsonConverter.Config()
    matDeco = acts.JsonMaterialDecorator(
        rConfig=config,
        jFileName=
        "thirdparty/OpenDataDetector/config/odd-material-mapping-config.json",
        level=acts.logging.WARNING,
    )

    geo, _ = detector.finalize(dd4hepConfig, matDeco)

    assert count_surfaces(geo) == 18824
コード例 #5
0
    g4AlgCfg.detectorConstruction = g4geo

    g4Alg = acts.examples.geant4.Geant4Simulation(
        level=acts.logging.INFO, config=g4AlgCfg
    )

    s.addAlgorithm(g4Alg)

    s.addWriter(
        acts.examples.RootMaterialTrackWriter(
            prePostStep=True,
            recalculateTotals=True,
            collection="material_tracks",
            filePath=os.path.join(outputDir, "geant4_material_tracks.root"),
            level=acts.logging.INFO,
        )
    )

    return s


if "__main__" == __name__:

    dd4hepSvc = acts.examples.dd4hep.DD4hepGeometryService(
        xmlFileNames=[str(getOpenDataDetectorDirectory() / "xml/OpenDataDetector.xml")]
    )
    g4geo = acts.examples.geant4.dd4hep.DDG4DetectorConstruction(dd4hepSvc)

    runMaterialRecording(g4geo=g4geo, tracksPerEvent=10, outputDir=os.getcwd()).run()
コード例 #6
0
ファイル: event_recording.py プロジェクト: hrzhao76/acts
        seed1=43,
        seed2=44,
        detectorConstruction=g4geo,
    )

    erAlg = acts.examples.geant4.hepmc3.EventRecording(config=erAlgCfg,
                                                       level=acts.logging.INFO)

    s.addAlgorithm(erAlg)

    s.addWriter(
        acts.examples.hepmc3.HepMC3AsciiWriter(
            level=acts.logging.INFO,
            outputDir=hepmc_dir,
            outputStem="events",
            inputEvents=erAlg.config.outputHepMcTracks,
        ))

    return s


if "__main__" == __name__:

    dd4hepSvc = acts.examples.dd4hep.DD4hepGeometryService(xmlFileNames=[
        str(getOpenDataDetectorDirectory() / "xml/OpenDataDetector.xml")
    ])

    g4geo = acts.examples.geant4.dd4hep.DDG4DetectorConstruction(dd4hepSvc)

    runEventRecording(g4geo=g4geo, outputDir=os.getcwd()).run()
コード例 #7
0
#!/usr/bin/env python3
import argparse
import pathlib, acts, acts.examples
import acts.examples.dd4hep
from common import getOpenDataDetector, getOpenDataDetectorDirectory

u = acts.UnitConstants
outputDir = pathlib.Path.cwd() / "odd_output"
outputDir.mkdir(exist_ok=True)

oddDir = getOpenDataDetectorDirectory()

oddMaterialMap = oddDir / "data/odd-material-maps.root"
oddDigiConfig = oddDir / "config/odd-digi-smearing-config.json"
oddSeedingSel = oddDir / "config/odd-seeding-config.json"
oddMaterialDeco = acts.IMaterialDecorator.fromFile(oddMaterialMap)

detector, trackingGeometry, decorators = getOpenDataDetector(
    mdecorator=oddMaterialDeco)
field = acts.ConstantBField(acts.Vector3(0.0, 0.0, 2.0 * u.T))
rnd = acts.examples.RandomNumbers(seed=42)

from particle_gun import addParticleGun, MomentumConfig, EtaConfig, ParticleConfig
from fatras import addFatras
from digitization import addDigitization
from seeding import addSeeding, SeedingAlgorithm, TruthSeedRanges
from ckf_tracks import addCKFTracks

s = acts.examples.Sequencer(events=100,
                            numThreads=-1,
                            logLevel=acts.logging.INFO)