Geant4 Cross Reference |
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 Example B1 7 Example B1 8 ----------- 8 ----------- 9 9 10 This example demonstrates a very simple appli 10 This example demonstrates a very simple application where an energy 11 deposit is accounted in user actions and thei 11 deposit is accounted in user actions and their associated objects 12 and a dose in a selected volume is calculated << 12 and a dose in a selected volume is calculated. 13 << 14 13 >> 14 15 1- GEOMETRY DEFINITION 15 1- GEOMETRY DEFINITION 16 << 16 17 The geometry is constructed in the B1::Dete << 17 The geometry is constructed in the B1DetectorConstruction class. 18 The setup consists of a an envelope of box 18 The setup consists of a an envelope of box shape containing two 19 volumes: a spherical cone and a trapezoid. 19 volumes: a spherical cone and a trapezoid. 20 20 21 In this example we use some common materia 21 In this example we use some common materials materials for medical 22 applications. The envelope is made of water 22 applications. The envelope is made of water and the two inner volumes 23 are made from tissue and bone materials. << 23 are made from tissue and bone materials. 24 The materials are created with the help of 24 The materials are created with the help of the G4NistManager class, 25 which allows to build a material from the N 25 which allows to build a material from the NIST database using their 26 names. All available materials can be found 26 names. All available materials can be found in the Geant4 User's Guide 27 for Application Developers, Appendix 10: Ge 27 for Application Developers, Appendix 10: Geant4 Materials Database. 28 << 28 29 2- PHYSICS LIST 29 2- PHYSICS LIST 30 << 30 31 The particle's type and the physic processe 31 The particle's type and the physic processes which will be available 32 in this example are set in the QBBC physics << 32 in this example are set in the QBBC physics list. This physics list 33 requires data files for electromagnetic and 33 requires data files for electromagnetic and hadronic processes. 34 See more on installation of the datasets in 34 See more on installation of the datasets in Geant4 Installation Guide, 35 Chapter 3.3: Note On Geant4 Datasets: 35 Chapter 3.3: Note On Geant4 Datasets: 36 http://geant4.web.cern.ch/geant4/UserDocume 36 http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides 37 /In 37 /InstallationGuide/html/ch03s03.html 38 The following datasets: G4LEDATA, G4LEVELGA << 38 The following datasets: G4LEDATA, G4LEVELGAMMADATA, G4NEUTRONXSDATA and 39 G4SAIDXSDATA and G4ENSDFSTATEDATA are manda << 39 G4SAIDXSDATA are mandatory for this example. 40 40 41 In addition the build-in interactive comman 41 In addition the build-in interactive command: 42 /process/(in)activate processNa 42 /process/(in)activate processName 43 allows to activate/inactivate the processes 43 allows to activate/inactivate the processes one by one. 44 << 44 45 3- ACTION INITALIZATION 45 3- ACTION INITALIZATION 46 46 47 A newly introduced class, B1::ActionInitial << 47 A newly introduced class, B1ActionInitialization, instantiates and registers 48 to Geant4 kernel all user action classes. 48 to Geant4 kernel all user action classes. 49 49 50 While in sequential mode the action classes 50 While in sequential mode the action classes are instatiated just once, 51 via invoking the method: 51 via invoking the method: 52 B1::ActionInitialization::Build() << 52 B1ActionInitialization::Build() 53 in multi-threading mode the same method is 53 in multi-threading mode the same method is invoked for each thread worker 54 and so all user action classes are defined 54 and so all user action classes are defined thread-local. 55 55 56 A run action class is instantiated both thr << 56 A run action class is instantiated both thread-local 57 and global that's why its instance is creat << 57 and global that's why its instance has is created also in the method 58 B1::ActionInitialization::BuildForMaster << 58 B1ActionInitialization::BuildForMaster() 59 which is invoked only in multi-threading mo 59 which is invoked only in multi-threading mode. 60 << 60 61 4- PRIMARY GENERATOR 61 4- PRIMARY GENERATOR 62 << 62 63 The primary generator is defined in the B1: << 63 The primary generator is defined in the B1PrimaryGeneratorAction class. 64 The default kinematics is a 6 MeV gamma, ra 64 The default kinematics is a 6 MeV gamma, randomly distributed in front 65 of the envelope across 80% of the transvers << 65 of the envelope across 80% of the transverse (X,Y) envelope size. 66 This default setting can be changed via the << 66 This default setting can be changed via the Geant4 built-in commands 67 of the G4ParticleGun class. 67 of the G4ParticleGun class. 68 << 68 69 5- DETECTOR RESPONSE 69 5- DETECTOR RESPONSE 70 70 71 This example demonstrates a simple scoring 71 This example demonstrates a simple scoring implemented directly 72 in the user action classes. Alternative wa << 72 in the user action classes and B1Run object. 73 can be found in the other examples. << 73 Alternative ways of scoring via Geant4 classes can be found in the 74 << 74 other examples. >> 75 75 The energy deposited is collected step by s 76 The energy deposited is collected step by step for a selected volume 76 in B1::SteppingAction and accumulated event << 77 in B1SteppingAction and accumulated event by event in B1EventAction. 77 << 78 78 At end of event, the value acummulated in B << 79 At end of event, the value acummulated in B1EventAction is added in B1Run 79 and summed over the whole run (see B1::Even << 80 and summed over the whole run (see B1EventAction::EndOfevent()). 80 << 81 81 Total dose deposited is computed at B1::Run << 82 Total dose deposited is computed at B1RunAction::EndOfRunAction(), 82 and printed together with informations abou 83 and printed together with informations about the primary particle. 83 In multi-threading mode the energy accumula << 84 84 workers is merged to the master in B1::RunA << 85 In multi-threading mode the energy accumulated in B1Run objects per >> 86 workers is merged to the master in B1Run::Merge() and the final 85 result is printed on the screen. 87 result is printed on the screen. 86 88 87 G4Parameter<G4double> type instead of G4dou << 89 An example of creating and computing new units (e.g., dose) is also shown 88 data members in order to facilitate merging << 90 in the class constructor. 89 to the master. Currently the accumulables << 90 and G4AccumulablesManager::Merge() has to b << 91 to be further simplified with a closer inte << 92 the Geant4 kernel next year. << 93 << 94 An example of creating and computing new un << 95 in the class constructor. << 96 91 97 The following paragraphs are common to all ba 92 The following paragraphs are common to all basic examples 98 93 99 A- VISUALISATION 94 A- VISUALISATION 100 95 101 The visualization manager is set via the G4 96 The visualization manager is set via the G4VisExecutive class 102 in the main() function in exampleB1.cc. << 97 in the main() function in exampleB1.cc. 103 The initialisation of the drawing is done v 98 The initialisation of the drawing is done via a set of /vis/ commands 104 in the macro vis.mac. This macro is automat 99 in the macro vis.mac. This macro is automatically read from 105 the main function when the example is used 100 the main function when the example is used in interactive running mode. 106 101 107 By default, vis.mac opens an OpenGL viewer 102 By default, vis.mac opens an OpenGL viewer (/vis/open OGL). 108 The user can change the initial viewer by c 103 The user can change the initial viewer by commenting out this line 109 and instead uncommenting one of the other / 104 and instead uncommenting one of the other /vis/open statements, such as 110 HepRepFile or DAWNFILE (which produce files 105 HepRepFile or DAWNFILE (which produce files that can be viewed with the 111 HepRApp and DAWN viewers, respectively). N 106 HepRApp and DAWN viewers, respectively). Note that one can always 112 open new viewers at any time from the comma 107 open new viewers at any time from the command line. For example, if 113 you already have a view in, say, an OpenGL 108 you already have a view in, say, an OpenGL window with a name 114 "viewer-0", then 109 "viewer-0", then 115 /vis/open DAWNFILE 110 /vis/open DAWNFILE 116 then to get the same view 111 then to get the same view 117 /vis/viewer/copyView viewer-0 112 /vis/viewer/copyView viewer-0 118 or to get the same view *plus* scene-modifi 113 or to get the same view *plus* scene-modifications 119 /vis/viewer/set/all viewer-0 114 /vis/viewer/set/all viewer-0 120 then to see the result 115 then to see the result 121 /vis/viewer/flush 116 /vis/viewer/flush 122 117 123 The DAWNFILE, HepRepFile drivers are always 118 The DAWNFILE, HepRepFile drivers are always available 124 (since they require no external libraries), 119 (since they require no external libraries), but the OGL driver requires 125 that the Geant4 libraries have been built w 120 that the Geant4 libraries have been built with the OpenGL option. 126 121 127 From Release 9.6 the vis.mac macro in examp 122 From Release 9.6 the vis.mac macro in example B1 has additional commands 128 that demonstrate additional functionality o 123 that demonstrate additional functionality of the vis system, such as 129 displaying text, axes, scales, date, logo a 124 displaying text, axes, scales, date, logo and shows how to change 130 viewpoint and style. Consider copying thes 125 viewpoint and style. Consider copying these to other examples or 131 your application. To see even more command 126 your application. To see even more commands use help or 132 ls or browse the available UI commands in t 127 ls or browse the available UI commands in the Application 133 Developers Guide, Section 7.1. 128 Developers Guide, Section 7.1. 134 129 135 For more information on visualization, incl 130 For more information on visualization, including information on how to 136 install and run DAWN, OpenGL and HepRApp, s 131 install and run DAWN, OpenGL and HepRApp, see the visualization tutorials, 137 for example, 132 for example, 138 http://geant4.slac.stanford.edu/Presentatio 133 http://geant4.slac.stanford.edu/Presentations/vis/G4[VIS]Tutorial/G4[VIS]Tutorial.html 139 (where [VIS] can be replaced by DAWN, OpenG 134 (where [VIS] can be replaced by DAWN, OpenGL and HepRApp) 140 135 141 The tracks are automatically drawn at the e 136 The tracks are automatically drawn at the end of each event, accumulated 142 for all events and erased at the beginning 137 for all events and erased at the beginning of the next run. 143 138 144 B- USER INTERFACES 139 B- USER INTERFACES 145 << 140 146 The user command interface is set via the G 141 The user command interface is set via the G4UIExecutive class 147 in the main() function in exampleB1.cc << 142 in the main() function in exampleB1.cc 148 The selection of the user command interface << 143 The selection of the user command interface is then done automatically 149 according to the Geant4 configuration or it << 144 according to the Geant4 configuration or it can be done explicitly via 150 the third argument of the G4UIExecutive con << 145 the third argument of the G4UIExecutive constructor (see exampleB4a.cc). 151 << 146 152 C- HOW TO RUN 147 C- HOW TO RUN 153 148 154 - Execute exampleB1 in the 'interactive mo 149 - Execute exampleB1 in the 'interactive mode' with visualization: 155 % ./exampleB1 150 % ./exampleB1 156 and type in the commands from run1.mac l << 151 and type in the commands from run1.mac line by line: 157 Idle> /control/verbose 2 152 Idle> /control/verbose 2 158 Idle> /tracking/verbose 1 153 Idle> /tracking/verbose 1 159 Idle> /run/beamOn 10 << 154 Idle> /run/beamOn 10 160 Idle> ... 155 Idle> ... 161 Idle> exit 156 Idle> exit 162 or 157 or 163 Idle> /control/execute run1.mac 158 Idle> /control/execute run1.mac 164 .... 159 .... 165 Idle> exit 160 Idle> exit 166 161 167 - Execute exampleB1 in the 'batch' mode f << 162 - Execute exampleB1 in the 'batch' mode from macro files 168 (without visualization) 163 (without visualization) 169 % ./exampleB1 run2.mac 164 % ./exampleB1 run2.mac 170 % ./exampleB1 exampleB1.in > exampleB1 165 % ./exampleB1 exampleB1.in > exampleB1.out 171 166 172 << 167