From c4c49250a89da1dded1e9c888f35a81e5158cf08 Mon Sep 17 00:00:00 2001
From: deserevi <deserevi@nptool>
Date: Thu, 17 Sep 2009 14:31:48 +0000
Subject: [PATCH] * The detector from the Target class is now a private member
 of the   EventGeneratorXXX classes instead of part of its own private members

* Update of the TODO file
---
 NPSimulation/include/DetectorConstruction.hh  |  21 +--
 NPSimulation/include/EventGeneratorBeam.hh    |  61 +++----
 .../include/EventGeneratorTransfert.hh        | 167 ++++++++----------
 .../EventGeneratorTransfertToResonance.hh     |  27 +--
 NPSimulation/include/VEventGenerator.hh       |   4 +
 NPSimulation/src/DetectorConstruction.cc      |  26 ++-
 NPSimulation/src/EventGeneratorBeam.cc        |  31 ++--
 NPSimulation/src/EventGeneratorTransfert.cc   |  96 +++++-----
 .../src/EventGeneratorTransfertToResonance.cc |  21 ++-
 NPSimulation/src/PrimaryGeneratorAction.cc    |  33 ++--
 TODO                                          |  23 +--
 11 files changed, 231 insertions(+), 279 deletions(-)

diff --git a/NPSimulation/include/DetectorConstruction.hh b/NPSimulation/include/DetectorConstruction.hh
index e59a3ea18..8a65ee3ab 100644
--- a/NPSimulation/include/DetectorConstruction.hh
+++ b/NPSimulation/include/DetectorConstruction.hh
@@ -36,6 +36,7 @@ class G4VPhysicalVolume;
 
 // NPTool headers
 #include "VDetector.hh"
+#include "Target.hh"
 
 // ROOT headers
 #include "TTree.h"
@@ -58,30 +59,20 @@ public:
 
 private:
    // Logical volumes
-   G4LogicalVolume* world_log      ;
+   G4LogicalVolume* world_log;
 
    // Physical volumes
-   G4VPhysicalVolume* world_phys   ;
+   G4VPhysicalVolume* world_phys;
 
    // Virtual Detector Vector
-   vector<VDetector*> m_Detectors   ;
+   vector<VDetector*> m_Detectors;
 
 
 private: // Data about the target
-   G4double m_TargetThickness ;
-   G4double m_TargetRadius    ;
-   G4double m_TargetAngle     ;
-   G4double m_TargetX         ;
-   G4double m_TargetY         ;
-   G4double m_TargetZ         ;
+   Target*  m_Target;
 
 public:  // Getter and Setter
-   G4double GetTargetThickness()	{return m_TargetThickness;}
-   G4double GetTargetRadius()    	{return m_TargetRadius;}
-   G4double GetTargetAngle()    	{return m_TargetAngle;}
-   G4double GetTargetX() 		{return m_TargetX;}
-   G4double GetTargetY() 		{return m_TargetY;}
-   G4double GetTargetZ() 		{return m_TargetZ;}
+   Target*  GetTarget()		{return m_Target;}
 };
 
 #endif
diff --git a/NPSimulation/include/EventGeneratorBeam.hh b/NPSimulation/include/EventGeneratorBeam.hh
index 0576110df..04e2cd742 100644
--- a/NPSimulation/include/EventGeneratorBeam.hh
+++ b/NPSimulation/include/EventGeneratorBeam.hh
@@ -32,6 +32,7 @@
 // NPTool header
 #include "VEventGenerator.hh"
 #include "TInitialConditions.h"
+#include "Target.hh"
 
 using namespace std  ;
 
