00001 // $Id: MagneticFieldSvc.h,v 1.27 2009/01/26 12:45:44 cattanem Exp $ 00002 #ifndef MAGNETICFIELDSVC_H 00003 #define MAGNETICFIELDSVC_H 1 00004 00005 // Include files 00006 #include "Kernel/ILHCbMagnetSvc.h" 00007 #include "DetDesc/Condition.h" 00008 00009 #include "GaudiKernel/Vector3DTypes.h" 00010 #include "GaudiKernel/Point3DTypes.h" 00011 #include "GaudiKernel/Service.h" 00012 00013 #include <vector> 00014 #include <string> 00015 00016 // Forward declarations 00017 template <class TYPE> class SvcFactory; 00018 class IToolSvc; 00019 class IUpdateManagerSvc; 00020 class IMagFieldTool; 00021 00032 class MagneticFieldSvc : public Service, 00033 virtual public ILHCbMagnetSvc { 00034 00035 protected: 00036 00040 MagneticFieldSvc( const std::string& name, ISvcLocator* svc ); 00041 00043 virtual ~MagneticFieldSvc(); 00044 00045 public: 00046 00048 virtual StatusCode initialize(); 00049 00051 virtual StatusCode finalize(); 00052 00058 virtual StatusCode queryInterface( const InterfaceID& riid, 00059 void** ppvInterface ); 00060 00066 virtual StatusCode fieldVector( const Gaudi::XYZPoint& xyz, 00067 Gaudi::XYZVector& fvec ) const; 00068 00069 bool useRealMap() const; 00070 double scaleFactor() const { return m_scaleFactor; } 00071 00072 private: 00073 00075 friend class SvcFactory<MagneticFieldSvc>; 00076 StatusCode initializeWithCondDB(); 00077 StatusCode initializeWithoutCondDB(); 00078 00079 StatusCode i_updateConditions(); 00080 StatusCode updateTool( int polarity ); 00081 00082 // Properties to configure the service 00083 bool m_UseConditions; 00084 bool m_UseSetCurrent; 00085 double m_nominalCurrent; 00086 std::string m_mapFilePath; 00087 00088 // Special properties to use constant field (and no condDB!) 00089 bool m_useConstField; 00090 std::vector<double> m_constFieldVector; 00091 00092 // Properties to over-ride values in CondDB 00093 std::vector<std::string> m_mapFileNames; 00094 int m_polarity; 00095 double m_scaleFactor; 00096 00097 // Private data 00098 bool m_mapFromOptions; 00099 bool m_scaleFromOptions; 00100 00101 Condition* m_mapFilesUpPtr; 00102 Condition* m_mapFilesDownPtr; 00103 Condition* m_scaleUpPtr; 00104 Condition* m_scaleDownPtr; 00105 Condition* m_currentPtr; 00106 00107 IMagFieldTool* m_fieldTool; 00108 IMagFieldTool* m_DC06FieldUp; 00109 IMagFieldTool* m_DC06FieldDown; 00110 IMagFieldTool* m_RealFieldUp; 00111 IMagFieldTool* m_RealFieldDown; 00112 00113 IUpdateManagerSvc* m_updMgrSvc; 00114 IToolSvc* m_toolSvc; 00115 00116 // Following are obsolete, will be removed soon 00117 bool m_useRealMap; 00118 std::string m_filename; 00119 std::string m_qfilename[4]; 00120 std::string m_condPath; 00121 00122 }; 00123 00124 #endif // MAGNETICFIELDSVC_H