Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
GarfieldPrimaryGeneratorAction Class Reference

#include <GarfieldPrimaryGeneratorAction.hh>

+ Inheritance diagram for GarfieldPrimaryGeneratorAction:

Public Member Functions

 GarfieldPrimaryGeneratorAction ()
 
virtual ~GarfieldPrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *event)
 
void SetRandomFlag (G4bool value)
 

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 48 of file GarfieldPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

◆ GarfieldPrimaryGeneratorAction()

GarfieldPrimaryGeneratorAction::GarfieldPrimaryGeneratorAction ( )

Definition at line 44 of file GarfieldPrimaryGeneratorAction.cc.

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

◆ ~GarfieldPrimaryGeneratorAction()

GarfieldPrimaryGeneratorAction::~GarfieldPrimaryGeneratorAction ( )
virtual

Definition at line 62 of file GarfieldPrimaryGeneratorAction.cc.

62 {
63 delete fParticleGun;
64}

Member Function Documentation

◆ GeneratePrimaries()

void GarfieldPrimaryGeneratorAction::GeneratePrimaries ( G4Event * event)
virtual

Definition at line 68 of file GarfieldPrimaryGeneratorAction.cc.

68 {
69 // This function is called at the begining of event
70
71 /*
72 G4double worldZHalfLength = 0;
73 G4LogicalVolume* worldLV
74 = G4LogicalVolumeStore::GetInstance()->GetVolume("World");
75 G4Box* worldBox = nullptr;
76 if (worldLV) worldBox = dynamic_cast<G4Box*>(worlLV->GetSolid());
77 if (worldBox) {
78 worldZHalfLength = worldBox->GetZHalfLength();
79 } else {
80 G4ExceptionDescription msg;
81 msg << "World volume of box not found." << G4endl;
82 msg << "Perhaps you have changed geometry." << G4endl;
83 msg << "The gun will be place in the center.";
84 G4Exception("GarfieldPrimaryGeneratorAction::GeneratePrimaries()",
85 "MyCode0002", JustWarning, msg);
86 }
87 // Set gun position
88 fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
89 */
90 fParticleGun->GeneratePrimaryVertex(anEvent);
91}

◆ SetRandomFlag()

void GarfieldPrimaryGeneratorAction::SetRandomFlag ( G4bool value)

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