From cc42e2f5a42c5e579897822939bb4906c768f184 Mon Sep 17 00:00:00 2001
From: matta <matta@npt>
Date: Fri, 13 Nov 2009 00:59:34 +0000
Subject: [PATCH] * Adding beam energy loss in the rear windows target

---
 .../DetectorConfiguration/Riken_65mm.detector |  4 +--
 NPSimulation/src/Target.cc                    | 31 ++++++++++++++++---
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/Inputs/DetectorConfiguration/Riken_65mm.detector b/Inputs/DetectorConfiguration/Riken_65mm.detector
index a0e5ee510..0855d67ee 100644
--- a/Inputs/DetectorConfiguration/Riken_65mm.detector
+++ b/Inputs/DetectorConfiguration/Riken_65mm.detector
@@ -7,7 +7,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 GeneralTarget
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-Target
+%Target
 	THICKNESS= 10000
 	RADIUS=	45
 	MATERIAL= CD2
@@ -16,7 +16,7 @@ Target
 	Y= 0
 	Z= 0
 	
-%CryoTarget
+CryoTarget
 	THICKNESS= 3000
 	RADIUS=	45
 	TEMPERATURE= 26
diff --git a/NPSimulation/src/Target.cc b/NPSimulation/src/Target.cc
index 4dc4efa24..af9f4998b 100644
--- a/NPSimulation/src/Target.cc
+++ b/NPSimulation/src/Target.cc
@@ -555,12 +555,35 @@ void Target::CalculateBeamInteraction(	double MeanPosX, double SigmaPosX, double
       InterCoord = G4ThreeVector(x0, y0, z0);
 
 		G4EmCalculator emCalculator;
-		for (G4int i = 0; i < m_TargetNbLayers; i++) 
+		if(m_TargetType)
 			{
-				G4double dedx = emCalculator.ComputeTotalDEDX(IncidentBeamEnergy, BeamName, m_TargetMaterial);
-				G4double de   = dedx * EffectiveTargetThicknessBeforeInteraction / m_TargetNbLayers;
-				IncidentBeamEnergy -= de;
+				for (G4int i = 0; i < m_TargetNbLayers; i++) 
+					{
+						G4double dedx = emCalculator.ComputeTotalDEDX(IncidentBeamEnergy, BeamName, m_TargetMaterial);
+						G4double de   = dedx * EffectiveTargetThicknessBeforeInteraction / m_TargetNbLayers;
+						IncidentBeamEnergy -= de;
+					}
+			
+			}
+		else
+			{		//	Windows
+					for (G4int i = 0; i < m_TargetNbLayers; i++) 
+						{
+							G4double dedx = emCalculator.ComputeTotalDEDX(IncidentBeamEnergy, BeamName, m_WindowsMaterial);
+							G4double de   = dedx * m_WindowsThickness * uniform / (cos(AngleIncidentTheta)*m_TargetNbLayers);
+							IncidentBeamEnergy -= de;
+						}
+						
+					// Target
+					for (G4int i = 0; i < m_TargetNbLayers; i++) 
+						{
+							G4double dedx = emCalculator.ComputeTotalDEDX(IncidentBeamEnergy, BeamName, m_TargetMaterial);
+							G4double de   = dedx * EffectiveTargetThicknessBeforeInteraction / m_TargetNbLayers;
+							IncidentBeamEnergy -= de;
+						}
+			
 			}
+		
 FinalBeamEnergy=IncidentBeamEnergy;
 }
 
-- 
GitLab