User Application Luciano Pandola INFN-LNGS Partially based on a presentation by Maria Grazia Pia (INFN-Ge)

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

山下智弘 JST CREST/ 神戸大学 Borrowing especially from presentations of M. Asai(SLAC) Geant4 Japan Oct, RCNS, based on Geant4 9.0.p01.
Geant4 v9.2p02 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Introduction and Getting Started ESA/ESTEC Makoto Asai (SLAC)
Makoto Asai (SLAC) Geant4 Users CERN Nov. 15 th, 2002 Customizing Run Management.
Geant4 v9.4 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11 th, 2002 Getting Started.
14 User Documents and Examples I SLAC Geant4 Tutorial 3 November 2009 Dennis Wright Geant4 V9.2.p02.
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.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002 Stack management, Digitization and Pile-up.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Japan.
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
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.
Tabular Editors for Geant4 Geant4 Geometry Editor and Geant4 Physics Editor CHEP 2000 at Padova Hajime Yoshida Naruto University of Education.
15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 1 Python Interface for Geant4 Medical Applications K.Murakami (KEK) 15/Jul/05.
User Documents and Examples I Sébastien Incerti Slides thanks to Dennis Wrigth, SLAC.
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.
Work_Geant4 Bo-Wen Shiou. #include "G4RunManager.hh“ #include "G4RunManager.hh“ #include "G4UImanager.hh" #include "G4UImanager.hh" #include "ExN01DetectorConstruction.hh“
Maria Grazia Pia Detector Response Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
Basic Structure of the Geant4 Simulation Toolkit
Primary particle Giovanni Santin ESA / ESTEC and RheaTech Ltd On behalf of the Geant4 collaboration Ecole Geant4 Annecy, and Nov 2008 With.
7th December 2007Geant4 Manchester Seminar1 Geant4 A simulation toolkit Geometry and tracking 4th incarnation.
Geant4 internal Classes and Objects Gunter Folger / CERN Geant4 course, Annecy 2008 User Action & Information Classes.
Monte Carlo /12/07. What is Geant ? Monte Carlo simulation tool for nuclear and particle physics Set up detectors –Sensitive detector which returns.
User Application Toolkit + User application toolkit Geant4 is a toolkit –i.e. you cannot “run” it out of the box –You must write.
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
Monte carlo and analysis tool study Shi-hong yao.
Geant4 internal Classes and Objects Geant4 Users’ Tutorial February 2010 Gunter Folger / CERN User Action & Information Classes.
Geant4 versus External Frameworks Approaches, Requirements and Constraints ATLAS, LHCb, CMS, Alice M. Stavrianakou CERN/CMC Geant4  -review
Maria Grazia Pia INFN Genova Salamanca, July 2002
A proposal for a Proposal for a Simulation Framework in BTeV G. Cerati, E. Di Maio, S. Magni, D. Menasce.
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.
Maria Grazia Pia Hands-on exercises Unit 2 Modelling the experimental set-up.
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.
N ATIONAL E NERGY R ESEARCH S CIENTIFIC C OMPUTING C ENTER Charles Leggett Prototype GEANT4 Service for ATHENA framework ATLAS Software Workshop Dec 3.
1 Exercises 0 Go inside the “hadrontherapy” directory: cd hadrontherapy Copy the Hadrontherapy example to your home folder: cp –r $G4INSTALL/examples/advanced/hadrontherapy.
Maria Grazia Pia Retrieving information from kernel Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
Interaction with the Geant4 kernel
Pablo Cirrone INFN-LNS
J. Apostolakis, M. Asai, G. Cosmo, A. Howard
Pablo Cirrone INFN-LNS
GUI Parallel Session Hajime Yoshida
Interaction with the Geant4 kernel
User Documents and Examples I
Basics of a user application
Geant4:User Actions and Analysis
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11th, 2002
G.A.P.Cirrone, S.E.Mazzaglia - INFN/LNS, Italy
The n-3He Simulation Using Geant4
Introductory Course PTB, Braunschweig, June 2009
User Application
Introductory Course ORNL, May 2008
The n-3He Simulation Using Geant4
A Short Course on Geant4 Simulation Toolkit How to learn more?
A Short Course on Geant4 Simulation Toolkit How to learn more?
User Application
Mantis a framework and toolkit for Geant4 simulation in CMS
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
The full set of lecture notes of this Geant4 Course is available at
Visualisation and (G)UI
Simulation in Experiments searching for rare events
Presentation transcript:

User Application Luciano Pandola INFN-LNGS Partially based on a presentation by Maria Grazia Pia (INFN-Ge)

