Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -26,13 +26,15 @@
|
||||
/// \file field/field02/src/F02PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the F02PrimaryGeneratorAction class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//
|
||||
// $Id: F02PrimaryGeneratorAction.cc 77893 2013-11-29 08:57:22Z gcosmo $
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "F02PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "F02DetectorConstruction.hh"
|
||||
#include "F02PrimaryGeneratorMessenger.hh"
|
||||
|
||||
@@ -40,22 +42,23 @@
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4String F02PrimaryGeneratorAction::fgPrimaryParticleName = "proton" ;
|
||||
G4ParticleDefinition* F02PrimaryGeneratorAction::fgPrimaryParticle = 0;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
F02PrimaryGeneratorAction::F02PrimaryGeneratorAction(
|
||||
F02DetectorConstruction* det)
|
||||
: fParticleGun(0),
|
||||
fDetector(det),
|
||||
fMessenger(0),
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),
|
||||
fDetector(det),
|
||||
fGunMessenger(0),
|
||||
fRndmFlag("off"),
|
||||
fXVertex(0.),
|
||||
fYVertex(0.),
|
||||
@@ -63,11 +66,10 @@ F02PrimaryGeneratorAction::F02PrimaryGeneratorAction(
|
||||
fVertexDefined(false)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
// create a messenger for this class
|
||||
//
|
||||
fMessenger = new F02PrimaryGeneratorMessenger(this);
|
||||
fGunMessenger = new F02PrimaryGeneratorMessenger(this);
|
||||
|
||||
// default particle kinematic
|
||||
|
||||
@@ -76,8 +78,8 @@ F02PrimaryGeneratorAction::F02PrimaryGeneratorAction(
|
||||
G4ParticleDefinition* particle
|
||||
= particleTable->FindParticle(particleName="proton");
|
||||
fParticleGun->SetParticleDefinition(particle);
|
||||
|
||||
fgPrimaryParticleName = particle->GetParticleName() ;
|
||||
|
||||
fgPrimaryParticle = particle;
|
||||
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
fParticleGun->SetParticleEnergy(100.*GeV);
|
||||
@@ -87,85 +89,84 @@ F02PrimaryGeneratorAction::F02PrimaryGeneratorAction(
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
F02PrimaryGeneratorAction::~F02PrimaryGeneratorAction()
|
||||
{
|
||||
delete fParticleGun;
|
||||
delete fMessenger;
|
||||
delete fGunMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void F02PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
// this function is called at the begining of event
|
||||
//
|
||||
fgPrimaryParticleName
|
||||
= fParticleGun->GetParticleDefinition()->GetParticleName() ;
|
||||
//
|
||||
fgPrimaryParticle = fParticleGun->GetParticleDefinition();
|
||||
|
||||
G4double x0,y0,z0 ;
|
||||
G4double x0,y0,z0;
|
||||
if (fVertexDefined)
|
||||
{
|
||||
x0 = fXVertex ;
|
||||
y0 = fYVertex ;
|
||||
z0 = fZVertex ;
|
||||
x0 = fXVertex;
|
||||
y0 = fYVertex;
|
||||
z0 = fZVertex;
|
||||
}
|
||||
else
|
||||
{
|
||||
x0 = 0. ;
|
||||
y0 = 0. ;
|
||||
z0 = 0. ; // -0.5*(fDetector->GetWorldSizeZ()) ;
|
||||
x0 = 0.;
|
||||
y0 = 0.;
|
||||
z0 = 0.; // -0.5*(fDetector->GetWorldSizeZ());
|
||||
}
|
||||
|
||||
G4double r0,phi0 ;
|
||||
G4double r0,phi0;
|
||||
if (fRndmFlag == "on")
|
||||
{
|
||||
r0 = (fDetector->GetAbsorberRadius())*std::sqrt(G4UniformRand());
|
||||
phi0 = twopi*G4UniformRand();
|
||||
x0 = r0*std::cos(phi0);
|
||||
y0 = r0*std::sin(phi0);
|
||||
}
|
||||
r0 = (fDetector->GetAbsorberRadius())*std::sqrt(G4UniformRand());
|
||||
phi0 = twopi*G4UniformRand();
|
||||
x0 = r0*std::cos(phi0);
|
||||
y0 = r0*std::sin(phi0);
|
||||
}
|
||||
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4String F02PrimaryGeneratorAction::GetPrimaryName()
|
||||
{
|
||||
return fgPrimaryParticleName ;
|
||||
return fgPrimaryParticle->GetParticleName();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void F02PrimaryGeneratorAction::SetXVertex(G4double x)
|
||||
{
|
||||
fVertexDefined = true ;
|
||||
fXVertex = x ;
|
||||
fVertexDefined = true;
|
||||
fXVertex = x;
|
||||
G4cout << " X coordinate of the primary vertex = " << fXVertex/mm <<
|
||||
" mm." << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void F02PrimaryGeneratorAction::SetYVertex(G4double y)
|
||||
{
|
||||
fVertexDefined = true ;
|
||||
fYVertex = y ;
|
||||
fVertexDefined = true;
|
||||
fYVertex = y;
|
||||
G4cout << " Y coordinate of the primary vertex = " << fYVertex/mm <<
|
||||
" mm." << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void F02PrimaryGeneratorAction::SetZVertex(G4double z)
|
||||
{
|
||||
fVertexDefined = true ;
|
||||
fZVertex = z ;
|
||||
fVertexDefined = true;
|
||||
fZVertex = z;
|
||||
G4cout << " Z coordinate of the primary vertex = " << fZVertex/mm <<
|
||||
" mm." << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user