Presentation is loading. Please wait.

Presentation is loading. Please wait.

Run and Event G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector.

Similar presentations


Presentation on theme: "Run and Event G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector."— Presentation transcript:

1

2 Run and Event

3 G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector geometry, the setup of the sensitive detectors and the physics processes cannot be modified A Run is represented by an object of the G4Run class A Run begins when the BeamOn() method of the G4RunManager class is invoked

4 G4Run G4Run contains a run identification number which should be set by the user and the number of events to be simulated during that Run The Run identification number is not used by the Geant4 kernel and it is then an arbitrary number which is provided for the convenience of the user G4Run contains pointers to the name tables of G4VHitsCollection’s and G4VDigiCollection’s which are associated in case Sensitive Detectors and Digitizers are implemented

5 G4RunManager The G4RunManager class manages the procedures of a run. In the G4RunManagerConstructor, all the Geant4 manager classes are constructed. These managers are then deleted in the G4RunManager destructor G4RunManager is a singleton, only one run manager can exist throughout the whole program. A pointer to this object can be obtained by invoking the G4RunManager’s method GetRunManager() All user initialization classes and user action classes should be assigned to G4RunManager before the initialization of the Geant4 kernel by using the SetUserInitialization() and the SetUserAction() methods

6 G4RunManager’s public methods Initialize() –construction of the detector geometry and setup of the sensitive detectors/digitizers –construction of particles and physics processes –calculation of cross-section tables BeamOn(G4int numberOfEvents) –triggers the actual simulation of a run (event loop). It takes an integer argument, the number of events to be simulated GetRunManager() –returns the pointer to the G4RunManager singleton object GetCurrentEvent() –returns a pointer to the G4Event object currently being simulated. This method is only available while events are being produced (EventProc state). A const pointer is returned (read-only)

7 G4RunManager’s public methods (2) SetNumberOfEventsToBeStored(G4int nPrevious) –For the case of piling up more than one event, it is essential to access more than one event at the same moment. By invoking this method, G4RunManager keeps nPrevious G4Event objects in memory. This method must be invoked before beamOn() GetPreviousEvent(G4int i_thPrevious) –Returns a pointer to the i_thPrevious G4Event object stored. The pointer returned is const, hence the G4Event returned cannot be modified

8 How Geant4 runs (initialization)

9 How Geant4 runs (event loop) loop

10 G4UserRunAction G4UserRunAction is one of the user action classes one can derive his/her concrete class from The G4UserRunAction class has two virtual methods the user must implement –BeginOfRunAction() invoked at the beginning of the BeamOn() method but after confirming the conditions of the Geant4 kernel. To be used for setting the run identification number, book histograms, setup run-specific conditions, etc.. –EndOfRunAction() invoked at the very end of the BeamOn() method. It can be used to store histograms, manipulate run summaries, etc...

11 Geant4 is a state machine Geant4 is designed as a state machine. Certain methods are only available in certain states. G4RunManager controls the state changes. –PreInit state The application starts in this state. Geant4 need to be initialized. The application comes back to this state if geometry, physics or cut-off have been modified –Init state G4RunManager initialize() is being invoked –Idle state The application is ready to process a run –GeomClosed state BeamOn() has been invoked –EventProc state An event is being processed. GetCurrentEvent() and GetPreviousEvent() are only available at this state –Quit state G4RunManager’s destructor has been invoked. The application is dead

12 Aborting a run To abort a Geant4 run being processed (for whichever reason) the AbortRun() method of G4RunManager must be invoked AbortRun() is only available in the GeomClosed and EventProc states AbortRun() safely stops the run processing even when a particular event is being simulated The last event of the aborted run is incomplete and it should not be used for further analysis

