Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/basic/B1/README.md is written in an unsupported language. File is not indexed.

0001 \page ExampleB1 Example B1
0002 
0003  This example demonstrates a very simple application where an energy
0004  deposit is accounted in user actions and their associated objects
0005  and a dose in a selected volume is calculated.
0006 
0007 ## GEOMETRY DEFINITION
0008 
0009    The geometry is constructed in the B1::DetectorConstruction class.
0010    The setup consists of a an envelope of box shape containing two
0011    volumes: a spherical cone and a trapezoid.
0012 
0013    In this example we use  some common materials materials for medical
0014    applications. The envelope is made of water and the two inner volumes
0015    are made from tissue and bone materials.
0016    The materials are created with the help of the G4NistManager class,
0017    which allows to build a material from the NIST database using their
0018    names. Available materials and their compositions can be found in
0019    <a href="http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides
0020                                     /ForApplicationDeveloper/html/apas10.html">
0021    the Geant4 User's Guide for Application Developers, Appendix 10:
0022    Geant4 Materials Database
0023    </a>.
0024 
0025 ## PHYSICS LIST
0026 
0027    The particle's type and the physic processes which will be available
0028    in this example are set in the QBBC physics list. This physics list
0029    requires data files for electromagnetic and hadronic processes.
0030    See more on installation of the datasets in
0031    <a href="http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides
0032                                          /InstallationGuide/html/ch03s03.html">
0033    Geant4 Installation Guide, Chapter 3.3: Note On Geant4 Datasets </a>.
0034    The following datasets: G4LEDATA, G4LEVELGAMMADATA, G4NEUTRONXSDATA,
0035    G4SAIDXSDATA and G4ENSDFSTATEDATA are mandatory for this example.
0036 
0037    In addition the build-in interactive command:
0038 ```
0039 /process/(in)activate processName
0040 ```
0041      allows to activate/inactivate the processes one by one.
0042 
0043 ## ACTION INITALIZATION
0044 
0045    A newly introduced class, B1::ActionInitialization, instantiates and registers
0046    to Geant4 kernel all user action classes.
0047 
0048    While in sequential mode the action classes are instatiated just once,
0049    via invoking the method:
0050       B1::ActionInitialization::Build()
0051    in multi-threading mode the same method is invoked for each thread worker
0052    and so all user action classes are defined thread-local.
0053 
0054    A run action class is instantiated both thread-local
0055    and global that's why its instance is created also in the method
0056       B1::ActionInitialization::BuildForMaster()
0057    which is invoked only in multi-threading mode.
0058 
0059 ## PRIMARY GENERATOR
0060 
0061    The primary generator is defined in the B1::PrimaryGeneratorAction class.
0062    The default kinematics is a 6 MeV gamma, randomly distributed in front
0063    of the envelope across 80% of the transverse (X,Y) envelope size.
0064    This default setting can be changed via the Geant4 built-in commands
0065    of the G4ParticleGun class.
0066 
0067 ## DETECTOR RESPONSE
0068 
0069    This example demonstrates a simple scoring implemented directly
0070    in the user action classes.  Alternative ways of scoring via Geant4 classes
0071    can be found in the other examples.
0072 
0073    The energy deposited is collected step by step for a selected volume
0074    in B1::SteppingAction and accumulated event by event in B1::EventAction.
0075 
0076    At end of event, the value acummulated in B1::EventAction is added in B1::RunAction
0077    and summed over the whole run (see B1::EventAction::EndOfevent()).
0078 
0079    Total dose deposited is computed at B1::RunAction::EndOfRunAction(),
0080    and printed together with informations about the primary particle.
0081    In multi-threading mode the energy accumulated in G4Accumulable objects per
0082    workers is merged to the master in B1::RunAction::EndOfRunAction() and the final
0083    result is printed on the screen.
0084 
0085    G4Accumulable<G4double> type instead of G4double type is used for the B1::RunAction
0086    data members in order to facilitate merging of the values accumulated on workers
0087    to the master.  Currently the accumulables have to be registered to G4AccumulablesManager
0088    and G4AccumulablesManager::Merge() has to be called from the users code. This is planned
0089    to be further simplified with a closer integration of G4Accumulable classes in
0090    the Geant4 kernel next year.
0091 
0092    An example of creating and computing new units (e.g., dose) is also shown
0093    in the class constructor.
0094 
0095 <hr>
0096 
0097 ## VISUALISATION
0098 
0099    The visualization manager is set via the G4VisExecutive class
0100    in the main() function in exampleB1.cc.
0101    The initialisation of the drawing is done via a set of /vis/ commands
0102    in the macro vis.mac. This macro is automatically read from
0103    the main function when the example is used in interactive running mode.
0104 
0105    By default, vis.mac opens the default viewer (/vis/open).
0106    This chooses a graphics system (in order of priority):
0107    - by argument in G4VisExecutive construction.
0108    - by environment variable, G4VIS_DEFAULT_DRIVER.
0109    - by information in ~/.g4session.
0110    - by mode (batch/interactive) and if interactive, by your build flags.
0111 
0112    The user can change the initial viewer
0113    - with environment variable G4VIS_DEFAULT_DRIVER. The format is
0114      ```
0115      <graphics-system> [<window-size-hint>]
0116      ```
0117      Set this, e.g:
0118      - (bash) export G4VIS_DEFAULT_DRIVER=TSG
0119      - (tcsh) setenv G4VIS_DEFAULT_DRIVER OI
0120        - The window-size-hint can optionally be added, e.g:
0121        - (bash) export G4VIS_DEFAULT_DRIVER="RayTracerQt 1000x1000-0+0"
0122    - on the command line, precede the app invocation, e.g:
0123      - ```
0124        G4VIS_DEFAULT_DRIVER=Vtk ./<application-name>
0125        ```
0126    - with ~/.g4session.
0127 
0128    For other suggestions for G4VIS_DEFAULT_DRIVER (see list of registered
0129    graphics systems printed at the start):
0130    - DAWNFILE: to create a .prim file suitable for viewing in DAWN.
0131    - VRML2FILE: to create a .wrl file suitable for viewing in a VRML viewer.
0132    - "TSG_OFFSCREEN 1200x1200": to create an image file with TSG.
0133      - See the tsg_offscreen.mac in examples/basic/B5 for more commands
0134        to change the file format, file name, picture size, etc.
0135 
0136    See "Choosing a graphics viewer" in the Application Guide for details.
0137 
0138    Of course you can change the viewer by editing the /vis/open line in vis.mac.
0139 
0140    Also, after the initial viewer opens, you may open a different viewer by typing
0141    on the command line, e.g:
0142 ```
0143 /vis/open DAWNFILE
0144 ```
0145    or
0146 ```
0147 /vis/open RayTraceQt
0148 ```
0149    (if you are using the Qt GUI).
0150 
0151    The view parameters of the existing viewer are copied.
0152 
0153    The DAWNFILE and similar drivers are always available
0154    (since they require no external libraries), but the OGL driver requires
0155    that the Geant4 libraries have been built with the OpenGL option.
0156 
0157    The vis.mac macro in example B1 has additional commands
0158    that demonstrate additional functionality of the vis system, such as
0159    displaying text, axes, scales, date, logo and shows how to change
0160    viewpoint and style.  Consider copying these to other examples or
0161    your application.  To see even more commands use help or
0162    ls or browse the available UI commands in the Application
0163    Developers Guide, "Controlling Visualization from Commands".
0164 
0165 ## USER INTERFACES
0166 
0167    The user command interface is set via the G4UIExecutive class
0168    in the main() function in exampleB1.cc
0169 
0170    The selection of the user command interface is then done automatically
0171    according to the Geant4 configuration or it can be done explicitly via
0172    the third argument of the G4UIExecutive constructor (see exampleB4a.cc).
0173 
0174    The gui.mac macros are provided in examples B2, B4 and B5. This macro
0175    is automatically executed if Geant4 is built with any GUI session.
0176    It is also possible to customise the icons menu bar which is
0177    demonstrated in the icons.mac macro in example B5.
0178 
0179 ## HOW TO RUN
0180 
0181    - Execute exampleB1 in the 'interactive mode' with visualization
0182 ```
0183 % exampleB1
0184 and type in the commands from run1.mac line by line:
0185 Idle> /control/verbose 2
0186 Idle> /tracking/verbose 1
0187 Idle> /run/beamOn 10
0188 Idle> ...
0189 Idle> exit
0190 ```
0191       or
0192 ```
0193 Idle> /control/execute run1.mac
0194 ....
0195 Idle> exit
0196 ```
0197 
0198    - Execute exampleB1 in the 'batch' mode from macro files
0199    (without visualization)
0200 ```
0201 % exampleB1 run2.mac
0202 % exampleB1 exampleB1.in > exampleB1.out
0203 ```
0204 
0205