From 666bb71700c28e8878a992dc3bc0eafe8a1a67e1 Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Thu, 19 Jul 2018 11:41:58 +0200
Subject: [PATCH] * Fixing Compilation on Mac OS X * Fxing issue with Example1

---
 Examples/Example1/Analysis.cxx                | 38 ++++++---
 Examples/Example1/Analysis.h                  | 13 +++-
 Examples/Example1/ShowResults.C               | 25 +++++-
 .../DetectorConfiguration/Example1.detector   |  8 +-
 NPLib/Core/NPDetectorManager.cxx              | 50 ++++++++++--
 NPLib/Core/NPDetectorManager.h                | 78 +++++++++----------
 NPLib/Core/NPVAnalysis.cxx                    |  4 -
 NPLib/Core/NPVAnalysis.h                      |  7 +-
 NPLib/Detectors/CATS/TCATSPhysics.cxx         | 42 +++++-----
 NPLib/Physics/TReactionConditions.h           |  8 +-
 NPLib/Utility/npanalysis.cxx                  |  4 +-
 NPSimulation/Core/CMakeLists.txt              |  2 +-
 12 files changed, 171 insertions(+), 108 deletions(-)

diff --git a/Examples/Example1/Analysis.cxx b/Examples/Example1/Analysis.cxx
index ae5a67abe..fa8554aeb 100644
--- a/Examples/Example1/Analysis.cxx
+++ b/Examples/Example1/Analysis.cxx
@@ -6,9 +6,9 @@
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: Adrien MATTA  contact address: a.matta@surrey.ac.uk      *
+ * Original Author: Adrien MATTA  contact address: matta@lpccaen.in2p3.fr    *
  *                                                                           *
- * Creation Date  : march 2025                                               *
+ * Creation Date  : march 2015                                               *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
@@ -30,15 +30,17 @@ using namespace std;
 ////////////////////////////////////////////////////////////////////////////////
 Analysis::Analysis(){
 }