13 Customizing G4RunManager G4RunManager, still being a concrete class, has a complete set of virtual functions. The user may decide to inherit his/her own manager class and re- implement part or most of the functionality of the G4RunManager public: virtual void Initialize();main entry point of GEANT4 kernel initialization virtual void DefineWorldVolume(G4VPhysicalVolume * worldVol); Set the world volume to G4Navigator virtual void AbortRun(); Run abortion virtual void BeamOn(G4int n_event)main entry point of the event loop protected: virtual void InitializeGeometry(); Geometry construction virtual void InitializePhysics();physics processes construction virtual void InitializeCutOff();Build cross-section tables virtual G4bool ConfirmBeamOnCondition(); Check the kernel conditions for the event loop virtual void RunInitialization();Prepare a run virtual void DoEventLoop(G4int n_events);Manage an event loop virtual G4Event* GenerateEvent(G4int i_event); Generation of G4Event object virtual void AnalyzeEvent(G4Event* anEvent); Storage/analysis of an event virtual void RunTermination(); Terminate a run

14 Changing the detector geometry The detector geometry defined in G4VUserDetectorConstruction class can be changed during the run break (between two runs) –In the case one wants to delete the entire structure and set up a completely new structure, one has to register the new World volume with G4RunManager –More likely, one may want to modify his/her geometry only slightly (e.g. rotate a testbeam setup wrt the beam line or modify the thickness of the active layers of a calorimeter). This action does generally not require a complete redefinition of the geometry and can normally be implemented by calling some function at the beginning of each run. In any case, G4RunManager must be notified that the geometry must be re-built G4RunManager* runManager = G4RunManager::GetRunManager(); MyNewGeometry newGeometry; G4VPhysicalVolume* newWorldPhys=newGeometry.Construct(); runManager->DefineWorldVolume(newWorldPhys); runManager->GeometryHasBeenModified()

15 Events An Event in Geant4 is represented by the class G4Event, which contains all quantities needed to characterize the simulated event A G4Event object is constructed by the G4RunManager and sent to the G4EventManager The event being processed can be gotten at any moment by means of the GetCurrentEvent() method of G4RunManager

16 G4Event An G4Event object contains four major pieces of information which are available via get methods –Primary vertexes and primary particles –Trajectories Stored in an object of type G4TrajectoryContainer, which can can be accessed from G4Event –Hits collections Generated by Sensitive Detectors, they are kept in an object of type G4HCofThisEvent, whose pointer is kept in G4Event –Digits collections Generated by Digitizers, they are kept in an object of type G4DCofThisEvent, whose pointer is kept by G4Event

17 G4EventManager G4EventManager is the manager class which takes care of the Event. Its main tasks are –to convert G4PrimaryVertex and G4PrimaryParticle objects associated with the current G4Event object to G4Track objects. All G4Track objects are sent to G4StackManager –Pop one track object from G4StackManager and send it to G4TrackingManager. The current G4Track object is deleted by G4EventManager after the track is simulated by G4TrackingManager, if the track is marked as “killed” –In case the primary track is “suspended” or “postponed to the next event”, it is sent back to the G4StackManager. Secondary G4Track object returned by G4TrackingManager are also sent to G4StackManager –When G4StackManager returns NULL to the pop request, G4EventManager terminates the current event processing

18 How Geant4 runs (event process)

19 G4UserEventAction G4UserEventAction is one of the user action classes G4UserEventAction has two virtual method which are invoked for each event and which can be implemented by the user –BeginOfEventAction() Invoked before converting the primary particles to G4Track objects. Used for initialization and/or histogram booking for one particular event –EndOfEventAction() Invoked at the very end of the event processing. Used for simple analysis of the current event

20 G4UserSteppingAction G4UserSteppingAction is a class that the user must inherit from to have the possibility of intervening after a step has been undertaken. An object of the class that the user implements must be passed to the RunManager by invoking SetUserAction in the main program The user must implement the method –void UserSteppingAction(const G4Step*) This will be invoked step by step during tracking. The pointer to an object of type G4Step provides (hopefully) enough information to allow the user to retrieve any information he/she might need


Download ppt "Run and Event G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector."

Similar presentations


Ads by Google