Ignore:
Timestamp:
Dec 16, 2009, 12:14:47 PM (15 years ago)
Author:
garnier
Message:

CVS update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Appendix/pythonInterface.xml

    r1211 r1222  
    33<!--  [History]                                               -->
    44<!--    Created by Koichi Murakami, Dec-2008                  -->
     5<!--    Correct typo by KM Dec-2009                           -->
    56<!--                                                          -->
    67<!-- ******************************************************** -->
    78
    8 
    99<!-- ******************* Section (Level#1) ****************** -->
    1010<sect1 id="sect.PythonInterface">
     
    1515<para>
    1616Python is a popular scripting language with an interactive interpreter.
    17 Geant4Py, a Geant4-Python bridge, provides a bridge for Geant4 classes. 
     17Geant4Py, a Geant4-Python bridge, provides a bridge for Geant4 classes.
    1818This enables to directly access Geant4 classes from Python scripting.
    19 User applications can be easily configured with many Python 
     19User applications can be easily configured with many Python
    2020third-party modules, such as PyROOT, on the Python software bus.
    2121</para>
     
    3737
    3838<para>
    39 Geant4Py requires 
    40 <ulink url="http://www.boost.org/">Boost-C++ external library</ulink>, 
     39Geant4Py requires
     40<ulink url="http://www.boost.org/">Boost-C++ external library</ulink>,
    4141which helps Python binding of C++ codes.
    42 A Precompiled package is available for many Linux distributions 
     42A Precompiled package is available for many Linux distributions
    4343(SL, SuSE, Ubuntu, etc) and Mac OSX.
    4444</para>
    4545
    4646<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, 
     47Geant4 libraries can be built as "static" and "granular",
     48where library components (variables, functions, ...)
     49used in the application are linked statically and shipped
     50with the application.
     51On the other hands, in dynamic binding, the library components
     52are not included in the application, and their binding is
     53carried out at run time.
     54The modular approach of Python is based on dynamic binding mechanism,
     55so you have Geant4 shared libraries are required instead.
     56</para>
     57
     58<para>
     59For generic information about building Geant4 libraries,
    6060please refer to the <ulink url="http://cern.ch/geant4/G4UsersDocuments/UsersGuides/InstallationGuide/html/">Installation Guide</ulink>.
    6161</para>
    6262
    6363<para>
    64 Here are some tips for manually building "global" and "shared" libraries 
     64Here are some tips for manually building "global" and "shared" libraries
    6565from an already existing "static + granular" installation.
    6666After setting additional environment variables like:
     
    129129</informalexample>
    130130
    131 In addition, it is required that all header files are installed 
     131In addition, it is required that all header files are installed
    132132in a single directory.
    133133
     
    139139</informalexample>
    140140
    141 This will collect all relevant header files 
     141This will collect all relevant header files
    142142in <literal>$G4INSTALL/include</literal> (or <literal>$G4INCLUDE</literal>).
    143143</para>
    144144
    145145<para>
    146 There are also additional tools for helping building a Geant4 library in
     146There are additional tools for helping building a Geant4 library in
    147147the directory <literal>g4py/tools/</literal>.
    148148</para>
     
    213213<programlisting>
    214214# ./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/include
    218   --with-clhep-libdir=/opt/heplib/CLHEP/2.0.4.4/lib
    219   --with-clhep-lib=CLHEP-2.0.4.4
    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 
     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
     223The configure script automatically check your environment,
     224and create <literal>config/config.gmk</literal>,
     225which describes your envrionment.
     226
     227After executing the configure script successfully, then
    228228
    229229<informalexample>
     
    246246
    247247<para>
    248 <emphasis role="bold">PYTHONPATH</emphasis> environment variable 
     248<emphasis role="bold">PYTHONPATH</emphasis> environment variable
    249249should 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
     251Python module search directories, given by a colon-separated list
     252of directories. Practically, the variable is
    253253<literal>(your g4py directory)/lib</literal>.
    254254</para>
     
    264264<programlisting>
    265265# python
    266 Python 2.5.2 (r252:60911, Aug  1 2008, 00:37:21)
    267 [GCC 4.3.2] on linux2
     266Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21)
     267[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2
    268268Type "help", "copyright", "credits" or "license" for more information.
    269269&gt;&gt;&gt; from Geant4 import *
     
    277277
    278278Visualization Manager instantiating...
    279 &gt;&gt;&gt; 
     279&gt;&gt;&gt;
    280280</programlisting>
    281281</informalexample>
     
    290290<para>
    291291When 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 
     292object will be automatically instantiated. Geant4 singleton objects are also
     293automatically instantiated. These singleton objects can be accessed
    294294by "gXXXX" variables, like "gRunManager".
    295295
     
    301301gElementTable           gParticleIterator       gUImanager
    302302gEmCalculator           gParticleTable          gVisManager
    303 gEventManager           gProcessTable           
    304 gExceptionHandler       gProductionCutsTable   
    305 gG4Date                 gRunManager             
    306 gG4VERSION_NUMBER       gRunManagerKernel       
    307 gG4Version              gStackManager           
    308 gGeometryManager        gStartUISession         
    309 gGetCurrentValues       gStateManager           
     303gEventManager           gProcessTable
     304gExceptionHandler       gProductionCutsTable
     305gG4Date                 gRunManager
     306gG4VERSION_NUMBER       gRunManagerKernel
     307gG4Version              gStackManager
     308gGeometryManager        gStartUISession
     309gGetCurrentValues       gStateManager
    310310</programlisting>
    311311</informalexample>
     
    319319
    320320<para>
    321 Once a Python object of a Geant4 class instantiated, 
     321Once a Python object of a Geant4 class instantiated,
    322322Geant4 methods can be directly called the same way as in C++.
    323323
     
    352352
    353353<para>
    354 Geant4Py provides additional utility modules called "g4py" in the directory 
    355 <literal>site-modules</literal>. It consists of predifined geometries, 
     354Geant4Py provides additional utility modules called "g4py" in the directory
     355<literal>site-modules</literal>. It consists of predifined geometries,
    356356materials, physics lists, primary generator actions, and so on.
    357357</para>
     
    363363
    364364<para>
    365 The <emphasis>ezgeom</emphasis> module provides an alternative way 
    366 of defining simple geometry. 
     365The <emphasis>ezgeom</emphasis> module provides an alternative way
     366of defining simple geometry.
    367367An example code for defining a simple geometry is shown here:
    368368</para>
     
    396396
    397397<para>
    398 The <emphasis>NISTmaterials</emphasis> module provides an instant 
     398The <emphasis>NISTmaterials</emphasis> module provides an instant
    399399use of Geant4 NIST materials.
    400400An example code for creating NIST materials:
     
    418418
    419419<para>
    420 The <emphasis>ParticleGun</emphasis> module provides 
     420The <emphasis>ParticleGun</emphasis> module provides
    421421a primary generator action with <literal>G4ParticleGun</literal>.
    422422An example code is shown here:
     
    456456
    457457<para>
    458 There are some examples of Geant4Py in the directories 
     458There are some examples of Geant4Py in the directories
    459459<literal>"tests/"</literal> and <literal>"examples/"</literal>.
    460460</para>
    461461
    462 In the <literal>"tests/"</literal> directory, 
     462In the <literal>"tests/"</literal> directory,
    463463
    464464<informalexample>
     
    474474</informalexample>
    475475
    476 The <literal>"examples/"</literal> directory contains 
     476The <literal>"examples/"</literal> directory contains
    477477a set of examples of Geant4Py.
    478478
     
    483483<para>
    484484An 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, 
     485This demo program shows that a Geant4 application well coworks with Root
     486on Python front end. VisManager, PrimaryGeneratorAction, UserAction-s,
    487487histogramming with Root are implemented in Python;
    488488<itemizedlist>
     
    521521<para>
    522522GUI interface of ExN03, which can control geometry configuration,
    523 intial particle condition, physics processes, cut value, 
     523intial particle condition, physics processes, cut value,
    524524magnetic field and visualization outputs.
    525525</para>
Note: See TracChangeset for help on using the changeset viewer.