1 |
#include <iostream> |
2 |
#include <TString.h> |
3 |
#include "PamVMCSQLMgr.h" |
4 |
|
5 |
|
6 |
using std::cout; |
7 |
using std::endl; |
8 |
|
9 |
PamVMCSQLMgr * PamVMCSQLMgr::fsql = 0; |
10 |
|
11 |
PamVMCSQLMgr * PamVMCSQLMgr::Instance(){ |
12 |
|
13 |
if(fsql == 0) { |
14 |
fsql = new PamVMCSQLMgr(); |
15 |
} |
16 |
return fsql; |
17 |
} |
18 |
|
19 |
PamVMCSQLMgr::PamVMCSQLMgr(){ |
20 |
|
21 |
TString G4WORKDIR=gSystem->Getenv("G4WORKDIR"); |
22 |
TString PLATFORM=gSystem->Getenv("PLATFORM"); |
23 |
TString PAM_VMC=gSystem->Getenv("PAM_VMC"); |
24 |
|
25 |
fpathtodata = PAM_VMC+"/lib/tgt_"+PLATFORM; |
26 |
fdbhost = gSystem->Getenv("PAM_DBHOST"); |
27 |
fdbuser = gSystem->Getenv("PAM_DBUSER"); |
28 |
fdbpsw = gSystem->Getenv("PAM_DBPSW"); |
29 |
fdbc = TSQLServer::Connect(fdbhost.Data(),fdbuser.Data(),fdbpsw.Data()); |
30 |
fglt = new GL_TABLES(fdbhost.Data(),fdbuser.Data(),fdbpsw.Data()); |
31 |
fglparam = new GL_PARAM(); |
32 |
fglroot = new GL_ROOT(); |
33 |
fglcalo = new GL_CALO_CALIB(); |
34 |
|
35 |
if(fdbc){ |
36 |
// |
37 |
// Use UTC in the DB and make timeout bigger |
38 |
// |
39 |
stringstream myquery; |
40 |
myquery.str(""); |
41 |
myquery << "SET time_zone='+0:00'"; |
42 |
fdbc->Query(myquery.str().c_str()); |
43 |
myquery.str(""); |
44 |
myquery << "SET wait_timeout=173000;"; |
45 |
fdbc->Query(myquery.str().c_str()); |
46 |
// |
47 |
} |
48 |
|
49 |
if ( fglt->IsConnected(fdbc) ){ |
50 |
cout<<"DB was connected.. Information:"<<endl |
51 |
<<" SQL: "<<fdbc->GetDBMS()<<endl |
52 |
<<"VERSION: "<<fdbc->ServerInfo()<<endl |
53 |
<<" HOST: "<<fdbc->GetHost()<<endl |
54 |
<<" PORT: "<<fdbc->GetPort()<<endl; |
55 |
|
56 |
} else { |
57 |
cout<<"All paths to calibration files will be load from file" |
58 |
<<fpathtodata+"/calib_path.txt"<<endl; |
59 |
|
60 |
//Here I'll implement a possibility to load paths to detector |
61 |
//calibration files to use software in GRID (without DB) |
62 |
//in this case standard directory to keep all datafiles |
63 |
//should be the library directory |
64 |
|
65 |
} |
66 |
} |