Toolkit and User Application toolkit (= a collection of tools) Geant4 is a toolkit (= a collection of tools) i.e. you cannot “run” it out of the box You must write an application, which uses Geant4 tools Consequences: There are no such concepts as “Geant4 defaults” You must provide the necessary information to configure your simulation You must deliberately choose which Geant4 tools to use examples are provided Guidance: many examples are provided Novice Examples Novice Examples: overview of Geant4 tools Advanced Examples Advanced Examples: Geant4 tools in real-life applications

Basic concepts MUST What you MUST do: experimental set-up Describe your experimental set-up primary particles Provide the primary particles input to your simulation particlesphysics models Decide which particles and physics models you want to use out of those available in Geant4 and the precision of your simulation (cuts to produce and track secondary particles) You may also want control To interact with Geant4 kernel to control your simulation visualise To visualise your simulation configuration or results histograms, tuples To produce histograms, tuples etc. to be further analysed

Interaction with the Geant4 kernel - 1 tools Geant4 design provides tools for a user application To tell the kernel about your simulation configuration To interact with Geant4 kernel itself base classes Geant4 tools for user interaction are base classes your own concrete class You create your own concrete class derived from the base classes  interface to the Geant4 kernel (polymorphism) Geant4 kernel handles your own derived classes transparently through their base class interface (polymorphism)

Interaction with the Geant4 kernel - 2 Abstract base classes Abstract base classes for user interaction (classes starting with G4V) User derived concrete classes are mandatory User to implement the purely virtual methods Concrete base classes Concrete base classes (with virtual dummy default methods) for user interaction optional User derived classes are optional Two types of Geant4 base classes:

User Classes Initialisation classes Invoked at the initialization G4VUserDetectorConstruction G4VUserPhysicsList Action classes Invoked during the execution loop G4VUserPrimaryGeneratorAction G4UserRunAction G4UserEventAction G4UserTrackingAction G4UserStackingAction G4UserSteppingAction Classes having name starting with G4V are abstract classes (containing purely virtual methods)

User Classes - 2 Mandatory classes in ANY Geant4 User Application G4VUserDetectorConstruction describe the experimental set-up G4VUserPhysicsList select the physics you want to activate G4VUserPrimaryGeneratorAction generate primary events

Only virtual interface provided  users MUST implement their concrete implementation Given concrete (dummy) implementation. User MAY give an alternative implementation Geant4 kernel VGeometryVPhysicsVPrimary MyGeomMyPhysicsMyPrimary RunActionEvtActionStepAction MyStep G4RunManager Geant4 concept

The main() program - 1 main() Geant4 does not provide the main() Geant4 is a toolkit! The main() is part of the user application must In his/her main(), the user must G4RunManager construct G4RunManager (or his/her own derived class) notify the G4RunManager mandatory user classes derived from G4VUserDetectorConstruction G4VUserPhysicsList G4VUserPrimaryGeneratorAction

The main() program - 2 The user may define in his/her main() optional user action classes VisManager, (G)UI session The user also has to take care of retrieving and saving the relevant information from the simulation (Geant4 will not do that by default) Don’t forget to delete the G4RunManager at the end

