Warning, /geant4/examples/basic/B3/README.md is written in an unsupported language. File is not indexed.
0001 \page ExampleB3 Example B3
0002
0003 This example simulates schematically a Positron Emitted Tomography system.
0004
0005 ## GEOMETRY DEFINITION
0006
0007 The support of gamma detection are scintillating crystals. A small number
0008 of such crystals are optically grouped in a matrix of crystals. In
0009 this example, individual crystals are not described; only the matrix of
0010 crystals is and it is still called 'Crystal' hereafter.
0011
0012 Crystals are circularly arranged to form a ring. Few rings make up the full
0013 detector (gamma camera). This is done by positionning Crystals in
0014 Ring with an appropriate rotation matrix. Several copies of Ring are
0015 then placed in the full detector.
0016
0017 The head of a patient is schematised as a homogeneous cylinder of brain
0018 tissue, placed at the center of full detector.
0019
0020 The Crystal material, Lu2SiO5, is not included in the G4Nist database.
0021 Therefore, it is explicitly built in DefineMaterials().
0022
0023 ## PHYSICS LIST
0024
0025 The physics list contains standard electromagnetic processes and the
0026 radioactiveDecay module for GenericIon. It is defined in the B3::PhysicsList
0027 class as a Geant4 modular physics list with registered physics builders
0028 provided in Geant4:
0029 - G4DecayPhysics - defines all particles and their decay processes
0030 - G4RadioactiveDecayPhysics - defines radioactiveDecay for GenericIon
0031 - G4EmStandardPhysics - defines all EM standard processes
0032
0033 This physics list requires data files for:
0034 - low energy electromagnetic processes which path is defined via
0035 the G4LEDATA envirnoment variable
0036 - data files for nuclides properties which path is defined via
0037 the G4ENSDFSTATEDATA envirnoment variable
0038 - radioactive decay hadronic processes which path is defined via
0039 the G4RADIOACTIVEDATA envirnoment variable.
0040
0041 See more on installation of the datasets in
0042 <a href="http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides
0043 /InstallationGuide/html/ch03s03.html">
0044 Geant4 Installation Guide, Chapter 3.3: Note On Geant4 Datasets </a>.
0045
0046 ## ACTION INITALIZATION
0047
0048 B3a::ActionInitialization class (see also B3b::ActionInitialization) instantiates and registers to Geant4 kernel all user action classes.
0049
0050 While in sequential mode the action classes are instatiated just once,
0051 via invoking the method:
0052 B3a::ActionInitialization::Build()
0053 (see also B3b::ActionInitialization::Build)
0054 in multi-threading mode the same method is invoked for each thread worker
0055 and so all user action classes are defined thread-local.
0056
0057 A run action class is instantiated both thread-local
0058 and global that's why its instance is created also in the method
0059 B3a::ActionInitialization::BuildForMaster()
0060 (see also B3b::ActionInitialization::Build)
0061 which is invoked only in multi-threading mode.
0062
0063 Beta decay of Fluor generates a neutrino. One wishes not to track this
0064 neutrino; therefore one kills it immediately, before created particles
0065 are put in a stack. This is done via the G4RunManager::SetDefaultClassification()
0066 call in the Build() function.
0067
0068 ## PRIMARY GENERATOR
0069
0070 The default particle beam is an ion (F18), at rest, randomly distributed
0071 within a zone inside a patient and is defined in
0072 B3::PrimaryGeneratorAction::GeneratePrimaries().
0073 The type of a primary particle can be changed with G4ParticleGun commands
0074 (see run2.mac).
0075
0076 ## DETECTOR RESPONSE : scorers
0077
0078 A 'good' event is an event in which an identical energy of 511 keV is
0079 deposited in two separate Crystals. A count of the number of such events
0080 corresponds to a measure of the efficiency of the PET system.
0081 The total dose deposited in a patient during a run is also computed.
0082
0083 Scorers are defined in B3::DetectorConstruction::ConstructSDandField(). There are
0084 two G4MultiFunctionalDetector objects: one for the Crystal (EnergyDeposit),
0085 and one for the Patient (DoseDeposit)
0086
0087 The scorers hits are saved in form of ntuples in a Root file using Geant4
0088 analysis tools. This feature is activated in the main() function with instantiating
0089 G4TScoreNtupleWriter.
0090
0091 Two variants of accumulation event statistics in a run are demonstrated
0092 in this example:
0093
0094 B3a:
0095
0096 At the end of event, the values acummulated in B3a::EventAction are passed
0097 in B3a::RunAction and summed over the whole run (see B3a::EventAction::EndOfevent()).
0098 In multi-threading mode the data accumulated in G4Accumulable objects per
0099 workers is merged to the master in B3a::RunAction::EndOfRunAction() and the final
0100 result is printed on the screen.
0101
0102 G4Accumulable<> type instead of G4double and G4int types is used for the B3a::RunAction
0103 data members in order to facilitate merging of the values accumulated on workers
0104 to the master. Currently the accumulables have to be registered to G4AccumulablesManager
0105 and G4AccumulablesManager::Merge() has to be called from the users code. This is planned
0106 to be further simplified with a closer integration of G4Accumulable classes in
0107 the Geant4 kernel next year.
0108
0109 B3b:
0110
0111 B3b::Run::RecordEvent(), called at end of event, collects informations
0112 event per event from the hits collections, and accumulates statistic for
0113 B3b::RunAction::EndOfRunAction().
0114 In addition, results for dose are accumulated in a
0115 standard floating-point summation and using a new lightweight statistical
0116 class called G4StatAnalysis. The G4StatAnalysis class records four values:
0117 (1) the sum, (2) sum^2, (3) number of entries, and (4) the number of entries
0118 less than mean * machine-epsilon (the machine epsilon is the difference
0119 between 1.0 and the next value representable by the floating-point type).
0120 From these 4 values, G4StatAnalysis provides the mean, FOM, relative error,
0121 standard deviation, variance, coefficient of variation, efficiency, r2int,
0122 and r2eff.
0123
0124 In multi-threading mode the statistics accumulated per workers is merged
0125 to the master in B3b::Run::Merge().
0126
0127 <hr>
0128
0129 The following paragraphs are common to all basic examples
0130
0131 ## VISUALISATION
0132
0133 The visualization manager is set via the G4VisExecutive class
0134 in the main() function in exampleB3.cc.
0135 The initialisation of the drawing is done via a set of /vis/ commands
0136 in the macro vis.mac. This macro is automatically read from
0137 the main function when the example is used in interactive running mode.
0138
0139 By default, vis.mac opens the default viewer (/vis/open).
0140 This chooses a graphics system (in order of priority):
0141 - by argument in G4VisExecutive construction.
0142 - by environment variable, G4VIS_DEFAULT_DRIVER.
0143 - by information in ~/.g4session.
0144 - by mode (batch/interactive) and if interactive, by your build flags.
0145
0146 The user can change the initial viewer
0147 - with environment variable G4VIS_DEFAULT_DRIVER. The format is
0148 ```
0149 <graphics-system> [<window-size-hint>]
0150 ```
0151 Set this, e.g:
0152 - (bash) export G4VIS_DEFAULT_DRIVER=TSG
0153 - (tcsh) setenv G4VIS_DEFAULT_DRIVER OI
0154 - The window-size-hint can optionally be added, e.g:
0155 - (bash) export G4VIS_DEFAULT_DRIVER="RayTracerQt 1000x1000-0+0"
0156 - on the command line, precede the app invocation, e.g:
0157 - ```
0158 G4VIS_DEFAULT_DRIVER=Vtk ./<application-name>
0159 ```
0160 - with ~/.g4session.
0161
0162 For other suggestions for G4VIS_DEFAULT_DRIVER (see list of registered
0163 graphics systems printed at the start):
0164 - DAWNFILE: to create a .prim file suitable for viewing in DAWN.
0165 - VRML2FILE: to create a .wrl file suitable for viewing in a VRML viewer.
0166 - "TSG_OFFSCREEN 1200x1200": to create an image file with TSG.
0167 - See the tsg_offscreen.mac in examples/basic/B5 for more commands
0168 to change the file format, file name, picture size, etc.
0169
0170 See "Choosing a graphics viewer" in the Application Guide for details.
0171
0172 Of course you can change the viewer by editing the /vis/open line in vis.mac.
0173
0174 Also, after the initial viewer opens, you may open a different viewer by typing
0175 on the command line, e.g:
0176 ```
0177 /vis/open DAWNFILE
0178 ```
0179 or
0180 ```
0181 /vis/open RayTraceQt
0182 ```
0183 (if you are using the Qt GUI).
0184
0185 The view parameters of the existing viewer are copied.
0186
0187 The DAWNFILE and similar drivers are always available
0188 (since they require no external libraries), but the OGL driver requires
0189 that the Geant4 libraries have been built with the OpenGL option.
0190
0191 ## USER INTERFACES
0192
0193 The user command interface is set via the G4UIExecutive class
0194 in the main() function in exampleB3.cc
0195
0196 The selection of the user command interface is then done automatically
0197 according to the Geant4 configuration or it can be done explicitly via
0198 the third argument of the G4UIExecutive constructor (see exampleB4a.cc).
0199
0200 The gui.mac macros are provided in examples B2, B4 and B5. This macro
0201 is automatically executed if Geant4 is built with any GUI session.
0202 It is also possible to customise the icons menu bar which is
0203 demonstrated in the icons.mac macro in example B5.
0204
0205 ## HOW TO RUN
0206
0207 - Execute exampleB3a in the 'interactive mode' with visualization
0208 ```
0209 % ./exampleB3a
0210 and type in the commands from run1.mac line by line:
0211 Idle> /control/verbose 2
0212 Idle> /tracking/verbose 2
0213 Idle> /run/beamOn 1
0214 Idle> ...
0215 Idle> exit
0216 ```
0217 or
0218 ```
0219 Idle> /control/execute run1.mac
0220 ....
0221 Idle> exit
0222 ```
0223
0224 - Execute exampleB3a in the 'batch' mode from macro files
0225 (without visualization)
0226 ```
0227 % ./exampleB3a run2.mac
0228 % ./exampleB3a exampleB3.in > exampleB3.out
0229 ```