45 #include <Geant4/G4SystemOfUnits.hh>
46 #include <Geant4/G4UniformMagField.hh>
47 #include <Geant4/G4MagneticField.hh>
48 #include <Geant4/G4FieldManager.hh>
49 #include <Geant4/G4TransportationManager.hh>
50 #include <Geant4/G4EquationOfMotion.hh>
51 #include <Geant4/G4EqMagElectricField.hh>
52 #include <Geant4/G4Mag_UsualEqRhs.hh>
53 #include <Geant4/G4MagIntegratorStepper.hh>
54 #include <Geant4/G4MagIntegratorDriver.hh>
55 #include <Geant4/G4ChordFinder.hh>
57 #include <Geant4/G4ExplicitEuler.hh>
58 #include <Geant4/G4ImplicitEuler.hh>
59 #include <Geant4/G4SimpleRunge.hh>
60 #include <Geant4/G4SimpleHeum.hh>
61 #include <Geant4/G4ClassicalRK4.hh>
62 #include <Geant4/G4HelixExplicitEuler.hh>
63 #include <Geant4/G4HelixImplicitEuler.hh>
64 #include <Geant4/G4HelixSimpleRunge.hh>
65 #include <Geant4/G4CashKarpRKF45.hh>
66 #include <Geant4/G4RKG3_Stepper.hh>
88 fEquation =
new G4Mag_UsualEqRhs(fEMfield);
94 double point[4] = {0,0,0,0};
95 fEMfield->GetFieldValue(&point[0],&magfield_at_000[0]);
96 for (
size_t i=0; i<
sizeof(magfield_at_000)/
sizeof(
double);i++)
98 magfield_at_000[i] = magfield_at_000[i]/tesla;
102 cout <<
"field: x" << magfield_at_000[0]
103 <<
", y: " << magfield_at_000[1]
104 <<
", z: " << magfield_at_000[2]
108 fDummyFieldManager =
new G4FieldManager();
109 fDummyFieldManager->SetDetectorField(0);
186 delete fFieldMessenger;
201 fFieldManager->SetDetectorField(fEMfield );
205 fIntgrDriver =
new G4MagInt_Driver(fMinStep,
207 fStepper->GetNumberOfVariables() );
209 fChordFinder =
new G4ChordFinder(fIntgrDriver);
211 fFieldManager->SetChordFinder( fChordFinder );
225 std::stringstream message;
227 switch ( fStepperType )
230 fStepper =
new G4ExplicitEuler( fEquation, nvar );
231 message <<
"Stepper in use: G4ExplicitEuler";
234 fStepper =
new G4ImplicitEuler( fEquation, nvar );
235 message <<
"Stepper in use: G4ImplicitEuler";
238 fStepper =
new G4SimpleRunge( fEquation, nvar );
239 message <<
"Stepper in use: G4SimpleRunge";
242 fStepper =
new G4SimpleHeum( fEquation, nvar );
243 message <<
"Stepper in use: G4SimpleHeum";
246 fStepper =
new G4ClassicalRK4( fEquation, nvar );
247 message <<
"Stepper in use: G4ClassicalRK4 (default)";
250 fStepper =
new G4CashKarpRKF45( fEquation, nvar );
251 message <<
"Stepper in use: G4CashKarpRKF45";
255 message <<
"G4RKG3_Stepper is not currently working for Magnetic Field";
259 message <<
"G4HelixExplicitEuler is not valid for Magnetic Field";
263 message <<
"G4HelixImplicitEuler is not valid for Magnetic Field";
267 message <<
"G4HelixSimpleRunge is not valid for Magnetic Field";
269 default: fStepper =
NULL;
273 G4cout <<
" ---------- G4TBMagneticFieldSetup::SetStepper() -----------" << G4endl;
274 G4cout <<
" " << message.str() << endl;
275 G4cout <<
" Minimum step size: " << fMinStep/mm <<
" mm" << G4endl;
276 G4cout <<
" -----------------------------------------------------------" << G4endl;
281 cout <<
"no stepper set, edxiting now" << endl;
295 G4ThreeVector fieldVector( 0.0, 0.0, fieldValue );
310 if(fieldVector != G4ThreeVector(0.,0.,0.))
312 if(fEMfield)
delete fEMfield;
313 fEMfield =
new G4UniformMagField(fieldVector);
315 fEquation->SetFieldObj(fEMfield);
319 fieldMgr->SetDetectorField(fEMfield);
325 if(fEMfield)
delete fEMfield;
327 fEquation->SetFieldObj(fEMfield);
329 G4MagneticField* fEMfield = 0;
330 fieldMgr->SetDetectorField(fEMfield);
340 return G4TransportationManager::GetTransportationManager()->GetFieldManager();
G4FieldManager * GetGlobalFieldManager()
void SetFieldValue(const G4ThreeVector fieldVector)
G4TBMagneticFieldSetup(PHField *phfield)
virtual ~G4TBMagneticFieldSetup()
transient DST object for field storage and access
PHG4MagneticField interfaces with Geant4.