Geant4  10.02.p01
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: F03FieldSetup.cc 77294 2013-11-22 11:01:00Z gcosmo $
31 //
32 //
33 // Field Setup class implementation.
34 //
35 //
36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
38 
39 #include "F03FieldSetup.hh"
40 #include "F03FieldMessenger.hh"
41 
42 #include "G4MagneticField.hh"
43 #include "G4UniformMagField.hh"
44 #include "G4FieldManager.hh"
46 #include "G4Mag_UsualEqRhs.hh"
48 #include "G4ChordFinder.hh"
49 
50 #include "G4ExplicitEuler.hh"
51 #include "G4ImplicitEuler.hh"
52 #include "G4SimpleRunge.hh"
53 #include "G4SimpleHeum.hh"
54 #include "G4ClassicalRK4.hh"
55 #include "G4HelixExplicitEuler.hh"
56 #include "G4HelixImplicitEuler.hh"
57 #include "G4HelixSimpleRunge.hh"
58 #include "G4CashKarpRKF45.hh"
59 #include "G4RKG3_Stepper.hh"
60 
61 #include "G4PhysicalConstants.hh"
62 #include "G4SystemOfUnits.hh"
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67  : fFieldManager(0),
68  fLocalFieldManager(0),
69  fChordFinder(0),
70  fLocalChordFinder(0),
71  fEquation(0),
72  fLocalEquation(0),
73  fMagneticField(0),
74  fLocalMagneticField(0),
75  fStepper(0),
76  fLocalStepper(0),
77  fFieldMessenger(0)
78 {
80  0.0, // 0.5*tesla,
81  0.0));
83  0.0, // 0.5*tesla,
84  0.0));
85 
87 
90 
91  fMinStep = 0.25*mm ; // minimal step of 1 mm is default
92  fStepperType = 4 ; // ClassicalRK4 is default stepper
93 
96 
97  UpdateField();
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101 
103 {
104  delete fMagneticField;
105  delete fChordFinder;
106  delete fStepper;
107  delete fFieldMessenger;
108 }
109 
110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111 
113 {
114  SetStepper();
115  G4cout<<"The minimal step is equal to "<<fMinStep/mm<<" mm"<<G4endl;
116 
119 
120  if (fChordFinder) delete fChordFinder;
122 
126 
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 
134 {
135  if (fStepper) delete fStepper;
136 
137  switch ( fStepperType )
138  {
139  case 0:
142  G4cout<<"G4ExplicitEuler is called"<<G4endl;
143  break;
144  case 1:
147  G4cout<<"G4ImplicitEuler is called"<<G4endl;
148  break;
149  case 2:
152  G4cout<<"G4SimpleRunge is called"<<G4endl;
153  break;
154  case 3:
157  G4cout<<"G4SimpleHeum is called"<<G4endl;
158  break;
159  case 4:
162  G4cout<<"G4ClassicalRK4 (default) is called"<<G4endl;
163  break;
164  case 5:
167  G4cout<<"G4HelixExplicitEuler is called"<<G4endl;
168  break;
169  case 6:
172  G4cout<<"G4HelixImplicitEuler is called"<<G4endl;
173  break;
174  case 7:
177  G4cout<<"G4HelixSimpleRunge is called"<<G4endl;
178  break;
179  case 8:
182  G4cout<<"G4CashKarpRKF45 is called"<<G4endl;
183  break;
184  case 9:
187  G4cout<<"G4RKG3_Stepper is called"<<G4endl;
188  break;
189  default: fStepper = 0;
190  }
191 }
192 
193 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
194 
196 {
197  G4ThreeVector fieldSetVec(0.0, 0.0, fieldStrength);
198  SetFieldValue( fieldSetVec );
199 }
200 
201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
202 
204 {
205  if(fMagneticField) delete fMagneticField;
206 
207  if(fieldVector != G4ThreeVector(0.,0.,0.))
208  {
209  fMagneticField = new G4UniformMagField(fieldVector);
210  }
211  else
212  {
213  // If the new field's value is Zero, then
214  // setting the pointer to zero ensures
215  // that it is not used for propagation.
216  fMagneticField = 0;
217  }
218 
219  // Either
220  // - UpdateField() to reset all (ChordFinder, Equation);
221  // UpdateField();
222  // or simply update the field manager & equation of motion
223  // with pointer to new field
226 
227 }
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
230 
232 {
234  ->GetFieldManager();
235 }
236 
237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
238 
240 {
241  static G4double fieldValue[6], position[4];
242  position[0] = position[1] = position[2] = position[3] = 0.0;
243 
244  fMagneticField->GetFieldValue( position, fieldValue);
245  G4ThreeVector fieldVec(fieldValue[0], fieldValue[1], fieldValue[2]);
246 
247  return fieldVec;
248 }
249 
250 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetFieldValue(G4ThreeVector fieldVector)
CLHEP::Hep3Vector G4ThreeVector
G4ThreeVector GetConstantFieldValue()
G4bool SetDetectorField(G4Field *detectorField)
Definition of the F03FieldMessenger class.
G4MagIntegratorStepper * fStepper
G4ChordFinder * fChordFinder
virtual void GetFieldValue(const G4double Point[4], G4double *Bfield) const =0
void SetChordFinder(G4ChordFinder *aChordFinder)
G4Mag_UsualEqRhs * fLocalEquation
#define position
Definition: xmlparse.cc:622
G4GLOB_DLL std::ostream G4cout
G4MagIntegratorStepper * fLocalStepper
G4MagneticField * fLocalMagneticField
F03FieldMessenger * fFieldMessenger
G4FieldManager * GetGlobalFieldManager()
static G4TransportationManager * GetTransportationManager()
G4FieldManager * GetFieldManager() const
G4ChordFinder * fLocalChordFinder
virtual ~F03FieldSetup()
G4double fMinStep
void SetFieldObj(G4Field *pField)
G4FieldManager * fLocalFieldManager
#define G4endl
Definition: G4ios.hh:61
static const double tesla
Definition: G4SIunits.hh:265
G4Mag_UsualEqRhs * fEquation
double G4double
Definition: G4Types.hh:76
G4MagneticField * fMagneticField
Definition of the F03FieldSetup class.
static const double mm
Definition: G4SIunits.hh:114
G4FieldManager * fFieldManager