Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
VtkVis::PrimaryGeneratorAction Class Reference

The primary generator action class with particle gun. More...

#include <Doxymodules_visualization.h>

Inheritance diagram for VtkVis::PrimaryGeneratorAction:
G4VUserPrimaryGeneratorAction

Public Member Functions

 PrimaryGeneratorAction ()
 
 ~PrimaryGeneratorAction () override
 
void GeneratePrimaries (G4Event *) override
 
const G4ParticleGunGetParticleGun () const
 

Private Attributes

G4ParticleGunfParticleGun = nullptr
 
G4BoxfEnvelopeBox = nullptr
 

Detailed Description

The primary generator action class with particle gun.

The default kinematic is a 6 MeV gamma, randomly distribued in front of the phantom across 80% of the (X,Y) phantom size.

Definition at line 52 of file Doxymodules_visualization.h.

Constructor & Destructor Documentation

◆ PrimaryGeneratorAction()

VtkVis::PrimaryGeneratorAction::PrimaryGeneratorAction ( )

Definition at line 47 of file PrimaryGeneratorAction.cc.

48{
49 G4int n_particle = 1;
50 fParticleGun = new G4ParticleGun(n_particle);
51
52 // default particle kinematic
53 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
54 G4String particleName;
55 G4ParticleDefinition* particle
56 = particleTable->FindParticle(particleName="e-");
57 fParticleGun->SetParticleDefinition(particle);
58 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
59 fParticleGun->SetParticleEnergy(16.5*GeV);
60}

◆ ~PrimaryGeneratorAction()

VtkVis::PrimaryGeneratorAction::~PrimaryGeneratorAction ( )
override

Definition at line 64 of file PrimaryGeneratorAction.cc.

65{
66 delete fParticleGun;
67}

Member Function Documentation

◆ GeneratePrimaries()

void VtkVis::PrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
override

Definition at line 71 of file PrimaryGeneratorAction.cc.

72{
73 //this function is called at the begining of ecah event
74 //
75
76 // In order to avoid dependence of PrimaryGeneratorAction
77 // on DetectorConstruction class we get Envelope volume
78 // from G4LogicalVolumeStore.
79
80 G4double envSizeXY = 0;
81 G4double envSizeZ = 0;
82
83 if (!fEnvelopeBox)
84 {
85 G4LogicalVolume* envLV
86 = G4LogicalVolumeStore::GetInstance()->GetVolume("Envelope");
87 if ( envLV ) fEnvelopeBox = dynamic_cast<G4Box*>(envLV->GetSolid());
88 }
89
90 if ( fEnvelopeBox ) {
91 envSizeXY = fEnvelopeBox->GetXHalfLength()*2.;
92 envSizeZ = fEnvelopeBox->GetZHalfLength()*2.;
93 }
94 else {
95 G4ExceptionDescription msg;
96 msg << "Envelope volume of box shape not found.\n";
97 msg << "Perhaps you have changed geometry.\n";
98 msg << "The gun will be place at the center.";
99 G4Exception("PrimaryGeneratorAction::GeneratePrimaries()",
100 "MyCode0002",JustWarning,msg);
101 }
102
103 G4double size = 0.8;
104 G4double x0 = size * envSizeXY * (G4UniformRand()-0.5);
105 G4double y0 = size * envSizeXY * (G4UniformRand()-0.5);
106 G4double z0 = 0.5*envSizeZ;
107
108 fParticleGun->SetParticlePosition(G4ThreeVector(0,0,-z0));
109
110 fParticleGun->GeneratePrimaryVertex(anEvent);
111}

◆ GetParticleGun()

const G4ParticleGun * VtkVis::PrimaryGeneratorAction::GetParticleGun ( ) const
inline

Definition at line 59 of file PrimaryGeneratorAction.hh.

59{ return fParticleGun; }

Member Data Documentation

◆ fParticleGun

G4ParticleGun* VtkVis::PrimaryGeneratorAction::fParticleGun = nullptr
private

Definition at line 62 of file PrimaryGeneratorAction.hh.

◆ fEnvelopeBox

G4Box* VtkVis::PrimaryGeneratorAction::fEnvelopeBox = nullptr
private

Definition at line 63 of file PrimaryGeneratorAction.hh.


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

Applications | User Support | Publications | Collaboration