Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
Public Member Functions | Private Attributes
PrimaryGeneratorAction Class Reference

Mandatory user class providing the primary particle generator. More...

#include <PrimaryGeneratorAction.hh>

List of all members.

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.
DetectorConstructionDetector
 Pointer to DetectorConstruction.
RunActionmyRunAction
PrimaryGeneratorMessengergunMessenger
 Messenger for this class.
G4String rndmFlag
 Flag for random gun position.

Detailed Description

Mandatory user class providing the primary particle generator.

Definition at line 42 of file PrimaryGeneratorAction.hh.


Constructor & Destructor Documentation

PrimaryGeneratorAction::PrimaryGeneratorAction ( DetectorConstruction DC,
RunAction run 
)

Constructor. Sets the particle gun position, energy and direction.

Parameters:
DCObject containing the information the constructor needs.
runPointer 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));
}

Member Function Documentation

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.

Parameters:
ZThe atomic number of the particle.
AThe atomic mass of the particle.
EThe excitation energy of the particle.
QThe 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);
    }
}

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark