Geant 4 User Actions and Analysis Geant 4
















- Slides: 16
Geant 4: User Actions and Analysis ¬Geant 4 user interface ¬User actions ¬Analysis tools ¬External frameworks Geant 4 26. 05. 2005 User Actions
Geant 4 User Interface ¬ Simulation of particle transport and interaction in Geant 4 is under control of Geant 4 kernel ¬ There a variety of possibilities for user to get intermediate information and to score results of simulation • User actions • Sensitive detector • Physics processes Geant 4 26. 05. 2005 User Actions 2
Geant 4 User Actions ¬ G 4 User. Run. Action – Begin and end of the run CMS simulation of SUSY event ¬ G 4 User. Event. Action – Begin and end of an event ¬ G 4 User. Tracking. Action – Begin and end of tracking of a G 4 Track ¬ G 4 User. Stepping. Action – At each step ¬ G 4 User. Stacking. Action – Classification of new G 4 Track Geant 4 26. 05. 2005 User Actions 3
Geant 4 User Actions ¬ Interfaces of user action use const references and pointers to preserve Geant 4 kernel from user interventions: void G 4 User. Run. Action: : Begin. Of. Run. Action(const G 4 Run* run) void G 4 User. Run. Action: : End. Of. Run. Action(const G 4 Run* run) void G 4 User. Event. Action: : Begin. Of. Event. Action(const G 4 Event* evt) void G 4 User. Event. Action: : End. Of. Event. Action(const G 4 Event* evt) G 4 Classification. Of. New. Track G 4 User. Stacking. Action: : Classify. New. Track(const G 4 Track* track) G 4 Classification. Of. New. Track = f. Urgent f. Waiting f. Postpone f. Kill Geant 4 - put into urgent stack - put into waiting stack - postpone to the next event - kill without stacking 26. 05. 2005 User Actions 4
Geant 4 User Actions ¬ When G 4 Track is taken from a stack for tracking the user action is invoked: – void G 4 User. Tracking. Action: : Pre. User. Tracking. Action (const G 4 Track* track) – Information is available about mother particle, vertex, position, 4 -momentum, creation process, etc ¬ After the end of tracking the user action is invoked: – void G 4 User. Tracking. Action: : Post. User. Tracking. Action (const G 4 Track* track) ¬ Tracking action allows to control event history Geant 4 26. 05. 2005 User Actions 5
Geant 4 User Actions ¬ At each step user have access to complete information about each step of simulation – void G 4 User. Stepping. Action: : User. Stepping. Action (const G 4 Step* step) ¬ The pointer to G 4 Step allows to access other instances: – const G 4 Track* track = step->Get. Track(); – const G 4 Step. Point* pre. Point = step->Get. Pre. Step. Point(); – const G 4 Step. Point* post. Point = step->Get. Post. Step. Point(); ¬ WARNING: user code may be source of CPU penalty ¬ All what can be done using sensitive detector approach, can be also done inside User. Stepping. Action for complete responsibility of the user – Inside G 4 User. Stepping. Action the complete navigation in the geometry tree needs to be done – Sensitive Detector is called only if step is performed inside corresponding volume Geant 4 26. 05. 2005 User Actions 6
G 4 User. Stepping. Action example // example/extended/electromagnetic/Muon. Processes void Stepping. Action: : User. Stepping. Action( const G 4 Step* a. Step ) { G 4 Step. Point* pre. Point = a. Step->Get. Pre. Step. Point(); G 4 Step. Point* post. Point = a. Step->Get. Post. Step. Point(); //plot energy transfered G 4 double kin. Energy. Pre. Step = pre. Point->Get. Kinetic. Energy(); G 4 double kin. Energy. Post. Step = pre. Point->Get. Kinetic. Energy(); G 4 double lgeps. E = 1. 0 – kin. Energy. Post. Step/ kin. Energy. Pre. Step; if (etrans > 0. ) lgeps. E = std: : log 10(lgeps. E); //count processes G 4 String proc. Name = post. Point->Get. Process. Defined. Step()->Get. Process. Name(); G 4 int id = 0; if (proc. Name == "mu. Ioni") id = 1; if (proc. Name == "mu. Pair. Prod") id = 2; if (proc. Name == "mu. Brems") id = 3; if (proc. Name == "mu. Nucl") id = 4; histo. Manager->Fill. Histo(id, lgeps. E); } Geant 4 26. 05. 2005 User Actions 7
Verbosity ¬ Standard Geant 4 verbosity can be activated via UI commands: • /run/verbose 1 • /event/verbose 1 • /tracking/verbose 1 ¬ User have a possibility to have additional verbosity in user action classes ¬ It is possible to have user implementation of G 4 VStepping. Verbose class, for example, • $G 4 INSTALL/example/extended/electromagnetic/Test. Em 1 Geant 4 26. 05. 2005 User Actions 8
Analysis Tools ¬ Analysis tools allow to store histograms, n. Tuples, and other objects with results of Geant 4 simulation ¬ Geant 4 has no any native analysis tool – it is external software ¬ There are several Geant 4 examples using analysis tools: • examples/extended/analysis/ • examples/extended/electromagnetic • examples/advanced ¬ Available tools: • • PI (CERN) ROOT (CERN) JAS (SLAC) Open Scientist (LAL) ¬ AIDA interfaces ¬ Output formats: hbook, root, xml ¬ Analysis software under intensive development Geant 4 26. 05. 2005 User Actions 9
Example of Analysis - Test. Em 7 class Run. Action : public G 4 User. Run. Action { public: Run. Action(Detector. Construction*, Physics. List*, Primary. Generator. Action*); ~Run. Action(); void Begin. Of. Run. Action (const G 4 Run*); void End. Of. Run. Action (const G 4 Run*); // Specific methods for the example void Fill. Tally. Edep (G 4 int n, G 4 double e) {tally. Edep[n] += e; }; G 4 double Get. Bin. Length() {return bin. Length; }; G 4 double Get. Offset. X() {return offset. X; } void Fill. Histo(G 4 int id, G 4 double x, G 4 double weight = 1. 0); void Add. Proj. Range (G 4 double x) {proj. Range += x; proj. Range 2 += x*x; }; private: void book. Histo(); void clean. Histo(); // Access to external software // Specific members of the example Detector. Construction* detector; Physics. List* physics; Primary. Generator. Action* kinematic; G 4 double* tally. Edep; G 4 double bin. Length; G 4 double offset. X; G 4 double proj. Range, proj. Range 2; // AIDA interfaces AIDA: : IAnalysis. Factory* af; AIDA: : ITree* tree; AIDA: : IHistogram 1 D* histo[1]; }; Geant 4 26. 05. 2005 User Actions 10
External Frameworks ¬ Each large HEP project has a software framework and Geant 4 as a toolkit can be driven by the framework ¬ User actions are used to exchange data between Geant 4 kernel and the framework – Factory approach: many specialized user actions ¬ There also useful tools built on top of Geant 4, which can be used in small projects Geant 4 26. 05. 2005 User Actions 11
Ba. Bar (SLAC, Stanford) - Leader Experiment Using Geant 4 D. Wright, 2003 Geant 4 26. 05. 2005 User Actions 12
LHCb: Gauss Application (2004) Job. Opts LH Hep. MC Geant 4 Cnv Pythia, Evt. Gen etc Gi. Ga Cnv Int. face Ex ch mo ang de e l Cb mo Eve de nt l MCParticle MCVertex MCHits Cnv POOL Two phases POOL Event generation Detector Simulation primary event generator specialized decay package pile-up generation geometry (LHCb G 4) tracking through materials (G 4) hit creation ( G 4 LHCb ) MC truth generation (G 4 LHCb) Geant 4 26. 05. 2005 User Actions 13
GATE Software for Tomography Geant 4 26. 05. 2005 User Actions 14
General Radiation Analysis for Space - GRAS ¬ New project of ESA ¬ Service for radiation studies for space applications ¬ Generic dosimetry and analysis ¬ Can be applied for studying of different problems ¬ Available for testers, public release soon Geant 4 26. 05. 2005 User Actions 15
Conclusion remarks ¬ The Geant 4 toolkit provides a wide choice of user actions allowing detailed monitoring of the simulation ¬ It is user’s responsibility to choose and design of user actions and/or analysis engine ¬ In Geant 4 examples (novice, extended, advanced) there are proposed solutions for different usecases ¬ User actions may require extra CPU and/or memory Geant 4 26. 05. 2005 User Actions 16