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 |
|
24 |
fpathtodata = G4WORKDIR+"/lib/tgt_"+PLATFORM; |
25 |
fdbhost = gSystem->Getenv("PAM_DBHOST"); |
26 |
fdbuser = gSystem->Getenv("PAM_DBUSER"); |
27 |
fdbpsw = gSystem->Getenv("PAM_DBPSW"); |
28 |
fdbc = TSQLServer::Connect(fdbhost.Data(),fdbuser.Data(),fdbpsw.Data()); |
29 |
fglt = new GL_TABLES(fdbhost.Data(),fdbuser.Data(),fdbpsw.Data()); |
30 |
fglparam = new GL_PARAM(); |
31 |
fglroot = new GL_ROOT(); |
32 |
fglcalo = new GL_CALO_CALIB(); |
33 |
|
34 |
if(fdbc){ |
35 |
// |
36 |
// Use UTC in the DB and make timeout bigger |
37 |
// |
38 |
stringstream myquery; |
39 |
myquery.str(""); |
40 |
myquery << "SET time_zone='+0:00'"; |
41 |
fdbc->Query(myquery.str().c_str()); |
42 |
myquery.str(""); |
43 |
myquery << "SET wait_timeout=173000;"; |
44 |
fdbc->Query(myquery.str().c_str()); |
45 |
// |
46 |
} |
47 |
|
48 |
if ( fglt->IsConnected(fdbc) ){ |
49 |
cout<<"DB was connected.. Information:"<<endl |
50 |
<<" SQL: "<<fdbc->GetDBMS()<<endl |
51 |
<<"VERSION: "<<fdbc->ServerInfo()<<endl |
52 |
<<" HOST: "<<fdbc->GetHost()<<endl |
53 |
<<" PORT: "<<fdbc->GetPort()<<endl; |
54 |
|
55 |
} else { |
56 |
cout<<"All paths to calibration files will be load from file" |
57 |
<<fpathtodata+"/calib_path.txt"<<endl; |
58 |
|
59 |
//Here I'll implement a possibility to load paths to detector |
60 |
//calibration files to use software in GRID (without DB) |
61 |
//in this case standard directory to keep all datafiles |
62 |
//should be the library directory |
63 |
|
64 |
} |
65 |
} |