From 03b699052c52745e2c6a16ea5366df5b5a4309d5 Mon Sep 17 00:00:00 2001
From: Adrien Matta <matta@lpccaen.in2p3.fr>
Date: Thu, 7 May 2020 14:27:24 +0200
Subject: [PATCH] * twicking details in random generator

---
 Examples/Example4/run.mac            | 2 +-
 NPLib/Physics/NPReaction.cxx         | 4 +---
 NPSimulation/Process/BeamReaction.cc | 6 +++---
 NPSimulation/Simulation.cc           | 1 +
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/Examples/Example4/run.mac b/Examples/Example4/run.mac
index ced78f727..8eec34f7c 100644
--- a/Examples/Example4/run.mac
+++ b/Examples/Example4/run.mac
@@ -1 +1 @@
-/run/beamOn 10
+/run/beamOn 1000
diff --git a/NPLib/Physics/NPReaction.cxx b/NPLib/Physics/NPReaction.cxx
index ba6e8803b..566194f56 100644
--- a/NPLib/Physics/NPReaction.cxx
+++ b/NPLib/Physics/NPReaction.cxx
@@ -87,7 +87,6 @@ ClassImp(Reaction)
     fshoot3=true;
     fshoot4=true;
     fUseExInGeant4=true;
-    RandGen=gRandom;
 
     fLabCrossSection=false; // flag if the provided cross-section is in the lab or not
 
@@ -156,7 +155,6 @@ Reaction::Reaction(string reaction){
 
   fshoot3=true;
   fshoot4=true;
-  RandGen=gRandom;
 
   fLabCrossSection=false;
 
@@ -357,7 +355,7 @@ double  Reaction::EnergyLabFromThetaLab(double ThetaLab){
  
   if(B>D) {
     ThetaLabMax = asin(sqrt(D/B));
-    if(RandGen->Rndm()<0.5) sign=-1;
+    if(gRandom->Rndm()<0.5) sign=-1;
   }
   if(ThetaLab>ThetaLabMax) return -1;
 
diff --git a/NPSimulation/Process/BeamReaction.cc b/NPSimulation/Process/BeamReaction.cc
index b077304f5..f51b1f9c1 100644
--- a/NPSimulation/Process/BeamReaction.cc
+++ b/NPSimulation/Process/BeamReaction.cc
@@ -320,7 +320,7 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack,
         // Angles
         // Shoot and Set a Random ThetaCM
         m_Reaction.ShootRandomThetaCM();
-        double phi = RandFlat::shoot() * 2. * pi;
+        double phi = G4RandFlat::shoot() * 2. * pi;
 
         //////////////////////////////////////////////////
         /////  Momentum and angles from  kinematics  /////
@@ -453,8 +453,8 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack,
         // Shoot and Set a Random ThetaCM
         //m_QFS.ShootRandomThetaCM();
         //m_QFS.ShootRandomPhiCM();
-        double theta = RandFlat::shoot() *  pi;
-        double phi = RandFlat::shoot() * 2. * pi - pi; //rand in [-pi,pi]
+        double theta = G4RandFlat::shoot() *  pi;
+        double phi = G4RandFlat::shoot() * 2. * pi - pi; //rand in [-pi,pi]
 
         m_QFS.SetThetaCM(theta);
         m_QFS.SetPhiCM(phi);
diff --git a/NPSimulation/Simulation.cc b/NPSimulation/Simulation.cc
index ba0ce3916..ed862a21d 100644
--- a/NPSimulation/Simulation.cc
+++ b/NPSimulation/Simulation.cc
@@ -67,6 +67,7 @@ int main(int argc, char** argv){
     
     // initialize the state of the root and geant4 random generator
     if(OptionManager->GetRandomSeed()>0){
+      std::cout << " Seeds for random generators set to: " << OptionManager->GetRandomSeed() << std::endl;
       gRandom->SetSeed(OptionManager->GetRandomSeed()); 
       CLHEP::HepRandom::setTheSeed(OptionManager->GetRandomSeed(),3);
     }
-- 
GitLab