Skip to content
Snippets Groups Projects
EventGeneratorBeam.cc 4.86 KiB
Newer Older
Unknown's avatar
Unknown committed
/*****************************************************************************
 * Copyright (C) 2009-2013   this file is part of the NPTool Project         *
Unknown's avatar
Unknown committed
 *                                                                           *
 * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
 * For the list of contributors see $NPTOOL/Licence/Contributors             *
 *****************************************************************************/

/*****************************************************************************
 * Original Author: Adrien MATTA  contact address: matta@ipno.in2p3.fr       *
 *                                                                           *
 * Creation Date  : January 2009                                             *
 * Last update    :                                                          *
 *---------------------------------------------------------------------------*
 * Decription:                                                               *
 *  This event Generator is used to simulated Radioactive Ion beam           *
 *  Emmitance, Energy spread and dispersion are taken into account           *
 *---------------------------------------------------------------------------*
 * Comment:                                                                  *
 *                                                                           *
 *                                                                           *
 *****************************************************************************/

// C++
#include <limits>

Unknown's avatar
Unknown committed
// G4 header
#include "G4ParticleTable.hh"

// G4 headers including CLHEP headers
// for generating random numbers
#include "Randomize.hh"

// NPSimulation header
Unknown's avatar
Unknown committed
#include "EventGeneratorBeam.hh"
#include "Particle.hh"
// NPL header
Unknown's avatar
Unknown committed
#include "RootOutput.h"

using namespace CLHEP;



//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventGeneratorBeam::EventGeneratorBeam(){
  m_ParticleStack  = ParticleStack::getInstance();
  m_Target         = NULL    ;
  m_particle       = NULL    ;
  m_Beam           = new NPL::Beam();
Unknown's avatar
Unknown committed
}
Unknown's avatar
Unknown committed
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventGeneratorBeam::~EventGeneratorBeam(){
  delete m_Beam;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void   EventGeneratorBeam::SetTarget(Target* Target){
  if(Target!=0){
    m_Target = Target;
  }
  
  // Set the target parameter for the internal event generator of m_Beam
  m_Beam->SetTargetSize(m_Target->GetTargetRadius());
  m_Beam->SetTargetAngle(m_Target->GetTargetAngle());
  m_Beam->SetTargetThickness(m_Target->GetTargetThickness());
  m_Beam->SetTargetZ(m_Target->GetTargetZ());
  
Unknown's avatar
Unknown committed
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
matta's avatar
matta committed
void EventGeneratorBeam::ReadConfiguration(string Path,int){
  m_Beam->ReadConfigurationFile(Path);
Unknown's avatar
Unknown committed
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventGeneratorBeam::GenerateEvent(G4Event* anEvent){
  if( anEvent->GetEventID()==0){
    // Define the particle to be shoot
    m_particle = G4ParticleTable::GetParticleTable()->GetIon(m_Beam->GetZ(), m_Beam->GetA() ,m_Beam->GetExcitationEnergy());
  }
  
  ///////////////////////////////////////////////////////////////////////
  ///// Calculate the incident beam direction as well as the vertex /////
  ///// of interaction in target and Energy Loss of the beam within /////
  ///// the target.                                                 /////
  ///////////////////////////////////////////////////////////////////////
  G4ThreeVector InterCoord;
  
  G4double Beam_theta, Beam_phi, FinalBeamEnergy, InitialBeamEnergy, x0, y0, z0, Beam_thetaX, Beam_phiY;

  m_Beam->GenerateRandomEvent(InitialBeamEnergy, x0, y0, z0, Beam_thetaX, Beam_phiY);
  G4double Xdir = sin(Beam_thetaX);
  G4double Ydir = sin(Beam_phiY);
  G4double Zdir = cos(Beam_thetaX) + cos(Beam_phiY);
  G4ThreeVector BeamDir(Xdir,Ydir,Zdir);
  G4ThreeVector BeamPos(x0,y0,z0);
  Beam_theta = BeamDir.theta()    ;
  Beam_phi   = BeamDir.phi()      ; Beam_phi *= 1;
  FinalBeamEnergy = m_Target->SlowDownBeam(m_particle, InitialBeamEnergy,z0-m_Beam->GetTargetZ(),Beam_theta);
  ///////////////////////////////////////////////////////
  ///// Add the Beam particle to the particle Stack /////
  ///////////////////////////////////////////////////////
  Particle BeamParticle( m_particle,
                        InitialBeamEnergy,
                        FinalBeamEnergy,
                        BeamDir.unit(),
                        BeamPos,
                        1);
  
  m_ParticleStack->AddBeamParticleToStack(BeamParticle);
Unknown's avatar
Unknown committed
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventGeneratorBeam::InitializeRootOutput(){
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......