Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
B4::PrimaryGeneratorAction Class Reference
basic » B4 » B4a | basic » B4 » B4b | basic » B4 » B4c | basic » B4 » B4d

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

#include <Doxymodules_basic.h>

Inheritance diagram for B4::PrimaryGeneratorAction:
G4VUserPrimaryGeneratorAction

Public Member Functions

 PrimaryGeneratorAction ()
 
 ~PrimaryGeneratorAction () override
 
void GeneratePrimaries (G4Event *event) override
 

Private Attributes

G4ParticleGunfParticleGun = nullptr
 

Detailed Description

The primary generator action class with particle gum.

It defines a single particle which hits the calorimeter perpendicular to the input face. The type of the particle can be changed via the G4 build-in commands of G4ParticleGun class (see the macros provided with this example).

Definition at line 124 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ PrimaryGeneratorAction()

B4::PrimaryGeneratorAction::PrimaryGeneratorAction ( )

Definition at line 48 of file PrimaryGeneratorAction.cc.

49{
50 G4int nofParticles = 1;
51 fParticleGun = new G4ParticleGun(nofParticles);
52
53 // default particle kinematic
54 //
55 auto particleDefinition
56 = G4ParticleTable::GetParticleTable()->FindParticle("e-");
57 fParticleGun->SetParticleDefinition(particleDefinition);
58 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
59 fParticleGun->SetParticleEnergy(300.*MeV);
60}

◆ ~PrimaryGeneratorAction()

B4::PrimaryGeneratorAction::~PrimaryGeneratorAction ( )
override

Definition at line 64 of file PrimaryGeneratorAction.cc.

65{
66 delete fParticleGun;
67}

Member Function Documentation

◆ GeneratePrimaries()

void B4::PrimaryGeneratorAction::GeneratePrimaries ( G4Event event)
override

Definition at line 71 of file PrimaryGeneratorAction.cc.

72{
73 // This function is called at the begining of event
74
75 // In order to avoid dependence of PrimaryGeneratorAction
76 // on DetectorConstruction class we get world volume
77 // from G4LogicalVolumeStore
78 //
79 G4double worldZHalfLength = 0.;
80 auto worldLV = G4LogicalVolumeStore::GetInstance()->GetVolume("World");
81
82 // Check that the world volume has box shape
83 G4Box* worldBox = nullptr;
84 if ( worldLV ) {
85 worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
86 }
87
88 if ( worldBox ) {
89 worldZHalfLength = worldBox->GetZHalfLength();
90 }
91 else {
92 G4ExceptionDescription msg;
93 msg << "World volume of box shape not found." << G4endl;
94 msg << "Perhaps you have changed geometry." << G4endl;
95 msg << "The gun will be place in the center.";
96 G4Exception("PrimaryGeneratorAction::GeneratePrimaries()",
97 "MyCode0002", JustWarning, msg);
98 }
99
100 // Set gun position
102 ->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
103
104 fParticleGun->GeneratePrimaryVertex(anEvent);
105}

Member Data Documentation

◆ fParticleGun

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

Definition at line 58 of file PrimaryGeneratorAction.hh.


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

Applications | User Support | Publications | Collaboration