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] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/README.HowToRun (Version 11.3.0) and /examples/README.HowToRun (Version 10.7)


  1 ----------------------------------------------      1 -------------------------------------------------------------------
  2                                                     2 
  3      =========================================      3      =========================================================
  4      Geant4 - an Object-Oriented Toolkit for S      4      Geant4 - an Object-Oriented Toolkit for Simulation in HEP
  5      =========================================      5      =========================================================
  6                                                     6 
  7                  How to build and run an examp      7                  How to build and run an example
  8                  -----------------------------      8                  -------------------------------
  9                                                     9 
 10  All basic and most of extended examples have  <<  10  All novice, basic and most of extended examples have a similar structure.
 11  The main () function is included in exampleXY     11  The main () function is included in exampleXYZ.cc in the example top directory
 12  and the example source code is structered in      12  and the example source code is structered in include and src subdirectories.
 13  When the example is built, the executable tak     13  When the example is built, the executable takes the same name as the file with
 14  main() function without .cc extension, exampl     14  main() function without .cc extension, exampleXYZ.
 15                                                    15 
 16  Then several macros are provided to run the e     16  Then several macros are provided to run the example with various start-up
 17  conditions. These macros have usually .mac ex     17  conditions. These macros have usually .mac extension. Besides these macros,
 18  there is often a macro exampleXYZ.in (note it     18  there is often a macro exampleXYZ.in (note its different extension)
 19  which is used in Geant4 testing and which out     19  which is used in Geant4 testing and which output, exampleXYZ.out, can also included
 20  in the distribution.                              20  in the distribution.
 21                                                    21 
 22  You can find all details about building the e     22  You can find all details about building the examples in the Geant4 Installation Guide:
 23  "https://geant4-userdoc.web.cern.ch/UsersGuid <<  23  "http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/index.html"
 24  in the section How to Use the Geant4 Toolkit  <<  24  in the section 3.2. Building Applications with Geant4:
 25  https://geant4-userdoc.web.cern.ch/UsersGuide <<  25  http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch03s02.html"
 26  Here we recall only the basics.                   26  Here we recall only the basics. 
 27                                                    27 
 28  1) COMPILE AND LINK TO GENERATE AN EXECUTABLE     28  1) COMPILE AND LINK TO GENERATE AN EXECUTABLE
 29                                                    29 
 30        % cd path_to_exampleXYZ     # go to dir <<  30     1a) With CMake
 31        % mkdir exampleXYZ_build                <<  31 
 32        % cd exampleXYZ_build                   <<  32         % cd path_to_exampleXYZ     # go to directory which contains your example
 33        % cmake -DGeant4_DIR=path_to_Geant4_ins <<  33         % mkdir exampleXYZ_build
 34        % make -j N exampleXYZ      # "N" is th <<  34         % cd exampleXYZ_build
 35        % make install              # this step <<  35         % cmake -DGeant4_DIR=path_to_Geant4_installation/lib[64]/Geant4-10.0.0/ ../exampleXYZ
                                                   >>  36         % make -j N exampleXYZ      # "N" is the number of processes 
                                                   >>  37         % make install              # this step is optional              
                                                   >>  38 
                                                   >>  39     1b) With GNUmake 
                                                   >>  40 
                                                   >>  41     To use GNUmake build system when Geant4 was installed with CMake, you have to source first
                                                   >>  42     the setup script in order to define needed environment variables:
                                                   >>  43 
                                                   >>  44         % source path_to_Geant4_installation/share/Geant4-10.0.0/geant4make/geant4make.[c]sh 
                                                   >>  45 
                                                   >>  46     Then to build example
                                                   >>  47 
                                                   >>  48         % cd path_to_exampleXYZ/exampleXYZ
                                                   >>  49         % gmake
                                                   >>  50 
                                                   >>  51     An additional step is needed when building an example using shared classes
                                                   >>  52     (usually from ../shared directory) or classes from common:
                                                   >>  53 
                                                   >>  54         % cd path_to_exampleXYZ/exampleXYZ
                                                   >>  55         % gmake setup
                                                   >>  56         % gmake
                                                   >>  57 
                                                   >>  58     When building the example in this way make sure that the path to the example executable 
                                                   >>  59     and its shared library is added in the paths defined on your system 
                                                   >>  60     (eg. PATH and LD_LIBRARY_PATH on Linux). 
 36                                                    61 
 37  2) EXECUTE EXAMPLEXYZ IN 'BATCH' MODE FROM MA     62  2) EXECUTE EXAMPLEXYZ IN 'BATCH' MODE FROM MACRO FILES
 38                                                    63     
 39        ... go to the directory where the examp <<  64        ... go to the directory where examples was built/installed
 40        % ./exampleXYZ  xyz.mac                 <<  65        % exampleXYZ  xyz.mac
 41                                                    66     
 42  3) EXECUTE EXAMPLEXYZ IN 'INTERACTIVE MODE' W     67  3) EXECUTE EXAMPLEXYZ IN 'INTERACTIVE MODE' WITH VISUALIZATION
 43                                                    68 
 44        ... go to the directory where the examp <<  69        ... go to the directory where examples was built/installed
 45        % ./exampleXYZ                          <<  70        % exampleXYZ
 46        ....                                        71        ....
 47        Idle> type your commands                    72        Idle> type your commands
 48        ....                                        73        ....
 49        Idle> exit                                  74        Idle> exit
 50                                                    75 
 51                                                    76 
 52  Below we give the explicit instructions for t     77  Below we give the explicit instructions for the example 
 53  extended/electromagnetic/TestEm1.                 78  extended/electromagnetic/TestEm1. 
 54                                                    79 
 55  Let's suppose that the TestEm1 directory is a     80  Let's suppose that the TestEm1 directory is available in $HOME and Geant4 
 56  installation in /usr/local and we work within     81  installation in /usr/local and we work within bash shell on a 64-bit machine.
 57                                                    82 
 58  1) COMPILE AND LINK TESTEM1 TO GENERATE AN EX     83  1) COMPILE AND LINK TESTEM1 TO GENERATE AN EXECUTABLE
 59                                                    84 
 60     % cd $HOME                                 <<  85     1a) With CMake
 61     % mkdir TestEm1_build                      <<  86 
 62     % cd TestEm1_build                         <<  87         % cd $HOME
 63     % cmake -DGeant4_DIR=/usr/local/lib64/Gean <<  88         % mkdir TestEm1_build
 64     % make -j 2 TestEm1                        <<  89         % cd TestEm1_build
                                                   >>  90         % cmake -DGeant4_DIR=/usr/local/lib64/Geant4-10.0.0/ ../TestEm1
                                                   >>  91         % make -j 2 TestEm1
                                                   >>  92 
                                                   >>  93    1b) With GNUmake
                                                   >>  94 
                                                   >>  95        % cd $HOME/TestEm1
                                                   >>  96        % source /usr/local/share/Geant4-10.0.0/geant4make/geant4make.sh
                                                   >>  97        % make 
 65                                                    98 
 66  2) EXECUTE TESTEM1 IN 'BATCH' MODE FROM MACRO     99  2) EXECUTE TESTEM1 IN 'BATCH' MODE FROM MACRO FILES
 67                                                   100 
 68     % cd $HOME/TestEm1_build    # or cd $HOME/    101     % cd $HOME/TestEm1_build    # or cd $HOME/TestEm1 if example was built with GNUmake
 69     % ./TestEm1 annihil.mac                    << 102     % TestEm1 annihil.mac
 70     % ./TestEm1 brem.mac                       << 103     % TestEm1 brem.mac
 71     % ./TestEm1 TestEm1.in >& myTestEm1.out    << 104     % TestEm1 TestEm1.in >& myTestEm1.out   # redirecting output in a file
 72                                                   105     
 73  3) EXECUTE TESTEM1 IN 'INTERACTIVE MODE' WITH    106  3) EXECUTE TESTEM1 IN 'INTERACTIVE MODE' WITH VISUALIZATION
 74                                                   107 
 75     % cd $HOME/TestEm1_build    # or cd $HOME/    108     % cd $HOME/TestEm1_build    # or cd $HOME/TestEm1 if example was built with GNUmake
 76     % ./TestEm1                                << 109     % TestEm1
 77     PreInit> /run/initialize                      110     PreInit> /run/initialize 
 78     Idle>    /run/beamOn 1                        111     Idle>    /run/beamOn 1
 79     ...                                           112     ...
 80     Idle>    exit                                 113     Idle>    exit
                                                   >> 114 
                                                   >> 115 */