From 2e4c47605ddecde8e569e264bcab71a7a572dae4 Mon Sep 17 00:00:00 2001
From: deserevi <deserevi@nptool>
Date: Fri, 6 Nov 2009 09:59:42 +0000
Subject: [PATCH] * Add new Token in Target.{hh,cc}    + Token NBLAYERS is used
 to slow down the beam in the target from the      entrance to the beam
 interaction point

---
 .../gaspardTestSpheric.detector               |  1 +
 NPSimulation/include/Target.hh                |  6 +++++-
 NPSimulation/src/EventGeneratorTransfert.cc   |  2 +-
 NPSimulation/src/Target.cc                    | 20 ++++++++++++++++++-
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/Inputs/DetectorConfiguration/gaspardTestSpheric.detector b/Inputs/DetectorConfiguration/gaspardTestSpheric.detector
index 96fcce7a4..91d535366 100644
--- a/Inputs/DetectorConfiguration/gaspardTestSpheric.detector
+++ b/Inputs/DetectorConfiguration/gaspardTestSpheric.detector
@@ -13,6 +13,7 @@ Target
 	ANGLE= 0
 	RADIUS=	12
 	MATERIAL= CD2
+	NBLAYERS= 50
 	X= 0
 	Y= 0
 	Z= 0
diff --git a/NPSimulation/include/Target.hh b/NPSimulation/include/Target.hh
index 92da2be70..f34c7677e 100644
--- a/NPSimulation/include/Target.hh
+++ b/NPSimulation/include/Target.hh
@@ -11,7 +11,7 @@
  * Original Author: Adrien MATTA  contact address: matta@ipno.in2p3.fr       *
  *                                                                           *
  * Creation Date  : January 2009                                             *
- * Last update    : 16/09/2009                                               *
+ * Last update    : 06/11/2009                                               *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
  *  This class describe Cryogenic and standard Target. Derived from VDetector*
@@ -22,6 +22,8 @@
  *                                                                           *
  *  + 16/09/2009: Add support for positioning the target with an angle with  *
  *                respect to the beam (N. de Sereville)                      *
+ *  + 06/11/2009: Add new Token NBLAYERS defining the number of steps used   *
+ *                to slow down the beam in the target (N. de Sereville)      *
  *                                                                           *
  *****************************************************************************/
 // C++ headers
@@ -86,6 +88,7 @@ public:
    G4double    GetTargetX()		{return m_TargetX;}
    G4double    GetTargetY()		{return m_TargetY;}
    G4double    GetTargetZ()		{return m_TargetZ;}
+   G4int       GetTargetNbLayers()	{return m_TargetNbLayers;}
 
 
 private:
@@ -97,6 +100,7 @@ private:
    G4double    m_TargetRadius;
    G4double    m_TargetAngle;
    G4Material* m_TargetMaterial;
+   G4int       m_TargetNbLayers;
 
    // For Cryo Target
    G4double    m_TargetTemperature;
diff --git a/NPSimulation/src/EventGeneratorTransfert.cc b/NPSimulation/src/EventGeneratorTransfert.cc
index 19de24764..0f7e15c94 100644
--- a/NPSimulation/src/EventGeneratorTransfert.cc
+++ b/NPSimulation/src/EventGeneratorTransfert.cc
@@ -396,7 +396,7 @@ void EventGeneratorTransfert::GenerateEvent(G4Event* anEvent , G4ParticleGun* pa
    G4double IncidentBeamEnergy = RandGauss::shoot(NominalBeamEnergy, m_BeamEnergySpread / 2.35);
    // Slowing down the beam to the interaction layer in the target
    // Number of Layers
-   const G4int NbLayers = 50;
+   G4int NbLayers = m_Target->GetTargetNbLayers();
    G4EmCalculator emCalculator;
    for (G4int i = 0; i < NbLayers; i++) {
 //      G4double dedx = emCalculator.GetDEDX(IncidentBeamEnergy, BeamName, m_Target->GetTargetMaterial());
diff --git a/NPSimulation/src/Target.cc b/NPSimulation/src/Target.cc
index e176eae06..798c028ee 100644
--- a/NPSimulation/src/Target.cc
+++ b/NPSimulation/src/Target.cc
@@ -9,7 +9,7 @@
  * Original Author: Adrien MATTA  contact address: matta@ipno.in2p3.fr       *
  *                                                                           *
  * Creation Date  : January 2009                                             *
- * Last update    : 16/09/2009                                               *
+ * Last update    : 06/11/2009                                               *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
  *  This class describe Cryogenic and standard Target. Derived from VDetector*
@@ -21,6 +21,8 @@
  *  + 16/09/2009: Add support for positioning the target with an angle with  *
  *                respect to the beam (N. de Sereville)                      *
  *  + 16/09/2009: Add CH2 material for targets (N. de Sereville)             *
+ *  + 06/11/2009: Add new Token NBLAYERS defining the number of steps used   *
+ *                to slow down the beam in the target (N. de Sereville)      *
  *                                                                           *
  *****************************************************************************/
 // C++ header
@@ -57,6 +59,7 @@ Target::Target()
    m_WindowsThickness   = 0   ;
    m_TargetTemperature  = 0   ;
    m_TargetPressure  	= 0   ;
+   m_TargetNbLayers      = 50;	// Number of steps by default
 }
 
 G4Material* Target::GetMaterialFromLibrary(G4String MaterialName, G4double Temperature, G4double Pressure)
@@ -209,6 +212,7 @@ void Target::ReadConfiguration(string Path)
    bool check_X = false ;
    bool check_Y = false ;
    bool check_Z = false ;
+   bool check_NbLayers = false;
 
    bool check_Temperature = false ;
    bool check_Pressure = false ;
@@ -283,6 +287,13 @@ void Target::ReadConfiguration(string Path)
 	            cout  << m_TargetZ / mm << " )" << endl ;           
 	         }
 
+	        else if (DataBuffer.compare(0, 9, "NBLAYERS=") == 0) {
+	        	check_NbLayers = true ;
+	            ConfigFile >> DataBuffer;
+	            m_TargetNbLayers = atoi(DataBuffer.c_str());
+	            cout  << "Number of steps for slowing down the beam in target: " << m_TargetNbLayers << endl;
+	         }
+
 	        ///////////////////////////////////////////////////
 			//	If no Beam Token and no comment, toggle out
 	         else 
@@ -370,6 +381,13 @@ void Target::ReadConfiguration(string Path)
 	            cout << m_TargetZ / mm << " )" << endl ;
 	         }
 
+	        else if (DataBuffer.compare(0, 9, "NBLAYERS=") == 0) {
+	        	check_NbLayers = true ;
+	            ConfigFile >> DataBuffer;
+	            m_TargetNbLayers = atoi(DataBuffer.c_str());
+	            cout  << "Number of steps for slowing down the beam in target: " << m_TargetNbLayers << endl;
+	         }
+
 	        ///////////////////////////////////////////////////
 			//	If no Beam Token and no comment, toggle out
 	         else 
-- 
GitLab