Reproducing runs on different systems


I’m in the process of moving my geant4 simulation onto a different computer, and I want to verify the results by comparing the outputs on the two different computers. I was able to figure out how to get the run seeds to be the same using /random/setSeeds. However, even though the run seeds are the same, the event seeds (in currentEvent.rndm in seeds directory) are different for the last/current run. I don’t understand how I’m getting different event seeds despite my run seeds being identical. Is there a way to further set the seeds so that the output should be identical?

Thanks in advance


if you have multithreading enabled, the seeding is afaik a bit more complicated. One option would be to switch of MT, and see if that solves it for you.

If not:
I have managed to reproduce identical results on very different machines (windows/linux, different number of threads in multithreading) with the following (probably very inefficient) procedure:

for relevant/all events, obtain the respective seeds, e.g., in a sensitive detector

G4long fEventSeed1 = G4Random::getTheSeeds()[0];
G4long fEventSeed2 = G4Random::getTheSeeds()[1];

and store them, e.g. in a G4NTuple that was created like so:

analysisManager->CreateNtuple("Seeds", "Hits");

for replay, the output file for the ntuple was read back into two vectors, and passed to the PrimaryGeneratorAction class / GeneratePrimaries function, and for each eventID, directly prior to each fGeneralParticleSource->GeneratePrimaryVertex(anEvent) the random number state is reset to

if(anEvent->GetEventID()< static_cast<int>(fReplay1.size())) {
  G4cerr << "Replay: " <<>GetEventID()) << " " <<>GetEventID()) << G4endl;
  G4long fEventSeeds [2] = {>GetEventID()),>GetEventID())};