Introduction to Geant4 User Interface J. Perl1 6 June 2005 Introduction to Geant4 User Interface Joseph Perl Stanford Linear Accelerator Center.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

First Step on User Commands Makoto Asai (SLAC) Geant4 Users CERN Nov. 11th, 2002.
Geant4 v9.2p02 User Interface I Makoto Asai (SLAC) Geant4 Tutorial Course.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
1 Strings and Text I/O. 2 Motivations Often you encounter the problems that involve string processing and file input and output. Suppose you need to write.
User Interface I Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.3.
山下智弘 JST CREST/ 神戸大学 Borrowing especially from presentations of M. Asai(SLAC) Geant4 Japan Oct, RCNS, based on Geant4 9.0.p01.
FILE TRANSFER PROTOCOL Short for File Transfer Protocol, the protocol for exchanging files over the Internet. FTP works in the same way as HTTP for transferring.
Geant4 v9.2p02 User Interface II Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Particle Gun Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 User Interface Overview Geant4 Mini-Tutorial Hebden Bridge 15 September 2007 Joseph Perl, SLAC (mostly stolen from a talk by Makoto Asai)
Makoto Asai (SLAC) Geant4 Users CERN Nov. 15 th, 2002 Customizing Run Management.
Geant4 v9.4 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.4 User Interface I Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.3p01 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
User Commands Makoto Asai (SLAC) Geant4 Users SLAC Feb. 19th, 2002.
Chapter 11: Classes and Data Abstraction
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
User Interface II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Using Linux Commands 2 Lab#5
Using Linux Commands 2 Lab#5. Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z.
Fundamentals of Python: From First Programs Through Data Structures
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
Fundamentals of Python: First Programs
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
A stable interface to read and write IAEA phase-space files in Geant4 M. A. Cortés-Giraldo 1, R. Capote 2, J. M. Quesada 1 1 Dep. Física Atómica, Molecular.
Introduction to Shell Script Programming
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
An Introduction to Unix Shell Scripting
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
1 Primary particles Geant4 User's Tutorial CERN, February 2010 Talk from previous tutorial by Giovanni Santin Ecole Geant4, Annecy 2008.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Chapter 11: Classes and Data Abstraction. C++ Programming: Program Design Including Data Structures, Fourth Edition2 Objectives In this chapter, you will:
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Primary particle Giovanni Santin ESA / ESTEC and RheaTech Ltd On behalf of the Geant4 collaboration Ecole Geant4 Annecy, and Nov 2008 With.
UI command Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
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.
Geant4 examples Sébastien Incerti On behalf of the Geant4 collaboration with special thanks to Luciano Pandola, INFN.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 12: Classes and Data Abstraction.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
MONTE CARLO TRANSPORT SIMULATION Panda Computing Week 2012, Torino.
The full set of lecture notes of this Geant4 Course is available at
Visualisation and (G)UI
Introduction to javadoc
User Interface
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Introduction to javadoc
Geant4 course - exercices
Customizing Run Management
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002
Introduction to Bash Programming, part 3
Visualisation and (G)UI
Presentation transcript:

Introduction to Geant4 User Interface J. Perl1 6 June 2005 Introduction to Geant4 User Interface Joseph Perl Stanford Linear Accelerator Center

Introduction to Geant4 User Interface J. Perl2 6 June 2005 Contents  Command Syntax  Customizing the User Interface: Defining Your Own Commands  Customizing the User Interface: Alternative Interfaces

Introduction to Geant4 User Interface J. Perl3 6 June 2005 Geant4 Command Syntax  A Geant4 command consists of three parts: /run/verbose 1  Parameters can be of type “string”, “Boolean”, “integer” or “double.”  Delimiter is space.  Use double-quotes (“”) around strings that need to include spaces.  Some parameters can be omitted.  For some commands, the omitted parameter is replaced by a predefined default value, for other commands, omitting a parameter means to continue using the current value.  You can use the default value for the first parameter while setting a non-default value for the second parameter by specifying the first parameter as the special character “!”:  /dir/command ! second Directory CommandParameters

Introduction to Geant4 User Interface J. Perl4 6 June 2005 Command Submission  A Geant4 command can come from one of three sources:  Interactive command submission  Macro file  Hard-coded implementation  Slow but no need for the targeting class pointer  Take care not to do this from within the event loop G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/run/verbose 1");  The availability of individual commands and the choice and range of parameters can vary according to the your specific application and can even vary dynamically during the execution of your job.  Some commands are available only for limited Geant4 application states. Geant4 is a “state machine”, where states are: PreInit, Init, Idle, GeomClosed, EventProc, Quit  E.g. /run/beamOn is available only for Idle state.

