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.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]
1
2 =========================================================
3 Geant4 - an Object-Oriented Toolkit for Simulation in HEP
4 =========================================================
5
6
7
8 field04 Example
9 ---------------
10
11 This example shows how to define/use OVERLAPPING field elements
12 in Geant4. Fields might be either magnetic, electric or both.
13
14 Credit goes to Tom Roberts and Muons Inc. since much of the code
15 and ideas were taken at liberty from the (GNU GPL) source of
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 following optional arguments:
29
30 % field04 [-m macro ] [-p physicsList] [-r randomSeed] [-s preinit|idle]
31
32 If a macro is provided with the option "-m", the program runs in a batch mode,
33 otherwise the program open the interactive session after executing the
34 default initialization macro init_vis.mac. The option "-s preinit" can be used
35 to start the program without initialization in PreInit phase.
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 initial seed:
45 % field04 -m field04.in -r 12345
46
47
48 2- GEOMETRY DEFINITION
49
50 The geometry consists of two solenoidal magnets: a "CaptureMgnt"
51 followed by a (blue-colored "TransferMgnt". By definition, the
52 axis and center of the "CaptureMgnt" coincide with the "World". The
53 position of the "TransferMgnt" relative to the downstream end of the
54 "CaptureMgnt", as well as its axis angle, both may vary. A cylindrical
55 "Target" is positioned inside the "CaptureMgnt". Its axis can vary
56 from 0 to 180 deg, and hence also the direction of the incoming
57 proton beam wrt the "CaptureMgnt"'s axis. A "Degrader" is located
58 inside the "TransferMgnt", its default position being at the
59 upstream end of the "TransferMgnt". Finally, also a "TestPlane" is
60 located inside the "TransferMgnt", by default at its downstream end.
61
62
63 The "World" consists of a solid cylinder made of a given material.
64 (It is the responsibility of the user to make the world
65 large enough to contain the rest of the geometry!)
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 of a given material.
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 "CaptureMgnt",
85 - the target axis angle relative to that of the "CaptureMgnt".
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 made of a given material.
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 the "TransferMgnt" center.
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 (vacuum cylinder). It is either
111 a two-sided or a one-sided magnetic bottle with the B field
112 varying linearly from the center value B1 to the edge value B2.
113 The one-sided F04FocusSolenoid has the open end at +z and focuses
114 on the z < 0 side.
115
116 Four parameters define the "CaptureMgnt":
117 - the magnet radius,
118 - the magnet length,
119 - the weaker magnetic field at the center B1
120 - the stronger magnetic field at the edge B2
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 (vacuum cylinder) with a
130 constant B-field. When the "TransferMgnt" follows immediately
131 the "CaptureMgnt", its relative position is at 0 cm.
132
133 Four parameters define the "TransferMgnt":
134 - the magnet radius,
135 - the magnet length,
136 - the magnet field,
137 - the magnet relative position
138 (its upstream face wrt the downstream face of the "CaptureMgnt".)
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 F04DetectorConstruction class,
147 but all the parameters can be changed via the commands defined in
148 the F04DetectorMessenger class.
149
150
151 3- MATERIAL DEFINITION
152
153 Material definitions are done through the singleton class F04Materials
154 which keeps a pointer to the G4NistManager. It has a method
155 GetMaterial by name (G4String) which in turn invokes the
156 G4NistManager::FindOrBuildMaterial, and/or G4Material::GetMaterial
157 methods. It has also a method CreateMaterials which, for materials
158 absent from the NIST data base, shows how to create them using the
159 G4NistManager::ConstructNewMaterial method.
160
161
162 4- AN EVENT: THE PRIMARY GENERATOR
163
164 The primary kinematic consists of a single particle which hits the
165 target perpendicular to its upstream face. The type of the particle
166 and its energy are set in the F04PrimaryGeneratorAction class, and can
167 be changed via the G4 build-in commands of the G4ParticleGun class.
168 In addition, there is a fRndmFlag, which once set allows the beam to
169 explore randomly the whole cross section of the target. The default
170 beam consists of 500 MeV protons, starting at the upstream face of
171 the target, directed along dx = dy = 0, dz = 1 wrt the target frame.
172 The default direction should NOT be changed! The arguments of the
173 x/y/zvertex commands are relative to the target center.
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 program via F04SteppingAction
185 at the TestPlane.
186
187
188 6- PHYSICS
189
190 The F04PhysicsList extends a selected Geant4 physics list.
191 The base physics list name is provided by its name in the F04PhysicsList
192 constructor.
193
194 In addition to processes defined in the base Geant4 physics list,
195 there is added the F04StepMax process and the decay of pions can be assigned
196 via dedicated commands in F04PhysicsListMessenger.
197
198 The command to define maximum step:
199 /exp/phys/stepMax value unit
200
201 The decay of pions can be assigned via (pi -> e nu, pi -> mu nu):
202
203 /decay/pienu
204 /decay/pimunu
205
206 The pienu assignment includes a small fraction of radiative decay:
207 e nu gamma (G4PionRadiativeDecayChannel).
208
209 The standard/default muon decay chain is modified to be 98.6%
210 G4MuonDecayChannelWithSpin and 1.4% G4MuonRadiativeDecayChannelWithSpin
211 in ConstructParticle().
212
213 The pion decay process G4PolDecay inherits from G4Decay and implements
214 the virtual method - empty in the base class - DaughterPolarization
215
216 The muon decay process is G4DecayWithSpin
217
218 Furthermore, the following commands are also available, but
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 instantiated in
227 F04DetectorConstruction() and assigned to the global field manager
228 in UpdateField():
229
230 fFieldManager = GetGlobalFieldManager();
231 fFieldManager->SetDetectorField(this);
232
233 The F04GlobalField has a std::vector<ElementField*> FieldList
234
235 The field from each individual beamline element is given by a
236 F04ElementField object. Any number of overlapping F04ElementField
237 objects can be added to the F04GlobalField. Any element that
238 represents an element with an EM field must add the appropriate
239 F04ElementField to the global F04GlobalField object.
240
241 Of course, the F04GlobalField has the method GetFieldValue implemented.
242
243 Before /run/initialize in the macro file or command, the update
244 field command must have been issued if any of the other following
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 bounding box in global
260 coordinate space which is checked before a point is verified to
261 actually be inside the F04ElementField (IsWithin and IsOutside).
262 SetGlobalPoint is called 8 times for the corners of the local
263 bounding box, after a local->global coordinate transform.
264
265 The F04ElementField is the interface class used by F04GlobalField to
266 compute the field value at a given point[].
267
268 A beamline element, for example the F04SimpleSolenoid, will derive
269 from F04ElementField and implement the computation for the element.
270
271 simpleSolenoid
272 = new F04SimpleSolenoid(B, l, logicTransferMgnt,TransferMgntCenter);
273
274 Besides the magnetic field and the length of the simple solenoid,
275 the constructor needs the knowledge of the G4LogicalVolume for
276 the beamline element and where its center is located in the
277 'World'.
278
279 The F04ElementField has a G4AffineTransform "fGlobal2local" which
280 allows the quick computation of coordinate transformations. It can
281 only be determined by knowing the element's coordinate origin in
282 the global frame and after all of the geometry has been defined.
283 For this reason, the object is prepared in two stages, through the
284 constructor providing it with the coordinate center and a pointer
285 to the G4LogicalVolume. Later the Construct() method is called to
286 calculate the fGlobal2local and the bounding box. This can be done
287 from the F04RunAction::BeginOfRunAction method, for only then are we
288 certain that the geometry has been completely built:
289
290 FieldList* fields = F04GlobalField::GetObject()->GetFields();
291
292 if (fields) {
293 if (fields->size()>0) {
294 FieldList::iterator i;
295 for (i=fields->begin(); i!=fields->end(); ++i)(*i)->Construct();
296 }
297 }
298
299 The F04ElementField constructor will also add the derived object into
300 F04GlobalField. Finally, its AddFieldValue() will add the field value
301 for this element to field[].
302
303
304 8- User Action Classes
305
306 F04RunActionMessenger:
307
308 /rndm/save freq - to save rndm status in external files
309 0 not saved
310 >0 saved on: beginOfRun.rndm
311 1 saved on: endOfRun.rndm
312 2 saved on: endOfEvent.rndm
313 /rndm/read random/run0evt8268.rndm
314
315 F04RunAction:
316 BeginOfRunAction: Deal with random number storage,
317 initialization etc. Call the Construct() method of
318 F04ElementFields in the FieldList of F04GlobalField object.
319 EndOfRunAction: random number storage/status printing.
320
321 F04EventActionMessenger:
322 /event/setverbose
323
324 F04EventAction(RunAction* RA):
325 Customized BeginOfEvent printing
326 EndofEvent:
327 saveEngingStatus and showEngineStatus according to flag
328 in F04RunAction
329
330 F04TrackingAction:
331 PreUserTrackingAction: Instantiate F04UserTrackInformation
332 and set the application TrackStatus.
333 PostUserTrackingAction: Retreive F04UserTrackInformation
334 and decide to save random number status accordingly.
335
336 F04SteppingActionMessenger:
337
338 F04SteppingAction:
339 UserSteppingAction: Kill primary if/when outside Target
340 volume. Diagnostic/histogram filling for particles at a
341 TestPlane. Find decay position and when particle
342 FIRST reverses z-momentum component via using a
343 F04UserTrackInformation object.
344
345 F04StackingAction:
346 Track only primaries, pi+ or mu+
347
348 F04UserTrackInformation:
349 Keep an application F04TrackStatus for the track:
350 undefined, left, right, reverse
351
352 F04SteppingVerbose:
353 Only print track header and step information for
354 pi+ and mu+.
355 Note: the information for primary protons is not printed.
356
357 F04Trajectory, TrajectoryPoint:
358 Example of application specific implementations
359
360 9- HOW TO START ?
361
362 - Execute field04 in 'batch' mode from macro files e.g.
363 % field04 -m field04.in
364
365 - Execute field04 in 'interactive' mode with visualization
366 % field04
367 ....
368 Idle> type your commands
369 ....
370
371 - Execute field04 in 'interactive' mode without initialization
372 % field04 -s preinit
373 ....
374 Idle> type your commands, then
375 Idle> /run/initialize
376 Idle> /control/execute vis.mac
377 ....