Geant4 Cross Reference |
1 2 ========================================= 3 Geant4 - an Object-Oriented Toolkit for S 4 ========================================= 5 6 7 8 field04 Example 9 --------------- 10 11 This example shows how to define/use OVER 12 in Geant4. Fields might be either magneti 13 14 Credit goes to Tom Roberts and Muons Inc. 15 and ideas were taken at liberty from the 16 G4BEAMLINE release 1.12. 17 18 http://g4beamline.muonsinc.com 19 20 ************** 21 *Classes Used* 22 ************** 23 24 1 - main() 25 26 See field04.cc. 27 28 The example can be run with the follow 29 30 % field04 [-m macro ] [-p physicsList] 31 32 If a macro is provided with the option 33 otherwise the program open the interac 34 default initialization macro init_vis. 35 to start the program without initializ 36 37 For example: 38 to assign the F04PhysicsList: 39 % field04 -p QGSP_BERT 40 41 an initial random number seed with: 42 % field04 field04.in -r 12345 43 44 to start with a macro file and an init 45 % field04 -m field04.in -r 12345 46 47 48 2- GEOMETRY DEFINITION 49 50 The geometry consists of two solenoida 51 followed by a (blue-colored "TransferM 52 axis and center of the "CaptureMgnt" c 53 position of the "TransferMgnt" relativ 54 "CaptureMgnt", as well as its axis ang 55 "Target" is positioned inside the "Cap 56 from 0 to 180 deg, and hence also the 57 proton beam wrt the "CaptureMgnt"'s ax 58 inside the "TransferMgnt", its default 59 upstream end of the "TransferMgnt". Fi 60 located inside the "TransferMgnt", by 61 62 63 The "World" consists of a solid cylind 64 (It is the responsibility of the use 65 large enough to contain the rest of 66 67 Three parameters define the world : 68 - the material of the world, 69 - the world radius, 70 - the world length. 71 72 Example (default values): 73 /field04/SetWorldMat G4_AIR 74 /field04/SetWorldR 5.0 m 75 /field04/SetWorldZ 50.0 m 76 77 78 The "Target" is a solid cylinder made 79 80 Five parameters define the target: 81 - the material of the target, 82 - the target radius, 83 - the target thickness, 84 - the target position inside the "Capt 85 - the target axis angle relative to th 86 87 Example (default values): 88 /field04/SetTgtMat G4_W 89 /field04/SetTgtRad 0.4 cm 90 /field04/SetTgtThick 16.0 cm 91 /field04/SetTgtPos 0.0 cm 92 /field04/SetTgtAng 170 93 94 95 The "Degrader" is a solid cylinder ma 96 97 Four parameters define the degrader: 98 - the material of the degrader, 99 - the degrader radius, 100 - the degrader thickness, 101 - the degrader position relative to th 102 103 Example (default values): 104 /field04/SetDgrMat G4_Pb 105 /field04/SetDgrRad 30.0 cm 106 /field04/SetDgrThick 0.1 cm 107 #/field04/SetDgrPos -7.4 m 108 109 110 The "CaptureMgnt" is a solenoid (vacuu 111 a two-sided or a one-sided magnetic bo 112 varying linearly from the center value 113 The one-sided F04FocusSolenoid has the 114 on the z < 0 side. 115 116 Four parameters define the "CaptureMgn 117 - the magnet radius, 118 - the magnet length, 119 - the weaker magnetic field at the cen 120 - the stronger magnetic field at the e 121 122 Example (default values): 123 /field04/SetCaptureR 0.6 m 124 /field04/SetCaptureZ 4.0 m 125 /field/SetCaptureB1 2.5 tesla 126 /field/SetCaptureB2 5.0 tesla 127 128 129 The "TransferMgnt" is a solenoid (vacu 130 constant B-field. When the "TransferMg 131 the "CaptureMgnt", its relative positi 132 133 Four parameters define the "TransferMg 134 - the magnet radius, 135 - the magnet length, 136 - the magnet field, 137 - the magnet relative position 138 (its upstream face wrt the downstrea 139 140 Example (default values): 141 /field04/SetTransferR 0.3 m 142 /field04/SetTransferZ 15.0 m 143 /field/SetTransferB 5.0 tesla 144 /field04/SetTransferP 0.0 m 145 146 The default geometry is constructed in 147 but all the parameters can be changed 148 the F04DetectorMessenger class. 149 150 151 3- MATERIAL DEFINITION 152 153 Material definitions are done through 154 which keeps a pointer to the G4NistMan 155 GetMaterial by name (G4String) which i 156 G4NistManager::FindOrBuildMaterial, an 157 methods. It has also a method CreateMa 158 absent from the NIST data base, shows 159 G4NistManager::ConstructNewMaterial me 160 161 162 4- AN EVENT: THE PRIMARY GENERATOR 163 164 The primary kinematic consists of a si 165 target perpendicular to its upstream f 166 and its energy are set in the F04Prima 167 be changed via the G4 build-in command 168 In addition, there is a fRndmFlag, whi 169 explore randomly the whole cross secti 170 beam consists of 500 MeV protons, star 171 the target, directed along dx = dy = 0 172 The default direction should NOT be ch 173 x/y/zvertex commands are relative to t 174 175 Example: 176 /gun/random on 177 #/gun/xvertex 0 mm 178 #/gun/yvertex 0 mm 179 #/gun/zvertex -100 mm 180 181 182 5- DETECTOR RESPONSE 183 184 Information is extracted from the prog 185 at the TestPlane. 186 187 188 6- PHYSICS 189 190 The F04PhysicsList extends a selected 191 The base physics list name is provided 192 constructor. 193 194 In addition to processes defined in th 195 there is added the F04StepMax process 196 via dedicated commands in F04PhysicsLi 197 198 The command to define maximum step: 199 /exp/phys/stepMax value unit 200 201 The decay of pions can be assigned via 202 203 /decay/pienu 204 /decay/pimunu 205 206 The pienu assignment includes a small 207 e nu gamma (G4PionRadiativeDecayChanne 208 209 The standard/default muon decay chain 210 G4MuonDecayChannelWithSpin and 1.4% G4 211 in ConstructParticle(). 212 213 The pion decay process G4PolDecay inhe 214 the virtual method - empty in the base 215 216 The muon decay process is G4DecayWithS 217 218 Furthermore, the following commands ar 219 may only be used AFTER /run/initialize 220 221 /process/inactivate msc 222 /process/activate msc 223 224 7- Overlapping Fields 225 226 The F04GlobalField (a singleton) is in 227 F04DetectorConstruction() and assigned 228 in UpdateField(): 229 230 fFieldManager = GetGlobalFieldManager( 231 fFieldManager->SetDetectorField(this); 232 233 The F04GlobalField has a std::vector<E 234 235 The field from each individual beamlin 236 F04ElementField object. Any number of 237 objects can be added to the F04GlobalF 238 represents an element with an EM field 239 F04ElementField to the global F04Globa 240 241 Of course, the F04GlobalField has the 242 243 Before /run/initialize in the macro fi 244 field command must have been issued if 245 field commands was employed: 246 247 /field/update 248 249 Other options are: 250 251 /field/setStepperType 4 252 /field/setMinStep 10 mm 253 /field/setDeltaChord 3.0 mm 254 /field/setDeltaOneStep 0.01 mm 255 /field/setDeltaIntersection 0.1 mm 256 /field/setEpsMin 2.5e-7 mm 257 /field/setEpsMax 0.05 mm 258 259 Each field element has a rectilinear b 260 coordinate space which is checked befo 261 actually be inside the F04ElementField 262 SetGlobalPoint is called 8 times for t 263 bounding box, after a local->global co 264 265 The F04ElementField is the interface c 266 compute the field value at a given poi 267 268 A beamline element, for example the F0 269 from F04ElementField and implement the 270 271 simpleSolenoid 272 = new F04SimpleSolenoid(B, l, logicT 273 274 Besides the magnetic field and the len 275 the constructor needs the knowledge of 276 the beamline element and where its cen 277 'World'. 278 279 The F04ElementField has a G4AffineTran 280 allows the quick computation of coordi 281 only be determined by knowing the elem 282 the global frame and after all of the 283 For this reason, the object is prepare 284 constructor providing it with the coor 285 to the G4LogicalVolume. Later the Cons 286 calculate the fGlobal2local and the bo 287 from the F04RunAction::BeginOfRunActio 288 certain that the geometry has been com 289 290 FieldList* fields = F04GlobalField::Ge 291 292 if (fields) { 293 if (fields->size()>0) { 294 FieldList::iterator i; 295 for (i=fields->begin(); i!=field 296 } 297 } 298 299 The F04ElementField constructor will a 300 F04GlobalField. Finally, its AddFieldV 301 for this element to field[]. 302 303 304 8- User Action Classes 305 306 F04RunActionMessenger: 307 308 /rndm/save freq - to save 309 0 not saved 310 >0 saved on: b 311 1 saved on: 312 2 saved on: e 313 /rndm/read random/run0evt 314 315 F04RunAction: 316 BeginOfRunAction: Deal wi 317 initialization etc. Call 318 F04ElementFields in the F 319 EndOfRunAction: random nu 320 321 F04EventActionMessenger: 322 /event/setverbose 323 324 F04EventAction(RunAction* RA): 325 Customized BeginOfEvent p 326 EndofEvent: 327 saveEngingStatus and show 328 in F04RunAction 329 330 F04TrackingAction: 331 PreUserTrackingAction: In 332 and set the application T 333 PostUserTrackingAction: R 334 and decide to save random 335 336 F04SteppingActionMessenger: 337 338 F04SteppingAction: 339 UserSteppingAction: Kill 340 volume. Diagnostic/histog 341 TestPlane. Find decay pos 342 FIRST reverses z-momentum 343 F04UserTrackInformation o 344 345 F04StackingAction: 346 Track only primaries, pi+ 347 348 F04UserTrackInformation: 349 Keep an application F04Tr 350 undefined, left, rig 351 352 F04SteppingVerbose: 353 Only print track header an 354 pi+ and mu+. 355 Note: the information for 356 357 F04Trajectory, TrajectoryPoint: 358 Example of application spe 359 360 9- HOW TO START ? 361 362 - Execute field04 in 'batch' mode from 363 % field04 -m field04.in 364 365 - Execute field04 in 'interactive' mod 366 % field04 367 .... 368 Idle> type your commands 369 .... 370 371 - Execute field04 in 'interactive' mod 372 % field04 -s preinit 373 .... 374 Idle> type your commands, then 375 Idle> /run/initialize 376 Idle> /control/execute vis.mac 377 ....