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

#include <PrimaryGeneratorAction3.hh>

Public Member Functions

 PrimaryGeneratorAction3 (G4ParticleGun *)
 
 ~PrimaryGeneratorAction3 ()
 
void GeneratePrimaries (G4Event *)
 
G4ThreeVector GetNewUz ()
 
G4double GetAlphaMax ()
 

Detailed Description

Definition at line 47 of file PrimaryGeneratorAction3.hh.

Constructor & Destructor Documentation

PrimaryGeneratorAction3::PrimaryGeneratorAction3 ( G4ParticleGun gun)

Definition at line 48 of file PrimaryGeneratorAction3.cc.

49 : fParticleGun(gun)
50 {
51  // direction
52  //
53  G4double theta = 90*deg, phi = 45*deg;
54  fNewUz = G4ThreeVector(std::sin(theta)*std::cos(phi),
55  std::sin(theta)*std::sin(phi),
56  std::cos(theta));
57 
58  fAlphaMax = 15*deg;
59 }
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
PrimaryGeneratorAction3::~PrimaryGeneratorAction3 ( )

Definition at line 63 of file PrimaryGeneratorAction3.cc.

64 { }

Member Function Documentation

void PrimaryGeneratorAction3::GeneratePrimaries ( G4Event anEvent)

Definition at line 68 of file PrimaryGeneratorAction3.cc.

69 {
70  //particle direction uniform around fNewUz axis
71  //
72  //1- in World frame
73  //cosAlpha uniform in [cos(0), cos(fAlphaMax)]
74  G4double cosAlpha = 1. - G4UniformRand()*(1.- std::cos(fAlphaMax));
75  G4double sinAlpha = std::sqrt(1. - cosAlpha*cosAlpha);
76  G4double psi = twopi*G4UniformRand(); //psi uniform in [0, 2*pi]
77  G4ThreeVector dir(sinAlpha*std::cos(psi),sinAlpha*std::sin(psi),cosAlpha);
78 
79  //2- rotate dir (rotateUz transforms uz to fNewUz)
80  dir.rotateUz(fNewUz);
81 
82  fParticleGun->SetParticleMomentumDirection(dir);
83 
84  //set energy
85  //
86  fParticleGun->SetParticleEnergy(1*MeV);
87 
88  //create vertex
89  //
90  fParticleGun->GeneratePrimaryVertex(anEvent);
91 }
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
static constexpr double twopi
Definition: G4SIunits.hh:76
#define G4UniformRand()
Definition: Randomize.hh:97
void SetParticleEnergy(G4double aKineticEnergy)
static constexpr double MeV
Definition: G4SIunits.hh:214
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4double PrimaryGeneratorAction3::GetAlphaMax ( )
inline

Definition at line 58 of file PrimaryGeneratorAction3.hh.

58 { return fAlphaMax; };
G4ThreeVector PrimaryGeneratorAction3::GetNewUz ( )
inline

Definition at line 57 of file PrimaryGeneratorAction3.hh.

57 { return fNewUz; };

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