diff --git a/src/G4System.cc b/src/G4System.cc index 6ef87a3..a24ed72 100644 --- a/src/G4System.cc +++ b/src/G4System.cc @@ -4,6 +4,11 @@ #include #include +#include +#include + +#include + void G4System::init(GeometryDescriptor &CW){ if(CW.isAssigned()){ @@ -19,6 +24,9 @@ void G4System::init(GeometryDescriptor &CW){ bool first_init=true; + int seed=std::time(NULL) ; + CLHEP::HepRandom::setTheSeed(seed); G4Random::setTheSeed(seed); + if(runManager == nullptr){ // Construct the default run manager @@ -150,6 +158,8 @@ void G4System::run_gui(){ void G4System::run_batch(int nEvents,const std::string& partSpecies, double minEnergy, double maxEnergy){ check(); + + G4String partSpec = partSpecies; G4cout << "running with particle species " << partSpec << G4endl; UImanager->ApplyCommand("/run/initialize"); diff --git a/src/PrimaryGeneratorAction.cc b/src/PrimaryGeneratorAction.cc index 61d9418..b6cde79 100644 --- a/src/PrimaryGeneratorAction.cc +++ b/src/PrimaryGeneratorAction.cc @@ -41,6 +41,9 @@ #include "Randomize.hh" #include "G4INCLRandom.hh" #include +#include + +#include namespace B4 { @@ -56,8 +59,9 @@ PrimaryGeneratorAction::PrimaryGeneratorAction() minPartEnergy = 1000; maxPartEnergy = 1000; - G4INCL::Random::setGenerator( new G4INCL::Geant4RandomGenerator()); - + // This function is called at the begining of event + auto gen = new G4INCL::Geant4RandomGenerator(); + G4INCL::Random::setGenerator( gen); // default particle kinematic // @@ -75,9 +79,6 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction() void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { - - // This function is called at the begining of event - G4double rand = 0; while(rand > 1 || rand <= 0) rand = G4INCL::Random::shoot();