An example of main() { … // Construct the default run manager G4RunManager; G4RunManager* runManager = new G4RunManager; // Set mandatory user initialization classes MyDetectorConstruction; MyDetectorConstruction* detector = new MyDetectorConstruction; runManager->SetUserInitialization(detector); MyPhysicsList; MyPhysicsList* physicsList = new MyPhysicsList; runManager->SetUserInitialization(myPhysicsList); // Set mandatory user action classes MyPrimaryGeneratorAction runManager->SetUserAction(new MyPrimaryGeneratorAction); // Set optional user action classes MyEventAction(); MyEventAction* eventAction = new MyEventAction(); runManager->SetUserAction(eventAction); MyRunAction(); MyRunAction* runAction = new MyRunAction(); runManager->SetUserAction(runAction); … }

Define detector geometry - 1 Three conceptual layers: G4VSolid Info about shape and dimensions G4LogicalVolume Add info about material, sensitivity, visualization, magnetic field, etc. G4VPhysicalVolume Add information about placement, position and rotation (the same logical volume can be placed many times in the geometry)

Define detector geometry - 2 World Volume B (daughter) Volume A (mother) e.g.: Volume A is mother of Volume B The mother must contain the daughter volume entirely A unique physical volume (the world volume), which represents the experimental area, must exist and fully contain all other components

How to build the world volume G4VSolid* solidWorld = new G4Box(“World", halfWorldLength, halfWorldLength, halfWorldLength); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, air, "World", 0, 0, 0); G4VPhysicalVolume* physicalWorld = new G4PVPlacement(0, //no rotation G4ThreeVector(), // at (0,0,0) logicWorld, // its logical volume "World", // its name 0, // its mother volume false, // no boolean operations 0); // no magnetic field material dimensions

Let’s build an other volume G4VSolid* solidTarget = new G4Box(“Target",targetSizeX/2., targetSizeY/2.,targetSizeZ/2.); G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, targetMaterial, “Target_log", 0, 0, 0); G4VPhysicalVolume* physicalTarger = new G4PVPlacement(0, //no rotation G4ThreeVector(), // at (0,0,0) logicTarget, // its logical volume “Target", // its name logicWorld, // its mother volume false, // no boolean operations 0); // no magnetic field G4Material* dimensions

Select physics processes Geant4 doesn ’ t have any default particles or processes Derive your own concrete class from the G4VUserPhysicsList abstract base class define all necessary particles define all necessary processes and assign them to proper particles define  /  production thresholds (in terms of range) Pure virtual methods of G4VUserPhysicsList must be implemented by the user in his/her concrete derived class ConstructParticles() ConstructProcesses() SetCuts()

Optional user classes - 1 virtual member functions Five concrete base classes whose virtual member functions the user may override to gain control of the simulation at various stages G4UserRunAction G4UserEventAction G4UserTrackingAction G4UserStackingAction G4UserSteppingAction Each member function of the base classes has a dummy implementation (not purely virtual) Empty implementation: does nothing e.g. actions to be done at the beginning and end of each event

Optional user classes - 2 The user may implement the member functions he desires in his/her derived classes E.g. one may want to perform some action at each tracking step Objects of user action classes must be registered with G4RunManager runManager-> SetUserAction(new MyEventActionClass);

Methods of user classes - 1 G4UserRunAction - BeginOfRunAction(const G4Run*) // book histos - EndOfRunAction(const G4Run*) //store histos G4UserEventAction -BeginOfEventAction(const G4Event*) //initialize event -EndOfEventAction (const G4Event*) // analyze event G4UserTrackingAction - PreUserTrackingAction(const G4Track*) //decide to store/not store a given track -PostUserTrackingAction(const G4Track*)

Methods of user classes - 2 G4UserSteppingAction - UserSteppingAction(const G4Step*) //kill, suspend, pospone the track, draw the step, … G4UserStackingAction -PrepareNewEvent() //reset priority control -ClassifyNewTrack(const G4Track*) // Invoked when a new track is registered (e.g. kill, pospone) - NewStage() // Invoked when the Urgent stack becomes empty (re-classify, abort event)

Only virtual interface provided  users MUST implement their concrete implementation Given concrete (dummy) implementation. User MAY give an alternative implementation Geant4 kernel VGeometryVPhysicsVPrimary MyGeomMyPhysicsMyPrimary RunActionEvtActionStepAction MyStep G4RunManager Geant4 concept

Optional: select (G)UI In your main(), taking into account your computer environment, instantiate a G4UIsession concrete/derived class provided by Geant4 and invoke its SessionStart() method mysession->SessionStart(); Geant4 provides: G4UIterminal csh or tcsh like character terminal G4GAG Opacs G4UIBatch batch job with macro file …

Optional: select visualization In your main(), taking into account your computer environment, instantiate a G4VisExecutive and invoke its Initialize() method Geant4 provides interfaces to various graphics drivers: DAWN (Fukui renderer) WIRED RayTracer (ray tracing by Geant4 tracking) OpenGL OpenInventor VRML …

General recipe for novice users Design your application… requires some preliminar thinking (what is it supposed to do?) Create your derived mandatory user classes MyDetectorConstruction MyPhysicsList MyPrimaryGeneratorAction Create optionally your derived user action classes MyUserRunAction, MyUserEventAction, … Create your main() Instantiate G4RunManager or your own derived MyRunManager Notify the RunManager of your mandatory and optional user classes Optionally initialize your favourite User Interface and Visualization That’s all! Experienced users may do much more, but the conceptual process is still the same…

Initialization Describe your experimental set-up Activate physics processes appropriate to your experiment

Beam On Generate primary events according to distributions relevant to your experiment

Event loop Generate primary events according to distributions relevant to your experiment

Backup

Development of a Geant4 application The following slides provide an overview of the basic concepts of a Geant4 user application software process Your application development will be greatly facilitated, if you adopt a sound software process Vision of your simulation, clear user requirements Documented architecture and detailed software design Test process at various levels (unit, integration, system…) Well defined, documented procedures