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

#include <PrimaryGenerator.hh>

Inheritance diagram for PrimaryGenerator:
Collaboration diagram for PrimaryGenerator:

Public Member Functions

 PrimaryGenerator ()
 
 ~PrimaryGenerator ()
 
virtual void GeneratePrimaryVertex (G4Event *)
 
- Public Member Functions inherited from G4VPrimaryGenerator
 G4VPrimaryGenerator ()
 
virtual ~G4VPrimaryGenerator ()
 
G4ThreeVector GetParticlePosition ()
 
G4double GetParticleTime ()
 
void SetParticlePosition (G4ThreeVector aPosition)
 
void SetParticleTime (G4double aTime)
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VPrimaryGenerator
static G4bool CheckVertexInsideWorld (const G4ThreeVector &pos)
 
- Protected Attributes inherited from G4VPrimaryGenerator
G4ThreeVector particle_position
 
G4double particle_time
 

Detailed Description

Definition at line 44 of file PrimaryGenerator.hh.

Constructor & Destructor Documentation

PrimaryGenerator::PrimaryGenerator ( )

Definition at line 48 of file PrimaryGenerator.cc.

PrimaryGenerator::~PrimaryGenerator ( )

Definition at line 54 of file PrimaryGenerator.cc.

55 { }

Member Function Documentation

void PrimaryGenerator::GeneratePrimaryVertex ( G4Event event)
virtual

Implements G4VPrimaryGenerator.

Definition at line 59 of file PrimaryGenerator.cc.

60 {
61  //vertex A uniform on a cylinder
62  //
63  const G4double r = 2*mm;
64  const G4double zmax = 8*mm;
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  G4ThreeVector positionA(r*ux,r*uy,z);
71  G4double timeA = 0*s;
72  //
73  G4PrimaryVertex* vertexA = new G4PrimaryVertex(positionA, timeA);
74 
75  //particle 1 at vertex A
76  //
77  G4ParticleDefinition* particleDefinition
79  G4PrimaryParticle* particle1 = new G4PrimaryParticle(particleDefinition);
80  particle1->SetMomentumDirection(G4ThreeVector(ux,uy,0));
81  particle1->SetKineticEnergy(1*MeV);
82  //
83  vertexA->SetPrimary(particle1);
84  event->AddPrimaryVertex(vertexA);
85 
86  //vertex (B) symetric to vertex A
87  //
88  alpha += pi;
89  ux = std::cos(alpha);
90  uy = std::sin(alpha);
91  G4ThreeVector positionB(r*ux,r*uy,z);
92  G4double timeB = 1*s;
93  //
94  G4PrimaryVertex* vertexB = new G4PrimaryVertex(positionB, timeB);
95 
96  //particles 2 and 3 at vertex B
97  //
98  const G4double dalpha = 10*deg;
99  ux = std::cos(alpha + dalpha);
100  uy = std::sin(alpha + dalpha);
101  G4PrimaryParticle* particle2 = new G4PrimaryParticle(particleDefinition);
102  particle2->SetMomentumDirection(G4ThreeVector(ux,uy,0));
103  particle2->SetKineticEnergy(1*keV);
104  //
105  ux = std::cos(alpha - dalpha);
106  uy = std::sin(alpha - dalpha);
107  G4PrimaryParticle* particle3 = new G4PrimaryParticle(particleDefinition);
108  particle3->SetMomentumDirection(G4ThreeVector(ux,uy,0));
109  particle3->SetKineticEnergy(1*GeV);
110  //
111  vertexB->SetPrimary(particle2);
112  vertexB->SetPrimary(particle3);
113  event->AddPrimaryVertex(vertexB);
114 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static constexpr double mm
Definition: G4SIunits.hh:115
CLHEP::Hep3Vector G4ThreeVector
static constexpr double twopi
Definition: G4SIunits.hh:76
void SetKineticEnergy(G4double eKin)
const XML_Char * s
Definition: expat.h:262
#define G4UniformRand()
Definition: Randomize.hh:97
static G4ParticleTable * GetParticleTable()
void SetMomentumDirection(const G4ThreeVector &p)
static constexpr double GeV
Definition: G4SIunits.hh:217
tuple z
Definition: test.py:28
void SetPrimary(G4PrimaryParticle *pp)
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: