MT How to create random number "checkpoints" for recovering a crash

Dear all,

in my PrimaryAction periodically (every few minutes or fraction of primaries) I am dumping the random number seed, just in case of a crash to be able in a short period of time to reproduce the crash and debug it.
The approach works fine when running in a single thread with the G4RunManager, but not when I am running in multi threaded mode.

How I can periodically dump the random number seed of the MTRunManager, that was used to generate the seed for the simulated event and dump it?

Thanks in advance

Hi Vasilis,

I can’t answer exactly your question, but something that can help you for
reproducing errors in sequential mode from an original run in multi-threaded mode
is the following:

Use the following macro commands in the multi-threaded run:
/random/setSavingFlag 1
/random/saveEachEventFlag 1

Then, in sequential mode, you do:

/random/resetEngineFrom start.rndm

where “start.rndm” is the latest saved random number seed file
of the thread which fails (from the name of the files you can see
the thread number and event number).

Hope it helps,

Thank you Alberto,
my checkpoint was doing almost what you proposed, however I wanted to restart it in MT mode and not in sequential.
Is there a way to restart in sequential mode an application that
it is compiled in MT?

As far as I know, there is no way to restart in MT mode from a given random number seed file.
And I don’t think it is possible to restart in sequential mode an application that was built in MT mode:
you need to have two executables, one sequential and one MT, then you run the latter (and saving its state event by event) and use the sequential one only for those cases that you want to reproduce…

Contrary to what I have said in my previous post, it seems that there is a way to restart in MT mode from a given random number seed file:
let’s suppose that the random number seed file we want to start with is “G4Worker2_run0evt7.rndm”.
Then, by renaming it as “run0evt0.rndm” and using the macro command:

/random/resetEngineFromEachEvent true

and then running in MT mode with “/run/beamOn 1” , the thread that will execute
this event seem to reproduce correctly the event.

Sorry for the confusion!