21 MsgStream log(messageService(), name());
24 StatusCode sc = serviceLocator()->service(
"DatabaseSvc",m_dbsvc,
true);
25 if (sc .isFailure() ) {
26 log << MSG::ERROR <<
"Unable to find DatabaseSvc " << endreq;
30 std::cout <<
"*************************************************************" << std::endl;
31 std::cout <<
"Test 1: Numbers" << std::endl;
32 std::cout <<
"*************************************************************" << std::endl;
35 sprintf(stmt,
"select Vx, Vy, Vz, SigmaVx, SigmaVy, SigmaVz,RunNo from BeamPar where RunNo > 9950 and RunNo < 9980 and SftVer='6.5.1'");
39 row_no = m_dbsvc->
query(
"offlinedb",stmt,res);
41 std::cerr <<
"Query \"" << stmt <<
"\" failed" << std::endl;
42 return StatusCode::FAILURE;
50 for (row=0;row<row_no;row++){
52 sscanf(records[
"Vx"],
"%lf", &vx);
53 sscanf(records[
"SigmaVx"],
"%lf", &svx);
54 cout <<
"Read from DB: RunNo " << records[
"RunNo"] <<
" Vx= " << vx <<
" SigmaVx= " << svx << endl;
55 cout <<
" " << records.
GetLong(
"RunNo") <<
" Vx= " << records.
GetDouble(
"Vx") <<
" SigmaVx= " << records.
GetDouble(
"SigmaVx") << endl;
59 std::cout <<
"*************************************************************" << std::endl;
60 std::cout <<
"Test 2: BLOBs" << std::endl;
61 std::cout <<
"*************************************************************" << std::endl;
64 sprintf(stmt,
"select EndTofPar,BarTofPar from TofCalConst where RunFrom <= 11000 and RunTo >= 11000 and SftVer='6.5.1'");
65 row_no = m_dbsvc->
query(
"offlinedb", stmt, res);
67 std::cerr <<
"Query \"" << stmt <<
"\" failed" << std::endl;
68 return StatusCode::FAILURE;
70 for (row=0;row<row_no;row++)
74 TBufferFile *buf1 =
new TBufferFile(TBuffer::kRead);
75 buf1->SetBuffer(records[
"EndTofPar"],32768,kFALSE);
76 TTree* curvetree =
new TTree();
77 curvetree->Streamer(*buf1);
84 int entries=curvetree->GetEntries();
85 if(entries>10) entries = 10;
86 for(
int iiii=0; iiii<entries;iiii++)
88 curvetree->GetEntry(iiii);
89 for(
int jjj=0;jjj<5;jjj++){
90 std::cout<<
"cnvAtten["<<jjj<<
"]="<<cnvAtten[jjj]<<
" ";
98 std::cout <<
"*************************************************************" << std::endl;
99 std::cout <<
"Test 3: Strings" << std::endl;
100 std::cout <<
"*************************************************************" << std::endl;
103 sprintf(stmt,
"select XtTree,QtTree,T0Tree,SdTree,RunFrom,RunTo,CalParVer,FileName from MdcCalConst where SftVer = '6.5.3'");
104 row_no = m_dbsvc->
query(
"offlinedb",stmt,res);
106 std::cerr <<
"Query \"" << stmt <<
"\" failed" << std::endl;
107 return StatusCode::FAILURE;
110 for (row=0;row<row_no;row++){
112 cout <<
"Read from DB: Runs " << records[
"RunFrom"] <<
" " << records[
"RunTo"] <<
" FileName = " << records[
"FileName"] << endl;
116 return StatusCode::SUCCESS;