Garfield++ 4.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 46 of file GarfieldPrimaryGeneratorAction.cc.

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

◆ ~GarfieldPrimaryGeneratorAction()

GarfieldPrimaryGeneratorAction::~GarfieldPrimaryGeneratorAction ( )
virtual

Definition at line 64 of file GarfieldPrimaryGeneratorAction.cc.

64 {
65 delete fParticleGun;
66}

Member Function Documentation

◆ GeneratePrimaries()

void GarfieldPrimaryGeneratorAction::GeneratePrimaries ( G4Event *  event)
virtual

Definition at line 70 of file GarfieldPrimaryGeneratorAction.cc.

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

◆ SetRandomFlag()

void GarfieldPrimaryGeneratorAction::SetRandomFlag ( G4bool  value)

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