Geant4 Cross Reference |
1 2 ========================================== 3 Geant4 - an Object-Oriented Toolkit for Si 4 ========================================== 5 6 Extended Example saxs 7 -------------------- 8 9 The example saxs implements the typical setu 10 Scattering (SAXS) experiment. It is meant to 11 usage of molecular interference (MI) of Rayl 12 of photons inside the matter, which is imple 13 G4PenelopeRayleighModelMI model. 14 15 1- GEOMETRY 16 17 The setup consists of a phantom/sample unde 18 to collimate the photon beam and a shielded 19 the photons scattered by the phantom (see S 20 21 The geometry is scalable through the intera 22 in the SAXSDetectorConstructionMessenger cl 23 quantities, such as the setup (scattering) 24 and size of all the volumes, as well as the 25 set via macro commands. 26 27 Two macro files come with this example: sax 28 29 In the saxs.in macro, the phantom is a cyli 30 a height of 10 mm made of a mixture of 80% 31 In general, if the argument of /det/setPhan 32 as in this case, the material is a biologic 33 defined as a mixture of fat, water, collage 34 The weight fraction of the mixture componen 35 /det/setComp0, /det/setComp1, /det/setComp2 36 The tissue form factor (including MI) is au 37 weighed sum of the form factors of the basi 38 In this case, no slits are foreseen and the 39 positioned 400 mm downstream of the phantom 40 transmitted and scattered by the phantom, w 41 by a pencil beam with an energy of 20 keV. 42 43 In the saxs_slits.in macro, the phantom is 44 diameter and a height of 10 mm. The phantom 45 material ("CustomMat") whose density and co 46 /det/setCustomMatDensity and /det/setCustom 47 /det/setCustomMatNmassfract, /det/setCustom 48 respectively. In general, a custom material 49 specifying the mass fraction of H, C, N, O, 50 commands analogous to those mentioned above 51 composition corresponds to that of ammonium 52 For a custom material, the user can provide 53 the material form factor (with MI) through 54 command. As an example, the file myFF.dat c 55 NH4NO3 measured by Harding in 1999. 56 In this case the slits upstream and downstr 57 are present. This setup is suitable for bot 58 polychromatic beams. To speed-up the simula 59 photon beam was chosen, but a polychromatic 60 61 2- PHYSICS 62 63 In this example, only electromagnetic proce 64 They are defined in a custom physics list t 65 choose among various EM PhysicsList constru 66 by choosing G4EmPenelopePhysicsMI and setti 67 it is possible to enable the molecular inte 68 is the default configuration. 69 70 3- ACTION INITALIZATION 71 72 SAXSActionInitialization class instantiates 73 Geant4 kernel all user action classes. Whil 74 the action classes are instatiated just onc 75 method: SAXSActionInitialization::Build(), 76 in multi-threading mode the same method is 77 worker and so all user action classes are d 78 79 A run action class is instantiated both thr 80 That's why its instance is created also in 81 SAXSActionInitialization::BuildForMaster(), 82 invoked only in multi-threading mode. 83 84 4- PRIMARY GENERATOR 85 86 The primary generator action class employs 87 generator. The primary beam has to be defin 88 commands of the G4GeneralParticleSource in 89 In particular, a photon beam directed towar 90 to test the MI effects. The X-ray beam can 91 polychromatic, parallel or divergent. 92 93 5- EVENT AND DETECTOR RESPONSE 94 95 An event consists of the generation of a si 96 transported through the phantom and then to 97 98 The interactions of the photons inside the 99 the scattering events, are scored in a dedi 100 SAXSSteppingAction class. 101 102 The hits of the particles on the sensitive 103 downstream of the phantom (SAXSSensitiveDet 104 in a dedicated ntuple through the SAXSSensi 105 106 6- ANALYSIS: 107 108 The analysis tools are used to accumulate s 109 ntuple are created in SAXSRunAction::SAXSRu 110 constructor for the following quantities: 111 112 Ntuple1 (part) - Particles impinging on the 113 - energy of the particles 114 - position of the hits 115 - momentum of the particles 116 - time of the hits 117 - type of impinging particles 118 - ID number of the impinging particles 119 - number of scattering events a primary had 120 - event number of the hits 121 122 Ntuple2 (scatt) - Interactions of photons in 123 - ID of the process occurred 124 (0-> transportation, 1->Rayleigh, 2->Com 125 - initial energy of the particles 126 - scattering angle 127 128 The ntuples are saved in the output file in 129 130 When running in multi-threading mode, the n 131 on threads are automatically merged in a si 132 133 The default output format is root. Two root 134 this example to analyze the output file: sc 135 ADXRD.C. The first can be used to analyze t 136 the second can be used for part ntuple. 137 138 7- HOW TO RUN 139 140 - Execute saxs in the 'interactive mode' w 141 % ./saxs 142 and type in the commands line by line: 143 Idle> /control/verbose 2 144 Idle> /tracking/verbose 1 145 Idle> ... 146 Idle> /run/beamOn 10 147 Idle> ... 148 Idle> exit 149 or it is possible to run a macro file (t 150 primary beam is defined through the usua 151 Idle> /control/execute test.in 152 Idle> /run/beamOn 10 153 .... 154 Idle> exit 155 156 - Execute saxs in the 'batch' mode from ma 157 (without visualization) 158 % ./saxs saxs.in [Ncores] 159 % ./saxs saxs_slits.in [Ncores] 160 Ncores (optional argument) is the number 161 MT mode. 162 163 164 The following paragraphs are common to all ba 165 166 A- VISUALISATION 167 168 The visualization manager is set via the G4 169 in the main() function in saxs.cc. 170 The initialisation of the drawing is done v 171 in the macro vis.mac. This macro is automat 172 the main function when the example is used 173 174 By default, vis.mac opens an OpenGL viewer 175 The user can change the initial viewer by c 176 and instead uncommenting one of the other / 177 HepRepFile or DAWNFILE (which produce files 178 HepRApp and DAWN viewers, respectively). N 179 open new viewers at any time from the comma 180 you already have a view in, say, an OpenGL 181 "viewer-0", then 182 /vis/open DAWNFILE 183 then to get the same view 184 /vis/viewer/copyView viewer-0 185 or to get the same view *plus* scene-modifi 186 /vis/viewer/set/all viewer-0 187 then to see the result 188 /vis/viewer/flush 189 190 The DAWNFILE, HepRepFile drivers are always 191 (since they require no external libraries), 192 that the Geant4 libraries have been built w 193 194 vis.mac has additional commands that demons 195 of the vis system, such as displaying text, 196 shows how to change viewpoint and style. 197 To see even more commands use help or ls or 198 in the Application Developers Guide. 199 200 For more information on visualization, incl 201 install and run DAWN, OpenGL and HepRApp, s 202 for example, 203 http://geant4.slac.stanford.edu/Presentatio 204 (where [VIS] can be replaced by DAWN, OpenG 205 206 The tracks are automatically drawn at the e 207 for all events and erased at the beginning 208 209 B- USER INTERFACES 210 211 The user command interface is set via the G 212 in the main() function in saxs.cc 213 The selection of the user command interface 214 according to the Geant4 configuration or it 215 the third argument of the G4UIExecutive con 216 217