Garfield++ v1r0
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 47 of file GarfieldPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

◆ GarfieldPrimaryGeneratorAction()

GarfieldPrimaryGeneratorAction::GarfieldPrimaryGeneratorAction ( )

Definition at line 46 of file GarfieldPrimaryGeneratorAction.cc.

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

◆ ~GarfieldPrimaryGeneratorAction()

GarfieldPrimaryGeneratorAction::~GarfieldPrimaryGeneratorAction ( )
virtual

Definition at line 66 of file GarfieldPrimaryGeneratorAction.cc.

67{
68 delete fParticleGun;
69}

Member Function Documentation

◆ GeneratePrimaries()

void GarfieldPrimaryGeneratorAction::GeneratePrimaries ( G4Event *  event)
virtual

Definition at line 73 of file GarfieldPrimaryGeneratorAction.cc.

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

◆ SetRandomFlag()

void GarfieldPrimaryGeneratorAction::SetRandomFlag ( G4bool  value)

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