76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
// Geant4 simulation for MuSR
|
|
// AUTHOR: Toni SHIROKA, Paul Scherrer Institut, PSI
|
|
// DATE : 2008-05
|
|
//
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
#include "lem4MagneticField.hh"
|
|
#include "G4FieldManager.hh"
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
lem4MagneticField::lem4MagneticField()
|
|
: G4UniformMagField(G4ThreeVector())
|
|
{
|
|
GetGlobalFieldManager()->SetDetectorField(this);
|
|
GetGlobalFieldManager()->CreateChordFinder(this);
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
lem4MagneticField::lem4MagneticField(G4ThreeVector fieldVector)
|
|
: G4UniformMagField(fieldVector)
|
|
{
|
|
GetGlobalFieldManager()->SetDetectorField(this);
|
|
GetGlobalFieldManager()->CreateChordFinder(this);
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
// Set the value of the Global Field to fieldValue along Z
|
|
//
|
|
void lem4MagneticField::SetFieldValue(G4double fieldValue)
|
|
{
|
|
G4UniformMagField::SetFieldValue(G4ThreeVector(0,0,fieldValue));
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
// Set the value of the Global Field
|
|
//
|
|
void lem4MagneticField::SetFieldValue(G4ThreeVector fieldVector)
|
|
{
|
|
// Find the Field Manager for the global field
|
|
G4FieldManager* fieldMgr= GetGlobalFieldManager();
|
|
|
|
if(fieldVector!=G4ThreeVector(0.,0.,0.))
|
|
{
|
|
G4UniformMagField::SetFieldValue(fieldVector);
|
|
fieldMgr->SetDetectorField(this);
|
|
} else {
|
|
// If the new field's value is Zero, then it is best to
|
|
// insure that it is not used for propagation.
|
|
G4MagneticField* magField = NULL;
|
|
fieldMgr->SetDetectorField(magField);
|
|
}
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
lem4MagneticField::~lem4MagneticField()
|
|
{
|
|
// GetGlobalFieldManager()->SetDetectorField(0);
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
#include "G4TransportationManager.hh"
|
|
|
|
G4FieldManager* lem4MagneticField::GetGlobalFieldManager()
|
|
{
|
|
return G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|