musrMagneticField.cc

Go to the documentation of this file.
00001 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00002 
00003 #include "musrMagneticField.hh"
00004 #include "G4FieldManager.hh"
00005 
00006 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00007 
00008 musrMagneticField::musrMagneticField()
00009   : G4UniformMagField(G4ThreeVector())
00010 {
00011   GetGlobalFieldManager()->SetDetectorField(this);
00012   GetGlobalFieldManager()->CreateChordFinder(this);
00013 }
00014 
00015 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00016 
00017 musrMagneticField::musrMagneticField(G4ThreeVector fieldVector)
00018   : G4UniformMagField(fieldVector)
00019 {
00020   GetGlobalFieldManager()->SetDetectorField(this);    
00021   GetGlobalFieldManager()->CreateChordFinder(this);
00022 }
00023 
00024 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00025 
00026 // Set the value of the Global Field to fieldValue along Z
00027 //
00028 void musrMagneticField::SetFieldValue(G4double fieldValue)
00029 {
00030    G4UniformMagField::SetFieldValue(G4ThreeVector(0,0,fieldValue));
00031 }
00032 
00033 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00034 
00035 // Set the value of the Global Field
00036 //
00037 void musrMagneticField::SetFieldValue(G4ThreeVector fieldVector)
00038 {
00039   // Find the Field Manager for the global field
00040   G4FieldManager* fieldMgr= GetGlobalFieldManager();
00041     
00042   if(fieldVector!=G4ThreeVector(0.,0.,0.))
00043   { 
00044     G4UniformMagField::SetFieldValue(fieldVector);
00045     fieldMgr->SetDetectorField(this);
00046   } else {
00047     // If the new field's value is Zero, then it is best to
00048     //  insure that it is not used for propagation.
00049     G4MagneticField* magField = NULL;
00050     fieldMgr->SetDetectorField(magField);
00051   }
00052 }
00053 
00054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00055 
00056 musrMagneticField::~musrMagneticField()
00057 {
00058   // GetGlobalFieldManager()->SetDetectorField(0);
00059 }
00060 
00061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00062 
00063 #include "G4TransportationManager.hh"
00064 
00065 G4FieldManager*  musrMagneticField::GetGlobalFieldManager()
00066 {
00067   return G4TransportationManager::GetTransportationManager()->GetFieldManager();
00068 }
00069 
00070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

Generated on Mon Mar 27 12:19:54 2006 for MUSR by  doxygen 1.4.6