From 8eb8e7c0b340334ba328165767ea876e976f0b34 Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Fri, 13 Nov 2020 09:08:40 +0100
Subject: [PATCH] * progress on eAGanil

---
 NPSimulation/Detectors/eAGanil/eAGanil.cc |  4 +-
 Projects/eAGanil/Analysis.cxx             | 55 ++++++++++++++++++++---
 Projects/eAGanil/Analysis.h               | 22 ++++++---
 Projects/eAGanil/Sn132.reac               |  4 +-
 Projects/eAGanil/eAGanil.detector         |  8 ++--
 5 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/NPSimulation/Detectors/eAGanil/eAGanil.cc b/NPSimulation/Detectors/eAGanil/eAGanil.cc
index 114a2e29f..c3a5e47ae 100644
--- a/NPSimulation/Detectors/eAGanil/eAGanil.cc
+++ b/NPSimulation/Detectors/eAGanil/eAGanil.cc
@@ -158,7 +158,7 @@ void eAGanil::ReadConfiguration(NPL::InputParser parser){
   if(NPOptionManager::getInstance()->GetVerboseLevel())
     cout << "//// " << blocks.size() << " detectors found " << endl; 
 
-  vector<string> sphe = {"R","Theta","Phi","EntranceWidth","EntranceHeigh","MomentumResolution"};
+  vector<string> sphe = {"R","Theta","Phi","EntranceWidth","EntranceHeight","MomentumResolution"};
 
   for(unsigned int i = 0 ; i < blocks.size() ; i++){
     if(blocks[i]->HasTokenList(sphe)){
@@ -168,7 +168,7 @@ void eAGanil::ReadConfiguration(NPL::InputParser parser){
       double Theta = blocks[i]->GetDouble("Theta","deg");
       double Phi = blocks[i]->GetDouble("Phi","deg");
       double EW = blocks[i]->GetDouble("EntranceWidth","cm");
-      double EH = blocks[i]->GetDouble("EntranceHeigh","cm");
+      double EH = blocks[i]->GetDouble("EntranceHeight","cm");
       double MR = blocks[i]->GetDouble("MomentumResolution","void"); 
       AddDetector(R,Theta,Phi,EW,EH,MR);
     }
diff --git a/Projects/eAGanil/Analysis.cxx b/Projects/eAGanil/Analysis.cxx
index 39077081a..852913403 100644
--- a/Projects/eAGanil/Analysis.cxx
+++ b/Projects/eAGanil/Analysis.cxx
@@ -1,18 +1,18 @@
 /*****************************************************************************
- * Copyright (C) 2009-2016    this file is part of the NPTool Project        *
+ * Copyright (C) 2009-2020    this file is part of the NPTool Project        *
  *                                                                           *
  * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
  * For the list of contributors see $NPTOOL/Licence/Contributors             *
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: XAUTHORX  contact address: XMAILX                        *
+ * Original Author: Adriment Matta contact address: matta@lpccaen.in2p3.fr   *
  *                                                                           *
- * Creation Date  : XMONTHX XYEARX                                           *
+ * Creation Date  : Octover 2020                                             *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class describe  eAGanil analysis project                       *
+ *  This class describe  eAGanil analysis project                            *
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
@@ -24,6 +24,14 @@ using namespace std;
 #include"Analysis.h"
 #include"NPAnalysisFactory.h"
 #include"NPDetectorManager.h"
+#include"NPOptionManager.h"
+#include"NPPhysicalConstants.h"
+#include"NPSystemOfUnits.h"
+#include"NPPhysicalConstants.h"
+using namespace NPUNITS;
+#include"RootInput.h"
+#include"RootOutput.h"
+
 ////////////////////////////////////////////////////////////////////////////////
 Analysis::Analysis(){
 }
@@ -33,11 +41,48 @@ Analysis::~Analysis(){
 
 ////////////////////////////////////////////////////////////////////////////////
 void Analysis::Init(){
-   eAGanil= (TeAGanilPhysicsPhysics*) m_DetectorManager->GetDetector("eAGanil");
+   eAGanil= (TeAGanilPhysics*) m_DetectorManager->GetDetector("eAGanil");
+   Inter = new TInteractionCoordinates();
+   RootInput:: getInstance()->GetChain()->SetBranchAddress("InteractionCoordinates",&Inter);
+   RootInput:: getInstance()->GetChain()->SetBranchAddress("ReactionConditions",&Initial ); 
+   RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex);
+   RootOutput::getInstance()->GetTree()->Branch("ELab",&ELab);
+   RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab);
+   RootOutput::getInstance()->GetTree()->Branch("Detected",&Detected);
+   RootOutput::getInstance()->GetTree()->Branch("Resolution",&Resolution);
+   m_reaction.ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile());
+   Resolution={5e-2,1e-2,5e-3,1e-3,5e-4,1e-4,5e-5,1e-5,5e-6,1e-6};
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Analysis::TreatEvent(){
+  Ex.clear(); ELab.clear(); ThetaLab.clear(); Detected.clear();
+  // Get the generated values
+  double Energy = Initial->GetKineticEnergy(0); 
+  double Theta = Initial->GetParticleDirection(0).Angle(TVector3(0,0,1));
+  unsigned int sizeR = Resolution.size();
+ for(unsigned int i = 0 ; i < sizeR ; i++){
+  
+  double E = Rand.Gaus(Energy,Energy*Resolution[i]);
+  //double E = Rand.Gaus(Energy,Energy*1e-4);
+  //double T = Rand.Gaus(Theta,Theta*Resolution[i]);
+   double ExO = m_reaction.ReconstructRelativistic(E,Theta);
+  //double ExO = m_reaction.ReconstructRelativistic(Energy,T);
+  Ex.push_back(ExO);
+  ThetaLab.push_back(Theta/deg);
+  ELab.push_back(E);
+  if(Inter->GetDetectedMultiplicity())
+    Detected.push_back(1);
+  else
+    Detected.push_back(0);
+  } 
+ /* static double m2 = electron_mass_c2*electron_mass_c2;
+  static double m = electron_mass_c2;
+    // Momentum in MeV.c
+    double q = sqrt((Energy+m)*(Energy+m)-m2);
+    q = Rand.Gaus(q,q*1e-4);
+    ELab = sqrt(q*q+m2)-m;
+    */
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/Projects/eAGanil/Analysis.h b/Projects/eAGanil/Analysis.h
index 744bf0cdf..fc1c6f99d 100644
--- a/Projects/eAGanil/Analysis.h
+++ b/Projects/eAGanil/Analysis.h
@@ -1,20 +1,20 @@
 #ifndef Analysis_h 
 #define Analysis_h
 /*****************************************************************************
- * Copyright (C) 2009-2016    this file is part of the NPTool Project        *
+ * Copyright (C) 2009-2020    this file is part of the NPTool Project        *
  *                                                                           *
  * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
  * For the list of contributors see $NPTOOL/Licence/Contributors             *
  *****************************************************************************/
 
 /*****************************************************************************
- * Original Author: XAUTHORX  contact address: XMAILX                        *
+ * Original Author: Adriment Matta contact address: matta@lpccaen.in2p3.fr   *
  *                                                                           *
- * Creation Date  : XMONTHX XYEARX                                           *
+ * Creation Date  : Octover 2020                                             *
  * Last update    :                                                          *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class describe  eAGanil analysis project                       *
+ *  This class describe  eAGanil analysis project                            *
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
@@ -23,6 +23,12 @@
 
 #include"NPVAnalysis.h"
 #include"TeAGanilPhysics.h"
+#include"TInteractionCoordinates.h"
+#include"TReactionConditions.h"
+#include"TRandom3.h"
+#include"NPReaction.h"
+#include<vector>
+using namespace std;
 class Analysis: public NPL::VAnalysis{
   public:
     Analysis();
@@ -35,8 +41,14 @@ class Analysis: public NPL::VAnalysis{
 
    static NPL::VAnalysis* Construct();
 
+  private:
+   TRandom3 Rand; 
+   NPL::Reaction m_reaction;
+   vector<double> Ex,ELab,ThetaLab,Resolution;
+   vector<int> Detected;
   private:
    TeAGanilPhysics* eAGanil;
-
+   TInteractionCoordinates* Inter;   
+   TReactionConditions* Initial;   
 };
 #endif
diff --git a/Projects/eAGanil/Sn132.reac b/Projects/eAGanil/Sn132.reac
index c6a3c3d91..a567b5ec2 100755
--- a/Projects/eAGanil/Sn132.reac
+++ b/Projects/eAGanil/Sn132.reac
@@ -2,7 +2,7 @@
 Beam
   Particle= electron
   Energy= 500 MeV
-  SigmaEnergy= 0 MeV
+  SigmaEnergy= 0.25 MeV
   SigmaThetaX= 0.1 deg
   SigmaPhiY= 0.1 deg
   SigmaX= 0.1 mm
@@ -20,7 +20,7 @@ TwoBodyReaction
  Heavy= 132Sn
  ExcitationEnergy3= 0.0 MeV
  ExcitationEnergy4= 0.0 MeV
- CrossSectionPath= mott.txt Mott
+ CrossSectionPath= flat.txt Mott
  ShootLight= 1
  ShootHeavy= 1
   
diff --git a/Projects/eAGanil/eAGanil.detector b/Projects/eAGanil/eAGanil.detector
index 0633fb6ea..26afdedbe 100644
--- a/Projects/eAGanil/eAGanil.detector
+++ b/Projects/eAGanil/eAGanil.detector
@@ -29,7 +29,7 @@ eAGanil Spectrometer
  Theta= 90 deg
  Phi= 0 deg
  EntranceWidth= 900 mm
- EntranceHeigh= 200 mm
+ EntranceHeight= 200 mm
  MomentumResolution= 0.0001
  
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -38,7 +38,7 @@ eAGanil Spectrometer
  Theta= 20 deg
  Phi= 0 deg
  EntranceWidth= 50 cm
- EntranceHeigh= 30 cm
+ EntranceHeight= 30 cm
  MomentumResolution= 0.0001
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -47,7 +47,7 @@ eAGanil Spectrometer
  Theta= -90 deg
  Phi= 0 deg
  EntranceWidth= 900 mm
- EntranceHeigh= 200 mm
+ EntranceHeight= 200 mm
  MomentumResolution= 0.0001
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -57,7 +57,7 @@ eAGanil Spectrometer
  Theta= 200 deg
  Phi= 0 deg
  EntranceWidth= 50 cm
- EntranceHeigh= 30 cm
+ EntranceHeight= 30 cm
  MomentumResolution= 0.0001
 
 
-- 
GitLab