G4MagIntegratorStepperFactory.cc

Go to the documentation of this file.
00001 // $Header: /cvs/lcd/slic/src/G4MagIntegratorStepperFactory.cc,v 1.6 2007/04/27 01:54:34 jeremy Exp $
00002 #include "G4MagIntegratorStepperFactory.hh"
00003 
00004 // G4
00005 #include "G4Mag_UsualEqRhs.hh"
00006 #include "G4ChordFinder.hh"
00007 #include "G4MagIntegratorStepper.hh"
00008 #include "G4ClassicalRK4.hh"
00009 #include "G4ExplicitEuler.hh"
00010 #include "G4HelixExplicitEuler.hh"
00011 #include "G4HelixHeum.hh"
00012 #include "G4HelixImplicitEuler.hh"
00013 #include "G4HelixSimpleRunge.hh"
00014 #include "G4ImplicitEuler.hh"
00015 //#include "G4RKG3_Stepper.hh"
00016 #include "G4SimpleHeum.hh"
00017 #include "G4SimpleRunge.hh"
00018 #include "G4CashKarpRKF45.hh"
00019 #include "G4MagneticField.hh"
00020 #include "G4FieldManager.hh"
00021 #include "G4TransportationManager.hh"
00022 
00023 using std::string;
00024 
00025 namespace slic
00026 {
00027   G4MagIntegratorStepperFactory::G4MagIntegratorStepperFactory()
00028     : Module( "G4MagIntegratorStepperFactory" )
00029   {
00030     m_fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
00031 
00032     if ( m_fieldMgr == 0 ) {
00033       G4Exception("G4FieldManager is null.");
00034     }
00035 
00036     m_field = static_cast<G4MagneticField*>(const_cast<G4Field*>(m_fieldMgr->GetDetectorField()));
00037 
00038     if ( m_field == 0 ) {
00039       log() << LOG::error << "Command refused.  Detector has no G4MagneticField." << LOG::done;
00040     }
00041     else {
00042       m_fieldEquations = new G4Mag_UsualEqRhs(m_field);
00043     }
00044   }
00045 
00046   G4MagIntegratorStepperFactory::~G4MagIntegratorStepperFactory()
00047   {
00048     delete m_fieldEquations;
00049   }
00050 
00051   void G4MagIntegratorStepperFactory::setupG4MagIntegratorStepper(std::string name)
00052   {
00053     G4MagIntegratorStepper* stepper = createG4MagIntegratorStepper(name);
00054 
00055     if ( stepper != 0 ) {
00056 
00057       G4ChordFinder* oldChordFinder = m_fieldMgr->GetChordFinder();
00058       if (oldChordFinder != 0) {
00059         delete oldChordFinder;
00060       }
00061 
00062       /* Create new chord finder with default step minimum. */
00063       m_fieldMgr->SetChordFinder(new G4ChordFinder(m_field, 1E-2*mm, stepper));
00064     }
00065   }
00066 
00067   G4MagIntegratorStepper* G4MagIntegratorStepperFactory::createG4MagIntegratorStepper(string name)
00068   {
00069     if (name=="G4ClassicalRK4") {
00070       return new G4ClassicalRK4(m_fieldEquations);
00071     }
00072     else if (name=="G4ExplicitEuler") {
00073       return new G4ExplicitEuler(m_fieldEquations);
00074     }
00075     else if (name=="G4HelixExplicitEuler") {
00076       return new G4HelixExplicitEuler(m_fieldEquations);
00077     }
00078     else if (name=="G4HelixHeum") {
00079       return new G4HelixHeum(m_fieldEquations);
00080     }
00081     else if (name=="G4HelixImplicitEuler") {
00082       return new G4HelixImplicitEuler(m_fieldEquations);
00083     }
00084     else if (name=="G4HelixSimpleRunge") {
00085       return new G4HelixSimpleRunge(m_fieldEquations);
00086     }
00087     else if (name=="G4ImplicitEuler") {
00088       return new G4ImplicitEuler(m_fieldEquations);
00089     }
00090     else if (name=="G4CashKarpRKF45") {
00091       return new G4CashKarpRKF45(m_fieldEquations);
00092     }
00093     else if (name=="G4SimpleHeum") {
00094       return new G4SimpleHeum(m_fieldEquations);
00095     }
00096     else if (name=="G4SimpleRunge") {
00097       return new G4SimpleRunge(m_fieldEquations);
00098     }
00099     else {
00100       log() << LOG::error << "Unknown G4MagIntegratorStepper <" + name << ">" << LOG::done;
00101     }
00102 
00103     return 0;
00104   }
00105 }

Generated on Thu Nov 15 15:24:15 2007 for Simulator for the Linear Collider by  doxygen 1.5.4