MagField.cxx

Go to the documentation of this file.
00001 #include "AtlfastEvent/MagField.h" 
00002 #include <iostream>
00003 
00004 namespace Atlfast{
00005 
00006   MagField* MagField::m_instance = 0;
00007 
00008   MagField::MagField(double str) : m_strength(str) {}
00009   
00010   MagField* MagField::Instance(){
00011     return Instance(0);
00012   }
00013   
00014   MagField* MagField::Instance(double str) {
00015     
00016     // User gets the MagField singleton using Instance(),
00017     // so the default 0 is passed as argument. If a finite argument is
00018     // passed, it is assumed the user wants a new MagField with this
00019     // field strength.
00020 
00021     if ( m_instance != 0 && str ){
00022       
00023       std::cout << "MagField instance already exists with field strength "
00024                 << m_instance->strength() << ", using that" << std::endl;
00025     }
00026     
00027     if ( m_instance == 0 ){
00028       m_instance = new MagField(str);
00029     }
00030     
00031     return m_instance;
00032     
00033   }
00034   
00035   bool MagField::is_on() const {
00036     
00037     return m_strength ? true : false;
00038     
00039   }
00040   
00041   double MagField::strength() const {
00042     
00043     return m_strength;
00044     
00045   }
00046 
00047 }

Generated on Fri Sep 21 13:00:10 2007 for AtlfastEvent by  doxygen 1.5.1