random seed

This commit is contained in:
Jan Kieseler
2023-10-10 10:12:31 +02:00
parent 6f6ffff96a
commit 19226f31e6
2 changed files with 16 additions and 5 deletions
+10
View File
@@ -4,6 +4,11 @@
#include <G4NistManager.hh>
#include <G4String.hh>
#include <G4INCLGeant4Random.hh>
#include <G4INCLRandomSeedVector.hh>
#include <ctime>
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");
+6 -5
View File
@@ -41,6 +41,9 @@
#include "Randomize.hh"
#include "G4INCLRandom.hh"
#include <G4INCLGeant4Random.hh>
#include <G4INCLRandomSeedVector.hh>
#include <ctime>
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();