00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef ST_SIMPLE_MAGNETIC_FIELD
00039 #define ST_SIMPLE_MAGNETIC_FIELD
00040
00041 #include <Stiostream.h>
00042
00043 #if defined(__sun) && ! defined(__GNUG__)
00044 #include <stdcomp.h>
00045 #endif
00046 #include "SystemOfUnits.h"
00047 #ifndef ST_NO_NAMESPACES
00048 using namespace units;
00049 #endif
00050
00051 #include "StMagneticField.hh"
00052
00053 class StSimpleMagneticField : public StMagneticField {
00054 public:
00055 ~StSimpleMagneticField();
00056
00057 static StMagneticField* instance();
00058 static StMagneticField* instance(const StThreeVector<double>& B);
00059 static StMagneticField* instance(const char* file);
00060
00061 const StThreeVector<double>& at(const StGlobalCoordinate& gc) const;
00062 const StThreeVector<double>& at(const StThreeVector<double>& v) const;
00063
00064 private:
00065 StSimpleMagneticField();
00066 StSimpleMagneticField(const StThreeVector<double>&);
00067 StSimpleMagneticField(const char*);
00068
00069 private:
00070 StThreeVector<double> mB;
00071 static StMagneticField* mInstance;
00072 };
00073
00074
00075
00076
00077
00078
00079 inline StMagneticField*
00080 StSimpleMagneticField::instance()
00081 {
00082 if (mInstance == 0) {
00083 cerr << "StSimpleMagneticField::getInstance(): " << endl;
00084 cerr << "\tWARNING" << endl;
00085 cerr << "\tNo arguments for instantiation of" << endl;
00086 cerr << "\tsingleton class. Zero magnetic field." << endl;
00087 mInstance = new StSimpleMagneticField;
00088 }
00089 return mInstance;
00090 }
00091
00092 inline const StThreeVector<double>&
00093 StSimpleMagneticField::at(const StGlobalCoordinate&) const {return mB;}
00094
00095 inline const StThreeVector<double>&
00096 StSimpleMagneticField::at(const StThreeVector<double>&) const {return mB;}
00097 #endif