Introduction to Geant4 User Interface J. Perl5 6 June 2005 Command refusal  Command will be refused if  Command is not found  Insufficient number of parameters  Wrong type of parameters  Parameters out of its allowed range (integer or double parameters)  Parameter out of its list of allowed string values (allowed string values are called “candidates” in Geant4)  Application is in wrong state (such as an attempt to execute /run/beamOn from a piece of C++ code that is called during Geant4’s Init phase)

Introduction to Geant4 User Interface J. Perl6 6 June 2005 Macro Files  Macro files are ASCII files that contains UI commands.  All commands must be given with their full-path directories.  Use “#” for comment lines.  Everything form the first “#” to the end of the line will be ignored.  Comment lines will be echoed if /control/verbose is set to 2.  Macro files can be executed  Interactively /control/execute file_name  From within other macro files /control/execute file_name  Hard-coded G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/control/execute file_name");

Introduction to Geant4 User Interface J. Perl7 6 June 2005 Command Guidance  Guidance on all commands is available from the command line:  Idle> help  Command directory path : /  Sub-directories :  1) /control/ UI control commands.  2) /units/ Available units.  3) /geometry/ Geometry control commands.  4) /tracking/ TrackingManager and SteppingManager control commands.  5) /event/ EventManager control commands.  6) /run/ Run control commands.  7) /random/ Random number status control commands.  8) /particle/ Particle control commands.  9) /process/ Process Table control commands.  10) /vis/ Visualization commands.  11) /mydet/ A01 detector setup control commands.  12) /hits/ Sensitive detectors and Hits  13) /gun/ Particle Gun control commands.  Commands :  Type the number ( 0:end, -n:n level back ) :

Introduction to Geant4 User Interface J. Perl8 6 June 2005 Guidance Detail  Guidance is hierarchical, providing full detail on all commands.  Command /gun/energy  Guidance :  Set kinetic energy.  Parameter : Energy  Parameter type : d  Omittable : True  Default value : taken from the current value  Parameter : Unit  Parameter type : s  Omittable : True  Default value : GeV  Candidates : eV keV MeV GeV TeV PeV J electronvolt kiloelectronvolt megaelectronvolt gigaelectronvolt teraelectronvolt petaelectronvolt joule  Particle Gun control commands.  Sub-directories :  Commands :  1) List * List available particles.  2) particle * Set particle to be generated.  3) direction * Set momentum direction.  4) energy * Set kinetic energy.  5) position * Set starting position of the particle.  6) time * Set initial time of the particle.  7) polarization * Set polarization.  8) number * Set number of particles to be generated.  9) ion * Set properties of ion to be generated.  Type the number ( 0:end, -n:n level back ) :  4

Introduction to Geant4 User Interface J. Perl9 6 June 2005 Command Listing  You can generate a complete listing of commands by /control/manual [directory]  Plane text format to standard output /control/createHTML [directory]  HTML file(s)  List of built-in commands is also available in section 7.1 of User's Guide For Application Developers.  Some “compound commands” are provided to allow you to accomplish several commands at once, such as: /vis/drawVolume  /vis/scene/create  /vis/scene/add/volume

Introduction to Geant4 User Interface J. Perl10 6 June 2005 Alias  An alias can be defined by /control/alias [name] [value]  In any subsequent command that contains the given “name” in curly brackets, the aliased “value” will be substituted.  For example, after:  /control/alias trv1 “/tracking/verbose 1”  You could issue the tracking command with just  {trv1}  Any alias that you set can be interpreted from within any subsequent macro:  /control/alias file1 /diskA/dirX/fileXX.dat  /control/execute myMacro  Then within myMacro:  /myCmd/getFile {file1}  Aliases can be used recursively:  /control/alias file1 /diskA/dirX/fileXX.dat  /control/alias file2 /diskB/dirY/fileYY.dat  /control/alias run 1  /myCmd/getFile {file{run}}

