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.

Slides:



Advertisements
Similar presentations
The Geant4 Kernel: Status and Recent Developments John Apostolakis, Gabriele Cosmo – CERN / PH Makoto Asai – SLAC On behalf the Geant4 collaboration April.
Advertisements

IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
Geant4 v9.2p02 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 20th, 2002 Stack management, Digitization and Pile-up.
Primary particle generation Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 15 th, 2002 Customizing Run Management.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 12 th, 2002 Detector Sensitivity.
Geant4 v9.4 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Detector Sensitivity.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11 th, 2002 Getting Started.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Geant4 v9.3p01 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 20th, 2002 Stack management, Digitization and Pile-up.
S. Guatelli, M.G Pia, INFN Genova S. Guatelli ( CERN, INFN Genova ) CERN, 13 November 2002 Users Workshop Where to put analysis in Geant4 Applications.
Geant4 v9.3 Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002 Stack management, Digitization and Pile-up.
Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
A introduction Luciano Pandola INFN-LNGS Partially based on a presentation by G.A.P. Cirrone (INFN-LNS) and M.G. Pia (INFN-Ge) Queen’s University, Belfast.
parameterisation The aim of the exercise is again to build a lead-scintillator calorimeter, this time though the calorimeter will be a trapezoid.
Marc Verderi - IN2P3 SLAC User's Workshop.1 Introduction G EANT4 has been designed to allow users to implement new processes the kernel will treat as any.
Adding a new process CERN User’s Workshop 13 November 2002 V.Ivanchenko, CERN, Budker Institute for Nuclear Physics Based on presentation of M.Verderi.
Other GEANT4 capabilities Event biasing Parameterisation (fast simulation) Scoring Persistency Parallelisation and integration in a distributed computing.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Geant4 Training 2003 Basic structure of the Geant4 Simulation Toolkit The full set of lecture notes of this Geant4 Course is available.
Introduction to Geant4 Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
Maria Grazia Pia Detector Response Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
Basic Structure of the Geant4 Simulation Toolkit
Geant4 internal Classes and Objects Gunter Folger / CERN Geant4 course, Annecy 2008 User Action & Information Classes.
User Application Toolkit + User application toolkit Geant4 is a toolkit –i.e. you cannot “run” it out of the box –You must write.
User Application Luciano Pandola INFN-LNGS Partially based on a presentation by Maria Grazia Pia (INFN-Ge)
Geant4 internal Classes and Objects Geant4 Users’ Tutorial February 2010 Gunter Folger / CERN User Action & Information Classes.
Maria Grazia Pia INFN Genova Salamanca, July 2002
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Makoto Asai (SLAC) Getting Started MGP: added class diagram of basic user application.
Geant4 internal Classes and Objects Gunter Folger / CERN MC-PAD, DESY/Hamburg January 2010 User Action & Information Classes.
Geant4 release 5.1 summary Gabriele Cosmo EP/SFT.
Read-out and detector response
Maria Grazia Pia Retrieving information from kernel Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
Unit 4 Retrieving information from the simulation
Interaction with the Geant4 kernel
J. Apostolakis, M. Asai, G. Cosmo, A. Howard
Makoto Asai (SLAC) Geant4 Tutorial Course
Interaction with the Geant4 kernel
Basics of a user application
C++ for Geant4 users A collection of most useful and/or common features used in and to use Geant4 Marc Verderi LLR – Ecole polytechnique 14/11/2018 Marc.
Geant4:User Actions and Analysis
Geant4 introduction 2008/03/18 Nobu Katayama KEK
Primary Particle Generation
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11th, 2002
G.A.P.Cirrone, S.E.Mazzaglia - INFN/LNS, Italy
Primary Particle Generation
Read-out and detector response
Detector sensitivity Makoto Asai (SLAC Computing Services)
Makoto Asai (SLAC) Geant4 Tutorial Course
Read-out and detector response
User Application
The n-3He Simulation Using Geant4
User Application
Marc Verderi GEANT4 collaboration meeting 01/10/2002
User Application
The full set of lecture notes of this Geant4 Course is available at
Customizing Run Management
The full set of lecture notes of this Geant4 Course is available at
Kernel Author: Makoto Asai.
The full set of lecture notes of this Geant4 Course is available at
Geant4: Detector description module
Simulation in Experiments searching for rare events
Presentation transcript:

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 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

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

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

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)

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

How Geant4 runs (initialization)

How Geant4 runs (event loop) loop

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...

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

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

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

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()

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

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

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

How Geant4 runs (event process)

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

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