From 5357883c4bf26ebd9dacbcf95bfcc15bdf7f57de Mon Sep 17 00:00:00 2001
From: matta <matta@npt>
Date: Wed, 24 Mar 2010 08:13:41 +0000
Subject: [PATCH] *Fixing small bug in EventGeneratorBeam: 	- Eloss Table
 was written to early, resulting a segmentation fault.

---
 NPSimulation/src/EventGeneratorBeam.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/NPSimulation/src/EventGeneratorBeam.cc b/NPSimulation/src/EventGeneratorBeam.cc
index 07fb551b4..3cad15c4d 100644
--- a/NPSimulation/src/EventGeneratorBeam.cc
+++ b/NPSimulation/src/EventGeneratorBeam.cc
@@ -57,7 +57,6 @@ void	EventGeneratorBeam::SetTarget(Target* Target)
    	if(Target!=0)	
    		{
    			m_Target = Target;
-   			m_Target->WriteDEDXTable(m_particle ,0, m_BeamEnergy);
    		}
    
    }
@@ -186,8 +185,8 @@ void EventGeneratorBeam::ReadConfiguration(string Path)
 void EventGeneratorBeam::GenerateEvent(G4Event* anEvent, G4ParticleGun* particleGun)
 {
 			//--------------write the DeDx Table -------------------
-  if(m_Target!=0)
-  	m_Target->WriteDEDXTable(m_particle ,0, m_BeamEnergy+4*m_BeamEnergySpread);
+  if(m_Target!=0 && anEvent->GetEventID()==0)
+  		m_Target->WriteDEDXTable(m_particle ,0, m_BeamEnergy+4*m_BeamEnergySpread);
 
 
    m_InitConditions->Clear();
-- 
GitLab