Introduction to Geant4 User Interface J. Perl11 6 June 2005Loop   The /control/loop and /control/foreach commands execute a macro file repeatedly.   They provide a variable that changes with each iteration of the loop.   In /control/loop, a variable starts at a specified initial value and then increases to a final value by a step size:   /control/loop [macroFile] [counterName] [initialValue] [finalValue] [stepSize]   Within the macro, {counterName} is the loop variable.   In /control/foreach, a variable iterates through a specifed list of values:   /control/foreach [macroFile] [counterName] [valueList]   Within the macro, {counterName} is the loop variable.   valueList must be enclosed by double quotes (" ")   For example, /control/loop myRun.mac Ekin   in myRun.mac /control/foreach mySingleRun.mac pname “p pi- mu-”   in mySingleRun.mac /gun/particle {pname} /gun/energy {Ekin} GeV /run/beamOn 100

Introduction to Geant4 User Interface J. Perl12 6 June 2005 Contents  Command Syntax  Customizing the User Interface: Defining Your Own Commands  Customizing the User Interface: Alternative Interfaces

Introduction to Geant4 User Interface J. Perl13 6 June 2005 Defining Your Own Commands (G)UI G4UImanager messenger (G4UImessenger) command (G4UIcommand) G4UIparameter Target class 1. register command 2. apply 3. do it 4. invoke   Implement a messenger class.   Instantiate commands.   Register the commands with the G4UImanager.   When user invokes the commands, target classes can use the results.

Introduction to Geant4 User Interface J. Perl14 6 June 2005 Messenger class  Each messenger class must be derived from the G4UImessenger base class. A single messenger class can handle more than one UI command.  A messenger class should be instantiated by the constructor of the target class to which commands should be delivered and should be deleted by the destructor of the target class.  Methods of the messenger class  Constructor  Define (instantiate) commands / command directories  Destructor  Delete commands / command directories  void SetNewValue(G4UIcommand* command,G4String newValue)  Convert "newValue" parameter string to appropriate value(s) and invoke a method of the target class  This method is invoked when a command is issued.  G4String GetCurrentValue(G4UIcommand* command)  Access a get-method of the target class and convert the current values to a string  This method is invoked when the (G)UI asks for the current value(s).

