| 1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 2. Getting Started with Geant4 - Running a Simple Example</title><link rel="stylesheet" href="../xml/XSLCustomizationLayer/G4HTMLStylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="Geant4 User's Guide for Application Developers"><link rel="up" href="index.html" title="Geant4 User's Guide for Application Developers"><link rel="prev" href="ch01s02.html" title="1.2. How to use this manual"><link rel="next" href="ch02s02.html" title="2.2. How to Define a Detector Geometry"><script language="JavaScript">
|
|---|
| 2 | function remote_win(fName)
|
|---|
| 3 | {
|
|---|
| 4 | var url = "AllResources/Detector/geometry.src/" + fName;
|
|---|
| 5 | RemoteWin=window.open(url,"","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=520,height=520")
|
|---|
| 6 | RemoteWin.creator=self
|
|---|
| 7 | }
|
|---|
| 8 | </script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 2.
|
|---|
| 9 | Getting Started with Geant4 - Running a Simple Example
|
|---|
| 10 | </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s02.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch02s02.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="chap.GettingStarted"></a>Chapter 2.
|
|---|
| 11 | Getting Started with Geant4 - Running a Simple Example
|
|---|
| 12 | </h2></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect.HowToDefMain"></a>2.1.
|
|---|
| 13 | How to Define the main() Program
|
|---|
| 14 | </h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefMain.SimpleMainMethod"></a>2.1.1.
|
|---|
| 15 | A Sample <code class="literal">main()</code> Method
|
|---|
| 16 | </h3></div></div></div><p>
|
|---|
| 17 | The contents of <code class="literal">main()</code> will vary according to the
|
|---|
| 18 | needs of a given simulation application and therefore must be supplied
|
|---|
| 19 | by the user. The Geant4 toolkit does not provide a <code class="literal">main()</code>
|
|---|
| 20 | method, but a sample is provided here as a guide to the beginning
|
|---|
| 21 | user. <a href="ch02.html#programlist_HowToDefMain_1" title="Example 2.1.
|
|---|
| 22 | Simplest example of main()
|
|---|
| 23 | ">Example 2.1</a> is the simplest example of
|
|---|
| 24 | <code class="literal">main()</code> required to build a simulation program.
|
|---|
| 25 | </p><div class="example"><a name="programlist_HowToDefMain_1"></a><p class="title"><b>Example 2.1.
|
|---|
| 26 | Simplest example of <code class="literal">main()</code>
|
|---|
| 27 | </b></p><div class="example-contents"><pre class="programlisting">
|
|---|
| 28 | #include "G4RunManager.hh"
|
|---|
| 29 | #include "G4UImanager.hh"
|
|---|
| 30 |
|
|---|
| 31 | #include "ExN01DetectorConstruction.hh"
|
|---|
| 32 | #include "ExN01PhysicsList.hh"
|
|---|
| 33 | #include "ExN01PrimaryGeneratorAction.hh"
|
|---|
| 34 |
|
|---|
| 35 | int main()
|
|---|
| 36 | {
|
|---|
| 37 | // construct the default run manager
|
|---|
| 38 | G4RunManager* runManager = new G4RunManager;
|
|---|
| 39 |
|
|---|
| 40 | // set mandatory initialization classes
|
|---|
| 41 | runManager->SetUserInitialization(new ExN01DetectorConstruction);
|
|---|
| 42 | runManager->SetUserInitialization(new ExN01PhysicsList);
|
|---|
| 43 |
|
|---|
| 44 | // set mandatory user action class
|
|---|
| 45 | runManager->SetUserAction(new ExN01PrimaryGeneratorAction);
|
|---|
| 46 |
|
|---|
| 47 | // initialize G4 kernel
|
|---|
| 48 | runManager->initialize();
|
|---|
| 49 |
|
|---|
| 50 | // get the pointer to the UI manager and set verbosities
|
|---|
| 51 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 52 | UI->ApplyCommand("/run/verbose 1");
|
|---|
| 53 | UI->ApplyCommand("/event/verbose 1");
|
|---|
| 54 | UI->ApplyCommand("/tracking/verbose 1");
|
|---|
| 55 |
|
|---|
| 56 | // start a run
|
|---|
| 57 | int numberOfEvent = 3;
|
|---|
| 58 | runManager->BeamOn(numberOfEvent);
|
|---|
| 59 |
|
|---|
| 60 | // job termination
|
|---|
| 61 | delete runManager;
|
|---|
| 62 | return 0;
|
|---|
| 63 | }
|
|---|
| 64 | </pre></div></div><br class="example-break"><p>
|
|---|
| 65 | The <code class="literal">main()</code> method is implemented by two toolkit
|
|---|
| 66 | classes, <span class="emphasis"><em>G4RunManager</em></span> and <span class="emphasis"><em>G4UImanager</em></span>,
|
|---|
| 67 | and three classes, <span class="emphasis"><em>ExN01DetectorConstruction</em></span>,
|
|---|
| 68 | <span class="emphasis"><em>ExN01PhysicsList</em></span> and
|
|---|
| 69 | <span class="emphasis"><em>ExN01PrimaryGeneratorAction</em></span>, which are derived from
|
|---|
| 70 | toolkit classes. Each of these are explained in the following sections.
|
|---|
| 71 | </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefMain.G4RunManager"></a>2.1.2.
|
|---|
| 72 | <span class="emphasis"><em>G4RunManager</em></span>
|
|---|
| 73 | </h3></div></div></div><p>
|
|---|
| 74 | The first thing <code class="literal">main()</code> must do is create an instance of
|
|---|
| 75 | the <span class="emphasis"><em>G4RunManager</em></span> class. This is the only manager class in
|
|---|
| 76 | the Geant4 kernel which should be explicitly constructed in the
|
|---|
| 77 | user's <code class="literal">main()</code>. It controls the flow of the program and
|
|---|
| 78 | manages the event loop(s) within a run. When <span class="emphasis"><em>G4RunManager</em></span> is
|
|---|
| 79 | created, the other major manager classes are also created. They are
|
|---|
| 80 | deleted automatically when <span class="emphasis"><em>G4RunManager</em></span> is deleted. The run
|
|---|
| 81 | manager is also responsible for managing initialization procedures,
|
|---|
| 82 | including methods in the user initialization classes. Through these
|
|---|
| 83 | the run manager must be given all the information necessary to
|
|---|
| 84 | build and run the simulation, including
|
|---|
| 85 | </p><div class="orderedlist"><ol type="1" compact><li><p>
|
|---|
| 86 | how the detector should be constructed,
|
|---|
| 87 | </p></li><li><p>
|
|---|
| 88 | all the particles and all the physics processes to be
|
|---|
| 89 | simulated,
|
|---|
| 90 | </p></li><li><p>
|
|---|
| 91 | how the primary particle(s) in an event should be produced
|
|---|
| 92 | and
|
|---|
| 93 | </p></li><li><p>
|
|---|
| 94 | any additional requirements of the simulation.</p></li></ol></div><p>
|
|---|
| 95 | In the sample <code class="literal">main()</code> the lines
|
|---|
| 96 |
|
|---|
| 97 | </p><div class="informalexample"><pre class="programlisting">
|
|---|
| 98 | runManager->SetUserInitialization(new ExN01DetectorConstruction);
|
|---|
| 99 | runManager->SetUserInitialization(new ExN01PhysicsList);
|
|---|
| 100 | </pre></div><p>
|
|---|
| 101 |
|
|---|
| 102 | create objects which specify the detector geometry and physics
|
|---|
| 103 | processes, respectively, and pass their pointers to the run
|
|---|
| 104 | manager. <span class="emphasis"><em>ExN01DetectorConstruction</em></span> is an example of a user
|
|---|
| 105 | initialization class which is derived from
|
|---|
| 106 | <span class="emphasis"><em>G4VUserDetectorConstruction</em></span>. This is where the user
|
|---|
| 107 | describes the entire detector setup, including
|
|---|
| 108 | </p><div class="itemizedlist"><ul type="disc" compact><li><p>
|
|---|
| 109 | its geometry,
|
|---|
| 110 | </p></li><li><p>
|
|---|
| 111 | the materials used in its construction,
|
|---|
| 112 | </p></li><li><p>
|
|---|
| 113 | a definition of its sensitive regions and
|
|---|
| 114 | </p></li><li><p>
|
|---|
| 115 | the readout schemes of the sensitive regions.
|
|---|
| 116 | </p></li></ul></div><p>
|
|---|
| 117 | Similarly <span class="emphasis"><em>ExN01PhysicsList</em></span> is derived from
|
|---|
| 118 | <span class="emphasis"><em>G4VUserPhysicsList</em></span> and requires the user to define
|
|---|
| 119 | </p><div class="itemizedlist"><ul type="disc" compact><li><p>
|
|---|
| 120 | the particles to be used in the simulation,
|
|---|
| 121 | </p></li><li><p>
|
|---|
| 122 | the range cuts for these particles and
|
|---|
| 123 | </p></li><li><p>
|
|---|
| 124 | all the physics processes to be simulated.
|
|---|
| 125 | </p></li></ul></div><p>
|
|---|
| 126 | The next instruction in <code class="literal">main()</code>
|
|---|
| 127 |
|
|---|
| 128 | </p><div class="informalexample"><pre class="programlisting">
|
|---|
| 129 | runManager->SetUserAction(new ExN01PrimaryGeneratorAction);
|
|---|
| 130 | </pre></div><p>
|
|---|
| 131 |
|
|---|
| 132 | creates an instance of a particle generator and passes its pointer
|
|---|
| 133 | to the run manager. <span class="emphasis"><em>ExN01PrimaryGeneratorAction</em></span> is an
|
|---|
| 134 | example of a user action class which is derived from
|
|---|
| 135 | <span class="emphasis"><em>G4VUserPrimaryGeneratorAction</em></span>. In this class the user must
|
|---|
| 136 | describe the initial state of the primary event. This class has a
|
|---|
| 137 | public virtual method named <code class="literal">generatePrimaries()</code> which will
|
|---|
| 138 | be invoked at the beginning of each event. Details will be given in
|
|---|
| 139 | <a href="ch02s06.html" title="2.6.
|
|---|
| 140 | How to Generate a Primary Event
|
|---|
| 141 | ">Section 2.6</a>.
|
|---|
| 142 | Note that Geant4 does not provide any default behavior for generating a primary event.
|
|---|
| 143 | </p><p>
|
|---|
| 144 | The next instruction
|
|---|
| 145 |
|
|---|
| 146 | </p><div class="informalexample"><pre class="programlisting">
|
|---|
| 147 | runManager->initialize();
|
|---|
| 148 | </pre></div><p>
|
|---|
| 149 |
|
|---|
| 150 | performs the detector construction, creates the physics processes,
|
|---|
| 151 | calculates cross sections and otherwise sets up the run. The final
|
|---|
| 152 | run manager method in <code class="literal">main()</code>
|
|---|
| 153 |
|
|---|
| 154 | </p><div class="informalexample"><pre class="programlisting">
|
|---|
| 155 | int numberOfEvent = 3;
|
|---|
| 156 | runManager->beamOn(numberOfEvent);
|
|---|
| 157 | </pre></div><p>
|
|---|
| 158 |
|
|---|
| 159 | begins a run of three sequentially processed events. The
|
|---|
| 160 | <code class="literal">beamOn()</code> method may be invoked any number of times within
|
|---|
| 161 | <code class="literal">main()</code> with each invocation representing a separate run.
|
|---|
| 162 | Once a run has begun neither the detector setup nor the physics
|
|---|
| 163 | processes may be changed. They may be changed between runs,
|
|---|
| 164 | however, as described in <a href="ch03s04.html#sect.Run.Custom" title="3.4.4.
|
|---|
| 165 | Customizing the Run Manager
|
|---|
| 166 | ">Section 3.4.4</a>.
|
|---|
| 167 | More information on <span class="emphasis"><em>G4RunManager</em></span> in general is found in
|
|---|
| 168 | <a href="ch03s04.html" title="3.4.
|
|---|
| 169 | Run
|
|---|
| 170 | ">Section 3.4</a>.
|
|---|
| 171 | </p><p>
|
|---|
| 172 | As mentioned above, other manager classes are created when the
|
|---|
| 173 | run manager is created. One of these is the user interface manager,
|
|---|
| 174 | <span class="emphasis"><em>G4UImanager</em></span>. In <code class="literal">main()</code> a pointer to
|
|---|
| 175 | the interface manager must be obtained
|
|---|
| 176 |
|
|---|
| 177 | </p><div class="informalexample"><pre class="programlisting">
|
|---|
| 178 | G4UImanager* UI = G4UImanager::getUIpointer();
|
|---|
| 179 | </pre></div><p>
|
|---|
| 180 |
|
|---|
| 181 | in order for the user to issue commands to the program. In the
|
|---|
| 182 | present example the <code class="literal">applyCommand()</code> method is called three
|
|---|
| 183 | times to direct the program to print out information at the run,
|
|---|
| 184 | event and tracking levels of simulation. A wide range of commands
|
|---|
| 185 | is available which allows the user detailed control of the
|
|---|
| 186 | simulation. A list of these commands can be found in
|
|---|
| 187 | <a href="ch07.html#sect.BuiltinCom" title="7.1.
|
|---|
| 188 | Built-in Commands
|
|---|
| 189 | ">Section 7.1</a>.
|
|---|
| 190 | </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefMain.UserInitAction"></a>2.1.3.
|
|---|
| 191 | User Initialization and Action Classes
|
|---|
| 192 | </h3></div></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToDefMain.UserInitAction.MandatoryUserClasses"></a>2.1.3.1.
|
|---|
| 193 | Mandatory User Classes
|
|---|
| 194 | </h4></div></div></div><p>
|
|---|
| 195 | There are three classes which must be defined by the user. Two
|
|---|
| 196 | of them are user initialization classes, and the other is a user
|
|---|
| 197 | action class. They must be derived from the abstract base classes
|
|---|
| 198 | provided by Geant4: <span class="emphasis"><em>G4VUserDetectorConstruction</em></span>,
|
|---|
| 199 | <span class="emphasis"><em>G4VuserPhysicsList</em></span> and
|
|---|
| 200 | <span class="emphasis"><em>G4VuserPrimaryGeneratorAction</em></span>.
|
|---|
| 201 | Geant4 does not provide default behavior for these classes.
|
|---|
| 202 | <span class="emphasis"><em>G4RunManager</em></span> checks for the existence of these mandatory
|
|---|
| 203 | classes when the <code class="literal">initialize()</code> and <code class="literal">BeamOn()</code>
|
|---|
| 204 | methods are invoked.
|
|---|
| 205 | </p><p>
|
|---|
| 206 | As mentioned in the previous section,
|
|---|
| 207 | <span class="emphasis"><em>G4VUserDetectorConstruction</em></span> requires the user to define the
|
|---|
| 208 | detector and <span class="emphasis"><em>G4VUserPhysicsList</em></span> requires the user to define
|
|---|
| 209 | the physics. Detector definition will be discussed in Sections
|
|---|
| 210 | </p><p>
|
|---|
| 211 | <a href="ch02s02.html" title="2.2.
|
|---|
| 212 | How to Define a Detector Geometry
|
|---|
| 213 | ">Section 2.2</a> and
|
|---|
| 214 | <a href="ch02s03.html" title="2.3.
|
|---|
| 215 | How to Specify Materials in the Detector
|
|---|
| 216 | ">Section 2.3</a>.
|
|---|
| 217 | Physics definition will be discussed in Sections
|
|---|
| 218 | <a href="ch02s04.html" title="2.4.
|
|---|
| 219 | How to Specify Particles
|
|---|
| 220 | ">Section 2.4</a>
|
|---|
| 221 | and
|
|---|
| 222 | <a href="ch02s05.html" title="2.5.
|
|---|
| 223 | How to Specify Physics Processes
|
|---|
| 224 | ">Section 2.5</a>.
|
|---|
| 225 | The user action <span class="emphasis"><em>G4VuserPrimaryGeneratorAction</em></span>
|
|---|
| 226 | requires that the initial event state be defined. Primary event generation will
|
|---|
| 227 | be discussed in
|
|---|
| 228 | <a href="ch02s07.html" title="2.7.
|
|---|
| 229 | How to Make an Executable Program
|
|---|
| 230 | ">Section 2.7</a>.
|
|---|
| 231 | </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToDefMain.UserInitAction.OptionalUserAction"></a>2.1.3.2.
|
|---|
| 232 | Optional User Action Classes
|
|---|
| 233 | </h4></div></div></div><p>
|
|---|
| 234 | Geant4 provides five user hook classes:
|
|---|
| 235 | </p><div class="itemizedlist"><ul type="disc" compact><li><p>
|
|---|
| 236 | <span class="emphasis"><em>G4UserRunAction</em></span>
|
|---|
| 237 | </p></li><li><p>
|
|---|
| 238 | <span class="emphasis"><em>G4UserEventAction</em></span>
|
|---|
| 239 | </p></li><li><p>
|
|---|
| 240 | <span class="emphasis"><em>G4UserStackingAction</em></span>
|
|---|
| 241 | </p></li><li><p>
|
|---|
| 242 | <span class="emphasis"><em>G4UserTrackingAction</em></span>
|
|---|
| 243 | </p></li><li><p>
|
|---|
| 244 | <span class="emphasis"><em>G4UserSteppingAction</em></span>
|
|---|
| 245 | </p></li></ul></div><p>
|
|---|
| 246 | There are several virtual methods in each of these classes which
|
|---|
| 247 | allow the specification of additional procedures at all levels of
|
|---|
| 248 | the simulation application. Details of the user initialization and
|
|---|
| 249 | action classes are provided in
|
|---|
| 250 | <a href="ch06.html" title="Chapter 6.
|
|---|
| 251 | User Actions
|
|---|
| 252 | ">Chapter 6</a>.
|
|---|
| 253 | </p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefMain.G4UImanagerUICommand"></a>2.1.4.
|
|---|
| 254 | <span class="emphasis"><em>G4UImanager</em></span> and UI CommandSubmission
|
|---|
| 255 | </h3></div></div></div><p>
|
|---|
| 256 | Geant4 provides a category named <span class="bold"><strong>intercoms</strong></span>.
|
|---|
| 257 | <span class="emphasis"><em>G4UImanager</em></span> is the manager class of this category. Using the
|
|---|
| 258 | functionalities of this category, you can invoke
|
|---|
| 259 | <span class="bold"><strong>set</strong></span> methods
|
|---|
| 260 | of class objects of which you do not know the pointer.
|
|---|
| 261 | In <a href="ch02.html#programlist_HowToDefMain_2" title="Example 2.2.
|
|---|
| 262 | An example of main() using interactive
|
|---|
| 263 | terminal and visualization. Code modified from the previous
|
|---|
| 264 | example are shown in blue.
|
|---|
| 265 | ">Example 2.2</a>,
|
|---|
| 266 | the verbosities of various Geant4 manager classes
|
|---|
| 267 | are set. Detailed mechanism description and usage of
|
|---|
| 268 | <span class="bold"><strong>intercoms</strong></span> will be given in the next chapter,
|
|---|
| 269 | with a list of available commands. Command submission can be done all through the
|
|---|
| 270 | application.
|
|---|
| 271 | </p><div class="example"><a name="programlist_HowToDefMain_2"></a><p class="title"><b>Example 2.2.
|
|---|
| 272 | An example of <code class="literal">main()</code> using interactive
|
|---|
| 273 | terminal and visualization. Code modified from the previous
|
|---|
| 274 | example are shown in <span class="color_blue">blue</span>.
|
|---|
| 275 | </b></p><div class="example-contents"><pre class="programlisting">
|
|---|
| 276 | #include "G4RunManager.hh"
|
|---|
| 277 | #include "G4UImanager.hh"
|
|---|
| 278 | <span class="color_blue">#include "G4UIterminal.hh"</span>
|
|---|
| 279 | #include "G4VisExecutive.hh"
|
|---|
| 280 |
|
|---|
| 281 | #include "N02DetectorConstruction.hh"
|
|---|
| 282 | #include "N02PhysicsList.hh"
|
|---|
| 283 | #include "N02PrimaryGeneratorAction.hh"
|
|---|
| 284 | #include "N02RunAction.hh"
|
|---|
| 285 | #include "N02EventAction.hh"
|
|---|
| 286 | #include "N02SteppingAction.hh"
|
|---|
| 287 |
|
|---|
| 288 | #include "g4templates.hh"
|
|---|
| 289 |
|
|---|
| 290 | int main(int argc,char** argv)
|
|---|
| 291 | {
|
|---|
| 292 | // construct the default run manager
|
|---|
| 293 | G4RunManager * runManager = new G4RunManager;
|
|---|
| 294 |
|
|---|
| 295 | // set mandatory initialization classes
|
|---|
| 296 | N02DetectorConstruction* detector = new N02DetectorConstruction;
|
|---|
| 297 | runManager->SetUserInitialization(detector);
|
|---|
| 298 | runManager->SetUserInitialization(new N02PhysicsList);
|
|---|
| 299 |
|
|---|
| 300 | // visualization manager
|
|---|
| 301 | G4VisManager* visManager = new G4VisExecutive;
|
|---|
| 302 | visManager->initialize();
|
|---|
| 303 |
|
|---|
| 304 | // set user action classes
|
|---|
| 305 | runManager->SetUserAction(new N02PrimaryGeneratorAction(detector));
|
|---|
| 306 | runManager->SetUserAction(new N02RunAction);
|
|---|
| 307 | runManager->SetUserAction(new N02EventAction);
|
|---|
| 308 | runManager->SetUserAction(new N02SteppingAction);
|
|---|
| 309 |
|
|---|
| 310 | // get the pointer to the User Interface manager
|
|---|
| 311 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 312 |
|
|---|
| 313 | <span class="color_blue">
|
|---|
| 314 | if(argc==1)
|
|---|
| 315 | // Define (G)UI terminal for interactive mode
|
|---|
| 316 | {
|
|---|
| 317 | G4UIsession * session = new G4UIterminal;
|
|---|
| 318 | UI->ApplyCommand("/control/execute prerun.g4mac");
|
|---|
| 319 | session->sessionStart();
|
|---|
| 320 | delete session;
|
|---|
| 321 | }
|
|---|
| 322 | else
|
|---|
| 323 | // Batch mode
|
|---|
| 324 | {
|
|---|
| 325 | G4String command = "/control/execute ";
|
|---|
| 326 | G4String fileName = argv[1];
|
|---|
| 327 | UI->ApplyCommand(command+fileName);
|
|---|
| 328 | }
|
|---|
| 329 | </span>
|
|---|
| 330 |
|
|---|
| 331 | // job termination
|
|---|
| 332 | delete visManager;
|
|---|
| 333 | delete runManager;
|
|---|
| 334 |
|
|---|
| 335 | return 0;
|
|---|
| 336 | }
|
|---|
| 337 | </pre></div></div><br class="example-break"></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefMain.G4coutG4cerr"></a>2.1.5.
|
|---|
| 338 | <span class="emphasis"><em>G4cout</em></span> and <span class="emphasis"><em>G4cerr</em></span>
|
|---|
| 339 | </h3></div></div></div><p>
|
|---|
| 340 | Although not yet included in the above examples, output streams
|
|---|
| 341 | will be needed. <span class="emphasis"><em>G4cout</em></span> and <span class="emphasis"><em>G4cerr</em></span>
|
|---|
| 342 | are <span class="bold"><strong>iostream</strong></span>
|
|---|
| 343 | objects defined by Geant4. The usage of these objects is exactly
|
|---|
| 344 | the same as the ordinary <span class="emphasis"><em>cout</em></span> and
|
|---|
| 345 | <span class="emphasis"><em>cerr</em></span>,
|
|---|
| 346 | except that the output streams will be handled by
|
|---|
| 347 | <span class="emphasis"><em>G4UImanager</em></span>.
|
|---|
| 348 | Thus, output strings may be displayed on another window or stored in a
|
|---|
| 349 | file. Manipulation of these output streams will be described in
|
|---|
| 350 | <a href="ch07s02.html#sect.UIDefNew.HowCont" title="7.2.4.
|
|---|
| 351 | How to control the output of G4cout/G4cerr
|
|---|
| 352 | ">Section 7.2.4</a>.
|
|---|
| 353 | These objects should be used instead of the ordinary
|
|---|
| 354 | <span class="emphasis"><em>cout</em></span> and <span class="emphasis"><em>cerr</em></span>.
|
|---|
| 355 | </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s02.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch02s02.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">1.2.
|
|---|
| 356 | How to use this manual
|
|---|
| 357 | </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="AllResources/IconsGIF/home.gif" alt="Home"></a></td><td width="40%" align="right" valign="top"> 2.2.
|
|---|
| 358 | How to Define a Detector Geometry
|
|---|
| 359 | </td></tr></table></div></body></html>
|
|---|