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

#include <PrimaryGeneratorGun1.hh>

Inheritance diagram for PrimaryGeneratorGun1:
Collaboration diagram for PrimaryGeneratorGun1:

Public Member Functions

 PrimaryGeneratorGun1 ()
 
 ~PrimaryGeneratorGun1 ()
 
virtual void GeneratePrimaries (G4Event *)
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Detailed Description

Definition at line 46 of file PrimaryGeneratorGun1.hh.

Constructor & Destructor Documentation

PrimaryGeneratorGun1::PrimaryGeneratorGun1 ( )

Definition at line 47 of file PrimaryGeneratorGun1.cc.

48  : G4VUserPrimaryGeneratorAction(), fParticleGun(0)
49 {
50  // default particle kinematic
51  //
52  G4int n_particle = 1;
53  fParticleGun = new G4ParticleGun(n_particle);
54 
55  G4ParticleDefinition* particle
57  fParticleGun->SetParticleDefinition(particle);
58  fParticleGun->SetParticleEnergy(1*eV);
59  fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.));
60 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
CLHEP::Hep3Vector G4ThreeVector
int G4int
Definition: G4Types.hh:78
void SetParticlePosition(G4ThreeVector aPosition)
static constexpr double eV
Definition: G4SIunits.hh:215
void SetParticleEnergy(G4double aKineticEnergy)
static G4ParticleTable * GetParticleTable()
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)

Here is the call graph for this function:

PrimaryGeneratorGun1::~PrimaryGeneratorGun1 ( )

Definition at line 64 of file PrimaryGeneratorGun1.cc.

65 {
66  delete fParticleGun;
67 }

Member Function Documentation

void PrimaryGeneratorGun1::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 71 of file PrimaryGeneratorGun1.cc.

72 {
73  //this function is called at the begining of event
74  //
75  //distribution uniform in solid angle
76  //
77  G4double cosTheta = 2*G4UniformRand() - 1., phi = twopi*G4UniformRand();
78  G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
79  G4double ux = sinTheta*std::cos(phi),
80  uy = sinTheta*std::sin(phi),
81  uz = cosTheta;
82 
83  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,uz));
84  fParticleGun->GeneratePrimaryVertex(anEvent);
85 }
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
static constexpr double twopi
Definition: G4SIunits.hh:76
#define G4UniformRand()
Definition: Randomize.hh:97
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:


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