From 60aa5984a2fb8b8204774e82dc82d59414ecaabd Mon Sep 17 00:00:00 2001
From: adrien matta <matta@lpccaen.in2p3.fr>
Date: Fri, 10 Mar 2017 16:09:31 +0100
Subject: [PATCH] * Fixing a bug affecting slow down of beam inside the target
 for * npsimulation         - The bug effectively slowed the beam with half a
 target

---
 NPSimulation/Core/Target.cc | 8 ++++----
 NPSimulation/Core/Target.hh | 1 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/NPSimulation/Core/Target.cc b/NPSimulation/Core/Target.cc
index 0ffa9abb0..ddf19b7c4 100644
--- a/NPSimulation/Core/Target.cc
+++ b/NPSimulation/Core/Target.cc
@@ -12,7 +12,8 @@
  * Last update    : 06/11/2009                                               *
  *---------------------------------------------------------------------------*
  * Decription:                                                               *
- *  This class describe Cryogenic and standard Target. Derived fromNPS::VDetector*
+ *  This class describe Cryogenic and standard Target. Derived from          *
+ *  NPS::VDetector                                                           * 
  *                                                                           *
  *---------------------------------------------------------------------------*
  * Comment:                                                                  *
@@ -67,7 +68,6 @@ Target::Target(){
   m_TargetRadius       = 0   ;
   m_WindowsThickness   = 0   ;
   m_TargetDensity      = 0   ;
-  m_EffectiveThickness = 0   ; // effective thickness at 0 deg, compute using angle and thickness
   m_TargetNbLayers     = 5;   // Number of steps by default
   // Set the global pointer
   TargetInstance = this;
@@ -254,7 +254,7 @@ G4double Target::SlowDownBeam(G4ParticleDefinition* Beam,
   }
 
   G4double ThicknessBeforeInteraction = 
-    abs(ZInteraction - 0.5*m_EffectiveThickness) / cos(m_TargetAngle);
+    abs(ZInteraction - 0.5*m_TargetThickness) / cos(m_TargetAngle);
 
   G4double dedx,de;
   static G4EmCalculator emCalculator;
@@ -278,7 +278,7 @@ G4double Target::SlowDownBeam(G4ParticleDefinition* Beam,
     if(m_WindowsThickness!=0)
       for (G4int i = 0; i < m_TargetNbLayers; i++){
         dedx = emCalculator.ComputeTotalDEDX(IncidentEnergy, Beam, m_WindowsMaterial);
-        de   = dedx * m_TargetNbLayers * m_WindowsThickness / cos(IncidentTheta);
+        de   = dedx  * m_WindowsThickness / (cos(IncidentTheta)* m_TargetNbLayers);
         IncidentEnergy -= de;
         if(IncidentEnergy<0){
           IncidentEnergy = 0;
diff --git a/NPSimulation/Core/Target.hh b/NPSimulation/Core/Target.hh
index 45c33930f..833243887 100644
--- a/NPSimulation/Core/Target.hh
+++ b/NPSimulation/Core/Target.hh
@@ -108,7 +108,6 @@ private:
   G4double    m_TargetThickness;
   G4double    m_TargetRadius;
   G4double    m_TargetAngle;
-  G4double    m_EffectiveThickness;
   G4Material* m_TargetMaterial;
   G4int       m_TargetNbLayers;
   
-- 
GitLab