Geant4 Cross Reference |
>> 1 $Id: README 78001 2013-12-02 08:24:53Z gcosmo $ 1 ---------------------------------------------- 2 ------------------------------------------------------------------- 2 3 3 ========================================= 4 ========================================================= 4 Geant4 - an Object-Oriented Toolkit for S 5 Geant4 - an Object-Oriented Toolkit for Simulation in HEP 5 ========================================= 6 ========================================================= 6 7 7 Example B2 8 Example B2 8 ---------- 9 ---------- 9 10 10 This example simulates a simplified fixed tar 11 This example simulates a simplified fixed target experiment. 11 12 12 1- GEOMETRY DEFINITION 13 1- GEOMETRY DEFINITION 13 << 14 14 The setup consists of a target followed b 15 The setup consists of a target followed by six chambers of increasing 15 transverse size at defined instances from << 16 transverse size at defined instances from the target. These chambers are 16 located in a region called the Tracker re << 17 located in a region called the Tracker region. 17 Their shape are cylinders, constructed as 18 Their shape are cylinders, constructed as simple cylinders 18 (in B2a::DetectorConstruction) and as par << 19 (in B2aDetectorConstruction) and as parametrised volumes 19 (in B2b::DetectorConstruction), see also << 20 (in B2bDetectorConstruction), see also B2bChamberParameterisation class. 20 21 21 In addition, a global, uniform, and trans << 22 In addition, a global, uniform, and transverse magnetic field can be 22 applied using G4GlobalMagFieldMessenger, << 23 applied using G4GlobalMagFieldMessenger, instantiated in 23 B2[a,b]::DetectorConstruction::ConstructS << 24 B2[a,b]DetectorConstruction::ConstructSDandField with a non zero field value, 24 or via interactive commands. << 25 or via interactive commands. 25 For example: 26 For example: 26 27 27 /globalField/setValue 0.2 0 0 tesla 28 /globalField/setValue 0.2 0 0 tesla 28 << 29 29 An instance of the B2::TrackerSD class is << 30 An instance of the B2TrackerSD class is created and associated with each 30 logical chamber volume (in B2a) and with << 31 logical chamber volume (in B2a) and with the one G4LogicalVolume associated 31 with G4PVParameterised (in B2b). << 32 with G4PVParameterised (in B2b). 32 33 33 One can change the materials of the targe 34 One can change the materials of the target and the chambers 34 interactively via the commands defined in << 35 interactively via the commands defined in B2aDetectorMessenger 35 (or B2b::DetectorMessenger). For example: << 36 (or B2bDetectorMessenger). For example: 36 37 37 /B2/det/setTargetMaterial G4_WATER 38 /B2/det/setTargetMaterial G4_WATER 38 /B2/det/setChamberMaterial G4_Ar 39 /B2/det/setChamberMaterial G4_Ar 39 << 40 40 2- PHYSICS LIST 41 2- PHYSICS LIST 41 42 42 The particle's type and the physic proces 43 The particle's type and the physic processes which will be available 43 in this example are set in the FTFP_BERT << 44 in this example are set in the FTFP_BERT physics list. This physics list 44 requires data files for electromagnetic a 45 requires data files for electromagnetic and hadronic processes. 45 See more on installation of the datasets 46 See more on installation of the datasets in Geant4 Installation Guide, 46 Chapter 3.3: Note On Geant4 Datasets: 47 Chapter 3.3: Note On Geant4 Datasets: 47 http://geant4.web.cern.ch/geant4/UserDocu 48 http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch03s03.html 48 The following datasets: G4LEDATA, G4LEVEL << 49 The following datasets: G4LEDATA, G4LEVELGAMMADATA and G4SAIDXSDATA are 49 G4ENSDFSTATEDATA are mandatory for this e << 50 mandatory for this example. 50 << 51 51 In addition, the build-in interactive com 52 In addition, the build-in interactive command: 52 /process/(in)activate processName 53 /process/(in)activate processName 53 allows the user to activate/inactivate th 54 allows the user to activate/inactivate the processes one by one. 54 55 55 3- ACTION INITALIZATION 56 3- ACTION INITALIZATION 56 57 57 A newly introduced class, B2::ActionInitial << 58 A newly introduced class, B2ActionInitialization, 58 instantiates and registers to Geant4 kernel 59 instantiates and registers to Geant4 kernel all user action classes. 59 << 60 60 While in sequential mode the action classes 61 While in sequential mode the action classes are instatiated just once, 61 via invoking the method: 62 via invoking the method: 62 B2::ActionInitialization::Build() << 63 B2ActionInitialization::Build() 63 in multi-threading mode the same method is 64 in multi-threading mode the same method is invoked for each thread worker 64 and so all user action classes are defined 65 and so all user action classes are defined thread-local. 65 66 66 A run action class is instantiated both thr << 67 A run action class is instantiated both thread-local 67 and global that's why its instance has is c 68 and global that's why its instance has is created also in the method 68 B2::ActionInitialization::BuildForMaster << 69 B2ActionInitialization::BuildForMaster() 69 which is invoked only in multi-threading mo 70 which is invoked only in multi-threading mode. 70 71 71 4- PRIMARY GENERATOR 72 4- PRIMARY GENERATOR 72 73 73 The primary generator action class employ << 74 The primary generator action class employs the G4ParticleGun. 74 The primary kinematics consists of a sing << 75 The primary kinematics consists of a single particle which hits the target 75 to the world boundary and hits the target << 76 perpendicular to the entrance face. The type of the particle 76 face. The type of the particle and its en << 77 and its energy can be changed via the G4 built-in commands of 77 Geant4 built-in commands of the G4Particl << 78 the G4ParticleGun class. 78 << 79 79 5- RUNS and EVENTS 80 5- RUNS and EVENTS 80 << 81 81 A run is a set of events. 82 A run is a set of events. 82 << 83 83 The user has control: 84 The user has control: 84 - at Begin and End of each run (class << 85 - at Begin and End of each run (class B2RunAction) 85 - at Begin and End of each event (clas << 86 - at Begin and End of each event (class B2EventAction) 86 - at Begin and End of each track (clas 87 - at Begin and End of each track (class TrackingAction, not used here) 87 - at End of each step (class SteppingAction, 88 - at End of each step (class SteppingAction, not used here) 88 << 89 89 The event number is written to the log fi << 90 The event number is written to the log file every requested number 90 of events in B2::EventAction::BeginOfEven << 91 of events in B2EventAction::BeginOfEventAction() and 91 B2::EventAction::EndOfEventAction(). << 92 B2EventAction::EndOfEventAction(). 92 Moreover, for the first 100 events and ev << 93 Moreover, for the first 100 events and every 100 events thereafter 93 information about the number of stored tr << 94 information about the number of stored trajectories in the event 94 is printed as well as the number of hits << 95 is printed as well as the number of hits stored in the G4VHitsCollection. 95 << 96 96 The run number is printed at B2::RunActio << 97 The run number is printed at B2RunAction::BeginOfRunAction(), where the 97 G4RunManager is also informed how to SetR << 98 G4RunManager is also informed how to SetRandomNumberStore for storing 98 initial random number seeds per run or pe << 99 initial random number seeds per run or per event. 99 100 100 6- USER LIMITS 101 6- USER LIMITS 101 << 102 102 This example also illustrates how to intro 103 This example also illustrates how to introduce tracking constraints 103 like maximum step length, minimum kinetic 104 like maximum step length, minimum kinetic energy etc. via the G4UserLimits 104 class and associated G4StepLimiter and G4U << 105 class and associated G4StepLimiter and G4UserSpecialCuts processes. 105 See B2a::DetectorConstruction (or B2b::Det << 106 See B2aDetectorConstruction (or B2bDetectorConstruction). 106 107 107 The maximum step limit in the tracker regi 108 The maximum step limit in the tracker region can be set by the interactive 108 command (see B2a::DetectorMessenger, B2b:: << 109 command (see B2aDetectorMessenger, B2bDetectorMessenger classes). 109 For example: 110 For example: 110 111 111 /B2/det/stepMax 1.0 mm 112 /B2/det/stepMax 1.0 mm 112 113 113 7- DETECTOR RESPONSE 114 7- DETECTOR RESPONSE 114 << 115 115 A HIT is a step per step record of all th 116 A HIT is a step per step record of all the information needed to 116 simulate and analyse the detector respons 117 simulate and analyse the detector response. 117 << 118 118 In this example the Tracker chambers are 119 In this example the Tracker chambers are considered to be the detector. 119 Therefore, the chambers are declared 'sen 120 Therefore, the chambers are declared 'sensitive detectors' (SD) in 120 the B2a::DetectorConstruction (or B2b::De << 121 the B2aDetectorConstruction (or B2bDetectorConstruction) class. 121 They are associated with an instance of t << 122 They are associated with an instance of the B2TrackerSD class. 122 << 123 123 Then, a Hit is defined as a set of 4 info 124 Then, a Hit is defined as a set of 4 informations per step, inside 124 the chambers, namely: 125 the chambers, namely: 125 - the track identifier (an integer), 126 - the track identifier (an integer), 126 - the chamber number, 127 - the chamber number, 127 - the total energy deposit in this step, and 128 - the total energy deposit in this step, and 128 - the position of the energy deposit. 129 - the position of the energy deposit. 129 130 130 A given hit is an instance of the class B << 131 A given hit is an instance of the class B2TrackerHit which is created 131 during the tracking of a particle, step b 132 during the tracking of a particle, step by step, in the method 132 B2::TrackerSD::ProcessHits(). This hit is << 133 B2TrackerSD::ProcessHits(). This hit is inserted in a HitsCollection. 133 134 134 The HitsCollection is printed at the end 135 The HitsCollection is printed at the end of each event (via the method 135 B2::TrackerSD::EndOfEvent()), under the c << 136 B2TrackerSD::EndOfEvent()), under the control of the command: 136 /hits/verbose 2 137 /hits/verbose 2 137 138 138 The following paragraphs are common to all ba 139 The following paragraphs are common to all basic examples 139 140 140 A- VISUALISATION 141 A- VISUALISATION 141 142 142 The visualization manager is set via the G4 143 The visualization manager is set via the G4VisExecutive class 143 in the main() function in exampleB2a.cc (or << 144 in the main() function in exampleB2a.cc (or exampleB2b.cc). 144 The initialisation of the drawing is done v 145 The initialisation of the drawing is done via a set of /vis/ commands 145 in the macro vis.mac. This macro is automat 146 in the macro vis.mac. This macro is automatically read from 146 the main function when the example is used 147 the main function when the example is used in interactive running mode. 147 148 148 By default, vis.mac opens an OpenGL viewer 149 By default, vis.mac opens an OpenGL viewer (/vis/open OGL). 149 The user can change the initial viewer by c 150 The user can change the initial viewer by commenting out this line 150 and instead uncommenting one of the other / 151 and instead uncommenting one of the other /vis/open statements, such as 151 HepRepFile or DAWNFILE (which produce files 152 HepRepFile or DAWNFILE (which produce files that can be viewed with the 152 HepRApp and DAWN viewers, respectively). N 153 HepRApp and DAWN viewers, respectively). Note that one can always 153 open new viewers at any time from the comma 154 open new viewers at any time from the command line. For example, if 154 you already have a view in, say, an OpenGL 155 you already have a view in, say, an OpenGL window with a name 155 "viewer-0", then 156 "viewer-0", then 156 /vis/open DAWNFILE 157 /vis/open DAWNFILE 157 then to get the same view 158 then to get the same view 158 /vis/viewer/copyView viewer-0 159 /vis/viewer/copyView viewer-0 159 or to get the same view *plus* scene-modifi 160 or to get the same view *plus* scene-modifications 160 /vis/viewer/set/all viewer-0 161 /vis/viewer/set/all viewer-0 161 then to see the result 162 then to see the result 162 /vis/viewer/flush 163 /vis/viewer/flush 163 164 164 The DAWNFILE, HepRepFile drivers are always 165 The DAWNFILE, HepRepFile drivers are always available 165 (since they require no external libraries), 166 (since they require no external libraries), but the OGL driver requires 166 that the Geant4 libraries have been built w 167 that the Geant4 libraries have been built with the OpenGL option. 167 168 168 Since 11.1, the TSG visualization driver ca << 169 file output in png, jpeg, gl2ps formats wit << 170 It can be controlled via UI commands provid << 171 demonstrated in the tsg_offscreen.mac macro << 172 << 173 For more information on visualization, incl 169 For more information on visualization, including information on how to 174 install and run DAWN, OpenGL and HepRApp, s 170 install and run DAWN, OpenGL and HepRApp, see the visualization tutorials, 175 for example, 171 for example, 176 http://geant4.slac.stanford.edu/Presentatio 172 http://geant4.slac.stanford.edu/Presentations/vis/G4[VIS]Tutorial/G4[VIS]Tutorial.html 177 (where [VIS] can be replaced by DAWN, OpenG 173 (where [VIS] can be replaced by DAWN, OpenGL and HepRApp) 178 174 179 The tracks are automatically drawn at the e 175 The tracks are automatically drawn at the end of each event, accumulated 180 for all events and erased at the beginning 176 for all events and erased at the beginning of the next run. 181 177 182 B- USER INTERFACES 178 B- USER INTERFACES 183 << 179 184 The user command interface is set via the G 180 The user command interface is set via the G4UIExecutive class 185 in the main() function in exampleB2a.cc << 181 in the main() function in exampleB2a.cc 186 << 182 The selection of the user command interface is then done automatically 187 The selection of the user command interface << 183 according to the Geant4 configuration or it can be done explicitly via 188 according to the Geant4 configuration or it << 184 the third argument of the G4UIExecutive constructor (see exampleB4a.cc). 189 the third argument of the G4UIExecutive con << 185 190 << 191 The gui.mac macros are provided in examples << 192 is automatically executed if Geant4 is buil << 193 It is also possible to customise the icons << 194 demonstrated in the icons.mac macro in exam << 195 << 196 C- HOW TO RUN 186 C- HOW TO RUN 197 << 187 198 - Execute exampleB2a in the 'interactive m 188 - Execute exampleB2a in the 'interactive mode' with visualization 199 % exampleB2a 189 % exampleB2a 200 and type in the commands from run1.mac l << 190 and type in the commands from run1.mac line by line: 201 Idle> /tracking/verbose 1 << 191 Idle> /tracking/verbose 1 202 Idle> /run/beamOn 1 192 Idle> /run/beamOn 1 203 Idle> ... 193 Idle> ... 204 Idle> exit 194 Idle> exit 205 or 195 or 206 Idle> /control/execute run1.mac or ru << 196 Idle> /control/execute run1.mac or run2.mac 207 .... 197 .... 208 Idle> exit 198 Idle> exit 209 199 210 - Execute exampleB2a in the 'batch' mode f << 200 - Execute exampleB2a in the 'batch' mode from macro files 211 (without visualization) 201 (without visualization) 212 % exampleB2a run2.mac 202 % exampleB2a run2.mac 213 % exampleB2a exampleB2.in > exampleB2. 203 % exampleB2a exampleB2.in > exampleB2.out 214 << 204