@@ -39,43 +40,33 @@ using namespace std  ;
 
 class EventGeneratorBeam : public VEventGenerator
 {
-	public:     // Constructor and destructor
-	   EventGeneratorBeam()   ;
-	   virtual ~EventGeneratorBeam()   ;
+public:     // Constructor and destructor
+   EventGeneratorBeam();
+   virtual ~EventGeneratorBeam();
+
+
+public:     // Inherit from VEventGenerator Class
+   void ReadConfiguration(string);
+   void GenerateEvent(G4Event*, G4ParticleGun*);
+   void InitializeRootOutput();
+
+   void SetTarget(Target* Target) {m_Target = Target;}
+
+
+private: // TTree to store initial value of beam and reaction
+   TInitialConditions*	m_InitConditions;
 
-	public:     // Inherit from VEventGenerator Class
-	   void  ReadConfiguration(string)           ;
-	   void  GenerateEvent(G4Event*, G4ParticleGun*) ;
-	   void  InitializeRootOutput()  ;
-	   void  SetTargetThickness(double TargetThickness)            {
-	      m_TargetThickness = TargetThickness     ;
-	   }
-	   void  SetTargetRadius(double TargetRadius)               {
-	      m_TargetRadius    = TargetRadius        ;
-	   }
-	   void  SetTargetCoordinate(G4double X, G4double Y, G4double Z)  {
-	      m_TargetX = X ;
-	      m_TargetY = Y ;
-	      m_TargetZ = Z ;
-	   }
-		
-		private: // TTree to store initial value of beam and reaction
-		   TInitialConditions*	m_InitConditions;
 		   
-	private: // Source parameter
-	   G4ParticleDefinition*   m_particle        ;  // Kind of particle to shoot
-	   G4double             m_BeamEnergy      ;
-	   G4double             m_BeamEnergySpread   ;
-	   G4double             m_SigmaX       ;
-	   G4double             m_SigmaY       ;
-	   G4double             m_SigmaThetaX     ;
-	   G4double				m_SigmaPhiY		;
+private: // Source parameter
+   G4ParticleDefinition*	m_particle;  // Kind of particle to shoot
+   G4double			m_BeamEnergy;
+   G4double			m_BeamEnergySpread;
+   G4double			m_SigmaX;
+   G4double			m_SigmaY;
+   G4double			m_SigmaThetaX;
+   G4double			m_SigmaPhiY;
 
-	private: // Target Value
-	   G4double             m_TargetThickness ;
-	   G4double             m_TargetRadius    ;
-	   G4double             m_TargetX         ;
-	   G4double          m_TargetY         ;
-	   G4double          m_TargetZ         ;
+private: // Target Value
+   Target* m_Target;
 };
 #endif
diff --git a/NPSimulation/include/EventGeneratorTransfert.hh b/NPSimulation/include/EventGeneratorTransfert.hh
index 88072ee35..dde7b3f2d 100644
--- a/NPSimulation/include/EventGeneratorTransfert.hh
+++ b/NPSimulation/include/EventGeneratorTransfert.hh
@@ -28,6 +28,7 @@
 
 // NPSimulation
 #include "VEventGenerator.hh"
+#include "Target.hh"
 
 // NPLib
 #include "TInitialConditions.h"
@@ -40,97 +41,81 @@ using namespace NPL ;
 
 
 class EventGeneratorTransfert : public VEventGenerator
