Warning, /geant4/examples/extended/field/field04/README is written in an unsupported language. File is not indexed.
0001
0002 =========================================================
0003 Geant4 - an Object-Oriented Toolkit for Simulation in HEP
0004 =========================================================
0005
0006
0007
0008 field04 Example
0009 ---------------
0010
0011 This example shows how to define/use OVERLAPPING field elements
0012 in Geant4. Fields might be either magnetic, electric or both.
0013
0014 Credit goes to Tom Roberts and Muons Inc. since much of the code
0015 and ideas were taken at liberty from the (GNU GPL) source of
0016 G4BEAMLINE release 1.12.
0017
0018 http://g4beamline.muonsinc.com
0019
0020 **************
0021 *Classes Used*
0022 **************
0023
0024 1 - main()
0025
0026 See field04.cc.
0027
0028 The example can be run with the following optional arguments:
0029
0030 % field04 [-m macro ] [-p physicsList] [-r randomSeed] [-s preinit|idle]
0031
0032 If a macro is provided with the option "-m", the program runs in a batch mode,
0033 otherwise the program open the interactive session after executing the
0034 default initialization macro init_vis.mac. The option "-s preinit" can be used
0035 to start the program without initialization in PreInit phase.
0036
0037 For example:
0038 to assign the F04PhysicsList:
0039 % field04 -p QGSP_BERT
0040
0041 an initial random number seed with:
0042 % field04 field04.in -r 12345
0043
0044 to start with a macro file and an initial seed:
0045 % field04 -m field04.in -r 12345
0046
0047
0048 2- GEOMETRY DEFINITION
0049
0050 The geometry consists of two solenoidal magnets: a "CaptureMgnt"
0051 followed by a (blue-colored "TransferMgnt". By definition, the
0052 axis and center of the "CaptureMgnt" coincide with the "World". The
0053 position of the "TransferMgnt" relative to the downstream end of the
0054 "CaptureMgnt", as well as its axis angle, both may vary. A cylindrical
0055 "Target" is positioned inside the "CaptureMgnt". Its axis can vary
0056 from 0 to 180 deg, and hence also the direction of the incoming
0057 proton beam wrt the "CaptureMgnt"'s axis. A "Degrader" is located
0058 inside the "TransferMgnt", its default position being at the
0059 upstream end of the "TransferMgnt". Finally, also a "TestPlane" is
0060 located inside the "TransferMgnt", by default at its downstream end.
0061
0062
0063 The "World" consists of a solid cylinder made of a given material.
0064 (It is the responsibility of the user to make the world
0065 large enough to contain the rest of the geometry!)
0066
0067 Three parameters define the world :
0068 - the material of the world,
0069 - the world radius,
0070 - the world length.
0071
0072 Example (default values):
0073 /field04/SetWorldMat G4_AIR
0074 /field04/SetWorldR 5.0 m
0075 /field04/SetWorldZ 50.0 m
0076
0077
0078 The "Target" is a solid cylinder made of a given material.
0079
0080 Five parameters define the target:
0081 - the material of the target,
0082 - the target radius,
0083 - the target thickness,
0084 - the target position inside the "CaptureMgnt",
0085 - the target axis angle relative to that of the "CaptureMgnt".
0086
0087 Example (default values):
0088 /field04/SetTgtMat G4_W
0089 /field04/SetTgtRad 0.4 cm
0090 /field04/SetTgtThick 16.0 cm
0091 /field04/SetTgtPos 0.0 cm
0092 /field04/SetTgtAng 170
0093
0094
0095 The "Degrader" is a solid cylinder made of a given material.
0096
0097 Four parameters define the degrader:
0098 - the material of the degrader,
0099 - the degrader radius,
0100 - the degrader thickness,
0101 - the degrader position relative to the "TransferMgnt" center.
0102
0103 Example (default values):
0104 /field04/SetDgrMat G4_Pb
0105 /field04/SetDgrRad 30.0 cm
0106 /field04/SetDgrThick 0.1 cm
0107 #/field04/SetDgrPos -7.4 m
0108
0109
0110 The "CaptureMgnt" is a solenoid (vacuum cylinder). It is either
0111 a two-sided or a one-sided magnetic bottle with the B field
0112 varying linearly from the center value B1 to the edge value B2.
0113 The one-sided F04FocusSolenoid has the open end at +z and focuses
0114 on the z < 0 side.
0115
0116 Four parameters define the "CaptureMgnt":
0117 - the magnet radius,
0118 - the magnet length,
0119 - the weaker magnetic field at the center B1
0120 - the stronger magnetic field at the edge B2
0121
0122 Example (default values):
0123 /field04/SetCaptureR 0.6 m
0124 /field04/SetCaptureZ 4.0 m
0125 /field/SetCaptureB1 2.5 tesla
0126 /field/SetCaptureB2 5.0 tesla
0127
0128
0129 The "TransferMgnt" is a solenoid (vacuum cylinder) with a
0130 constant B-field. When the "TransferMgnt" follows immediately
0131 the "CaptureMgnt", its relative position is at 0 cm.
0132
0133 Four parameters define the "TransferMgnt":
0134 - the magnet radius,
0135 - the magnet length,
0136 - the magnet field,
0137 - the magnet relative position
0138 (its upstream face wrt the downstream face of the "CaptureMgnt".)
0139
0140 Example (default values):
0141 /field04/SetTransferR 0.3 m
0142 /field04/SetTransferZ 15.0 m
0143 /field/SetTransferB 5.0 tesla
0144 /field04/SetTransferP 0.0 m
0145
0146 The default geometry is constructed in F04DetectorConstruction class,
0147 but all the parameters can be changed via the commands defined in
0148 the F04DetectorMessenger class.
0149
0150
0151 3- MATERIAL DEFINITION
0152
0153 Material definitions are done through the singleton class F04Materials
0154 which keeps a pointer to the G4NistManager. It has a method
0155 GetMaterial by name (G4String) which in turn invokes the
0156 G4NistManager::FindOrBuildMaterial, and/or G4Material::GetMaterial
0157 methods. It has also a method CreateMaterials which, for materials
0158 absent from the NIST data base, shows how to create them using the
0159 G4NistManager::ConstructNewMaterial method.
0160
0161
0162 4- AN EVENT: THE PRIMARY GENERATOR
0163
0164 The primary kinematic consists of a single particle which hits the
0165 target perpendicular to its upstream face. The type of the particle
0166 and its energy are set in the F04PrimaryGeneratorAction class, and can
0167 be changed via the G4 build-in commands of the G4ParticleGun class.
0168 In addition, there is a fRndmFlag, which once set allows the beam to
0169 explore randomly the whole cross section of the target. The default
0170 beam consists of 500 MeV protons, starting at the upstream face of
0171 the target, directed along dx = dy = 0, dz = 1 wrt the target frame.
0172 The default direction should NOT be changed! The arguments of the
0173 x/y/zvertex commands are relative to the target center.
0174
0175 Example:
0176 /gun/random on
0177 #/gun/xvertex 0 mm
0178 #/gun/yvertex 0 mm
0179 #/gun/zvertex -100 mm
0180
0181
0182 5- DETECTOR RESPONSE
0183
0184 Information is extracted from the program via F04SteppingAction
0185 at the TestPlane.
0186
0187
0188 6- PHYSICS
0189
0190 The F04PhysicsList extends a selected Geant4 physics list.
0191 The base physics list name is provided by its name in the F04PhysicsList
0192 constructor.
0193
0194 In addition to processes defined in the base Geant4 physics list,
0195 there is added the F04StepMax process and the decay of pions can be assigned
0196 via dedicated commands in F04PhysicsListMessenger.
0197
0198 The command to define maximum step:
0199 /exp/phys/stepMax value unit
0200
0201 The decay of pions can be assigned via (pi -> e nu, pi -> mu nu):
0202
0203 /decay/pienu
0204 /decay/pimunu
0205
0206 The pienu assignment includes a small fraction of radiative decay:
0207 e nu gamma (G4PionRadiativeDecayChannel).
0208
0209 The standard/default muon decay chain is modified to be 98.6%
0210 G4MuonDecayChannelWithSpin and 1.4% G4MuonRadiativeDecayChannelWithSpin
0211 in ConstructParticle().
0212
0213 The pion decay process G4PolDecay inherits from G4Decay and implements
0214 the virtual method - empty in the base class - DaughterPolarization
0215
0216 The muon decay process is G4DecayWithSpin
0217
0218 Furthermore, the following commands are also available, but
0219 may only be used AFTER /run/initialize
0220
0221 /process/inactivate msc
0222 /process/activate msc
0223
0224 7- Overlapping Fields
0225
0226 The F04GlobalField (a singleton) is instantiated in
0227 F04DetectorConstruction() and assigned to the global field manager
0228 in UpdateField():
0229
0230 fFieldManager = GetGlobalFieldManager();
0231 fFieldManager->SetDetectorField(this);
0232
0233 The F04GlobalField has a std::vector<ElementField*> FieldList
0234
0235 The field from each individual beamline element is given by a
0236 F04ElementField object. Any number of overlapping F04ElementField
0237 objects can be added to the F04GlobalField. Any element that
0238 represents an element with an EM field must add the appropriate
0239 F04ElementField to the global F04GlobalField object.
0240
0241 Of course, the F04GlobalField has the method GetFieldValue implemented.
0242
0243 Before /run/initialize in the macro file or command, the update
0244 field command must have been issued if any of the other following
0245 field commands was employed:
0246
0247 /field/update
0248
0249 Other options are:
0250
0251 /field/setStepperType 4
0252 /field/setMinStep 10 mm
0253 /field/setDeltaChord 3.0 mm
0254 /field/setDeltaOneStep 0.01 mm
0255 /field/setDeltaIntersection 0.1 mm
0256 /field/setEpsMin 2.5e-7 mm
0257 /field/setEpsMax 0.05 mm
0258
0259 Each field element has a rectilinear bounding box in global
0260 coordinate space which is checked before a point is verified to
0261 actually be inside the F04ElementField (IsWithin and IsOutside).
0262 SetGlobalPoint is called 8 times for the corners of the local
0263 bounding box, after a local->global coordinate transform.
0264
0265 The F04ElementField is the interface class used by F04GlobalField to
0266 compute the field value at a given point[].
0267
0268 A beamline element, for example the F04SimpleSolenoid, will derive
0269 from F04ElementField and implement the computation for the element.
0270
0271 simpleSolenoid
0272 = new F04SimpleSolenoid(B, l, logicTransferMgnt,TransferMgntCenter);
0273
0274 Besides the magnetic field and the length of the simple solenoid,
0275 the constructor needs the knowledge of the G4LogicalVolume for
0276 the beamline element and where its center is located in the
0277 'World'.
0278
0279 The F04ElementField has a G4AffineTransform "fGlobal2local" which
0280 allows the quick computation of coordinate transformations. It can
0281 only be determined by knowing the element's coordinate origin in
0282 the global frame and after all of the geometry has been defined.
0283 For this reason, the object is prepared in two stages, through the
0284 constructor providing it with the coordinate center and a pointer
0285 to the G4LogicalVolume. Later the Construct() method is called to
0286 calculate the fGlobal2local and the bounding box. This can be done
0287 from the F04RunAction::BeginOfRunAction method, for only then are we
0288 certain that the geometry has been completely built:
0289
0290 FieldList* fields = F04GlobalField::GetObject()->GetFields();
0291
0292 if (fields) {
0293 if (fields->size()>0) {
0294 FieldList::iterator i;
0295 for (i=fields->begin(); i!=fields->end(); ++i)(*i)->Construct();
0296 }
0297 }
0298
0299 The F04ElementField constructor will also add the derived object into
0300 F04GlobalField. Finally, its AddFieldValue() will add the field value
0301 for this element to field[].
0302
0303
0304 8- User Action Classes
0305
0306 F04RunActionMessenger:
0307
0308 /rndm/save freq - to save rndm status in external files
0309 0 not saved
0310 >0 saved on: beginOfRun.rndm
0311 1 saved on: endOfRun.rndm
0312 2 saved on: endOfEvent.rndm
0313 /rndm/read random/run0evt8268.rndm
0314
0315 F04RunAction:
0316 BeginOfRunAction: Deal with random number storage,
0317 initialization etc. Call the Construct() method of
0318 F04ElementFields in the FieldList of F04GlobalField object.
0319 EndOfRunAction: random number storage/status printing.
0320
0321 F04EventActionMessenger:
0322 /event/setverbose
0323
0324 F04EventAction(RunAction* RA):
0325 Customized BeginOfEvent printing
0326 EndofEvent:
0327 saveEngingStatus and showEngineStatus according to flag
0328 in F04RunAction
0329
0330 F04TrackingAction:
0331 PreUserTrackingAction: Instantiate F04UserTrackInformation
0332 and set the application TrackStatus.
0333 PostUserTrackingAction: Retreive F04UserTrackInformation
0334 and decide to save random number status accordingly.
0335
0336 F04SteppingActionMessenger:
0337
0338 F04SteppingAction:
0339 UserSteppingAction: Kill primary if/when outside Target
0340 volume. Diagnostic/histogram filling for particles at a
0341 TestPlane. Find decay position and when particle
0342 FIRST reverses z-momentum component via using a
0343 F04UserTrackInformation object.
0344
0345 F04StackingAction:
0346 Track only primaries, pi+ or mu+
0347
0348 F04UserTrackInformation:
0349 Keep an application F04TrackStatus for the track:
0350 undefined, left, right, reverse
0351
0352 F04SteppingVerbose:
0353 Only print track header and step information for
0354 pi+ and mu+.
0355 Note: the information for primary protons is not printed.
0356
0357 F04Trajectory, TrajectoryPoint:
0358 Example of application specific implementations
0359
0360 9- HOW TO START ?
0361
0362 - Execute field04 in 'batch' mode from macro files e.g.
0363 % field04 -m field04.in
0364
0365 - Execute field04 in 'interactive' mode with visualization
0366 % field04
0367 ....
0368 Idle> type your commands
0369 ....
0370
0371 - Execute field04 in 'interactive' mode without initialization
0372 % field04 -s preinit
0373 ....
0374 Idle> type your commands, then
0375 Idle> /run/initialize
0376 Idle> /control/execute vis.mac
0377 ....