Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TestDbAlg Class Reference

#include <TestDbAlg.h>

List of all members.

Public Member Functions

StatusCode execute ()
StatusCode execute ()
StatusCode finalize ()
StatusCode finalize ()
StatusCode initialize ()
StatusCode initialize ()
 TestDbAlg (const std::string &name, ISvcLocator *pSvcLocator)
 TestDbAlg (const std::string &name, ISvcLocator *pSvcLocator)


Constructor & Destructor Documentation

TestDbAlg::TestDbAlg const std::string &  name,
ISvcLocator *  pSvcLocator
 

00015                                                                     : Algorithm(name, pSvcLocator){
00016 }

TestDbAlg::TestDbAlg const std::string &  name,
ISvcLocator *  pSvcLocator
 


Member Function Documentation

StatusCode TestDbAlg::execute  ) 
 

StatusCode TestDbAlg::execute  ) 
 

00119                               {
00120   MsgStream log(msgSvc(), name());
00121   
00122   log << "TestDbAlg execute()" << endl;
00123 
00124   return StatusCode::SUCCESS;
00125 }

StatusCode TestDbAlg::finalize  ) 
 

StatusCode TestDbAlg::finalize  ) 
 

00129                                {
00130   return StatusCode::SUCCESS;
00131 }

StatusCode TestDbAlg::initialize  ) 
 

StatusCode TestDbAlg::initialize  ) 
 

00020                                 {
00021   MsgStream log(messageService(), name());
00022 
00023   IDatabaseSvc* m_dbsvc;
00024   StatusCode  sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
00025   if (sc .isFailure() ) {
00026     log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
00027     return sc;
00028   }
00029 
00030   std::cout << "*************************************************************" << std::endl;
00031   std::cout << "Test 1: Numbers" << std::endl;
00032   std::cout << "*************************************************************" << std::endl;
00033 
00034   char stmt[255];
00035   sprintf(stmt,"select Vx, Vy, Vz, SigmaVx, SigmaVy, SigmaVz,RunNo from BeamPar where RunNo > 9950 and RunNo < 9980 and SftVer='6.5.1'");
00036 
00037  DatabaseRecordVector res;
00038  int row_no;
00039  row_no = m_dbsvc->query("offlinedb",stmt,res);
00040  if(row_no<0){
00041    std::cerr << "Query \"" << stmt << "\" failed" << std::endl;
00042    return StatusCode::FAILURE;
00043  }
00044 
00045  int row;
00046  double vx, svx;
00047  vx = 0;
00048  svx = 0;
00049 
00050  for (row=0;row<row_no;row++){
00051    DatabaseRecord& records = *res[row];
00052    sscanf(records["Vx"], "%lf", &vx);
00053    sscanf(records["SigmaVx"], "%lf", &svx);
00054    cout << "Read from DB: RunNo " << records["RunNo"] << " Vx= " << vx << " SigmaVx= " << svx << endl;
00055    cout << "                    " << records.GetLong("RunNo") << " Vx= " << records.GetDouble("Vx") << " SigmaVx= " << records.GetDouble("SigmaVx") << endl;
00056  }
00057  
00058  // Check BLOBs
00059  std::cout << "*************************************************************" << std::endl;
00060  std::cout << "Test 2: BLOBs" << std::endl;
00061  std::cout << "*************************************************************" << std::endl;
00062 
00063  res.clear();
00064  sprintf(stmt,"select EndTofPar,BarTofPar from TofCalConst where RunFrom <= 11000 and RunTo >= 11000 and SftVer='6.5.1'");
00065  row_no = m_dbsvc->query("offlinedb", stmt, res);
00066  if(row_no<0){
00067    std::cerr << "Query \"" << stmt << "\" failed" << std::endl;
00068    return StatusCode::FAILURE;
00069  }
00070  for (row=0;row<row_no;row++)
00071    {
00072      DatabaseRecord& records = *res[row]; 
00073      TBuffer *buf1 = new TBuffer(TBuffer::kRead);
00074      buf1->SetBuffer(records["EndTofPar"],32768,kFALSE);
00075      TTree* curvetree = new TTree();
00076      curvetree->Streamer(*buf1);
00077      double cnvAtten[8];
00078      curvetree -> SetBranchAddress("Atten0", &cnvAtten[0]);
00079      curvetree -> SetBranchAddress("Atten1", &cnvAtten[1]);
00080      curvetree -> SetBranchAddress("Atten2", &cnvAtten[2]);
00081      curvetree -> SetBranchAddress("Atten3", &cnvAtten[3]);
00082      curvetree -> SetBranchAddress("Atten4", &cnvAtten[4]);
00083      int entries=curvetree->GetEntries();
00084      if(entries>10) entries = 10;
00085      for(int iiii=0; iiii<entries;iiii++)
00086        {
00087          curvetree->GetEntry(iiii);
00088          for(int jjj=0;jjj<5;jjj++){
00089            std::cout<<"cnvAtten["<<jjj<<"]="<<cnvAtten[jjj]<<" ";
00090          }
00091          std::cout<<std::endl;
00092        }
00093    }
00094 
00095  //sleep(600);
00096  // Test strings
00097  std::cout << "*************************************************************" << std::endl;
00098  std::cout << "Test 3: Strings" << std::endl;
00099  std::cout << "*************************************************************" << std::endl;
00100 
00101  res.clear();
00102  sprintf(stmt,"select XtTree,QtTree,T0Tree,SdTree,RunFrom,RunTo,CalParVer,FileName from MdcCalConst where SftVer = '6.5.3'");
00103  row_no = m_dbsvc->query("offlinedb",stmt,res);
00104  if(row_no<0){
00105    std::cerr << "Query \"" << stmt << "\" failed" << std::endl;
00106    return StatusCode::FAILURE;
00107  }
00108  
00109  for (row=0;row<row_no;row++){
00110    DatabaseRecord& records = *res[row];
00111    cout << "Read from DB: Runs " << records["RunFrom"] << " " << records["RunTo"] << " FileName = " << records["FileName"] << endl;
00112  }
00113 
00114  
00115  return StatusCode::SUCCESS;
00116 }


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 18:52:08 2011 for BOSS6.5.5 by  doxygen 1.3.9.1