Geant4  10.02.p03
PrimaryGeneratorAction4 Class Reference

#include <PrimaryGeneratorAction4.hh>

Collaboration diagram for PrimaryGeneratorAction4:

Public Member Functions

 PrimaryGeneratorAction4 (G4ParticleGun *)
 
 ~PrimaryGeneratorAction4 ()
 
void GeneratePrimaries (G4Event *)
 
G4double GetRmin3 ()
 
G4double GetRmax3 ()
 
G4double GetCosAlphaMin ()
 
G4double GetCosAlphaMax ()
 

Private Attributes

G4double fRmin3
 
G4double fRmax3
 
G4double fCosAlphaMin
 
G4double fCosAlphaMax
 
G4ParticleGunfParticleGun
 

Detailed Description

Definition at line 47 of file PrimaryGeneratorAction4.hh.

Constructor & Destructor Documentation

◆ PrimaryGeneratorAction4()

PrimaryGeneratorAction4::PrimaryGeneratorAction4 ( G4ParticleGun gun)

Definition at line 48 of file PrimaryGeneratorAction4.cc.

49 : fParticleGun(gun)
50 {
51  // vertex volume
52  //
53  G4double Rmin = 2.*mm;
54  G4double Rmax = 8.*mm;
55  fRmin3 = Rmin*Rmin*Rmin;
56  fRmax3 = Rmax*Rmax*Rmax;
57 
58  //opening angle
59  //
60  G4double alphaMin = 0.*deg;
61  G4double alphaMax = 60.*deg;
62  fCosAlphaMin = std::cos(alphaMin);
63  fCosAlphaMax = std::cos(alphaMax);
64 }
static const double deg
Definition: G4SIunits.hh:151
double G4double
Definition: G4Types.hh:76
static const double mm
Definition: G4SIunits.hh:114

◆ ~PrimaryGeneratorAction4()

PrimaryGeneratorAction4::~PrimaryGeneratorAction4 ( )

Definition at line 68 of file PrimaryGeneratorAction4.cc.

69 { }

Member Function Documentation

◆ GeneratePrimaries()

void PrimaryGeneratorAction4::GeneratePrimaries ( G4Event anEvent)

Definition at line 73 of file PrimaryGeneratorAction4.cc.

74 {
75  //vertex position uniform in spherical shell
76  //
77  G4double cosTheta = 2*G4UniformRand() - 1; //cosTheta uniform in [0, pi]
78  G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
79  G4double phi = twopi*G4UniformRand(); //phi uniform in [0, 2*pi]
80  G4ThreeVector ur(sinTheta*std::cos(phi),sinTheta*std::sin(phi),cosTheta);
81 
83  G4double R = std::pow(R3, 1./3);
84 
86 
87  //particle direction uniform around ur
88  //
89  //1- in World frame
90  //cosAlpha uniform in [cos(alphaMin), cos(alphaMax)]
92  G4double sinAlpha = std::sqrt(1. - cosAlpha*cosAlpha);
93  G4double psi = twopi*G4UniformRand(); //psi uniform in (0,2*pi)
94  G4ThreeVector dir(sinAlpha*std::cos(psi),sinAlpha*std::sin(psi),cosAlpha);
95 
96  //2- rotate dir (rotateUz transforms uz to ur)
97  dir.rotateUz(ur);
98 
100 
101  //energy
102  //
104 
105  //create vertex
106  //
108 }
static const double MeV
Definition: G4SIunits.hh:211
TDirectory * dir
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
void SetParticlePosition(G4ThreeVector aPosition)
#define G4UniformRand()
Definition: Randomize.hh:97
static const double twopi
Definition: G4SIunits.hh:75
void SetParticleEnergy(G4double aKineticEnergy)
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ GetCosAlphaMax()

G4double PrimaryGeneratorAction4::GetCosAlphaMax ( )
inline

Definition at line 59 of file PrimaryGeneratorAction4.hh.

◆ GetCosAlphaMin()

G4double PrimaryGeneratorAction4::GetCosAlphaMin ( )
inline

Definition at line 58 of file PrimaryGeneratorAction4.hh.

◆ GetRmax3()

G4double PrimaryGeneratorAction4::GetRmax3 ( )
inline

Definition at line 57 of file PrimaryGeneratorAction4.hh.

57 {return fRmax3;};

◆ GetRmin3()

G4double PrimaryGeneratorAction4::GetRmin3 ( )
inline

Definition at line 56 of file PrimaryGeneratorAction4.hh.

56 {return fRmin3;};

Member Data Documentation

◆ fCosAlphaMax

G4double PrimaryGeneratorAction4::fCosAlphaMax
private

Definition at line 65 of file PrimaryGeneratorAction4.hh.

◆ fCosAlphaMin

G4double PrimaryGeneratorAction4::fCosAlphaMin
private

Definition at line 64 of file PrimaryGeneratorAction4.hh.

◆ fParticleGun

G4ParticleGun* PrimaryGeneratorAction4::fParticleGun
private

Definition at line 67 of file PrimaryGeneratorAction4.hh.

◆ fRmax3

G4double PrimaryGeneratorAction4::fRmax3
private

Definition at line 63 of file PrimaryGeneratorAction4.hh.

◆ fRmin3

G4double PrimaryGeneratorAction4::fRmin3
private

Definition at line 59 of file PrimaryGeneratorAction4.hh.


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