In my application I see an apparent inconsistency in the random engine after loading the status from a file. I load the status for the Ranecu engine from this file:
Uvec
1878463799
2
99775361
86969112
using some code that I summarized in this reproducer:
#include <CLHEP/Random/Randomize.h>
int main(){
// Create the engine and set the initial seeds
CLHEP::RanecuEngine rndmEngine;
CLHEP::HepRandom::setTheEngine(&rndmEngine);
long seeds[2] = {1, 2};
CLHEP::HepRandom::setTheSeeds(seeds, 0);
// Show the status and the seeds
CLHEP::HepRandom::showEngineStatus();
std::cout << "Seeds: " << CLHEP::HepRandom::getTheSeeds()[0] << " " << CLHEP::HepRandom::getTheSeeds()[1] << std::endl;
// Load the status from file
CLHEP::HepRandom::restoreEngineStatus("engineStatus.txt");
// Show the status and the seeds again
CLHEP::HepRandom::showEngineStatus();
std::cout << "Seeds: " << CLHEP::HepRandom::getTheSeeds()[0] << " " << CLHEP::HepRandom::getTheSeeds()[1] << std::endl;
}
Compiling and launching the reproducer I get:
--------- Ranecu engine status ---------
Initial seed (index) = 0
Current couple of seeds = 1, 2
----------------------------------------
Seeds: 1 2
--------- Ranecu engine status ---------
Initial seed (index) = 2
Current couple of seeds = 99775361, 86969112
----------------------------------------
Seeds: 1 2
So it seems that the seeds reported by CLHEP::HepRandom::showEngineStatus()
and the ones returned by CLHEP::HepRandom::getTheSeeds()
are different after setting the engine status from file. The first method seems to indicate that the status has been correctly loaded from file, but then the second one gives different seed values so I’m not sure. Is there something I don’t understand or is this maybe a bug?
Thanks in advance for any help.
Using the CLHEP version bundled with Geant4 10.06.p02.