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

#include <PrimaryGeneratorAction1.hh>

Public Member Functions

 PrimaryGeneratorAction1 (G4ParticleGun *)
 
 ~PrimaryGeneratorAction1 ()
 
void GeneratePrimaries (G4Event *)
 

Detailed Description

Definition at line 46 of file PrimaryGeneratorAction1.hh.

Constructor & Destructor Documentation

PrimaryGeneratorAction1::PrimaryGeneratorAction1 ( G4ParticleGun gun)

Definition at line 48 of file PrimaryGeneratorAction1.cc.

49 : fParticleGun(gun)
50 { }
PrimaryGeneratorAction1::~PrimaryGeneratorAction1 ( )

Definition at line 54 of file PrimaryGeneratorAction1.cc.

55 { }

Member Function Documentation

void PrimaryGeneratorAction1::GeneratePrimaries ( G4Event anEvent)

Definition at line 59 of file PrimaryGeneratorAction1.cc.

60 {
61  const G4double r = 2*mm;
62  const G4double zmax = 8*mm;
63 
64  //vertex 1 uniform on cylinder
65  //
66  G4double alpha = twopi*G4UniformRand(); //alpha uniform in (0, 2*pi)
67  G4double ux = std::cos(alpha);
68  G4double uy = std::sin(alpha);
69  G4double z = zmax*(2*G4UniformRand() - 1); //z uniform in (-zmax, +zmax)
70 
71  fParticleGun->SetParticlePosition(G4ThreeVector(r*ux,r*uy,z));
72  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,0));
73  fParticleGun->SetParticleEnergy(1*MeV);
74  fParticleGun->GeneratePrimaryVertex(anEvent);
75 
76  //vertex 2 at opposite
77  //
78  alpha += pi;
79  ux = std::cos(alpha);
80  uy = std::sin(alpha);
81  fParticleGun->SetParticlePosition(G4ThreeVector(r*ux,r*uy,z));
82 
83  //particle 2 at vertex 2
84  //
85  const G4double dalpha = 10*deg;
86  ux = std::cos(alpha + dalpha);
87  uy = std::sin(alpha + dalpha);
88 
89  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,0));
90  fParticleGun->SetParticleEnergy(1*keV);
91  fParticleGun->GeneratePrimaryVertex(anEvent);
92 
93  //particle 3 at vertex 3 (same as vertex 2)
94  //
95  ux = std::cos(alpha - dalpha);
96  uy = std::sin(alpha - dalpha);
97 
98  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,0));
99  fParticleGun->SetParticleEnergy(1*GeV);
100  fParticleGun->GeneratePrimaryVertex(anEvent);
101 
102  // randomize time zero of anEvent
103  //
104  G4double tmin = 0*s, tmax = 10*s;
105  G4double t0 = tmin + (tmax - tmin)*G4UniformRand();
106  G4PrimaryVertex* aVertex = anEvent->GetPrimaryVertex();
107  while (aVertex) {
108  aVertex->SetT0(t0);
109  aVertex = aVertex->GetNext();
110  }
111 }
static constexpr double mm
Definition: G4SIunits.hh:115
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
static constexpr double twopi
Definition: G4SIunits.hh:76
const XML_Char * s
Definition: expat.h:262
void SetParticlePosition(G4ThreeVector aPosition)
#define G4UniformRand()
Definition: Randomize.hh:97
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
Definition: G4Event.hh:167
G4PrimaryVertex * GetNext() const
void SetParticleEnergy(G4double aKineticEnergy)
void SetT0(G4double t0)
static constexpr double GeV
Definition: G4SIunits.hh:217
tuple z
Definition: test.py:28
static constexpr double MeV
Definition: G4SIunits.hh:214
static constexpr double pi
Definition: G4SIunits.hh:75
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
static const G4double alpha
static constexpr double keV
Definition: G4SIunits.hh:216

Here is the call graph for this function:


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