+
 ////////////////////////////////////////////////////////////////////////////////
 Analysis::~Analysis(){
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Analysis::Init(){
-  M2= (TMust2Physics*) m_DetectorManager->GetDetector("M2Telescope");
-  SSSD= (TSSSDPhysics*) m_DetectorManager->GetDetector("SSSD");
-  Initial=new TInitialConditions();
+  M2 = (TMust2Physics*) m_DetectorManager->GetDetector("M2Telescope");
+  SSSD = (TSSSDPhysics*) m_DetectorManager->GetDetector("SSSD");
+  Initial = new TInitialConditions();
+  ReactionConditions = new TReactionConditions(); 
   InitOutputBranch();
   InitInputBranch();
   Rand = TRandom3();
@@ -57,12 +59,11 @@ void Analysis::Init(){
   E_M2 = 0;
   Si_X_M2 = 0;
   Si_Y_M2 = 0;
-  ZTarget = 0;
   TargetThickness = m_DetectorManager->GetTargetThickness();
   //	Energy loss table: the G4Table are generated by the simulation
-  He3CD2 = EnergyLoss("Example/He3_CD2.G4table","G4Table",100 );
-  He3Al = EnergyLoss("Example/He3_Al.G4table","G4Table",10);
-  He3Si = EnergyLoss("Example/He3_Si.G4table","G4Table",10);
+  He3CD2  = EnergyLoss("Example/He3_CD2.G4table","G4Table",100 );
+  He3Al   = EnergyLoss("Example/He3_Al.G4table","G4Table",10);
+  He3Si   = EnergyLoss("Example/He3_Si.G4table","G4Table",10);
   Li11CD2 = EnergyLoss("Example/Li11_CD2.G4table","G4Table",100);
 }
 
@@ -70,6 +71,10 @@ void Analysis::Init(){
 void Analysis::TreatEvent(){
   // Reinitiate calculated variable
   ReInitValue();
+  // Get the Original condition for the record
+  OriginalELab = ReactionConditions->GetKineticEnergy(0);
+  OriginalThetaLab = ReactionConditions->GetTheta(0);
+  OriginalBeamEnergy = ReactionConditions->GetBeamEnergy();
   // Get the Init information on beam position and energy
   // and apply by hand the experimental resolution
   // This is because the beam diagnosis are not simulated
@@ -92,9 +97,9 @@ void Analysis::TreatEvent(){
   XTarget = BeamPosition.X();
   YTarget = BeamPosition.Y();
   ZTarget = 0;
-
+  
   // Beam energy is measured using F3 and F2 plastic TOF with 4.5 MeV Resolution
-  double BeamEnergy = Rand.Gaus(Initial->GetIncidentInitialKineticEnergy(),4.5);
+  BeamEnergy = Rand.Gaus(Initial->GetIncidentInitialKineticEnergy(),4.5);
   BeamEnergy = Li11CD2.Slow(BeamEnergy,TargetThickness*0.5,0);
   He10Reaction->SetBeamEnergy(BeamEnergy);
   
@@ -198,6 +203,10 @@ void Analysis::InitOutputBranch() {
   RootOutput::getInstance()->GetTree()->Branch("ELab",&ELab,"ELab/D");
   RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab,"ThetaLab/D");
   RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM,"ThetaCM/D");
+  RootOutput::getInstance()->GetTree()->Branch("BeamEnergy",&BeamEnergy,"BeamEnergy/D"); 
+  RootOutput::getInstance()->GetTree()->Branch("OriginalELab",&OriginalELab,"OriginalELab/D");
+  RootOutput::getInstance()->GetTree()->Branch("OriginalThetaLab",&OriginalThetaLab,"OriginalThetaLab/D");
+  RootOutput::getInstance()->GetTree()->Branch("OriginalBeamEnergy",&OriginalBeamEnergy,"OriginalBeamEnergy/D");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -205,6 +214,9 @@ void Analysis::InitInputBranch(){
   RootInput:: getInstance()->GetChain()->SetBranchStatus("InitialConditions",true );
   RootInput:: getInstance()->GetChain()->SetBranchStatus("fIC_*",true );
   RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&Initial);
+  RootInput:: getInstance()->GetChain()->SetBranchStatus("ReactionConditions",true );
+  RootInput:: getInstance()->GetChain()->SetBranchStatus("fRC_*",true );
+  RootInput:: getInstance()->GetChain()->SetBranchAddress("ReactionConditions",&ReactionConditions);
 }
 
 ////////////////////////////////////////////////////////////////////////////////     
@@ -212,7 +224,11 @@ void Analysis::ReInitValue(){
   Ex = -1000 ;
   ELab = -1000;
   ThetaLab = -1000;
+  BeamEnergy = -1000;
   ThetaCM = -1000;
+  OriginalELab = -1000;
+  OriginalThetaLab = -1000;
+  
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/Examples/Example1/Analysis.h b/Examples/Example1/Analysis.h
index 2f1deee86..7f471c45f 100644
--- a/Examples/Example1/Analysis.h
+++ b/Examples/Example1/Analysis.h
@@ -8,9 +8,9 @@
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: Adrien MATTA  contact address: a.matta@surrey.ac.uk      *
+ * Original Author: Adrien MATTA  contact address: matta@lpccaen.in2p3.fr    *
  *                                                                           *
- * Creation Date  : march 2025                                               *
+ * Creation Date  : march 2015                                               *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
@@ -21,10 +21,11 @@
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
-#include"NPVAnalysis.h"
+#include "NPVAnalysis.h"
 #include "TMust2Physics.h"
 #include "TSSSDPhysics.h"
 #include "TInitialConditions.h"
+#include "TReactionConditions.h"
 #include "NPEnergyLoss.h"
 #include "NPReaction.h"
 #include "TRandom3.h"
@@ -47,6 +48,10 @@ class Analysis: public NPL::VAnalysis{
     double ELab;
     double ThetaLab;
     double ThetaCM;
+    double BeamEnergy;
+    double OriginalELab;
+    double OriginalThetaLab;
+    double OriginalBeamEnergy;
     NPL::Reaction* He10Reaction;
 
     // intermediate variable
@@ -64,7 +69,6 @@ class Analysis: public NPL::VAnalysis{
     double E_M2 ;
     double Si_X_M2;
     double Si_Y_M2;
-    double ZTarget;
     double TargetThickness;
 
     NPL::EnergyLoss He3CD2  ;
@@ -75,5 +79,6 @@ class Analysis: public NPL::VAnalysis{
     TMust2Physics* M2;
     TSSSDPhysics* SSSD;
     TInitialConditions* Initial;
+    TReactionConditions* ReactionConditions;
 };
 #endif
diff --git a/Examples/Example1/ShowResults.C b/Examples/Example1/ShowResults.C
index 5e3ba7044..3a2792926 100644
--- a/Examples/Example1/ShowResults.C
+++ b/Examples/Example1/ShowResults.C
@@ -3,7 +3,6 @@
 TCutG* ETOF=NULL;
 TCutG* EDE=NULL;
 TChain* chain=NULL ;
-TCanvas* c1 = NULL;
 
 ////////////////////////////////////////////////////////////////////////////////
 void LoadCuts(){
@@ -25,7 +24,7 @@ void ShowResults(){
     LoadChain();
     LoadCuts();
     
-    c1 = new TCanvas("Example1","Example1",0,0,600,600);
+    TCanvas* c1 = new TCanvas("Detected","Detected",0,0,600,600);
     c1->Divide(2,2);
     
     // Light Particle ID //
@@ -44,7 +43,6 @@ void ShowResults(){
     
     // Kinematical Line //
     c1->cd(3);
-    //chain->Draw("ELab:ThetaLab>>hKine(500,0,45,400,0,40)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz");
     chain->Draw("ELab:ThetaLab>>h(1000,0,90,1000,0,30)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz");
     
     NPL::Reaction r("11Li(d,3He)10He@553");
@@ -75,4 +73,25 @@ void ShowResults(){
     f->SetLineColor(kOrange-3);
     f->SetNpx(1000);
     
+    TCanvas* c2 = new TCanvas("Simulated","Simulated",600,0,600,600);
+    c2->Divide(2,2);
+    
+    c2->cd(1);
+    chain->Draw("OriginalELab:OriginalThetaLab>>hS(1000,0,90,1000,0,30)","","col");
+    Kine->Draw("c");
+    c2->cd(2);
+    chain->Draw("OriginalELab:ELab>>hS2(1000,0,30,1000,0,30)","ELab>0","col");
+    TLine* lE = new TLine(0,0,30,30);
+    lE->Draw();
+    c2->cd(3);
+    chain->Draw("OriginalThetaLab:ThetaLab>>hS3(1000,0,90,1000,0,90)","ThetaLab>0","col");
+    TLine* lT = new TLine(0,0,90,90);
+    lT->Draw();
+    c2->cd(4);
+    chain->Draw("OriginalBeamEnergy:BeamEnergy>>hS4(1000,500,600,1000,500,600)","BeamEnergy>0","col");
+    TLine* lB = new TLine(500,500,600,600);
+    lB->Draw();
+    
+
+
 }
diff --git a/Inputs/DetectorConfiguration/Example1.detector b/Inputs/DetectorConfiguration/Example1.detector
index 08299c188..e67ae572d 100644
--- a/Inputs/DetectorConfiguration/Example1.detector
+++ b/Inputs/DetectorConfiguration/Example1.detector
@@ -1,9 +1,9 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Target
- THICKNESS= 18 micrometer
- RADIUS=  30 mm
- MATERIAL= CD2
- ANGLE= 0 deg
+ Thickness= 18 micrometer
+ Radius=  30 mm
+ Material= CD2
+ Angle= 0 deg
  X= 0 mm
  Y= 0 mm 
  Z= 0 mm
diff --git a/NPLib/Core/NPDetectorManager.cxx b/NPLib/Core/NPDetectorManager.cxx
index bef210a1f..0f7646d30 100644
--- a/NPLib/Core/NPDetectorManager.cxx
+++ b/NPLib/Core/NPDetectorManager.cxx
@@ -45,6 +45,8 @@ using namespace NPUNITS;
 #include"TCanvas.h"
 #include "TROOT.h"
 ///////////////////////////////////////////////////////////////////////////////
+//double NPL::DetectorManager::GetTargetThickness    () {return  m_TargetThickness;}
+
 //   Default Constructor
 NPL::DetectorManager::DetectorManager(){
   m_BuildPhysicalPtr = &NPL::VDetector::BuildPhysicalEvent;
@@ -128,12 +130,12 @@ void NPL::DetectorManager::ReadConfigurationFile(std::string Path)   {
     }
     std::vector<std::string> token = {"Thickness","Radius","Material","Angle","X","Y","Z"};
     if(starget[0]->HasTokenList(token)){
-      m_TargetThickness= starget[0]->GetDouble("Thickness","micrometer");
-      m_TargetAngle=starget[0]->GetDouble("Angle","deg");
-      m_TargetMaterial=starget[0]->GetString("Material");
-      m_TargetX=starget[0]->GetDouble("X","mm");
-      m_TargetY=starget[0]->GetDouble("Y","mm");
-      m_TargetZ=starget[0]->GetDouble("Z","mm");
+      m_TargetThickness = starget[0]->GetDouble("Thickness","micrometer");
+      m_TargetAngle = starget[0]->GetDouble("Angle","deg");
+      m_TargetMaterial = starget[0]->GetString("Material");
+      m_TargetX = starget[0]->GetDouble("X","mm");
+      m_TargetY = starget[0]->GetDouble("Y","mm");
+      m_TargetZ = starget[0]->GetDouble("Z","mm");
     }
     else{
       std::cout << "ERROR: Target token list incomplete, check your input file" << std::endl;
@@ -150,8 +152,6 @@ void NPL::DetectorManager::ReadConfigurationFile(std::string Path)   {
     std::vector<std::string> FrameToken  = {"FrameRadius","FrameThickness","FrontCone","BackCone","FrameMaterial"};
     std::vector<std::string> ShieldToken = {"ShieldInnerRadius","ShieldOuterRadius""ShieldBottomLength","ShieldTopLength","ShieldFrontRadius","ShieldBackRadius","ShieldMaterial"};
 
-
-
     if(ctarget[0]->HasTokenList(CoreToken)){
        // Target 
       m_TargetThickness = ctarget[0]->GetDouble("NominalThickness","micrometer");
@@ -488,4 +488,38 @@ void NPL::DetectorManager::CheckSpectraServer(){
     std::cout <<"WARNING: requesting to check spectra server, which is not started" << std::endl; 
 
 }
+////////////////////////////////////////////////////////////////////////////////
+bool NPL::DetectorManager::IsCryogenic() {return  m_CryoTarget;};
+double NPL::DetectorManager::GetTargetThickness() {return m_TargetThickness;};
+double NPL::DetectorManager::GetNominalTargetThickness() {return  m_TargetThickness;};
+double NPL::DetectorManager::GetTargetDensity() {return  m_TargetDensity;};
+double NPL::DetectorManager::GetFrontDeformation() {return  m_FrontDeformation;};
+double NPL::DetectorManager::GetFrontThickness() {return  m_FrontThickness;};
+double NPL::DetectorManager::GetFrontRadius() {return  m_FrontRadius;};
+std::string NPL::DetectorManager::GetFrontMaterial() {return  m_FrontMaterial;};
+double NPL::DetectorManager::GetBackDeformation() {return  m_BackDeformation;};
+double NPL::DetectorManager::GetBackRadius() {return  m_BackRadius;};
+double NPL::DetectorManager::GetBackThickness() {return  m_BackThickness;};
+std::string NPL::DetectorManager::GetBackMaterial() {return  m_BackMaterial;};
+double NPL::DetectorManager::GetFrameRadius() {return  m_FrameRadius;};
+double NPL::DetectorManager::GetFrameThickness() {return  m_FrameThickness;};
+double NPL::DetectorManager::GetFrontCone() {return  m_FrontCone;};
+double NPL::DetectorManager::GetBackCone() {return  m_BackCone;};
+std::string NPL::DetectorManager::GetFrameMaterial() {return  m_FrameMaterial;};
+double NPL::DetectorManager::GetShieldInnerRadius() {return  m_ShieldInnerRadius;};
+double NPL::DetectorManager::GetShieldOuterRadius() {return  m_ShieldOuterRadius;};
+double NPL::DetectorManager::GetShieldBottomLength() {return  m_ShieldBottomLength;};
+double NPL::DetectorManager::GetShieldTopLength() {return  m_ShieldTopLength;};
+double NPL::DetectorManager::GetShieldFrontRadius() {return  m_ShieldFrontRadius;}; 
+double NPL::DetectorManager::GetShieldBackRadius() {return  m_ShieldBackRadius;};
+std::string NPL::DetectorManager::GetShieldMaterial() {return  m_ShieldMaterial;};
+std::string NPL::DetectorManager::GetTargetMaterial() {return m_TargetMaterial;};
+double NPL::DetectorManager::GetWindowsThickness() {return m_WindowsThickness;};
+std::string NPL::DetectorManager::GetWindowsMaterial() {return m_WindowsMaterial;};
+double NPL::DetectorManager::GetTargetRadius() {return m_TargetRadius;};
+double NPL::DetectorManager::GetTargetAngle() {return m_TargetAngle;};
+double NPL::DetectorManager::GetTargetX() {return m_TargetX;};
+double NPL::DetectorManager::GetTargetY() {return m_TargetY;};
+double NPL::DetectorManager::GetTargetZ() {return m_TargetZ;}; 
+
 
diff --git a/NPLib/Core/NPDetectorManager.h b/NPLib/Core/NPDetectorManager.h
index 980989f68..a838c9ee3 100644
--- a/NPLib/Core/NPDetectorManager.h
+++ b/NPLib/Core/NPDetectorManager.h
@@ -30,6 +30,7 @@
 #include <string>
 #include <map>
 #include <vector>
+#include <iostream>
 #if __cplusplus > 199711L 
 #include <thread>
 #include <mutex>
@@ -93,7 +94,6 @@ namespace NPL{
 #endif
 
     private: // Target property
-     
       double m_TargetThickness;
       double m_TargetAngle;
       double m_TargetRadius;
@@ -125,49 +125,43 @@ namespace NPL{
       double      m_ShieldFrontRadius; 
       double      m_ShieldBackRadius;
       std::string m_ShieldMaterial;
-
-    public:
-      inline bool IsCryogenic(){return m_CryoTarget;};
-      inline double GetTargetThickness      () {return m_TargetThickness;}
-      inline double GetTargetDensity      () {return  m_TargetDensity;}
-      inline double GetFrontDeformation   () {return  m_FrontDeformation;}
-      inline double GetFrontThickness     () {return  m_FrontThickness;}
-      inline double GetFrontRadius        () {return  m_FrontRadius;}
-      inline std::string GetFrontMaterial      () {return  m_FrontMaterial;}
-      inline double GetBackDeformation    () {return  m_BackDeformation;}
-      inline double GetBackRadius         () {return  m_BackRadius;}
-      inline double GetBackThickness      () {return  m_BackThickness;}
-      inline std::string GetBackMaterial       () {return  m_BackMaterial;}
-      inline double GetFrameRadius        () {return  m_FrameRadius;}
-      inline double GetFrameThickness     () {return  m_FrameThickness;}
-      inline double GetFrontCone          () {return  m_FrontCone;}
-      inline double GetBackCone           () {return  m_BackCone;}
-      inline std::string GetFrameMaterial      () {return  m_FrameMaterial;}
-      inline double GetShieldInnerRadius  () {return  m_ShieldInnerRadius;}
-      inline double GetShieldOuterRadius  () {return  m_ShieldOuterRadius;}
-      inline double GetShieldBottomLength () {return  m_ShieldBottomLength;}
-      inline double GetShieldTopLength    () {return  m_ShieldTopLength;}
-      inline double GetShieldFrontRadius  () {return  m_ShieldFrontRadius;} 
-      inline double GetShieldBackRadius   () {return  m_ShieldBackRadius;}
-      inline std::string GetShieldMaterial     () {return  m_ShieldMaterial;}
-
-      double m_WindowsThickness;
+      double      m_WindowsThickness;
       std::string m_WindowsMaterial;
-  
+ 
+    public: // those are define in cxx, otherwise the return value depend on context !?
+      bool IsCryogenic(); // {return  m_CryoTarget;};
+      double GetTargetThickness(); // {return m_TargetThickness;};
+      double GetNominalTargetThickness(); // {return  m_TargetThickness;};
+      double GetTargetDensity(); // {return  m_TargetDensity;};
+      double GetFrontDeformation(); // {return  m_FrontDeformation;};
+      double GetFrontThickness(); // {return  m_FrontThickness;};
+      double GetFrontRadius(); // {return  m_FrontRadius;};
+      std::string GetFrontMaterial(); // {return  m_FrontMaterial;};
+      double GetBackDeformation(); // {return  m_BackDeformation;};
+      double GetBackRadius(); // {return  m_BackRadius;};
+      double GetBackThickness(); // {return  m_BackThickness;};
+      std::string GetBackMaterial(); // {return  m_BackMaterial;};
+      double GetFrameRadius(); // {return  m_FrameRadius;};
+      double GetFrameThickness(); // {return  m_FrameThickness;};
+      double GetFrontCone(); // {return  m_FrontCone;};
+      double GetBackCone(); // {return  m_BackCone;};
+      std::string GetFrameMaterial(); // {return  m_FrameMaterial;};
+      double GetShieldInnerRadius(); // {return  m_ShieldInnerRadius;};
+      double GetShieldOuterRadius(); // {return  m_ShieldOuterRadius;};
+      double GetShieldBottomLength(); // {return  m_ShieldBottomLength;};
+      double GetShieldTopLength(); // {return  m_ShieldTopLength;};
+      double GetShieldFrontRadius(); // {return  m_ShieldFrontRadius;}; 
+      double GetShieldBackRadius(); // {return  m_ShieldBackRadius;};
+      std::string GetShieldMaterial(); // {return  m_ShieldMaterial;};
+      std::string GetTargetMaterial(); // {return m_TargetMaterial;};
+      double GetWindowsThickness(); // {return m_WindowsThickness;};
+      std::string GetWindowsMaterial(); // {return m_WindowsMaterial;};
+      double GetTargetRadius(); // {return m_TargetRadius;};
+      double GetTargetAngle(); // {return m_TargetAngle;};
+      double GetTargetX(); // {return m_TargetX;};
+      double GetTargetY(); // {return m_TargetY;};
+      double GetTargetZ(); // {return m_TargetZ;}; 
 
-      // Special treatment for the target for the moment
-      // If necessary we should change it to treat it as 
-      // a full "detector"
-
-    public:
-      std::string GetTargetMaterial()   {return m_TargetMaterial;}
-      double GetWindowsThickness()      {return m_WindowsThickness;}
-      std::string GetWindowsMaterial()  {return m_WindowsMaterial;}
-      double GetTargetRadius()          {return m_TargetRadius;}
-      double GetTargetAngle()           {return m_TargetAngle;}
-      double GetTargetX()               {return m_TargetX;}
-      double GetTargetY()               {return m_TargetY;}
-      double GetTargetZ()               {return m_TargetZ;} 
   };
 }
 
diff --git a/NPLib/Core/NPVAnalysis.cxx b/NPLib/Core/NPVAnalysis.cxx
index 21a27ab7d..da0821e5d 100644
--- a/NPLib/Core/NPVAnalysis.cxx
+++ b/NPLib/Core/NPVAnalysis.cxx
@@ -27,7 +27,3 @@ NPL::VAnalysis::VAnalysis(){
 ////////////////////////////////////////////////////////////////////////////////
 NPL::VAnalysis::~VAnalysis(){
 }
-////////////////////////////////////////////////////////////////////////////////
-void NPL::VAnalysis::SetDetectorManager(NPL::DetectorManager* det){
-  m_DetectorManager = det;
-}
diff --git a/NPLib/Core/NPVAnalysis.h b/NPLib/Core/NPVAnalysis.h
index dfba20149..b7a0b753e 100644
--- a/NPLib/Core/NPVAnalysis.h
+++ b/NPLib/Core/NPVAnalysis.h
@@ -10,7 +10,7 @@
 /*****************************************************************************
  * Original Author: Adrien MATTA  contact address: a.matta@surrey.ac.uk      *
  *                                                                           *
- * Creation Date  : march 2025                                               *
+ * Creation Date  : march 2015                                               *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
@@ -33,9 +33,8 @@ namespace NPL{
       virtual void TreatEvent(){};
       virtual void Init(){};
       virtual void End(){};
-      
-      void SetDetectorManager(NPL::DetectorManager*);
-
+      void SetDetectorManager(NPL::DetectorManager* det ) {m_DetectorManager=det;}
+    
     protected:
       NPL::DetectorManager* m_DetectorManager;
   };
diff --git a/NPLib/Detectors/CATS/TCATSPhysics.cxx b/NPLib/Detectors/CATS/TCATSPhysics.cxx
index 68181d8b0..0b7af5eee 100644
--- a/NPLib/Detectors/CATS/TCATSPhysics.cxx
+++ b/NPLib/Detectors/CATS/TCATSPhysics.cxx
@@ -109,7 +109,7 @@ void TCATSPhysics::BuildSimplePhysicalEvent(){
 
 //////////////////////////////////////////////////////////////////////////////		
 void TCATSPhysics::BuildPhysicalEvent(){
- 
+
 
 
   PreTreat();
@@ -203,9 +203,9 @@ void TCATSPhysics::BuildPhysicalEvent(){
 
   for(unsigned int i  = 0 ; i < NumberOfCATSHit ; i++ ){       
     // Return the position in strip unit
-     // Convention: the collected charge is atrributed to the center of the strip
-     // (histogram convention) so that a reconstructed position for a single strip
-     // goes from strip index -0.5 to strip index +0.5
+    // Convention: the collected charge is atrributed to the center of the strip
+    // (histogram convention) so that a reconstructed position for a single strip
+    // goes from strip index -0.5 to strip index +0.5
     double PosX =  ReconstructionFunctionX[DetMaxX[i]-1](Buffer_X_Q[i],StripMaxX[i]);
     double PosY =  ReconstructionFunctionY[DetMaxY[i]-1](Buffer_Y_Q[i],StripMaxY[i]);
     StripNumberX.push_back(PosX);
@@ -234,7 +234,7 @@ void TCATSPhysics::BuildPhysicalEvent(){
       PositionY.push_back(py0+(py1-py0)*(PosY-sy0));  
       //PositionX.push_back(2.54*(PosX-14));  
       //PositionY.push_back(2.54*(PosY-14));  
-    
+
       PositionZ.push_back(StripPositionZ[DetMaxX[i]-1]);
     }
 
@@ -867,7 +867,7 @@ namespace CATS_LOCAL{
 
 
   ////////////////////////////////////////////////////////////////////////
-  double fCATS_X_Q(const TCATSData* m_EventData , const int i){
+  double fCATS_X_Q(const TCATSData* m_EventData , const int& i){
     static string name; 
     name = "CATS/D" ;
     name+= NPL::itoa( m_EventData->GetCATSDetX(i) ) ;
@@ -876,10 +876,10 @@ namespace CATS_LOCAL{
     name+= "_Q";
     return CalibrationManager::getInstance()->ApplyCalibration( name,   
         m_EventData->GetCATSChargeX(i) + gRandom->Rndm() );
-        //m_EventData->GetCATSChargeX(i) + gRandom->Rndm() - fCATS_Ped_X(m_EventData, i) );
+    //m_EventData->GetCATSChargeX(i) + gRandom->Rndm() - fCATS_Ped_X(m_EventData, i) );
   }
   ////////////////////////////////////////////////////////////////////////
-  double fCATS_Y_Q(const TCATSData* m_EventData , const int i){
+  double fCATS_Y_Q(const TCATSData* m_EventData , const int& i){
     static string name; 
     name = "CATS/D" ;
     name+= NPL::itoa( m_EventData->GetCATSDetY(i) ) ;
@@ -888,10 +888,10 @@ namespace CATS_LOCAL{
     name+= "_Q";
     return CalibrationManager::getInstance()->ApplyCalibration( name ,   
         m_EventData->GetCATSChargeY(i) + gRandom->Rndm() );
-        //m_EventData->GetCATSChargeY(i) + gRandom->Rndm() - fCATS_Ped_Y(m_EventData, i) );
+    //m_EventData->GetCATSChargeY(i) + gRandom->Rndm() - fCATS_Ped_Y(m_EventData, i) );
   }
   ////////////////////////////////////////////////////////////////////////
-  bool fCATS_Threshold_X(const TCATSData* m_EventData , const int i){
+  bool fCATS_Threshold_X(const TCATSData* m_EventData , const int& i){
     static string name; 
     name = "CATS/D" ;
     name+= NPL::itoa( m_EventData->GetCATSDetX(i) ) ;
@@ -901,7 +901,7 @@ namespace CATS_LOCAL{
         m_EventData->GetCATSChargeX(i));
   }
   ////////////////////////////////////////////////////////////////////////
-  bool fCATS_Threshold_Y(const TCATSData* m_EventData , const int i){
+  bool fCATS_Threshold_Y(const TCATSData* m_EventData , const int& i){
     static string name; 
     name ="CATS/D" ;
     name+= NPL::itoa( m_EventData->GetCATSDetY(i) ) ;
@@ -911,7 +911,7 @@ namespace CATS_LOCAL{
         m_EventData->GetCATSChargeY(i));
   }
   ////////////////////////////////////////////////////////////////////////
-  double fCATS_Ped_X(const TCATSData* m_EventData, const int i){
+  double fCATS_Ped_X(const TCATSData* m_EventData, const int& i){
     static string name; 
     name =  "CATS/D" ;
     name+= NPL::itoa( m_EventData->GetCATSDetX(i) ) ;
@@ -920,7 +920,7 @@ namespace CATS_LOCAL{
     return CalibrationManager::getInstance()->GetPedestal(name);
   }
   ////////////////////////////////////////////////////////////////////////
-  double fCATS_Ped_Y(const TCATSData* m_EventData, const int i){
+  double fCATS_Ped_Y(const TCATSData* m_EventData, const int& i){
     static string name; 
     name = "CATS/D" ;
     name+= NPL::itoa( m_EventData->GetCATSDetY(i) ) ;
@@ -941,14 +941,14 @@ NPL::VDetector* TCATSPhysics::Construct(){
 //            Registering the construct method to the factory                 //
 ////////////////////////////////////////////////////////////////////////////////
 extern "C"{
-class proxy_cats{
-  public:
-    proxy_cats(){
-      NPL::DetectorFactory::getInstance()->AddToken("CATSDetector","CATS");
-      NPL::DetectorFactory::getInstance()->AddDetector("CATSDetector",TCATSPhysics::Construct);
-    }
-};
+  class proxy_cats{
+    public:
+      proxy_cats(){
+        NPL::DetectorFactory::getInstance()->AddToken("CATSDetector","CATS");
+        NPL::DetectorFactory::getInstance()->AddDetector("CATSDetector",TCATSPhysics::Construct);
+      }
+  };
 
-proxy_cats p;
+  proxy_cats p;
 }
 
diff --git a/NPLib/Physics/TReactionConditions.h b/NPLib/Physics/TReactionConditions.h
index 4cd451b1a..2a6769cce 100644
--- a/NPLib/Physics/TReactionConditions.h
+++ b/NPLib/Physics/TReactionConditions.h
@@ -100,10 +100,10 @@ public:
     
     /////////////////////           GETTERS           ////////////////////////
     // Beam parameter
-    string GetBeamParticleName   () const  {return fRC_Beam_Particle_Name   ;}//!
-    double GetBeamReactionEnergy  () const  {return fRC_Beam_Reaction_Energy  ;}//!
-    double GetBeamEmittanceTheta () const  {return fRC_Beam_Emittance_Theta ;}//!
-    double GetBeamEmittancePhi   () const  {return fRC_Beam_Emittance_Phi   ;}//!
+    string GetBeamParticleName    () const  {return fRC_Beam_Particle_Name   ;}//!
+    double GetBeamEnergy          () const  {return fRC_Beam_Reaction_Energy  ;}//!
+    double GetBeamEmittanceTheta  () const  {return fRC_Beam_Emittance_Theta ;}//!
+    double GetBeamEmittancePhi    () const  {return fRC_Beam_Emittance_Phi   ;}//!
     double GetBeamEmittanceThetaX () const  {return fRC_Beam_Emittance_ThetaX ;}//!
     double GetBeamEmittancePhiY   () const  {return fRC_Beam_Emittance_PhiY   ;}//!
     
diff --git a/NPLib/Utility/npanalysis.cxx b/NPLib/Utility/npanalysis.cxx
index d5cb6126c..9ad671f30 100644
--- a/NPLib/Utility/npanalysis.cxx
+++ b/NPLib/Utility/npanalysis.cxx
@@ -55,7 +55,7 @@ int main(int argc , char** argv){
   }
 
   // Case of a Physics tree produced
-  else if(!myOptionManager->GetInputPhysicalTreeOption()){ //
+  else if(!myOptionManager->GetInputPhysicalTreeOption()){ 
     TreeName="PhysicsTree";
     if(myOptionManager->IsDefault("OutputFileName"))
       OutputfileName="PhysicsTree";
@@ -85,7 +85,7 @@ int main(int argc , char** argv){
     UserAnalysis = NPL::AnalysisFactory::getInstance()->Construct(); 
     UserAnalysis->SetDetectorManager(myDetector);
     UserAnalysis->Init();
-  }
+  } 
   else{
     std::string str_error=error;
     if(str_error.find("image not found")!=std::string::npos ||str_error.find("No such file or directory")!=std::string::npos )
diff --git a/NPSimulation/Core/CMakeLists.txt b/NPSimulation/Core/CMakeLists.txt
index 95ea8b3b4..9ac5b1c90 100644
--- a/NPSimulation/Core/CMakeLists.txt
+++ b/NPSimulation/Core/CMakeLists.txt
@@ -1,2 +1,2 @@
 add_library(NPSCore SHARED $<TARGET_OBJECTS:NPSEventGenerator> EventAction.cc PrimaryGeneratorAction.cc Target.cc Chamber.cc PrimaryGeneratorActionMessenger.cc NPSVDetector.cc DetectorConstruction.cc MaterialManager.cc DetectorMessenger.cc MyMagneticField.cc  SteppingVerbose.cc NPSDetectorFactory.cc RunAction.cc Particle.cc ParticleStack.cc)
-target_link_libraries(NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} NPSScorers NPInitialConditions NPInteractionCoordinates )
+target_link_libraries(NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} NPSScorers NPSProcess NPInitialConditions NPInteractionCoordinates )
-- 
GitLab