Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F03PrimaryGeneratorAction Class Reference

#include <F03PrimaryGeneratorAction.hh>

Inheritance diagram for F03PrimaryGeneratorAction:
Collaboration diagram for F03PrimaryGeneratorAction:

Public Member Functions

 F03PrimaryGeneratorAction (F03DetectorConstruction *)
 
virtual ~F03PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *)
 
void SetRndmFlag (G4String val)
 
void SetXVertex (G4double x)
 
void SetYVertex (G4double y)
 
void SetZVertex (G4double z)
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Static Public Member Functions

static G4String GetPrimaryName ()
 

Detailed Description

Definition at line 50 of file F03PrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

F03PrimaryGeneratorAction::F03PrimaryGeneratorAction ( F03DetectorConstruction det)

Definition at line 56 of file F03PrimaryGeneratorAction.cc.

59  fParticleGun(0),
60  fDetector(det),
61  fGunMessenger(0),
62  fRndmFlag("off"),
63  fXVertex(0.),
64  fYVertex(0.),
65  fZVertex(0.),
66  fVertexDefined(false)
67 {
68  G4int n_particle = 1;
69  fParticleGun = new G4ParticleGun(n_particle);
70 
71  // create a messenger for this class
72  fGunMessenger = new F03PrimaryGeneratorMessenger(this);
73 
74  // default particle kinematic
75 
77  G4String particleName;
78  G4ParticleDefinition* particle
79  = particleTable->FindParticle(particleName="e-");
80  fParticleGun->SetParticleDefinition(particle);
81 
82  fgPrimaryParticle = particle;
83 
84  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,-1.));
85  fParticleGun->SetParticleEnergy(1.*GeV);
86 
87  fZVertex=fDetector->GetAbsorberZpos()-0.5*(fDetector->GetAbsorberThickness());
88  fParticleGun->SetParticlePosition(G4ThreeVector(fXVertex,fYVertex,fZVertex));
89 
90 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
int G4int
Definition: G4Types.hh:78
void SetParticlePosition(G4ThreeVector aPosition)
void SetParticleEnergy(G4double aKineticEnergy)
static G4ParticleTable * GetParticleTable()
static constexpr double GeV
Definition: G4SIunits.hh:217
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)

Here is the call graph for this function:

F03PrimaryGeneratorAction::~F03PrimaryGeneratorAction ( )
virtual

Definition at line 94 of file F03PrimaryGeneratorAction.cc.

95 {
96  delete fParticleGun;
97  delete fGunMessenger;
98 }

Member Function Documentation

void F03PrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 102 of file F03PrimaryGeneratorAction.cc.

103 {
104  // this function is called at the begining of event
105  //
106  fgPrimaryParticle = fParticleGun->GetParticleDefinition();
107 
108  G4double x0,y0,z0;
109  if (fVertexDefined)
110  {
111  x0 = fXVertex;
112  y0 = fYVertex;
113  z0 = fZVertex;
114  }
115  else
116  {
117  x0 = 0.;
118  y0 = 0.;
119  z0 = fDetector->GetAbsorberZpos()-0.5*(fDetector->GetAbsorberThickness());
120  }
121 
122  G4double r0,phi0;
123  if (fRndmFlag == "on")
124  {
125  r0 = (fDetector->GetAbsorberRadius())*std::sqrt(G4UniformRand());
126  phi0 = twopi*G4UniformRand();
127  x0 = r0*std::cos(phi0);
128  y0 = r0*std::sin(phi0);
129  }
130 
131  fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
132  fParticleGun->GeneratePrimaryVertex(anEvent);
133 }
CLHEP::Hep3Vector G4ThreeVector
virtual void GeneratePrimaryVertex(G4Event *evt)
static constexpr double twopi
Definition: G4SIunits.hh:76
void SetParticlePosition(G4ThreeVector aPosition)
#define G4UniformRand()
Definition: Randomize.hh:97
G4ParticleDefinition * GetParticleDefinition() const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4String F03PrimaryGeneratorAction::GetPrimaryName ( )
static

Definition at line 137 of file F03PrimaryGeneratorAction.cc.

138 {
139  return fgPrimaryParticle->GetParticleName();
140 }
const G4String & GetParticleName() const

Here is the call graph for this function:

void F03PrimaryGeneratorAction::SetRndmFlag ( G4String  val)
inline

Definition at line 58 of file F03PrimaryGeneratorAction.hh.

58 { fRndmFlag = val; }

Here is the caller graph for this function:

void F03PrimaryGeneratorAction::SetXVertex ( G4double  x)

Definition at line 144 of file F03PrimaryGeneratorAction.cc.

145 {
146  fVertexDefined = true;
147  fXVertex = x;
148  G4cout << " X coordinate of the primary vertex = " << fXVertex/mm <<
149  " mm." << G4endl;
150 }
static constexpr double mm
Definition: G4SIunits.hh:115
tuple x
Definition: test.py:50
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

void F03PrimaryGeneratorAction::SetYVertex ( G4double  y)

Definition at line 154 of file F03PrimaryGeneratorAction.cc.

155 {
156  fVertexDefined = true;
157  fYVertex = y;
158  G4cout << " Y coordinate of the primary vertex = " << fYVertex/mm <<
159  " mm." << G4endl;
160 }
static constexpr double mm
Definition: G4SIunits.hh:115
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

void F03PrimaryGeneratorAction::SetZVertex ( G4double  z)

Definition at line 164 of file F03PrimaryGeneratorAction.cc.

165 {
166  fVertexDefined = true;
167  fZVertex = z;
168  G4cout << " Z coordinate of the primary vertex = " << fZVertex/mm <<
169  " mm." << G4endl;
170 }
static constexpr double mm
Definition: G4SIunits.hh:115
G4GLOB_DLL std::ostream G4cout
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:


The documentation for this class was generated from the following files: