From 14f624d47fde938106c4048d5ff06340771d108f Mon Sep 17 00:00:00 2001
From: adrien matta <matta@lpccaen.in2p3.fr>
Date: Tue, 22 Mar 2022 13:55:46 +0100
Subject: [PATCH] * fixing case where NPREaction was called without CS token   
      - Program now issue a reasonable error message before exit

---
 NPLib/Detectors/TRex/TTRexData.h   |  2 +-
 NPLib/Physics/NPReaction.cxx       |  8 +++++---
 NPLib/Utility/nptool-installer.cxx |  1 +
 Projects/S034/minos_dali.detector  | 12 ++++++------
 Projects/S034/script/analysis.sh   |  2 +-
 Projects/S034/script/run.mac       |  2 +-
 Projects/S034/script/simu.sh       |  4 ++--
 7 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/NPLib/Detectors/TRex/TTRexData.h b/NPLib/Detectors/TRex/TTRexData.h
index b49d9b634..a7533373e 100644
--- a/NPLib/Detectors/TRex/TTRexData.h
+++ b/NPLib/Detectors/TRex/TTRexData.h
@@ -39,7 +39,7 @@ class TTRexData : public TObject {
     vector<UShort_t>   fTRexFront_E_DetectorNbr;
     vector<UShort_t>   fTRexFront_E_StripNbr;
     vector<Double_t>   fTRexFront_Energy;
-
+    
     // Time
     vector<UShort_t>   fTRexFront_T_DetectorNbr;
     vector<UShort_t>   fTRexFront_T_StripNbr;
diff --git a/NPLib/Physics/NPReaction.cxx b/NPLib/Physics/NPReaction.cxx
index 6ec299bb0..16c896c2b 100644
--- a/NPLib/Physics/NPReaction.cxx
+++ b/NPLib/Physics/NPReaction.cxx
@@ -209,7 +209,7 @@ double Reaction::ShootRandomThetaCM(){
     TH1D* Proj = fDoubleDifferentialCrossSectionHist->ProjectionX("proj",binY,binY);
     SetThetaCM( theta=Proj->GetRandom()*deg );
   }
-  else if (fLabCrossSection){
+  else if (fLabCrossSection&&fCrossSectionHist){
     double thetalab=-1;
     double energylab=-1;
     while(energylab<0){
@@ -219,7 +219,7 @@ double Reaction::ShootRandomThetaCM(){
     theta = EnergyLabToThetaCM(energylab, thetalab); //transform to theta CM
     SetThetaCM( theta );
   }
-  else{
+  else if(fCrossSectionHist){
     // When root perform a Spline interpolation to shoot random number out of
     // the distribution, it can over shoot and output a number larger that 180
     // this lead to an additional signal at 0-4 deg Lab, especially when using a
@@ -231,7 +231,9 @@ double Reaction::ShootRandomThetaCM(){
     //cout << " Shooting Random ThetaCM "  << theta << endl;
     SetThetaCM( theta*deg );
   }
-
+  else{
+    NPL::SendErrorAndExit("NPL::Reaction","No cross section provided, add relevant token to input file.");
+    }
 
   return theta;
 }
diff --git a/NPLib/Utility/nptool-installer.cxx b/NPLib/Utility/nptool-installer.cxx
index 0eeaaade4..55f710df7 100644
--- a/NPLib/Utility/nptool-installer.cxx
+++ b/NPLib/Utility/nptool-installer.cxx
@@ -104,6 +104,7 @@ std::cout << "nptool installer: ... " ;
       } 
     } 
   }
+
   // same for detector level
   // Copy pcm and rootmap file
   path = getenv("NPTOOL");
diff --git a/Projects/S034/minos_dali.detector b/Projects/S034/minos_dali.detector
index f21f81870..2ee456685 100644
--- a/Projects/S034/minos_dali.detector
+++ b/Projects/S034/minos_dali.detector
@@ -17,42 +17,42 @@ Minos
 Dali
  R = 212.4 mm 
  Alpha = 240 deg
- Zeta = 298,28 mm 
+ Zeta = 298.28 mm 
  Ring = 1
  Material = NaI(Tl)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Dali
  R = 212.4 mm 
  Alpha = 180 deg 
- Zeta = 298,28 mm
+ Zeta = 298.28 mm
  Ring = 1
  Material = NaI(Tl)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Dali
  R= 212.4 mm 
  Alpha = 120 deg 
- Zeta = 298,28 mm 
+ Zeta = 298.28 mm 
  Ring = 1
  Material = NaI(Tl)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Dali
  R = 212.4 mm 
  Alpha = 60 deg 
- Zeta = 298,28 mm
+ Zeta = 298.28 mm
  Ring = 1
  Material = NaI(Tl)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Dali
  R = 212.4 mm
  Alpha = 0 deg 
- Zeta = 298,28 mm
+ Zeta = 298.28 mm
  Ring = 1
  Material = NaI(Tl)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Dali
  R = 212.4 mm 
  Alpha = -60 deg 
- Zeta = 298,28 mm
+ Zeta = 298.28 mm
  Ring = 1
  Material = NaI(Tl)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/Projects/S034/script/analysis.sh b/Projects/S034/script/analysis.sh
index 24061c544..d43a90ee1 100755
--- a/Projects/S034/script/analysis.sh
+++ b/Projects/S034/script/analysis.sh
@@ -2,5 +2,5 @@
 
 for i in {1..30}
 do
-  nohup npanalysis -D minos_dali.detector -E reaction/pp.reaction -T root/simulation/simu_tpad_$i.root SimulatedTree -O simu_tpad_$i &
+  nohup npanalysis  -T root/simulation/simu_tpad_d5mm$i.root SimulatedTree -O simu_tpad_d5mm$i &
 done
diff --git a/Projects/S034/script/run.mac b/Projects/S034/script/run.mac
index 52501d498..58c82e9b7 100644
--- a/Projects/S034/script/run.mac
+++ b/Projects/S034/script/run.mac
@@ -1 +1 @@
-/run/beamOn 5000
+/run/beamOn 30000
diff --git a/Projects/S034/script/simu.sh b/Projects/S034/script/simu.sh
index f57738aa0..e57020486 100755
--- a/Projects/S034/script/simu.sh
+++ b/Projects/S034/script/simu.sh
@@ -1,6 +1,6 @@
 
 
-for i in {1..20}
+for i in {1..30}
 do
-  nohup npsimulation -D minos_dali.detector -E reaction/pp.reaction -B run.mac -O simu_tpad_$i --random-seed $i & 
+  nohup npsimulation -D minos_dali_short.detector -E reaction/pp.reaction -B script/run.mac -O simu_tpad_short_$i --random-seed $i & 
 done
-- 
GitLab