User Commands Makoto Asai (SLAC) Geant4 Users SLAC Feb. 19th, 2002.

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.
Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
Chapter 7: User-Defined Functions II
User Interface I Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.3.
ANT – Another Neat Tool Representation and Management of Data on the Internet.
山下智弘 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.
1 Ant – Another Neat Tool Representation and Management of Data on the Internet.
Geant4 User Interface Overview Geant4 Mini-Tutorial Hebden Bridge 15 September 2007 Joseph Perl, SLAC (mostly stolen from a talk by Makoto Asai)
Linux+ Guide to Linux Certification, Second Edition
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.
Chapter 11: Classes and Data Abstraction
Guide To UNIX Using Linux Third Edition
User Interface II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
OOP Languages: Java vs C++
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,
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
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Copyright  Hannu Laine C++-programming Part 3 Hannu Laine.
Linux+ Guide to Linux Certification, Third Edition
Chapter 11: Classes and Data Abstraction. C++ Programming: Program Design Including Data Structures, Fourth Edition2 Objectives In this chapter, you will:
Oracle Data Integrator Procedures, Advanced Workflows.
Introduction to Geant4 User Interface J. Perl1 6 June 2005 Introduction to Geant4 User Interface Joseph Perl Stanford Linear Accelerator Center.
UI command Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
More About Objects and Methods Chapter 5. Outline Programming with Methods Static Methods and Static Variables Designing Methods Overloading Constructors.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
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.
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.
MuSL Builder Handcrafting custom Mu Scenarios. MuSL in the Mu Scenario Editor.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
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.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Bash Shell. What is Shell? The shell is a command interpreter. It is the layer between the operating system kernel and the user.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Chapter 3 Part II. 3.8 Placing a Class in a Separate File for Reusability.cpp file is known as a source-code file. Header files ◦ Separate files in which.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Programming Fundamentals1 Chapter 7 INTRODUCTION TO CLASSES.
Tarik Booker CS 242. What we will cover…  Functions  Function Syntax  Local Variables  Global Variables  The Scope of Variables  Making Functions.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
PHP using MySQL Database for Web Development (part II)
Chapter VII: Arrays.
The full set of lecture notes of this Geant4 Course is available at
Introduction to javadoc
User Interface
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
CSCI The UNIX System Shell Startup and Variables
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Cmdlets “Command-lets”
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Introduction to javadoc
Customizing Run Management
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002
CST8177 Scripting 2: What?.
Presentation transcript:

User Commands Makoto Asai (SLAC) Geant4 Users SLAC Feb. 19th, 2002

Contents Geant4 UI command Built-in commands Macro file Alias, loop control User-defined command

Geant4 UI command Geant4 UI command can be issued by –(G)UI interactive command submission –Macro file –Hard-coded implementation Slow but no need for the targeting class pointer G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/run/verbose 1"); A command consists of –Command directory –Command –Parameter(s)

Available Commands You can get a list of available commands including your custom ones 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.

Available commands The availability of individual commands, the ranges of parameters, the available candidates on individual command parameters vary according to the implementation of your application and may even vary dynamically during the execution of your job. Commands may be available only for limited Geant4 application state(s). –E.g. /run/beamOn is available only for PreInit and Idle states. A parameter can be a type of string, boolean, integer or double. –Use double-quotes (”) for string with space(s). A parameter can be “omittable”. If it is the case, a default value will be taken if you omit the parameter. –Default value is either predefined default value or current value according to its definition –If you want to use the default value for your first parameter while you want to set your second parameter, use “!” as a place holder. /dir/command ! second

Available commands Command will be refused if –Wrong application state –Wrong type of parameter –Insufficient number of parameters –Parameter out of its range For ineteger or double type parameter –Parameter out of its candidate list For string type parameter –Miss-use of alias –Command not found

Macro file Macro file is an ASCII file contains UI commands. All commands must be given with their full-path directories. Use “#” for comment line. –First “#” to the end of the line will be ignored. –Comment lines will be echoed if /control/verbose is set to 2. Macro file can be executed by –/control/execute –/control/loop –/control/foreach You can recursively execute same and/or other macro file.

Alias Alias can be defined by /control/alias [name] [value] –Also by /control/loop and /control/foreach commands. Aliased value is string, even if it consists of numbers. Alias can be used by other UI command(s), for command name, directory path, parameter(s) or any combination of these. Use curly brackets “{” and “}” to use an alias. Alias can be interpreted recursively. /control/alias file1 /diskA/run1 /control/alias file2 /diskB/run2 /control/alias run 1 /myCommand/getFile {file{run}}.dat –You can shorten lengthy but frequently used command using alias.

Repeating macro execution /control/loop [macroFile] [counterName] [initialValue] [finalValue] [stepSize] »Execute a macro file more than once. Loop counter can be used as an aliased variable. /control/foreach [macroFile] [counterName] [valueList] »Execute a macro file more than once. Loop counter can be used as an aliased variable. Values must be separated by a space.

UI command and messenger (G)UI UImanager messenger command parameter Target class 1. register 2. apply 3. do it 4. invoke

User command To define user commands, you need to make your own concrete messenger class implementation class G4ParticleGun; class G4UIcmdWithADoubleAndUnit; #include "G4UImessenger.hh" class G4ParticleGunMessenger: public G4UImessenger { public: G4ParticleGunMessenger(G4ParticleGun * fPtclGun); ~G4ParticleGunMessenger(); void SetNewValue(G4UIcommand * command,G4String newValues); G4String GetCurrentValue(G4UIcommand * command); private: G4ParticleGun * fParticleGun; G4UIcmdWithADoubleAndUnit * energyCmd; };

Messenger class Constructor –Instanciate command objects, set guidance, parameter information, etc., and register commands to UImanager. Destructor –Delete commands (automatically unregistered). SetNewValue method –Convert parameter string to values –Invoke appropriate method of target class object GetCurrentValue method –Get current values from target class –Convert to string

Command class G4UIcommand –Base class, Still usable for complicated command G4UIdirectory –Definition of (sub-)directory G4UIcmdWith3Vector, G4UIcmdWith3VectorAndUnit, G4UIcmdWithADouble, G4UIcmdWithADoubleAndUnit, G4UIcmdWithAString, G4UIcmdWithABool, G4UIcmdWithAnInteger, G4UIcmdWithoutParameter –Each class has its adequate conversion methods. Valid application state(s) can be set.

Parameter Each parameter must has its unique name (within a command) If a parameter is set as “omittable”, default value must be given, or “current value as default” flag must be set. Range(s) of parameter(s) can be given by C++ syntax. –E.g. “ x>=0. && y>= 0. && x > y ” Candidate list is a string consists of candidates separated by spaces. directionCmd = new G4UIcmdWith3Vector("/gun/direction",this); directionCmd->Set_guidance("Set momentum direction."); directionCmd ->Set_guidance("Direction needs not to be a unit vector."); directionCmd->SetParameterName("Px","Py","Pz",true,true); directionCmd->SetRange("Px != 0 || Py != 0 || Pz != 0"); See section 7.2 of User's Guide For Application Developers for more detail and full example code.