![]() |
Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
|
Mandatory user class providing the primary particle generator. More...
#include <PrimaryGeneratorAction.hh>
Public Member Functions | |
PrimaryGeneratorAction (DetectorConstruction *, RunAction *) | |
Constructor. Sets the particle gun position, energy and direction. | |
void | SetParticle (G4int Z=6, G4int A=17, G4double E=0., G4double Q=0.) |
Obtains pointers to particle and ion tables, and retrieves the particle we want from them. | |
virtual | ~PrimaryGeneratorAction () |
Destructor, destroys the object. | |
void | GeneratePrimaries (G4Event *) |
Randoms the particle gun's position (if desired) and generates an event. | |
void | SetRndmFlag (G4String val) |
If rndmFlag is true, the gun's position is randomized at the beginning of each event. | |
G4ParticleGun * | GetParticleGun () |
Returns the ParticleGun. | |
void | PrintTargetSize () |
Print target size. | |
Private Attributes | |
G4ParticleGun * | particleGun |
Pointer a to the G4ParticleGun class. | |
DetectorConstruction * | Detector |
Pointer to DetectorConstruction. | |
RunAction * | myRunAction |
PrimaryGeneratorMessenger * | gunMessenger |
Messenger for this class. | |
G4String | rndmFlag |
Flag for random gun position. |
Mandatory user class providing the primary particle generator.
Definition at line 42 of file PrimaryGeneratorAction.hh.
PrimaryGeneratorAction::PrimaryGeneratorAction | ( | DetectorConstruction * | DC, |
RunAction * | run | ||
) |
Constructor. Sets the particle gun position, energy and direction.
DC | Object containing the information the constructor needs. |
run | Pointer to the RunAction, to inform this when we change the particle in the gun. |
Definition at line 27 of file PrimaryGeneratorAction.cc.
References Detector, DetectorConstruction::GetWorldSizeX(), gunMessenger, and particleGun.
:Detector(DC),myRunAction(run),rndmFlag("on") { G4int n_particle = 1; particleGun = new G4ParticleGun(n_particle); //create a messenger for this class gunMessenger = new PrimaryGeneratorMessenger(this); // default particle kinematic particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.)); particleGun->SetParticleEnergy(11*GeV); // old value: 2.2 GeV //default particle gun position. G4double position = -(Detector->GetWorldSizeX()); particleGun->SetParticlePosition(G4ThreeVector(position,0.*cm,0.*cm)); }
void PrimaryGeneratorAction::SetParticle | ( | G4int | Z = 6 , |
G4int | A = 17 , |
||
G4double | E = 0. , |
||
G4double | Q = 0. |
||
) |
Obtains pointers to particle and ion tables, and retrieves the particle we want from them.
Z | The atomic number of the particle. |
A | The atomic mass of the particle. |
E | The excitation energy of the particle. |
Q | The charge of the particle. |
Definition at line 11 of file PrimaryGeneratorAction.cc.
References particleGun.
Referenced by main().
{ G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); particleTable->GetIonTable()->CreateAllIon(); G4ParticleDefinition* particle = particleTable->GetIon(Z, A, E); if(particle!=NULL) { particleGun->SetParticleCharge(Q); particleGun->SetParticleDefinition(particle); myRunAction->SetParticleZ(Z); myRunAction->SetParticleA(A); } }