StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSimpleMagneticField.hh
1 /***************************************************************************
2  *
3  * $Id: StSimpleMagneticField.hh,v 1.7 2012/06/11 15:04:55 fisyak Exp $
4  *
5  * Author: Thomas Ullrich, May 1998
6  ***************************************************************************
7  *
8  * Description: Class is implemented as a Singleton
9  *
10  ***************************************************************************
11  *
12  * $Log: StSimpleMagneticField.hh,v $
13  * Revision 1.7 2012/06/11 15:04:55 fisyak
14  * std namespace
15  *
16  * Revision 1.6 2003/09/02 17:59:16 perev
17  * gcc 3.2 updates + WarnOff
18  *
19  * Revision 1.5 2000/01/10 23:11:29 lasiuk
20  * Include MACROS for compatibility with SUN CC5.0
21  *
22  * Revision 1.4 1999/06/16 14:26:51 fisyak
23  * Add flags for egcs on Solaris
24  *
25  * Revision 1.3 1999/03/15 13:45:59 lasiuk
26  * include SystemOfUnits from SCL
27  *
28  * Revision 1.2 1999/01/20 16:38:56 lasiuk
29  * add threevector capability
30  *
31  * Revision 1.1 1998/11/10 17:12:05 fisyak
32  * Put Brian trs versin into StRoot
33  *
34  * Revision 1.2 1998/05/20 19:00:00 ullrich
35  * Renamed getInstance() to instance().
36  *
37  * Revision 1.1 1998/05/20 14:58:25 ullrich
38  * Initial Revision
39  *
40  **************************************************************************/
41 #ifndef ST_SIMPLE_MAGNETIC_FIELD
42 #define ST_SIMPLE_MAGNETIC_FIELD
43 
44 #include <Stiostream.h>
45 
46 #if defined(__sun) && ! defined(__GNUG__)
47 #include <stdcomp.h>
48 #endif
49 #include "SystemOfUnits.h"
50 #ifndef ST_NO_NAMESPACES
51 using namespace units;
52 #endif
53 
54 #include "StMagneticField.hh"
55 
57 public:
59 
60  static StMagneticField* instance();
61  static StMagneticField* instance(const StThreeVector<double>& B);
62  static StMagneticField* instance(const char* file);
63 
64  const StThreeVector<double>& at(const StGlobalCoordinate& gc) const;
65  const StThreeVector<double>& at(const StThreeVector<double>& v) const;
66 
67 private:
70  StSimpleMagneticField(const char*);
71 
72 private:
74  static StMagneticField* mInstance;
75 };
76 
77 
78 //
79 // Inline member functions
80 //
81 
82 inline StMagneticField*
83 StSimpleMagneticField::instance()
84 {
85  if (mInstance == 0) {
86  std::cerr << "StSimpleMagneticField::getInstance(): " << endl;
87  std::cerr << "\tWARNING" << endl;
88  std::cerr << "\tNo arguments for instantiation of" << endl;
89  std::cerr << "\tsingleton class. Zero magnetic field." << endl;
90  mInstance = new StSimpleMagneticField;
91  }
92  return mInstance;
93 }
94 
95 inline const StThreeVector<double>&
96 StSimpleMagneticField::at(const StGlobalCoordinate&) const {return mB;}
97 
98 inline const StThreeVector<double>&
99 StSimpleMagneticField::at(const StThreeVector<double>&) const {return mB;}
100 #endif