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

#include <ExUCNPrimaryGeneratorAction.hh>

Inheritance diagram for ExUCNPrimaryGeneratorAction:
Collaboration diagram for ExUCNPrimaryGeneratorAction:

Public Member Functions

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

Detailed Description

Definition at line 46 of file ExUCNPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

ExUCNPrimaryGeneratorAction::ExUCNPrimaryGeneratorAction ( void  )

Definition at line 49 of file ExUCNPrimaryGeneratorAction.cc.

50 {
51  G4int n_particle = 1;
52  fParticleGun = new G4ParticleGun(n_particle);
53 
55 
56  G4ParticleDefinition* particle = particleTable->FindParticle("neutron");
57  fParticleGun->SetParticleDefinition(particle);
58 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
int G4int
Definition: G4Types.hh:78
static G4ParticleTable * GetParticleTable()
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)

Here is the call graph for this function:

ExUCNPrimaryGeneratorAction::~ExUCNPrimaryGeneratorAction ( )
virtual

Definition at line 62 of file ExUCNPrimaryGeneratorAction.cc.

63 {
64  delete fParticleGun;
65 }

Member Function Documentation

void ExUCNPrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 69 of file ExUCNPrimaryGeneratorAction.cc.

70 {
71  // This function is called at the begining of event
72 
73  fParticleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, 0.0));
74  fParticleGun->SetParticlePolarization(G4ThreeVector(0,1,0));
75 
76  G4double particleEnergy = 1e-9*eV + G4UniformRand()*(1e-7*eV-1e-9*eV);
77  fParticleGun->SetParticleEnergy(particleEnergy);
78 
79  G4double theta = 2*pi*G4UniformRand();
80  G4double phi = std::acos(1-2*G4UniformRand());
81  if (phi > pi/2 && phi < pi) phi = pi-phi;
82 
83  G4double z = std::sin(phi)*std::cos(theta);
84  G4double x = std::sin(phi)*std::sin(theta);
85  G4double y = std::cos(phi);
86 
87  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(x,y,z));
88 
89  fParticleGun->GeneratePrimaryVertex(anEvent);
90 }
CLHEP::Hep3Vector G4ThreeVector
tuple x
Definition: test.py:50
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
void SetParticlePolarization(G4ThreeVector aVal)
void SetParticlePosition(G4ThreeVector aPosition)
#define G4UniformRand()
Definition: Randomize.hh:97
static constexpr double eV
Definition: G4SIunits.hh:215
void SetParticleEnergy(G4double aKineticEnergy)
tuple z
Definition: test.py:28
static constexpr double pi
Definition: G4SIunits.hh:75
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: