Skip to content

Question about random seed reproducibility when detector XML is modified #1604

@Dr-Stubborn

Description

@Dr-Stubborn

I would like to ask whether the following behavior is expected in ddsim.

I am using a particle gun with a fixed photon energy and a fixed polar angle, while the azimuthal angle is generated uniformly between 0 and 360 degrees. The command I use is:

ddsim --random.seed 100 \
    --enableGun \
    --gun.distribution uniform \
    --gun.energy "100*GeV" \
    --gun.particle gamma \
    --gun.thetaMin "88.03*degree" \
    --gun.thetaMax "88.03*degree" \
    --gun.phiMin "0.0*degree" \
    --gun.phiMax "360.0*degree" \
    --numberOfEvents 10 \
    --outputFile ALLEGRO_sim.root \
    --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ALLEGRO_o1_v03.xml

With the same XML file and the same random seed, the results are reproducible.

However, if I modify the detector XML while keeping exactly the same command and the same random seed, I find that the events are no longer identical. In particular, from event 2 onward, the generated particle directions already become different. In my tests, this happens for example when I change the magnetic field strength in the XML, or when I remove the field entry.

What I compare is the particle-gun-generated photon direction reported in the ddsim output.

My expectation was the following: since the gun configuration is the same, and since the incident particle information should be determined by the random seed, I expected the generated gun kinematics to remain identical even if the detector geometry changes.

So my question is:

Is it expected that changing the detector XML can already change the particle-gun-generated events, even when the same random seed is used?

More specifically, is the intended behavior that modifications of the detector description can change the sequence of random-number calls already during event 1, so that the random-engine state is different by the time event 2 starts?

I understand that this may be normal if the same random engine is shared globally across the simulation, but I would like to confirm whether this is indeed the intended design in DD4hep / ddsim.

Thank you very much for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions