Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
field
field03
src
F03FieldSetup.cc
Go to the documentation of this file.
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
28
//
29
//
30
// $Id$
31
//
32
//
33
// Field Setup class implementation.
34
//
35
36
#include "
F03FieldSetup.hh
"
37
#include "
F03FieldMessenger.hh
"
38
39
#include "
G4UniformMagField.hh
"
40
#include "
G4MagneticField.hh
"
41
#include "
G4FieldManager.hh
"
42
#include "
G4TransportationManager.hh
"
43
#include "
G4Mag_UsualEqRhs.hh
"
44
#include "
G4MagIntegratorStepper.hh
"
45
#include "
G4ChordFinder.hh
"
46
47
#include "
G4ExplicitEuler.hh
"
48
#include "
G4ImplicitEuler.hh
"
49
#include "
G4SimpleRunge.hh
"
50
#include "
G4SimpleHeum.hh
"
51
#include "
G4ClassicalRK4.hh
"
52
#include "
G4HelixExplicitEuler.hh
"
53
#include "
G4HelixImplicitEuler.hh
"
54
#include "
G4HelixSimpleRunge.hh
"
55
#include "
G4CashKarpRKF45.hh
"
56
#include "
G4RKG3_Stepper.hh
"
57
#include "
G4SystemOfUnits.hh
"
58
60
//
61
// Constructors:
62
63
F03FieldSetup::F03FieldSetup
()
64
: fChordFinder(0), fLocalChordFinder(0), fStepper(0)
65
{
66
fMagneticField
=
new
G4UniformMagField
(
67
G4ThreeVector
(3.3*
tesla
,
68
0.0,
// 0.5*tesla,
69
0.0 ));
70
fLocalMagneticField
=
new
G4UniformMagField
(
71
G4ThreeVector
(3.3*
tesla
,
72
0.0,
// 0.5*tesla,
73
0.0 ));
74
75
fFieldMessenger
=
new
F03FieldMessenger
(
this
) ;
76
77
fEquation
=
new
G4Mag_UsualEqRhs
(
fMagneticField
);
78
fLocalEquation
=
new
G4Mag_UsualEqRhs
(
fLocalMagneticField
);
79
80
fMinStep
= 0.25*
mm
;
// minimal step of 1 mm is default
81
fStepperType
= 4 ;
// ClassicalRK4 is default stepper
82
83
fFieldManager
=
GetGlobalFieldManager
();
84
fLocalFieldManager
=
new
G4FieldManager
();
85
86
UpdateField
();
87
}
88
90
91
F03FieldSetup::F03FieldSetup
(
G4ThreeVector
fieldVector)
92
{
93
fMagneticField
=
new
G4UniformMagField
(fieldVector);
94
GetGlobalFieldManager
()->
CreateChordFinder
(
fMagneticField
);
95
}
96
98
99
F03FieldSetup::~F03FieldSetup
()
100
{
101
if
(
fMagneticField
)
delete
fMagneticField
;
102
if
(
fChordFinder
)
delete
fChordFinder
;
103
if
(
fStepper
)
delete
fStepper
;
104
}
105
107
//
108
// Update field
109
//
110
111
void
F03FieldSetup::UpdateField
()
112
{
113
SetStepper
();
114
G4cout
<<
"The minimal step is equal to "
<<
fMinStep
/
mm
<<
" mm"
<<
G4endl
;
115
116
fFieldManager
->
SetDetectorField
(
fMagneticField
);
117
fLocalFieldManager
->
SetDetectorField
(
fLocalMagneticField
);
118
119
if
(
fChordFinder
)
delete
fChordFinder
;
120
if
(
fLocalChordFinder
)
delete
fLocalChordFinder
;
121
122
fChordFinder
=
new
G4ChordFinder
(
fMagneticField
,
fMinStep
,
fStepper
);
123
fLocalChordFinder
=
new
G4ChordFinder
(
fLocalMagneticField
,
124
fMinStep
,
fLocalStepper
);
125
126
fFieldManager
->
SetChordFinder
(
fChordFinder
);
127
fLocalFieldManager
->
SetChordFinder
(
fLocalChordFinder
);
128
}
129
131
//
132
// Set stepper according to the stepper type
133
//
134
135
void
F03FieldSetup::SetStepper
()
136
{
137
if
(
fStepper
)
delete
fStepper
;
138
139
switch
(
fStepperType
)
140
{
141
case
0:
142
fStepper
=
new
G4ExplicitEuler
(
fEquation
);
143
fLocalStepper
=
new
G4ExplicitEuler
(
fLocalEquation
);
144
G4cout
<<
"G4ExplicitEuler is calledS"
<<
G4endl
;
145
break
;
146
case
1:
147
fStepper
=
new
G4ImplicitEuler
(
fEquation
);
148
fLocalStepper
=
new
G4ImplicitEuler
(
fLocalEquation
);
149
G4cout
<<
"G4ImplicitEuler is called"
<<
G4endl
;
150
break
;
151
case
2:
152
fStepper
=
new
G4SimpleRunge
(
fEquation
);
153
fLocalStepper
=
new
G4SimpleRunge
(
fLocalEquation
);
154
G4cout
<<
"G4SimpleRunge is called"
<<
G4endl
;
155
break
;
156
case
3:
157
fStepper
=
new
G4SimpleHeum
(
fEquation
);
158
fLocalStepper
=
new
G4SimpleHeum
(
fLocalEquation
);
159
G4cout
<<
"G4SimpleHeum is called"
<<
G4endl
;
160
break
;
161
case
4:
162
fStepper
=
new
G4ClassicalRK4
(
fEquation
);
163
fLocalStepper
=
new
G4ClassicalRK4
(
fLocalEquation
);
164
G4cout
<<
"G4ClassicalRK4 (default) is called"
<<
G4endl
;
165
break
;
166
case
5:
167
fStepper
=
new
G4HelixExplicitEuler
(
fEquation
);
168
fLocalStepper
=
new
G4HelixExplicitEuler
(
fLocalEquation
);
169
G4cout
<<
"G4HelixExplicitEuler is called"
<<
G4endl
;
170
break
;
171
case
6:
172
fStepper
=
new
G4HelixImplicitEuler
(
fEquation
);
173
fLocalStepper
=
new
G4HelixImplicitEuler
(
fLocalEquation
);
174
G4cout
<<
"G4HelixImplicitEuler is called"
<<
G4endl
;
175
break
;
176
case
7:
177
fStepper
=
new
G4HelixSimpleRunge
(
fEquation
);
178
fLocalStepper
=
new
G4HelixSimpleRunge
(
fLocalEquation
);
179
G4cout
<<
"G4HelixSimpleRunge is called"
<<
G4endl
;
180
break
;
181
case
8:
182
fStepper
=
new
G4CashKarpRKF45
(
fEquation
);
183
fLocalStepper
=
new
G4CashKarpRKF45
(
fLocalEquation
);
184
G4cout
<<
"G4CashKarpRKF45 is called"
<<
G4endl
;
185
break
;
186
case
9:
187
fStepper
=
new
G4RKG3_Stepper
(
fEquation
);
188
fLocalStepper
=
new
G4RKG3_Stepper
(
fLocalEquation
);
189
G4cout
<<
"G4RKG3_Stepper is called"
<<
G4endl
;
190
break
;
191
default
:
fStepper
= 0;
192
}
193
}
194
196
//
197
// Set the value of the Global Field to fieldValue along Z
198
//
199
200
void
F03FieldSetup::SetFieldValue
(
G4double
fieldStrength)
201
{
202
G4ThreeVector
fieldSetVec(0.0, 0.0, fieldStrength);
203
this->
SetFieldValue
( fieldSetVec );
204
// *************
205
206
}
207
209
//
210
// Set the value of the Global Field
211
//
212
213
void
F03FieldSetup::SetFieldValue
(
G4ThreeVector
fieldVector)
214
{
215
if
(
fMagneticField
)
delete
fMagneticField
;
216
217
if
(fieldVector !=
G4ThreeVector
(0.,0.,0.))
218
{
219
fMagneticField
=
new
G4UniformMagField
(fieldVector);
220
}
221
else
222
{
223
// If the new field's value is Zero, then
224
// setting the pointer to zero ensures
225
// that it is not used for propagation.
226
fMagneticField
= 0;
227
}
228
229
// Either
230
// - UpdateField() to reset all (ChordFinder, Equation);
231
// UpdateField();
232
// or simply update the field manager & equation of motion
233
// with pointer to new field
234
GetGlobalFieldManager
()->
SetDetectorField
(
fMagneticField
);
235
fEquation
->
SetFieldObj
(
fMagneticField
);
236
237
}
238
240
//
241
// Utility method
242
243
G4FieldManager
*
F03FieldSetup::GetGlobalFieldManager
()
244
{
245
return
G4TransportationManager::GetTransportationManager
()
246
->
GetFieldManager
();
247
}
248
249
250
// In place of G4UniformField::GetConstantFieldValue ...
251
//
252
G4ThreeVector
F03FieldSetup::GetConstantFieldValue
()
253
{
254
static
G4double
fieldValue[6],
position
[4];
255
position[0] = position[1] = position[2] = position[3] = 0.0;
256
257
fMagneticField
->
GetFieldValue
( position, fieldValue);
258
G4ThreeVector
fieldVec(fieldValue[0], fieldValue[1], fieldValue[2]);
259
260
return
fieldVec;
261
}
Generated on Sat May 25 2013 14:32:25 for Geant4 by
1.8.4