Changeset 1222 for trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Appendix/pythonInterface.xml
- Timestamp:
- Dec 16, 2009, 12:14:47 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Appendix/pythonInterface.xml
r1211 r1222 3 3 <!-- [History] --> 4 4 <!-- Created by Koichi Murakami, Dec-2008 --> 5 <!-- Correct typo by KM Dec-2009 --> 5 6 <!-- --> 6 7 <!-- ******************************************************** --> 7 8 8 9 9 <!-- ******************* Section (Level#1) ****************** --> 10 10 <sect1 id="sect.PythonInterface"> … … 15 15 <para> 16 16 Python is a popular scripting language with an interactive interpreter. 17 Geant4Py, a Geant4-Python bridge, provides a bridge for Geant4 classes. 17 Geant4Py, a Geant4-Python bridge, provides a bridge for Geant4 classes. 18 18 This enables to directly access Geant4 classes from Python scripting. 19 User applications can be easily configured with many Python 19 User applications can be easily configured with many Python 20 20 third-party modules, such as PyROOT, on the Python software bus. 21 21 </para> … … 37 37 38 38 <para> 39 Geant4Py requires 40 <ulink url="http://www.boost.org/">Boost-C++ external library</ulink>, 39 Geant4Py requires 40 <ulink url="http://www.boost.org/">Boost-C++ external library</ulink>, 41 41 which helps Python binding of C++ codes. 42 A Precompiled package is available for many Linux distributions 42 A Precompiled package is available for many Linux distributions 43 43 (SL, SuSE, Ubuntu, etc) and Mac OSX. 44 44 </para> 45 45 46 46 <para> 47 Geant4 libraries can be built as "static" and "granular", 48 where library components (variables, functions, ...) 49 used in the application are linked statically and shipped 50 with the application. 51 On the other hands, in dynamic binding, the library components 52 are not included in the application, and their binding is 53 carried out at run time. 54 The modular approach of Python is based on dynamic binding mechanism, 55 so you have Geant4 shared libraries are required instead. 56 </para> 57 58 <para> 59 For generic information about building Geant4 libraries, 47 Geant4 libraries can be built as "static" and "granular", 48 where library components (variables, functions, ...) 49 used in the application are linked statically and shipped 50 with the application. 51 On the other hands, in dynamic binding, the library components 52 are not included in the application, and their binding is 53 carried out at run time. 54 The modular approach of Python is based on dynamic binding mechanism, 55 so you have Geant4 shared libraries are required instead. 56 </para> 57 58 <para> 59 For generic information about building Geant4 libraries, 60 60 please refer to the <ulink url="http://cern.ch/geant4/G4UsersDocuments/UsersGuides/InstallationGuide/html/">Installation Guide</ulink>. 61 61 </para> 62 62 63 63 <para> 64 Here are some tips for manually building "global" and "shared" libraries 64 Here are some tips for manually building "global" and "shared" libraries 65 65 from an already existing "static + granular" installation. 66 66 After setting additional environment variables like: … … 129 129 </informalexample> 130 130 131 In addition, it is required that all header files are installed 131 In addition, it is required that all header files are installed 132 132 in a single directory. 133 133 … … 139 139 </informalexample> 140 140 141 This will collect all relevant header files 141 This will collect all relevant header files 142 142 in <literal>$G4INSTALL/include</literal> (or <literal>$G4INCLUDE</literal>). 143 143 </para> 144 144 145 145 <para> 146 There are a lso additional tools for helping building a Geant4 library in146 There are additional tools for helping building a Geant4 library in 147 147 the directory <literal>g4py/tools/</literal>. 148 148 </para> … … 213 213 <programlisting> 214 214 # ./configure linux64 215 --with-g4-incdir=/opt/heplib/Geant4/geant4.9.3/include 216 --with-g4-libdir=/opt/heplib/Geant4/geant4.9.3/slib/Linux-g++ 217 --with-clhep-incdir=/opt/heplib/CLHEP/2.0.4. 4/include218 --with-clhep-libdir=/opt/heplib/CLHEP/2.0.4. 4/lib219 --with-clhep-lib=CLHEP-2.0.4. 4220 </programlisting> 221 </informalexample> 222 223 The configure script automatically check your environment, 224 and create <literal>config/config.gmk</literal>, 225 which describes your envrionment. 226 227 After executing the configure script successfully, then 215 --with-g4-incdir=/opt/heplib/Geant4/geant4.9.3/include 216 --with-g4-libdir=/opt/heplib/Geant4/geant4.9.3/slib/Linux-g++ 217 --with-clhep-incdir=/opt/heplib/CLHEP/2.0.4.5/include 218 --with-clhep-libdir=/opt/heplib/CLHEP/2.0.4.5/lib 219 --with-clhep-lib=CLHEP-2.0.4.5 220 </programlisting> 221 </informalexample> 222 223 The configure script automatically check your environment, 224 and create <literal>config/config.gmk</literal>, 225 which describes your envrionment. 226 227 After executing the configure script successfully, then 228 228 229 229 <informalexample> … … 246 246 247 247 <para> 248 <emphasis role="bold">PYTHONPATH</emphasis> environment variable 248 <emphasis role="bold">PYTHONPATH</emphasis> environment variable 249 249 should be set at tun time. 250 <emphasis role="bold">PYTHONPATH</emphasis> environment variable indicates 251 Python module search directories, given by a colon-separated list 252 of directories. Practically, the variable is 250 <emphasis role="bold">PYTHONPATH</emphasis> environment variable indicates 251 Python module search directories, given by a colon-separated list 252 of directories. Practically, the variable is 253 253 <literal>(your g4py directory)/lib</literal>. 254 254 </para> … … 264 264 <programlisting> 265 265 # python 266 Python 2. 5.2 (r252:60911, Aug 1 2008, 00:37:21)267 [GCC 4. 3.2] on linux2266 Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) 267 [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 268 268 Type "help", "copyright", "credits" or "license" for more information. 269 269 >>> from Geant4 import * … … 277 277 278 278 Visualization Manager instantiating... 279 >>> 279 >>> 280 280 </programlisting> 281 281 </informalexample> … … 290 290 <para> 291 291 When importing the Geant4 module, the <literal>G4RunManager</literal> 292 object will be automatically instantiated. Geant4 singleton objects are also 293 automatically instantiated. These singleton objects can be accessed 292 object will be automatically instantiated. Geant4 singleton objects are also 293 automatically instantiated. These singleton objects can be accessed 294 294 by "gXXXX" variables, like "gRunManager". 295 295 … … 301 301 gElementTable gParticleIterator gUImanager 302 302 gEmCalculator gParticleTable gVisManager 303 gEventManager gProcessTable 304 gExceptionHandler gProductionCutsTable 305 gG4Date gRunManager 306 gG4VERSION_NUMBER gRunManagerKernel 307 gG4Version gStackManager 308 gGeometryManager gStartUISession 309 gGetCurrentValues gStateManager 303 gEventManager gProcessTable 304 gExceptionHandler gProductionCutsTable 305 gG4Date gRunManager 306 gG4VERSION_NUMBER gRunManagerKernel 307 gG4Version gStackManager 308 gGeometryManager gStartUISession 309 gGetCurrentValues gStateManager 310 310 </programlisting> 311 311 </informalexample> … … 319 319 320 320 <para> 321 Once a Python object of a Geant4 class instantiated, 321 Once a Python object of a Geant4 class instantiated, 322 322 Geant4 methods can be directly called the same way as in C++. 323 323 … … 352 352 353 353 <para> 354 Geant4Py provides additional utility modules called "g4py" in the directory 355 <literal>site-modules</literal>. It consists of predifined geometries, 354 Geant4Py provides additional utility modules called "g4py" in the directory 355 <literal>site-modules</literal>. It consists of predifined geometries, 356 356 materials, physics lists, primary generator actions, and so on. 357 357 </para> … … 363 363 364 364 <para> 365 The <emphasis>ezgeom</emphasis> module provides an alternative way 366 of defining simple geometry. 365 The <emphasis>ezgeom</emphasis> module provides an alternative way 366 of defining simple geometry. 367 367 An example code for defining a simple geometry is shown here: 368 368 </para> … … 396 396 397 397 <para> 398 The <emphasis>NISTmaterials</emphasis> module provides an instant 398 The <emphasis>NISTmaterials</emphasis> module provides an instant 399 399 use of Geant4 NIST materials. 400 400 An example code for creating NIST materials: … … 418 418 419 419 <para> 420 The <emphasis>ParticleGun</emphasis> module provides 420 The <emphasis>ParticleGun</emphasis> module provides 421 421 a primary generator action with <literal>G4ParticleGun</literal>. 422 422 An example code is shown here: … … 456 456 457 457 <para> 458 There are some examples of Geant4Py in the directories 458 There are some examples of Geant4Py in the directories 459 459 <literal>"tests/"</literal> and <literal>"examples/"</literal>. 460 460 </para> 461 461 462 In the <literal>"tests/"</literal> directory, 462 In the <literal>"tests/"</literal> directory, 463 463 464 464 <informalexample> … … 474 474 </informalexample> 475 475 476 The <literal>"examples/"</literal> directory contains 476 The <literal>"examples/"</literal> directory contains 477 477 a set of examples of Geant4Py. 478 478 … … 483 483 <para> 484 484 An example of "water phantom dosimetry". 485 This demo program shows that a Geant4 application well coworks with Root 486 on Python front end. VisManager, PrimaryGeneratorAction, UserAction-s, 485 This demo program shows that a Geant4 application well coworks with Root 486 on Python front end. VisManager, PrimaryGeneratorAction, UserAction-s, 487 487 histogramming with Root are implemented in Python; 488 488 <itemizedlist> … … 521 521 <para> 522 522 GUI interface of ExN03, which can control geometry configuration, 523 intial particle condition, physics processes, cut value, 523 intial particle condition, physics processes, cut value, 524 524 magnetic field and visualization outputs. 525 525 </para>
Note: See TracChangeset
for help on using the changeset viewer.