Introduction to Geant4 User Interface J. Perl15 6 June 2005 Definition (instantiation) of a command  To be implemented in the constructor of a messenger class. A01DetectorConstMessenger::A01DetectorConstMessenger (A01DetectorConstruction* tgt) :target(tgt){ mydetDir = new G4UIdirectory("/mydet/"); mydetDir = new G4UIdirectory("/mydet/"); mydetDir->SetGuidance("A01 detector setup commands."); mydetDir->SetGuidance("A01 detector setup commands."); armCmd = new G4UIcmdWithADoubleAndUnit("/mydet/armAngle",this); armCmd = new G4UIcmdWithADoubleAndUnit("/mydet/armAngle",this); armCmd->SetGuidance("Rotation angle of the second arm."); armCmd->SetGuidance("Rotation angle of the second arm."); armCmd->SetParameterName("angle",true); armCmd->SetParameterName("angle",true); armCmd->SetRange("angle>=0. && angle SetRange("angle>=0. && angle<180."); armCmd->SetDefaultValue(30.); armCmd->SetDefaultValue(30.); armCmd->SetDefaultUnit("deg"); armCmd->SetDefaultUnit("deg");}  Guidance should be more than one line with the first line utilized as a short command description.

Introduction to Geant4 User Interface J. Perl16 6 June 2005 G4UIcommand and its Derivatives  The class G4UIcommand represents a UI command.  The class G4UIparameter represents a parameter for a command.  Your command can be a direct instance of G4UIcommand, but more often you will find it convenient to use one of G4UIcommand’s derivatives that provides additional functionality for specific types of parameters:  G4UIcmdWithoutParameter  G4UIcmdWithAString  G4UIcmdWithABool  G4UIcmdWithAnInteger  G4UIcmdWithADouble, G4UIcmdWithADoubleAndUnit  G4UIcmdWith3Vector, G4UIcmdWith3VectorAndUnit  G4UIdirectory  A UI command with other types of parameters must be defined by the G4UIcommand base class with G4UIparameter.

Introduction to Geant4 User Interface J. Perl17 6 June 2005 Parameter name(s) void SetParameterName( const char*parName, G4bool omittable, G4bool currentAsDefault=false); void SetParameterName( const char*nam1, const char*nam2, const char*nam3, G4bool omittable, G4bool currentAsDefault=false);  Parameter names are used in help, and also in the definition of parameter range.  If "omittable" is true, the command can be issued without this particular parameter, and the default value will be used.  If "currentAsDefault" is true, current value of the parameter is used as a default value, otherwise default value must be defined with SetDefaultValue() method.

Introduction to Geant4 User Interface J. Perl18 6 June 2005 Range, unit and candidates void SetRange(const char* rangeString)  Available for a command with numeric-type parameters.  Range of parameter(s) must be given in C++ syntax. aCmd->SetRange("x>0. && y>z && z>(x+y)");  Not only comparison with hard-coded number but also comparison between variables and simple calculation are available.  Names of variables must be defined by SetParameterName() method. void SetDefaultUnit(const char* defUnit)  Available for a command which takes unit.  Once the default unit is defined, no other unit of different unit category (length, time, distance, etc.) will be accepted.  Alternatively, you can define a unit category without setting a default unit. void SetUnitCategory(const char* unitCategory) void SetCandidates(const char* candidateList)  Available for a command with string type parameter  Candidates must be delimited by a space.  Candidates can be dynamically updated.

Introduction to Geant4 User Interface J. Perl19 6 June 2005 Available state void AvailableForStates(G4ApplicationState s1,…)  Define command's applicability for Geant4 application states.  Geant4 has six application states.  G4State_PreInit  Material, Geometry, Particle and/or Physics Process need to be initialized  G4State_Idle  Ready to start a run  G4State_GeomClosed  Geometry is optimized and ready to process an event  G4State_EventProc  An event is processing  G4State_Quit, G4State_Abort  UI command unavailable PreInit Idle EventProc GeomClosed Quit Abort initialize beamOn exit

Introduction to Geant4 User Interface J. Perl20 6 June 2005 Converting between string and values  Derivatives of G4UIcommand with numeric and boolean parameters have corresponding conversion methods.  From a string to value G4bool GetNewBoolValue(const char*) G4int GetNewIntValue(const char*) G4double GetNewDoubleValue(const char*) G4ThreeVector GetNew3VectorValue(const char*)  To be used in SetNewValue() method in messenger.  Unit is taken into account automatically.  From value to string G4String ConvertToString(...) G4String ConvertToString(...,const char* unit)  To be used in GetCurrentValue() method in messenger.

Introduction to Geant4 User Interface J. Perl21 6 June 2005 SetNewValue and GetCurrentValue void A01DetectorConstMessenger ::SetNewValue(G4UIcommand* command,G4String newValue) { if( command==armCmd ) if( command==armCmd ) { target->SetArmAngle(armCmd->GetNewDoubleValue(newValue)); } { target->SetArmAngle(armCmd->GetNewDoubleValue(newValue)); }} G4String A01DetectorConstMessenger ::GetCurrentValue(G4UIcommand* command) { G4String cv; G4String cv; if( command==armCmd ) if( command==armCmd ) { cv = armCmd->ConvertToString(target->GetArmAngle(),"deg"); } { cv = armCmd->ConvertToString(target->GetArmAngle(),"deg"); } return cv; return cv;}

Introduction to Geant4 User Interface J. Perl22 6 June 2005 Contents  Command Syntax  Customizing the User Interface: Defining Your Own Commands  Customizing the User Interface: Alternative Interfaces

Introduction to Geant4 User Interface J. Perl23 6 June 2005 Alternative Interfaces  The interactive command submission interface described in the previous slides is really just one concrete implementation (G4UIterminal) of an abstract class (G4UIsession).  To allow interactive command submission, main routine needs to include  G4UIsession* session = new G4UIterminal();  session->SessionStart();  Additional tcsh-like functionality can be obtained by changing this line to (but this option works only on Linux, not Windows)  G4UIsession* session = new G4UIterminal(new G4UItcsh);  An example of a different user interface is G4UIGAG, which is used by GAG, the Geant4 Adaptive GUI.  G4UIsession* session = new G4UIGAG();

Introduction to Geant4 User Interface J. Perl24 6 June 2005 G4UIterminal Commands  G4UIterminal provides some additional commands that are not part of the Geant4 kernel.  Provide additional uinx-like functionality from the command line  But cannot be used from within macro files  G4UIterminal commands:  cd, pwd - change and display current command directory (so that you can omit that part of the directory string from subsequent commands).  ls - list available UI commands and sub-directories  history - show previous commands  !historyID - re-issue previous command  arrow keys (TC-shell only)  ?UIcommand - show current value  help [UIcommand] - help  exit - job termination