00001 #ifndef VERTEXDBSVC_H_ 00002 #define VERTEXDBSVC_H_ 00003 00004 #ifndef BEAN 00005 #include "GaudiKernel/IInterface.h" 00006 #include "GaudiKernel/Kernel.h" 00007 #include "GaudiKernel/Service.h" 00008 #include "GaudiKernel/IIncidentListener.h" 00009 #include "GaudiKernel/IDataProviderSvc.h" 00010 #include "VertexFit/IVertexDbSvc.h" 00011 #include <mysql.h> 00012 #include <map> 00013 #include <vector> 00014 #include "DatabaseSvc/IDatabaseSvc.h" 00015 #include "GaudiKernel/IService.h" 00016 //#include "rdbModel/Db/Connection.h" 00017 //#include "rdbModel/Tables/Assertion.h" 00018 #include "CLHEP/Matrix/Vector.h" 00019 #include "DatabaseSvc/IDatabaseSvc.h" 00020 using CLHEP::HepVector; 00021 #else 00022 #include <string> 00023 #include "DatabaseSvc/DatabaseSvc.h" 00024 #endif 00025 00026 #ifndef BEAN 00027 class VertexDbSvc: public Service, virtual public IVertexDbSvc, 00028 virtual public IIncidentListener{ 00029 public: 00030 VertexDbSvc( const std::string& name, ISvcLocator* svcloc ); 00031 ~VertexDbSvc(); 00032 00033 virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown); 00034 virtual StatusCode initialize(); 00035 virtual StatusCode finalize(); 00036 00037 // Incident handler 00038 void handle(const Incident&); 00039 00040 #else 00041 // -------------------------- BEAN ------------------------------------ 00042 class VertexDbSvc 00043 { 00044 private: 00045 VertexDbSvc(); 00046 ~VertexDbSvc(){} 00047 00048 public: 00049 static VertexDbSvc* instance() { 00050 return (m_vdb) ? m_vdb : (m_vdb = new VertexDbSvc()); 00051 } 00052 00053 const DatabaseSvc* GetDatabaseSvc() const {return m_dbsvc;} 00054 00055 void SetDbName(const std::string& _dbName) {dbName = _dbName;} 00056 std::string GetDbName() const {return dbName;} 00057 void SetBossVer(const std::string& _bossver) {m_bossver = _bossver;} 00058 std::string GetBossVer() const {return m_bossver;} 00059 void SetBossRelease(const std::string& _bossrelease) 00060 {m_bossRelease = _bossrelease;} 00061 std::string GetBossRelease() const {return m_bossRelease;} 00062 void SetVerPar(const std::string& _verpar) {m_verpar = _verpar;} 00063 std::string GetVerPar() const {return m_verpar;} 00064 00065 // New run handler 00066 void handle(int new_run); 00067 #endif 00068 00069 double * PrimaryVertex(); 00070 double * SigmaPrimaryVertex(); 00071 bool isVertexValid() {return m_isRunNumberValid;} 00072 00073 private: 00074 // common variables for BOSS & BEAN 00075 std::string dbName; 00076 std::string m_bossver; 00077 std::string m_verpar; 00078 std::string m_bossRelease; 00079 double m_primaryVertex[3]; 00080 double m_sigmaPrimaryVertex[3]; 00081 bool m_isRunNumberValid; 00082 00083 #ifndef BEAN 00084 std::string host; 00085 std::string table; 00086 std::string userName; 00087 std::string password; 00088 unsigned int serialNo; 00089 // RealDBUtil::ConnectionProvider* m_connect_offline; 00090 double m_vx; 00091 double m_vy; 00092 double m_vz; 00093 double m_sigmax; 00094 double m_sigmay; 00095 double m_sigmaz; 00096 00097 IDataProviderSvc* m_eventSvc; 00098 IDatabaseSvc* m_dbsvc; 00099 00100 StatusCode getVertexTableInfo(); 00101 #else 00102 static VertexDbSvc* m_vdb; 00103 00104 DatabaseSvc* m_dbsvc; 00105 00106 void getVertexTableInfo(int run); 00107 #endif 00108 00109 bool getReadBunchInfo(int run); 00110 }; 00111 #endif /* MDCCALIBFUNSVC_H_ */