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 ActionsG4UserEventActionThis class has two virtual methods which are invoked by G4EventManager <strong>for</strong> each event:beginOfEventAction()This method is invoked be<strong>for</strong>e converting the primary particles to G4Track objects. A typical use of thismethod would be to initialize and/or book histograms <strong>for</strong> a particular event.endOfEventAction()This method is invoked at the very end of event processing. It is typically used <strong>for</strong> a simple analysis of theprocessed event. If the user wants to keep the currently processing event until the end of the current run, theuser can invoke fpEventManager->KeepTheCurrentEvent(); so that it is kept in G4Run object.This should be quite useful if you simulate quite many events and want to visualize only the most interestones after the long execution. Given the memory size of an event and its contents may be large, it is the user'sresponsibility not to keep unnecessary events.Example 6.5. G4UserEventActionclass G4UserEventAction{public:G4UserEventAction() {;}virtual ~G4UserEventAction() {;}virtual void BeginOfEventAction(const G4Event*);virtual void EndOfEventAction(const G4Event*);protected:G4EventManager* fpEventManager;};G4UserStackingActionThis class has three virtual methods, ClassifyNewTrack, NewStage and PrepareNewEvent which theuser may override in order to control the various track stacking mechanisms. ExampleN04 could be a good exampleto understand the usage of this class.ClassifyNewTrack() is invoked by G4StackManager whenever a new G4Track object is"pushed" onto a stack by G4EventManager. ClassifyNewTrack() returns an enumerator,G4ClassificationOfNewTrack, whose value indicates to which stack, if any, the track will be sent. Thisvalue should be determined by the user. G4ClassificationOfNewTrack has four possible values:• fUrgent - track is placed in the urgent stack• fWaiting - track is placed in the waiting stack, and will not be simulated until the urgent stack is empty• fPostpone - track is postponed to the next event• fKill - the track is deleted immediately and not stored in any stack.These assignments may be made based on the origin of the track which is obtained as follows:G4int parent_ID = aTrack->get_parentID();where• parent_ID = 0 indicates a primary particle• parent_ID > 0 indicates a secondary particle• parent_ID < 0 indicates postponed particle from previous event.NewStage() is invoked when the urgent stack is empty and the waiting stack contains at least one G4Trackobject. Here the user may kill or re-assign to different stacks all the tracks in the waiting stack by calling the199

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

Saved successfully!

Ooh no, something went wrong!