ui command ui command
play

UI command UI command Makoto Asai (SLAC Computing Services) Makoto - PowerPoint PPT Presentation

UI command UI command Makoto Asai (SLAC Computing Services) Makoto Asai (SLAC Computing Services) Geant4 Tutorial Course @ Fermi Lab Geant4 Tutorial Course @ Fermi Lab th , 2003 October 27 th , 2003 October 27 Contents Contents Alias


  1. UI command UI command Makoto Asai (SLAC Computing Services) Makoto Asai (SLAC Computing Services) Geant4 Tutorial Course @ Fermi Lab Geant4 Tutorial Course @ Fermi Lab th , 2003 October 27 th , 2003 October 27

  2. Contents Contents � Alias and loop Alias and loop � � Mechanism of UI command Mechanism of UI command � � Messenger class Messenger class � � Defining a command Defining a command � � Implementing a messenger Implementing a messenger � UI command - - M.Asai (SLAC) M.Asai (SLAC) - - Oct. 27, 2003 @ Fermi Lab Oct. 27, 2003 @ Fermi Lab 2 UI command 2

  3. Alias Alias � Alias can be defined by Alias can be defined by � /control/alias [name] [value] [name] [value] /control/alias � It is also set with It is also set with /control/loop /control/loop and and /control/ /control/foreach foreach � commands commands � Aliased value is always treated as a string even if it contains Aliased value is always treated as a string even if it contains only only � numbers. numbers. � Alias is to be used with other UI command. Alias is to be used with other UI command. � � Use curly brackets, { and } . Use curly brackets, { and } . � � For example, frequently used lengthy command can be shortened by For example, frequently used lengthy command can be shortened by � aliasing. aliasing. /control/alias trv1 " "/tracking/verbose 1 /tracking/verbose 1" " /control/alias trv1 {trv1} {trv1} � Aliases can be used recursively. Aliases can be used recursively. � /control/alias file1 /diskA/dirX/fileXX.dat diskA/dirX/fileXX.dat /control/alias file1 / /control/alias file2 /diskB/dirY/fileYY.dat /control/alias file2 / diskB/dirY/fileYY.dat /control/alias run 1 /control/alias run 1 /myCmd/getFile myCmd/getFile { {file{run file{run}} }} / UI command - - M.Asai (SLAC) M.Asai (SLAC) - - Oct. 27, 2003 @ Fermi Lab Oct. 27, 2003 @ Fermi Lab 3 UI command 3

  4. Loop Loop � /control/loop /control/loop and and /control/ /control/foreach foreach commands execute a macro commands execute a macro � file more than once. Aliased variable can be used inside the macro file. ro file. file more than once. Aliased variable can be used inside the mac � /control/loop [ /control/loop [ macroFile macroFile ] [ ] [ counterName counterName ] ] � [ initialValue ] [ finalValue ] [ stepSize ] [ initialValue ] [ finalValue ] [ stepSize ] counterName is aliased to the number as a loop counter is aliased to the number as a loop counter � counterName � � /control/ /control/foreach foreach [ [ macroFile ] [ counterName ] [ valueList ] macroFile ] [ counterName ] [ valueList ] � counterName is aliased to a value in is aliased to a value in valueList � counterName valueList � valueList must be enclosed by double quotes (" ") must be enclosed by double quotes (" ") � valueList � � on UI terminal or other macro file on UI terminal or other macro file � /control/loop myRun.mac /control/loop myRun.mac Ekin Ekin 10. 20. 2. 10. 20. 2. � in in myRun.mac myRun.mac � /gun/energy {Ekin /gun/energy { Ekin} } GeV GeV /run/beamOn beamOn 100 100 /run/ UI command - - M.Asai (SLAC) M.Asai (SLAC) - - Oct. 27, 2003 @ Fermi Lab Oct. 27, 2003 @ Fermi Lab 4 UI command 4

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

  6. Messenger class Messenger class � Each messenger class must be derived from Each messenger class must be derived from G4UImessenger G4UImessenger base class. base class. � A messenger class can handle one or more UI commands. A messenger class can handle one or more UI commands. � A messenger class A messenger class should be instantiated by should be instantiated by the constructor of the the constructor of the target target � class to which commands should be delivered, and to which commands should be delivered, and should be deleted should be deleted by by class the destructor of the target class. the destructor of the target class. � Methods of messenger class Methods of messenger class � � Constructor Constructor � � Define (instantiate) commands / command directories Define (instantiate) commands / command directories � � Destructor Destructor � � Delete commands / command directories Delete commands / command directories � � void void SetNewValue SetNewValue(G4UIcommand* command,G4String (G4UIcommand* command,G4String newValue newValue) ) � � Convert " Convert "newValue newValue" parameter string to appropriate " parameter string to appropriate value(s value(s) and ) and � invoke a method of the target class invoke a method of the target class � G4String G4String GetCurrentValue GetCurrentValue(G4UIcommand* command) (G4UIcommand* command) � � Access to a get Access to a get- -method of the target class and convert the method of the target class and convert the � current values to a string current values to a string UI command - - M.Asai (SLAC) M.Asai (SLAC) - - Oct. 27, 2003 @ Fermi Lab Oct. 27, 2003 @ Fermi Lab 6 UI command 6

  7. Definition (instantiation) of a command Definition (instantiation) of a command � To be implemented in the constructor of a messenger class. To be implemented in the constructor of a messenger class. � A01DetectorConstMessenger::A01DetectorConstMessenger A01DetectorConstMessenger::A01DetectorConstMessenger (A01DetectorConstruction* tgt tgt) ) (A01DetectorConstruction* : :target(tgt target(tgt) ) { { mydetDir = new = new G4UIdirectory G4UIdirectory(" ("/mydet/ /mydet/"); "); mydetDir mydetDir- mydetDir -> >SetGuidance SetGuidance("A01 detector setup commands."); ("A01 detector setup commands."); armCmd = new = new armCmd G4UIcmdWithADoubleAndUnit(" ("/mydet/armAngle /mydet/armAngle",this); ",this); G4UIcmdWithADoubleAndUnit armCmd- armCmd -> >SetGuidance SetGuidance("Rotation ("Rotation angle of the second arm."); angle of the second arm."); armCmd- -> >SetParameterName SetParameterName("angle",true ("angle",true); ); armCmd armCmd- -> >SetRange SetRange("angle ("angle>=0. && angle<180."); >=0. && angle<180."); armCmd armCmd- armCmd -> >SetDefaultValue SetDefaultValue(30.); (30.); armCmd- -> >SetDefaultUnit SetDefaultUnit("deg ("deg"); "); armCmd } } � Guidance can (should) be more than one lines. The first line is Guidance can (should) be more than one lines. The first line is utilized utilized � as a short description of the command. as a short description of the command. UI command - - M.Asai (SLAC) M.Asai (SLAC) - - Oct. 27, 2003 @ Fermi Lab Oct. 27, 2003 @ Fermi Lab 7 UI command 7

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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend