From 4bb4709b733e2cfc98017b56c3ebe1bc0bc9af21 Mon Sep 17 00:00:00 2001 From: matta <matta@npt> Date: Thu, 25 Mar 2010 06:36:29 +0000 Subject: [PATCH] *Fixing one mor bug in EventGeneratorBeam - For some reason, 6He and 8He (at least) are not instiate in the Ion table before the runManager initialisation but 11Li yes... - To fix the problem the m_particle pointer is set at first event launch --- Inputs/EventGenerator/11Li.beam | 4 +-- NPSimulation/include/EventGeneratorBeam.hh | 2 ++ NPSimulation/src/EventGeneratorBeam.cc | 38 +++++++++++++--------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Inputs/EventGenerator/11Li.beam b/Inputs/EventGenerator/11Li.beam index 5a06c2798..c32a2702b 100644 --- a/Inputs/EventGenerator/11Li.beam +++ b/Inputs/EventGenerator/11Li.beam @@ -6,8 +6,8 @@ Beam ParticleZ= 3 ParticleA= 11 - BeamEnergy= 550 - BeamEnergySpread= 10 + BeamEnergy= 500 + BeamEnergySpread= 50 SigmaX= 6.232 SigmaY= 9.069 SigmaThetaX= 0.6921330164 diff --git a/NPSimulation/include/EventGeneratorBeam.hh b/NPSimulation/include/EventGeneratorBeam.hh index e8267f0e1..e18dba96b 100644 --- a/NPSimulation/include/EventGeneratorBeam.hh +++ b/NPSimulation/include/EventGeneratorBeam.hh @@ -57,6 +57,8 @@ private: // TTree to store initial value of beam and reaction private: // Source parameter G4ParticleDefinition* m_particle; // Kind of particle to shoot + G4int m_beamA; + G4int m_beamZ; G4double m_BeamEnergy; G4double m_BeamEnergySpread; G4double m_SigmaX; diff --git a/NPSimulation/src/EventGeneratorBeam.cc b/NPSimulation/src/EventGeneratorBeam.cc index 3cad15c4d..5d2639361 100644 --- a/NPSimulation/src/EventGeneratorBeam.cc +++ b/NPSimulation/src/EventGeneratorBeam.cc @@ -42,7 +42,10 @@ using namespace CLHEP; EventGeneratorBeam::EventGeneratorBeam() { m_InitConditions = new TInitialConditions(); - m_Target = 0; + m_Target = NULL ; + m_beamA = 0 ; + m_beamZ = 0 ; + m_particle = NULL ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -67,8 +70,6 @@ void EventGeneratorBeam::ReadConfiguration(string Path) string LineBuffer; string DataBuffer; - ////////Reaction Setting needs/////// - G4double particleZ = 0 , particleA = 0 ; ////////////////////////////////////////////////////////////////////////////////////////// ifstream ReactionFile; ReactionFile.open(Path.c_str()); @@ -91,14 +92,11 @@ void EventGeneratorBeam::ReadConfiguration(string Path) //Pick-up next line getline(ReactionFile, LineBuffer); - - if (LineBuffer.compare(0, 4, "Beam") == 0) { G4cout << "Beam Found" << G4endl ; ReadingStatus = true ; } - while(ReadingStatus){ ReactionFile >> DataBuffer; @@ -109,16 +107,22 @@ void EventGeneratorBeam::ReadConfiguration(string Path) else if (DataBuffer.compare(0, 10, "ParticleZ=") == 0) { check_Z = true ; ReactionFile >> DataBuffer; - particleZ = atof(DataBuffer.c_str()); + m_beamZ = atof(DataBuffer.c_str()); + + if(check_A) + G4cout << "Beam Particle: Z:" << m_beamZ << " A:" << m_beamA << G4endl; + } else if (DataBuffer.compare(0, 10, "ParticleA=") == 0) { check_A = true ; ReactionFile >> DataBuffer; - particleA = atof(DataBuffer.c_str()); - G4cout << "Beam Particle: Z:" << particleZ << " A:" << particleA << G4endl; - m_particle = G4ParticleTable::GetParticleTable()->GetIon(particleZ, particleA, 0.); + m_beamA = atof(DataBuffer.c_str()); + + if(check_Z) + G4cout << "Beam Particle: Z:" << m_beamZ << " A:" << m_beamA << G4endl; + } else if (DataBuffer.compare(0, 11, "BeamEnergy=") == 0) { @@ -184,11 +188,15 @@ void EventGeneratorBeam::ReadConfiguration(string Path) //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventGeneratorBeam::GenerateEvent(G4Event* anEvent, G4ParticleGun* particleGun) { - //--------------write the DeDx Table ------------------- - if(m_Target!=0 && anEvent->GetEventID()==0) - m_Target->WriteDEDXTable(m_particle ,0, m_BeamEnergy+4*m_BeamEnergySpread); - - + //--------------write the DeDx Table ------------------- + if( anEvent->GetEventID()==0) + { + m_particle = G4ParticleTable::GetParticleTable()->GetIon(m_beamZ, m_beamA , 0.); + + if(m_Target!=0 ) + m_Target->WriteDEDXTable(m_particle ,0, m_BeamEnergy+4*m_BeamEnergySpread); + } + m_InitConditions->Clear(); /////////////////////////////////////////////////////////////////////// -- GitLab