UI command Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.

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.
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.
Geant4 v9.2p02 User Interface II Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Particle Gun Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Improvement of G4Exception (and an announcement on G4ApplicationState) Makoto Asai (SLAC) on behalf of Architecture team.
Primary particle generation Makoto Asai (SLAC) Geant4 Users CERN Nov. 12 th, 2002.
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.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
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.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 20th, 2002 Stack management, Digitization and Pile-up.
User Commands Makoto Asai (SLAC) Geant4 Users SLAC Feb. 19th, 2002.
Chapter 11: Classes and Data Abstraction
Geant4 v9.3 Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course.
Guide To UNIX Using Linux Third Edition
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002 Stack management, Digitization and Pile-up.
User Interface II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Chapter 11: Classes and Data Abstraction. C++ Programming: Program Design Including Data Structures, Fourth Edition2 Objectives In this chapter, you will:
Introduction to Geant4 User Interface J. Perl1 6 June 2005 Introduction to Geant4 User Interface Joseph Perl Stanford Linear Accelerator Center.
Primary particle Giovanni Santin ESA / ESTEC and RheaTech Ltd On behalf of the Geant4 collaboration Ecole Geant4 Annecy, and Nov 2008 With.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
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.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
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.
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.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Geant4 Training 2003 Primary Particle Generation The full set of lecture notes of this Geant4 Course is available at
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Functions Chapter 5. Function A set of instructions that are designed to perform specific task. A complete and independent program. It is executed by.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Chapter VII: Arrays.
Test 2 Review Outline.
The full set of lecture notes of this Geant4 Course is available at
Why exception handling in C++?
Visualisation and (G)UI
User Interface
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Defining Classes and Methods
Arrays We often want to organize objects or primitive data in a way that makes them easy to access and change. An array is simple but powerful way to.
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
when it needs to be done at compile-time
CISC124 Labs start this week in JEFF 155. Fall 2018
Python Primer 1: Types and Operators
Geant4 course - exercices
Customizing Run Management
Primary particle Makoto Asai (SLAC Computing Services)
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002
Introduction to Bash Programming, part 3
ENERGY 211 / CME 211 Lecture 17 October 29, 2008.
Presentation transcript:

UI command Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01

UI command - M.Asai (SLAC)2 Contents  Alias and loop  Mechanism of UI command  Messenger class  Defining a command  Implementing a messenger

UI command - M.Asai (SLAC)3 Alias  Alias can be defined by /control/alias [name] [value]  It is also set with /control/loop and /control/foreach commands  Aliased value is always treated as a string even if it contains only numbers.  Alias is to be used with other UI command.  Use curly brackets, { and }.  For example, frequently used lengthy command can be shortened by aliasing. /control/alias trv1 "/tracking/verbose 1" {trv1}  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}}

UI command - M.Asai (SLAC)4Loop   /control/loop and /control/foreach commands execute a macro file more than once. Aliased variable name can be used inside the macro file.   /control/loop [macroFile] [counterName] [initialValue] [finalValue] [stepSize]   counterName is aliased to the number as a loop counter   /control/foreach [macroFile] [counterName] [valueList]   counterName is aliased to a value in valueList   valueList must be enclosed by double quotes (" ")   on UI terminal or other macro file /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

UI command - M.Asai (SLAC)5 Mechanism of UI command (G)UI G4UImanager messenger (G4UImessenger) command (G4UIcommand) G4UIparameter Target class 1. register command 2. apply 3. do it 4. invoke Object shown in green must be instantiated by the user Class shown in blue must be implemented and instantiated by the user

UI command - M.Asai (SLAC)6 Messenger class  Each messenger class must be derived from G4UImessenger base class. A messenger class can handle more than one UI commands.  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 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 to a get-method of the target class and convert the current values to a string  This method is invoked when the current value(s) of parameter(s) of a command is asked by (G)UI.

UI command - M.Asai (SLAC)7 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 can (should) be more than one lines. The first line is utilized as a short description of the command.

UI command - M.Asai (SLAC)8 G4UIcommand and its derivatives  G4UIcommand is a class which represent a UI command. G4UIparameter represents a parameter.  G4UIcommand can be directly used for a UI command. Geant4 provides its derivatives according to the types of associated parameters.  G4UIcmdWithoutParameter  G4UIcmdWithAString  G4UIcmdWithABool  G4UIcmdWithAnInteger  G4UIcmdWithADouble, G4UIcmdWithADoubleAndUnit  G4UIcmdWith3Vector, G4UIcmdWith3VectorAndUnit  G4UIdirectory  A UI command with other type of parameters must be defined by G4UIcommand base class with G4UIparameter.

UI command - M.Asai (SLAC)9 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 "currentAsDefalult" is true, current value of the parameter is used as a default value, otherwise default value must be defined with SetDefaultValue() method.

UI command - M.Asai (SLAC)10 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 dimension will be accepted.  Alternatively, you can define a dimension (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.

UI command - M.Asai (SLAC)11 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

UI command - M.Asai (SLAC)12 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.

UI command - M.Asai (SLAC)13 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;}