17-19 Oct, 2007Geant4 Japan 200717-19 Oct, 2007Geant4 Japan 200717-19 Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.

Slides:



Advertisements
Similar presentations
First Step on User Commands Makoto Asai (SLAC) Geant4 Users CERN Nov. 11th, 2002.
Advertisements

Geant4 v9.2p02 User Interface I Makoto Asai (SLAC) Geant4 Tutorial Course.
Lecture 9: More on objects, classes, strings discuss hw3 assign hw4 default values for variables scope of variables and shadowing null reference and NullPointerException.
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
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.
Improvement of G4Exception (and an announcement on G4ApplicationState) Makoto Asai (SLAC) on behalf of Architecture team.
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.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
ECE122 L3: Expression Evaluation February 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction.
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.
User Interface II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Data Types.
Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
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.
Introduction to Geant4 User Interface J. Perl1 6 June 2005 Introduction to Geant4 User Interface Joseph Perl Stanford Linear Accelerator Center.
Basic Structure of the Geant4 Simulation Toolkit
UI command Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
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.
Applications Development
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Chapter 14 Abstract Classes and Interfaces. Abstract Classes An abstract class extracts common features and functionality of a family of objects An abstract.
Strings and Text File I/O (and Exception Handling) Corresponds with Chapters 8 and 17.
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.
Detector Description – Part III Ivana Hrivnacova, IPN Orsay Tatiana Nikitina, CERN Aknowledgement: Slides by: J.Apostolakis, G.Cosmo, A. Lechner.
Methods Methods are how we implement actions – actions that objects can do, or actions that can be done to objects. In Alice, we have methods such as move,
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Makoto Asai (SLAC) Getting Started MGP: added class diagram of basic user application.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
17-19 Oct, 2007Geant4 Japan 2007 Geant4 Collaboration KEK/CRC 1.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Exception Handling How to handle the runtime errors.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Chapter VII: Arrays.
A variable is a name for a value stored in memory.
Updates on Intercoms / Interfaces
The full set of lecture notes of this Geant4 Course is available at
Why exception handling in C++?
Road Map Introduction to object oriented programming. Classes
Visualisation and (G)UI
C Basics.
User Interface
Makoto Asai (SLAC) Geant4 Tutorial Course
Chapter 3 Introduction to Classes, Objects Methods and Strings
Makoto Asai (SLAC) Geant4 Tutorial Course
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.
Physics I: Physics Lists
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Customizing Run Management
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002
Presentation transcript:

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration KEK/CRC 1

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 If built-in commands are not enough, you can make your own command. Geant4 provides several command classes, all derived from G4UIcommand: G4UIcmdWithoutParameter G4UIcmdWithABool G4UIcmdWithADouble and many more See also Application Developers Guide, Chapter 7.2 2

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan (G)UI G4UImanager Messenger (G4UImessenger) Messenger (G4UImessenger) Command (G4UIcommand) Command (G4UIcommand) Parameter (G4UIparameter) Target Class 1. register command 2. apply 3. do it 4. invoke You have to implement it. single object e.g. XXXManager

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 You have to implement your UI commands which handle the corresponding G4 class. Each concrete messenger class is derived from G4UImessenger base class. A messenger class should be instantiated in the constructor of the target class. Target class should be a single-object (singleton) class e.g. XXXManager Implementation of your messenger classes Define command directories / commands. void SetNewValue(G4UIcommand* command, G4String newValue) Convert "newValue" parameter string to appropriate value(s) and invoke a method of the target class G4String GetCurrentValue(G4UIcommand* command) Access to a get-method of the target class and convert the current values to a string 4

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 A01DetectorConstMessenger::A01DetectorConstMessenger (A01DetectorConstruction* tgt):target(tgt) { mydetDir = new G4UIdirectory("/mydet/"); mydetDir-> SetGuidance("A01 detector setup commands."); armCmd = new G4UIcmdWithADoubleAndUnit("/mydet/armAngle",this); armCmd-> SetGuidance("Rotation angle of the second arm."); armCmd-> SetParameterName("angle",true); armCmd-> SetRange("angle>=0. && angle<180."); armCmd-> SetDefaultValue(30.); armCmd-> SetDefaultUnit("deg"); } 5

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 G4UIcommand is a class which represents a UI command. G4UIparameter represents a parameter. Geant4 provides derived classes according to the types of associated parameters. G4UIcmdWithoutParameter G4UIcmdWithAString G4UIcmdWithABool G4UIcmdWithAnInteger G4UIcmdWithADouble, G4UIcmdWithADoubleAndUnit G4UIcmdWith3Vector, G4UIcmdWith3VectorAndUnit G4UIdirectory A UI command with other type of parameters can be also defined. 6

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 void SetParameterName(const char* parName, G4bool omittable, G4bool currentAsDefault=false); If "omittable" is true, the command can be issued without specifying a parameter value. If "currentAsDefalult" is true, the current value of the parameter is used as a default value. The default value must be defined with SetDefaultValue() method. 7

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 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)"); 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. You can also 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. 8

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 void AvailableForStates( G4ApplicationState s1,…) Geant4 has 6 application states. G4State_PreInit Material, Geometry, Particle and/or Physics Process need to be initialized/defined 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 (Normal) termination G4State_Abort A fatal exception occurred and program is aborting 9 PreInit Idle EventProc GeomClosed Quit Abort initialize beamOn exit Run (event loop)

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Derivatives of G4UIcommand with numeric and boolean parameters have corresponding conversion methods. From a string to value used in SetNewValue() method in a messenger G4bool GetNewBoolValue(const char*) G4int GetNewIntValue(const char*) G4double GetNewDoubleValue(const char*) G4ThreeVector GetNew3VectorValue(const char*) Unit is taken into account automatically. From a value to string used in GetCurrentValue() method in a messenger G4String ConvertToString(...) G4String ConvertToString(...,const char* unit) 10

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 void A01DetectorConstMessenger ::SetNewValue(G4UIcommand* command,G4String newValue) { if( command==armCmd ) { target->SetArmAngle(armCmd-> GetNewDoubleValue(newValue)); } } G4String A01DetectorConstMessenger ::GetCurrentValue(G4UIcommand* command) { G4String cv; if( command==armCmd ){ cv = armCmd->ConvertToString(target->GetArmAngle(),"deg"); } return cv; } 11

17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 “Complicated” UI command means a UI command with parameters which is not provided as the delivered classes. A UI command with other type of parameters can be directly defined by G4UIcommand and G4UIparameter. G4UIparameter(const char * parName, char theType, G4bool theOmittable); "theType" is the type of the parameter. ‘b’ (boolean), ‘i’ (integer), ‘d’ (double), and ‘s’ (string) Each parameter can take guidance, a default value in case “theOmittable” is true, parameter range, and a candidate list. Parameters can be added to a command by G4UIcommand::SetParameter(G4UIparameter* const) 12