Example of implementing a custom InitializeSeeds()?

I am (finally, only six releases late) trying to migrate my experiment’s simulation to handle multithreaded running. The last issue on my list is interfacing to the G4 random engine.

One of the features we include is a flag to generate job-by-job unique random sequences: we use libuuid for this, so that even batch jobs dispatched simultaneously will have different random sequences.

As described in the Toolkit Guide, for MT we should be doing this by overriding the G4MTRunManager::InitializeSeeds(G4int nEvents) function. The example there seems like a template, rather than working code. Does anyone have an implementation they use, which I could look at for a starting point?

1 Like

Any progress since then? I am wondering the same.

No progress. I was not able to get it to work successfully at all, so I backed out and implemented an ugly, not recommended at all, override: in my simulation framework’s PrimaryAction (which is the first thing which will use a random number), I my own “random manager” to get seeds from the user and set the engine state. This replaces the seeds passed through InitializeSeeds().

This is really the wrong way to handle the situation, but I just couldn’t understand how to override InitializeSeeds().

I eventually figured out something that worked out for me, check out my comment:

In summary, you can set the seed of the master random number generator used to generate the event seeds. Less fine-grained control, but at least it enables having more than one result…