-	{
-
-		public:     // Constructors and Destructors
-		   // Default constructor used to allocate memory
-		   EventGeneratorTransfert();
-
-		   // This is the constructor to be used
-		   EventGeneratorTransfert(string name1             ,        // Beam nuclei
-		             string name2             ,        // Target nuclei
-		             string name3             ,        // Product of reaction
-		             string name4             ,        // Product of reaction
-		             double BeamEnergy        ,        // Beam Energy
-		             double ExcitationEnergy  ,        // Excitation of Heavy Nuclei
-		             double BeamEnergySpread  ,
-		             double SigmaX         ,
-		             double SigmaY         ,
-		             double SigmaThetaX       ,
-		             double SigmaPhiY  ,
-		             bool   ShootLight        ,
-		             bool   ShootHeavy        ,
-		             string Path);                     // Path of the differentiel Cross Section
-
-		   // Default Destructor
-		   virtual ~EventGeneratorTransfert();
-
-
-		public:     // Inherit from VEventGenerator class
-		   void        ReadConfiguration(string)              ;
-		   void        GenerateEvent(G4Event*, G4ParticleGun*)       ;
-
-		   void        SetTargetCoordinate(G4double X, G4double Y, G4double Z) {
-																			      m_TargetX = X;
-																			      m_TargetY = Y;
-																			      m_TargetZ = Z;
-																			   }
-
-		   void        SetTargetThickness(double TargetThickness) {
-																      m_TargetThickness = TargetThickness ;
-																   }
-
-		   void        SetTargetRadius(double TargetRadius) {
-															   m_TargetRadius    = TargetRadius    ;
-															}
-		   void        SetTargetAngle(double TargetAngle) {
-															   m_TargetAngle    = TargetAngle    ;
-															}
-
-		private: // Particle Shoot Option
-		   bool        m_ShootLight   ;
-		   bool        m_ShootHeavy   ;
-
-		private: // TTree to store initial value of beam and reaction
-		   TInitialConditions*	m_InitConditions;
-
-		private: // Beam Parameter
-		   double         m_BeamEnergy ;
-		   double         m_BeamEnergySpread ;
-		   double         m_SigmaX        ;
-		   double         m_SigmaY        ;
-		   double         m_SigmaThetaX      ;
-		   double         m_SigmaPhiY      ;
-
-		private: // Target Parameter
-		   double         m_TargetThickness ;
-		   double         m_TargetRadius    ;
-		   double         m_TargetAngle     ;
-		   double         m_TargetX         ;
-		   double         m_TargetY         ;
-		   double         m_TargetZ         ;
-
-		private: // Reaction and CrossSection Shoot
-			Reaction*	m_Reaction			;
-		
-	   //Other
-	   void     Print() const  ;
-	   void            InitializeRootOutput();
-
-	   void     SetEverything(string name1             ,        // Beam nuclei
-		             string name2             ,        // Target nuclei
-		             string name3             ,        // Product of reaction
-		             string name4             ,        // Product of reaction
-		             double BeamEnergy        ,        // Beam Energy
-		             double ExcitationEnergy  ,        // Excitation of Heavy Nuclei
-		             double BeamEnergySpread  ,
-		             double SigmaX         ,
-		             double SigmaY         ,
-		             double SigmaThetaX       ,
-		             double SigmaPhiY  ,
-		             bool   ShootLight        ,
-		             bool   ShootHeavy        ,
-		             string Path);                     // Path of the differentiel Cross Section
+{
+public:     // Constructors and Destructors
+   // Default constructor used to allocate memory
+   EventGeneratorTransfert();
+
+   // This is the constructor to be used
+   EventGeneratorTransfert(string name1             ,        // Beam nuclei
+                           string name2             ,        // Target nuclei
+                           string name3             ,        // Product of reaction
+                           string name4             ,        // Product of reaction
+                           double BeamEnergy        ,        // Beam Energy
+                           double ExcitationEnergy  ,        // Excitation of Heavy Nuclei
+                           double BeamEnergySpread  ,
+                           double SigmaX            ,
+                           double SigmaY            ,
+                           double SigmaThetaX       ,
+                           double SigmaPhiY         ,
+                           bool   ShootLight        ,
+                           bool   ShootHeavy        ,
+                           string Path);                     // Path of the differentiel Cross Section
+
+   // Default Destructor
+   virtual ~EventGeneratorTransfert();
+
+
+public: // Inherit from VEventGenerator class
+   void        ReadConfiguration(string);
+   void        GenerateEvent(G4Event*, G4ParticleGun*);
+   void	       SetTarget(Target* Target) {m_Target = Target;}
+
+
+private: // Particle Shoot Option
+   bool        m_ShootLight;
+   bool        m_ShootHeavy;
+
+
+private: // Target Parameter
+   Target*     m_Target;
+
+
+private: // Reaction and CrossSection Shoot
+   Reaction*   m_Reaction;
+
+
+private: // Beam Parameters
+   double      m_BeamEnergy;
+   double      m_BeamEnergySpread;
+   double      m_SigmaX;
+   double      m_SigmaY;
+   double      m_SigmaThetaX;
+   double      m_SigmaPhiY;
+
+
+private: // TTree to store initial value of beam and reaction
+   TInitialConditions*	m_InitConditions;
+
+
+   // Other methods
+   void        Print() const;
+   void        InitializeRootOutput();
+
+   void        SetEverything(string name1             ,        // Beam nuclei
+	                     string name2             ,        // Target nuclei
+	                     string name3             ,        // Product of reaction
+	                     string name4             ,        // Product of reaction
+	                     double BeamEnergy        ,        // Beam Energy
+	                     double ExcitationEnergy  ,        // Excitation of Heavy Nuclei
+	                     double BeamEnergySpread  ,
+	                     double SigmaX            ,
+	                     double SigmaY            ,
+	                     double SigmaThetaX       ,
+	                     double SigmaPhiY         ,
+	                     bool   ShootLight        ,
+	                     bool   ShootHeavy        ,
+	                     string Path);                     // Path of the differentiel Cross Section
 };
 
 #endif
diff --git a/NPSimulation/include/EventGeneratorTransfertToResonance.hh b/NPSimulation/include/EventGeneratorTransfertToResonance.hh
index 51d85928d..ee5e3a223 100644
--- a/NPSimulation/include/EventGeneratorTransfertToResonance.hh
+++ b/NPSimulation/include/EventGeneratorTransfertToResonance.hh
@@ -16,11 +16,11 @@
  * Decription:                                                               *
  *  This event Generator is used to simulated two body TransfertReaction.    *
  *  A Phase Space calculation is then performed to decay the Heavy product.  *
- *	The TGenPhaseSpace from ROOT is used to calculate a phase space decay    *
- *	with flat distribution	                                                 *
+ *  The TGenPhaseSpace from ROOT is used to calculate a phase space decay    *
+ *  with flat distribution	                                             *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
- *   									                                     *
+ *   					                                     *
  *                                                                           *
  *****************************************************************************/
 // C++ header
@@ -28,6 +28,7 @@
 
 // NPSimulation
 #include "VEventGenerator.hh"
+#include "Target.hh"
 
 // NPLib
 #include "TInitialConditions.h"
@@ -74,19 +75,7 @@ class EventGeneratorTransfertToResonance : public VEventGenerator
 	   void        ReadConfiguration(string)              ;
 	   void        GenerateEvent(G4Event*, G4ParticleGun*)       ;
 
-	   void        SetTargetCoordinate(G4double X, G4double Y, G4double Z) {
-	      m_TargetX = X;
-	      m_TargetY = Y;
-	      m_TargetZ = Z;
-	   }
-
-	   void        SetTargetThickness(double TargetThickness) {
-	      m_TargetThickness = TargetThickness ;
-	   }
-
-	   void        SetTargetRadius(double TargetRadius) {
-	      m_TargetRadius    = TargetRadius    ;
-	   }
+           void        SetTarget(Target* Target) {m_Target = Target;}
 
 	private: // Particle Shoot Option
 	   bool        m_ShootLight         ;
@@ -105,11 +94,7 @@ class EventGeneratorTransfertToResonance : public VEventGenerator
 	   double         m_SigmaPhiY        ;
 
 	private: // Target Parameter
-	   double         m_TargetThickness    ;
-	   double         m_TargetRadius       ;
-	   double         m_TargetX            ;
-	   double         m_TargetY            ;
-	   double         m_TargetZ            ;
+           Target*        m_Target;
 
 	private: // Reaction
 		Reaction*	m_Reaction				;
diff --git a/NPSimulation/include/VEventGenerator.hh b/NPSimulation/include/VEventGenerator.hh
index b56e5791e..52b4d1497 100644
--- a/NPSimulation/include/VEventGenerator.hh
+++ b/NPSimulation/include/VEventGenerator.hh
@@ -35,6 +35,9 @@
 #include "G4ParticleGun.hh"
 #include "G4Event.hh"
 
+// NPTool headers
+#include "Target.hh"
+
 using namespace CLHEP;
 using namespace std;
 
@@ -52,6 +55,7 @@ public:
    virtual void InitializeRootOutput() {};
 
    // Used in some case to generate event inside the target
+   virtual void SetTarget(Target*) {};
    virtual void SetTargetThickness(G4double) {};
    virtual void SetTargetAngle(G4double) {};
    virtual void SetTargetRadius(G4double) {};
diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc
index 4c8fc67e1..529a01401 100644
--- a/NPSimulation/src/DetectorConstruction.cc
+++ b/NPSimulation/src/DetectorConstruction.cc
@@ -51,14 +51,14 @@
 DetectorConstruction::DetectorConstruction()
       :  world_log(0), world_phys(0)
 {
-   m_TargetRadius    = 0 ;
-   m_TargetThickness = 0 ;
-   m_TargetAngle    = 0 ;
+   m_Target	= 0;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 DetectorConstruction::~DetectorConstruction()
-{}
+{
+   delete m_Target;
+}
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 G4VPhysicalVolume* DetectorConstruction::Construct()
@@ -253,22 +253,18 @@ void DetectorConstruction::ReadConfigurationFile(string Path)
          G4cout << "////////// Target ///////////" << G4endl   << G4endl   ;
 
          // Instantiate the new array as a VDetector Objects
-         VDetector* myDetector = new Target()                     ;
+         VDetector* myDetector = new Target();
 
          // Read Position and target specification
-         ConfigFile.close()                                    ;
-         myDetector->ReadConfiguration(Path)                      ;
-         ConfigFile.open(Path.c_str())                         ;
+         ConfigFile.close();
+         myDetector->ReadConfiguration(Path);
+         ConfigFile.open(Path.c_str());
 
-         m_TargetThickness = ((Target*)myDetector)->GetTargetThickness()   ;
-         m_TargetRadius    = ((Target*)myDetector)->GetTargetRadius()   ;
-         m_TargetAngle     = ((Target*)myDetector)->GetTargetAngle()   ;
-         m_TargetX         = ((Target*)myDetector)->GetTargetX()         ;
-         m_TargetY         = ((Target*)myDetector)->GetTargetY()         ;
-         m_TargetZ         = ((Target*)myDetector)->GetTargetZ()         ;
+         // Add Target to DetectorConstruction
+         m_Target = (Target*) myDetector;
 
          // Add target to the VDetector Vector
-         AddDetector(myDetector)                               ;
+         AddDetector(myDetector);
       }
 
       //Nothing understandable
diff --git a/NPSimulation/src/EventGeneratorBeam.cc b/NPSimulation/src/EventGeneratorBeam.cc
index 80550358d..1b6410dc6 100644
--- a/NPSimulation/src/EventGeneratorBeam.cc
+++ b/NPSimulation/src/EventGeneratorBeam.cc
@@ -37,11 +37,17 @@ using namespace CLHEP;
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 EventGeneratorBeam::EventGeneratorBeam()
 {
-m_InitConditions	= new TInitialConditions()	;
+   m_InitConditions = new TInitialConditions();
+   m_Target         = 0;
 }
+
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 EventGeneratorBeam::~EventGeneratorBeam()
-{}
+{
+   delete m_InitConditions;
+   delete m_Target;
+}
+
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 void EventGeneratorBeam::ReadConfiguration(string Path)
 {
@@ -170,16 +176,21 @@ void EventGeneratorBeam::GenerateEvent(G4Event* anEvent, G4ParticleGun* particle
    // Vertex position and beam angle
    G4double x0 = 1000 * cm  ;
    G4double y0 = 1000 * cm  ;
+   G4double z0 = 0;
    G4double Beam_thetaX = 0  ;
    G4double Beam_phiY   = 0  ;
+   G4double TargetThick = 0;
    
    //shoot inside the target with correlated angle
-   if (m_TargetRadius != 0) 
+   if (m_Target->GetTargetRadius() != 0) 
 	   	{
-	      while (sqrt(x0*x0 + y0*y0) > m_TargetRadius) 
+	      while (sqrt(x0*x0 + y0*y0) > m_Target->GetTargetRadius()) 
 	      	{
 	      		RandomGaussian2D(0 , 0 , m_SigmaX , m_SigmaThetaX , x0 , Beam_thetaX );
 	      		RandomGaussian2D(0 , 0 , m_SigmaY , m_SigmaPhiY   , y0 , Beam_phiY   );
+                        G4double dz = x0 * tan(m_Target->GetTargetAngle());
+                        TargetThick = m_Target->GetTargetThickness() / cos(m_Target->GetTargetAngle());
+                        z0 = dz + (-TargetThick / 2 + RandFlat::shoot() * TargetThick);
 	      	}
 	   	}
 
@@ -187,6 +198,8 @@ void EventGeneratorBeam::GenerateEvent(G4Event* anEvent, G4ParticleGun* particle
 	   	{
 	     	RandomGaussian2D( 0 , 0 , 0 , m_SigmaThetaX , x0 , Beam_thetaX );
 	     	RandomGaussian2D( 0 , 0 , 0 , m_SigmaPhiY   , y0 , Beam_phiY   );
+                TargetThick = m_Target->GetTargetThickness() / cos(m_Target->GetTargetAngle());
+                z0 = (-TargetThick / 2 + RandFlat::shoot() * TargetThick);
 	   	}
 
 	 m_InitConditions->SetICIncidentEmittanceTheta(Beam_thetaX / deg);
@@ -201,14 +214,10 @@ void EventGeneratorBeam::GenerateEvent(G4Event* anEvent, G4ParticleGun* particle
 	G4double Beam_theta = acos ( Zdir / sqrt( Xdir*Xdir + Ydir*Ydir + Zdir*Zdir ) );
 	G4double Beam_phi   = atan2( Ydir , Xdir );
 
-   //must shoot inside the target.
-   G4double z0 = (-m_TargetThickness / 2 + CLHEP::RandFlat::shoot() * m_TargetThickness);
-
-
    // Move to the target
-   x0 += m_TargetX ;
-   y0 += m_TargetY ;
-   z0 += m_TargetZ ;
+   x0 += m_Target->GetTargetX() ;
+   y0 += m_Target->GetTargetY() ;
+   z0 += m_Target->GetTargetZ() ;
    
    // Store initial value
    m_InitConditions->SetICIncidentAngleTheta(Beam_theta / deg);
diff --git a/NPSimulation/src/EventGeneratorTransfert.cc b/NPSimulation/src/EventGeneratorTransfert.cc
index 9b11c9170..a38a7129b 100644
--- a/NPSimulation/src/EventGeneratorTransfert.cc
+++ b/NPSimulation/src/EventGeneratorTransfert.cc
@@ -48,17 +48,18 @@ using namespace CLHEP;
 EventGeneratorTransfert::EventGeneratorTransfert()
 {
    //------------- Default Constructor -------------
-   m_InitConditions	= new TInitialConditions()	;
-   m_Reaction = new Reaction()					;
-
-   m_BeamEnergy       = 0;
-   m_BeamEnergySpread = 0;
-   m_SigmaX        = 0;
-   m_SigmaY        = 0;
-   m_SigmaThetaX      = 0;
-   m_SigmaPhiY=0 ;
-   m_ShootLight       = 0;
-   m_ShootHeavy       = 0;
+   m_InitConditions	= new TInitialConditions();
+   m_Reaction 		= new Reaction();
+   m_Target		= 0;
+
+   m_BeamEnergy		= 0;
+   m_BeamEnergySpread	= 0;
+   m_SigmaX		= 0;
+   m_SigmaY		= 0;
+   m_SigmaThetaX	= 0;
+   m_SigmaPhiY		= 0;
+   m_ShootLight		= 0;
+   m_ShootHeavy		= 0;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -67,6 +68,7 @@ EventGeneratorTransfert::~EventGeneratorTransfert()
    //------------- Default Destructor ------------
    delete m_InitConditions;
    delete m_Reaction;
+   delete m_Target;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -338,28 +340,28 @@ void EventGeneratorTransfert::GenerateEvent(G4Event* anEvent , G4ParticleGun* pa
    G4double Beam_thetaX = 0  	;
    G4double Beam_phiY   = 0  	;
    G4double TargetThick = 0;
-   
+
    // Shoot inside the target with correlated angle
-   if (m_TargetRadius != 0) {
-      while (sqrt(x0*x0 + y0*y0) > m_TargetRadius) {
+   if (m_Target->GetTargetRadius() != 0) {
+      while (sqrt(x0*x0 + y0*y0) > m_Target->GetTargetRadius()) {
          RandomGaussian2D(0, 0, m_SigmaX, m_SigmaThetaX, x0, Beam_thetaX);
          RandomGaussian2D(0, 0, m_SigmaY, m_SigmaPhiY  , y0, Beam_phiY  );
       }
-      G4double dz = x0 * tan(m_TargetAngle);
-      TargetThick = m_TargetThickness / cos(m_TargetAngle);
+      G4double dz = x0 * tan(m_Target->GetTargetAngle());
+      TargetThick = m_Target->GetTargetThickness() / cos(m_Target->GetTargetAngle());
       z0 = dz + (-TargetThick / 2 + RandFlat::shoot() * TargetThick);
    }
    else {
       RandomGaussian2D(0,0,0,m_SigmaThetaX,x0,Beam_thetaX);
       RandomGaussian2D(0,0,0,m_SigmaPhiY  ,y0,Beam_phiY  );
-      TargetThick = m_TargetThickness / cos(m_TargetAngle);
+      TargetThick = m_Target->GetTargetThickness() / cos(m_Target->GetTargetAngle());
       z0 = (-TargetThick / 2 + RandFlat::shoot() * TargetThick);
    }
 
    // Move to the target
-   x0 += m_TargetX ;
-   y0 += m_TargetY ;
-   z0 += m_TargetZ ;
+   x0 += m_Target->GetTargetX() ;
+   y0 += m_Target->GetTargetY() ;
+   z0 += m_Target->GetTargetZ() ;
 
    // write vertex position to ROOT file
    m_InitConditions->SetICPositionX(x0);
@@ -496,36 +498,30 @@ void EventGeneratorTransfert::GenerateEvent(G4Event* anEvent , G4ParticleGun* pa
 
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-void EventGeneratorTransfert::SetEverything(string name1             ,        // Beam nuclei
-		             string name2             ,        // Target nuclei
-		             string name3             ,        // Product of reaction
-		             string name4             ,        // Product of reaction
-		             double BeamEnergy        ,        // Beam Energy
-		             double ExcitationEnergy  ,        // Excitation of Heavy Nuclei
-		             double BeamEnergySpread  ,
-		             double SigmaX         ,
-		             double SigmaY         ,
-		             double SigmaThetaX       ,
-		             double SigmaPhiY  ,
-		             bool   ShootLight        ,
-		             bool   ShootHeavy        ,
-		             string Path) 
+void EventGeneratorTransfert::SetEverything(string name1,		// Beam nuclei
+                                            string name2,		// Target nuclei
+                                            string name3,		// Product of reaction
+                                            string name4,		// Product of reaction
+                                            double BeamEnergy,		// Beam Energy
+                                            double ExcitationEnergy,	// Excitation of Heavy Nuclei
+                                            double BeamEnergySpread,
+                                            double SigmaX,
+                                            double SigmaY,
+                                            double SigmaThetaX,
+                                            double SigmaPhiY,
+                                            bool   ShootLight,
+                                            bool   ShootHeavy,
+                                            string Path) 
 {
-   m_Reaction = new Reaction(	name1					, 
-				name2					,
-	 			name3					,
-	 			name4					,
-				BeamEnergy 				,
-				ExcitationEnergy				,
-				Path 					);	
+   m_Reaction = new Reaction(name1, name2, name3, name4, BeamEnergy, ExcitationEnergy, Path);	
 		
-   m_BeamEnergy       =  BeamEnergy        ;
-   m_BeamEnergySpread =  BeamEnergySpread  ;
-   m_SigmaX        =  SigmaX         ;
-   m_SigmaY        =  SigmaY         ;
-   m_SigmaThetaX      =  SigmaThetaX       ;
-   m_SigmaPhiY      =  SigmaPhiY      ;
-   m_ShootLight       =  ShootLight        ;
-   m_ShootHeavy       =  ShootHeavy        ;
+   m_BeamEnergy       =  BeamEnergy;
+   m_BeamEnergySpread =  BeamEnergySpread;
+   m_SigmaX           =  SigmaX;
+   m_SigmaY           =  SigmaY;
+   m_SigmaThetaX      =  SigmaThetaX;
+   m_SigmaPhiY        =  SigmaPhiY;
+   m_ShootLight       =  ShootLight;
+   m_ShootHeavy       =  ShootHeavy;
 }
-
+ 
diff --git a/NPSimulation/src/EventGeneratorTransfertToResonance.cc b/NPSimulation/src/EventGeneratorTransfertToResonance.cc
index f9b564783..46261eb7b 100644
--- a/NPSimulation/src/EventGeneratorTransfertToResonance.cc
+++ b/NPSimulation/src/EventGeneratorTransfertToResonance.cc
@@ -56,6 +56,7 @@ EventGeneratorTransfertToResonance::EventGeneratorTransfertToResonance()
    //------------- Default Constructor -------------
 	m_InitConditions	= new TInitialConditions()	;
 	m_Reaction = new Reaction() ;
+	m_Target = 0;
 	m_SigmaX       		=  0 ;
 	m_SigmaY       		=  0 ;
 	m_SigmaThetaX     =  0 ;
@@ -70,6 +71,7 @@ EventGeneratorTransfertToResonance::~EventGeneratorTransfertToResonance()
    //------------- Default Destructor ------------
 	delete m_InitConditions;
 	delete m_Reaction ;
+	delete m_Target;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -392,19 +394,26 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part
    // Vertex position and beam angle inte world frame
    G4double x0 = 1000 * cm  	;
    G4double y0 = 1000 * cm  	;
+   G4double z0 =0;
    G4double Beam_thetaX = 0  	;
    G4double Beam_phiY   = 0  	;
+   G4double TargetThick = 0;
    
    //shoot inside the target with correlated angle
-   if (m_TargetRadius != 0) {
-      while (sqrt(x0*x0 + y0*y0) > m_TargetRadius) {
+   if (m_Target->GetTargetRadius() != 0) {
+      while (sqrt(x0*x0 + y0*y0) > m_Target->GetTargetRadius()) {
          RandomGaussian2D(0, 0, m_SigmaX, m_SigmaThetaX, x0, Beam_thetaX);
          RandomGaussian2D(0, 0, m_SigmaY, m_SigmaPhiY  , y0, Beam_phiY  );
       }
+      G4double dz = x0 * tan(m_Target->GetTargetAngle());
+      TargetThick = m_Target->GetTargetThickness() / cos(m_Target->GetTargetAngle());
+      z0 = dz + (-TargetThick / 2 + RandFlat::shoot() * TargetThick);
    }
    else {
       RandomGaussian2D(0,0,0,m_SigmaThetaX,x0,Beam_thetaX);
       RandomGaussian2D(0,0,0,m_SigmaPhiY  ,y0,Beam_phiY  );
+      TargetThick = m_Target->GetTargetThickness() / cos(m_Target->GetTargetAngle());
+      z0 = (-TargetThick / 2 + RandFlat::shoot() * TargetThick);
    }
 
    // write emittance angles to ROOT file
@@ -478,13 +487,11 @@ void EventGeneratorTransfertToResonance::GenerateEvent(G4Event* anEvent , G4Part
    // write angles/energy to ROOT file
    m_InitConditions->SetICEmittedAngleThetaLabIncidentFrame(ThetaLight / deg);
    m_InitConditions->SetICEmittedEnergy(EnergyLight/MeV);
-   //must shoot inside the target.
-   G4double z0 = (-m_TargetThickness / 2 + RandFlat::shoot() * m_TargetThickness);
 
    // Move to the target
-   x0 += m_TargetX ;
-   y0 += m_TargetY ;
-   z0 += m_TargetZ ;
+   x0 += m_Target->GetTargetX() ;
+   y0 += m_Target->GetTargetY() ;
+   z0 += m_Target->GetTargetZ() ;
 
    // write vertex position to ROOT file
    m_InitConditions->SetICPositionX(x0);
diff --git a/NPSimulation/src/PrimaryGeneratorAction.cc b/NPSimulation/src/PrimaryGeneratorAction.cc
index b1eb6c5aa..780d69fdb 100644
--- a/NPSimulation/src/PrimaryGeneratorAction.cc
+++ b/NPSimulation/src/PrimaryGeneratorAction.cc
@@ -123,30 +123,21 @@ void PrimaryGeneratorAction::ReadEventGeneratorFile(string Path)
          myEventGenerator->ReadConfiguration(Path)                      ;
          EventGeneratorFile.open(Path.c_str())                          ;
          myEventGenerator->InitializeRootOutput()           ;
-         myEventGenerator->SetTargetThickness(m_detector->GetTargetThickness())  ;
-         myEventGenerator->SetTargetRadius(m_detector->GetTargetRadius())     ;
-         myEventGenerator->SetTargetCoordinate(m_detector->GetTargetX() ,
-               m_detector->GetTargetY()   ,
-               m_detector->GetTargetZ())  ;
+         myEventGenerator->SetTarget(m_detector->GetTarget())  ;
          m_EventGenerator = myEventGenerator                            ;
       }
 
 
       //Search for Transfert To Resonance
       else if (LineBuffer.compare(0, 9, "Transfert") == 0 && !check_Transfert && LineBuffer.compare(0, 11, "TransfertTo") != 0) {
-         check_Transfert = true                                      ;
-         VEventGenerator* myEventGenerator = new EventGeneratorTransfert()                  ;
-         EventGeneratorFile.close()                                  ;
-         myEventGenerator->ReadConfiguration(Path)                      ;
-         EventGeneratorFile.open(Path.c_str())                          ;
-         myEventGenerator->InitializeRootOutput()           ;
-         myEventGenerator->SetTargetThickness(m_detector->GetTargetThickness())  ;
-         myEventGenerator->SetTargetAngle(m_detector->GetTargetAngle())     ;
-         myEventGenerator->SetTargetRadius(m_detector->GetTargetRadius())     ;
-         myEventGenerator->SetTargetCoordinate( m_detector->GetTargetX() ,
-               									m_detector->GetTargetY()   ,
-               									m_detector->GetTargetZ())  ;
-         m_EventGenerator = myEventGenerator                            ;
+         check_Transfert = true;
+         VEventGenerator* myEventGenerator = new EventGeneratorTransfert();
+         EventGeneratorFile.close();
+         myEventGenerator->ReadConfiguration(Path);
+         EventGeneratorFile.open(Path.c_str());
+         myEventGenerator->InitializeRootOutput();
+         myEventGenerator->SetTarget(m_detector->GetTarget());
+         m_EventGenerator = myEventGenerator;
       }
 
       //Search for Transfert To Resonance
@@ -157,11 +148,7 @@ void PrimaryGeneratorAction::ReadEventGeneratorFile(string Path)
          myEventGenerator->ReadConfiguration(Path)                      ;
          EventGeneratorFile.open(Path.c_str())                          ;
          myEventGenerator->InitializeRootOutput()           ;
-         myEventGenerator->SetTargetThickness(m_detector->GetTargetThickness())  ;
-         myEventGenerator->SetTargetRadius(m_detector->GetTargetRadius())     ;
-         myEventGenerator->SetTargetCoordinate(m_detector->GetTargetX() ,
-               m_detector->GetTargetY()   ,
-               m_detector->GetTargetZ())  ;
+         myEventGenerator->SetTarget(m_detector->GetTarget());
          m_EventGenerator = myEventGenerator                            ;
       }
    }
diff --git a/TODO b/TODO
index 03979e521..dbedcfcf7 100644
--- a/TODO
+++ b/TODO
@@ -22,32 +22,33 @@
 
 TODO for NPTool:
 ----------------
-   + Try to remove warnings from NPL / NPS compilation
-   + Change dEdX name for EnergyLoss
+   + Change dEdX name for EnergyLoss (Nicolas)
+   + Try to remove warnings from NPL / NPS compilation (Adrien + Nicolas)
    + Change map's index of scorers to deal a typical case like it is now done
-     for the dE-E with 2 plastics.
-   + Build a dummy detector as a simple example of how NPTool is working
-   + Target work
+     for the dE-E with 2 plastics. (Adrien + Nicolas)
+   + Build a dummy detector as a simple example of how NPTool is working (Adrien)
+   + Target work (Nicolas)
       + Make homogeneous treatment of materials definition wrt other detectors
+        (Adrien)
       + Possibility to tilt the target with a given angle and to deal with
         the emittance
       + Target object as a private member of VEventGenerator
       + Shooting in the target within a dedicated method in VEventGenerator
       + IsInsideTarget method for debugging purposes
-   + Add documentation
    + Add a dedicated class to deal with materials (see example from G4 tutorial)
      (still under debate)
    + Split physic list and give the possibility to choose which package to use
    + Add support for messengers
    + Build NPTool with the Autotool/Automake
+   + Add documentation (Adrien + Nicolas)
 
-TODO for NPAnlysis:
--------------------
-   + Add comment support for RunToTreat.txt
-   + Add calibration manager class from Julien
+TODO for NPAnalysis:
+--------------------
+   + Add comment support for RunToTreat.txt (Adrien)
+   + Check Makefiles dependency (mostly for Gaspard) (Nicolas)
+   + Add calibration manager class from Julien (Adrien)
    + Use only one class for the analysis per detector instead of two currently
      (ROOT feature in private member definition ( //!))
-   + Check Makefiles dependency (mostly for Gaspard)
 
 TODO for AnnularS1 detector:
 ----------------------------
-- 
GitLab