12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

User Actionspublic: // with description// remove and delete ProcessManagers <strong>for</strong> all particles in tha Particle Table// this routine is invoked from RunManagervoid RemoveProcessManager();public: // with description// add process manager <strong>for</strong> particles created on-the-flyvoid AddProcessManager(G4ParticleDefinition* newParticle,G4ProcessManager* newManager = 0 );};G4VUserPrimaryGeneratorActionExample 6.3. G4VUserPrimaryGeneratorActionclass G4VUserPrimaryGeneratorAction{public:G4VUserPrimaryGeneratorAction();virtual ~G4VUserPrimaryGeneratorAction();public:virtual void GeneratePrimaries(G4Event* anEvent) = 0;};6.2. Optional User ActionsThere are five virtual classes whose methods the user may override in order to gain control of the simulation at variousstages. Each method of each action class has an empty default implementation, allowing the user to inherit andimplement desired classes and methods. Objects of user action classes must be registered with G4RunManager.6.2.1. Usage of User ActionsG4UserRunActionThis class has three virtual methods which are invoked by G4RunManager <strong>for</strong> each run:GenerateRun()This method is invoked at the beginning of BeamOn. Because the user can inherit the class G4Run and createhis/her own concrete class to store some in<strong>for</strong>mation about the run, the GenerateRun() method is theplace to instantiate such an object. It is also the ideal place to set variables which affect the physics table (suchas production thresholds) <strong>for</strong> a particular run, because GenerateRun() is invoked be<strong>for</strong>e the calculationof the physics table.BeginOfRunAction()This method is invoked be<strong>for</strong>e entering the event loop. A typical use of this method would be to initialize and/or book histograms <strong>for</strong> a particular run. This method is invoked after the calculation of the physics tables.EndOfRunAction()This method is invoked at the very end of the run processing. It is typically used <strong>for</strong> a simple analysis ofthe processed run.Example 6.4. G4UserRunActionclass G4UserRunAction{public:G4UserRunAction();virtual ~G4UserRunAction();public:virtual G4Run* GenerateRun();virtual void BeginOfRunAction(const G4Run*);virtual void EndOfRunAction(const G4Run*);};198

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!