CheckMYSQL Class Reference

#include <CheckMySQL.h>

List of all members.

Public Member Functions

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


Detailed Description

Definition at line 51 of file CheckMySQL.h.


Constructor & Destructor Documentation

CheckMYSQL::CheckMYSQL ( const std::string name,
ISvcLocator *  pSvcLocator 
)

Definition at line 4 of file CheckMySQL.cxx.

00006   : Algorithm     ( name, pSvcLocator )
00007 {
00008   // Declare properties here.
00009 
00010 }


Member Function Documentation

StatusCode CheckMYSQL::execute (  ) 

Definition at line 24 of file CheckMySQL.cxx.

References genRecEmupikp::i, and msgSvc().

00024                                 {
00025    MsgStream log(msgSvc(), name());
00026  // int i;
00027  char *opt_host_name = "bes3db2.ihep.ac.cn";   
00028 // char *opt_host_name = "koala.ihep.ac.cn";
00029  char *opt_user_name = "maqm";   
00030  char *opt_password  = "maqm_offline";   
00031  unsigned int opt_port_num = 3306;   
00032  char *opt_socket_name = NULL;   
00033  char *opt_db_name = "offlinedb";   
00034  unsigned int opt_flags = 0;   
00035  MYSQL *conn;   
00036 
00037 
00038     
00039 // calibUtil::Metadata *meta = new calibUtil::Metadata(opt_host_name, "*",opt_db_name);
00040 conn = mysql_init(NULL);   
00041      
00042  mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password, 
00043                    opt_db_name, opt_port_num, opt_socket_name, opt_flags);
00044  printf("connect the database ok\n");
00045 
00046 
00047 time_t now;
00048 struct tm  *timenow;
00049 timenow = localtime(&now);
00050 printf("Local time is %s\n",asctime(timenow));
00051 
00052    TFile *f = new TFile("/ihepbatch/besd12/max/bBhabha_EsTime_run6018.root");
00053    cout<<"step11111111"<<endl;
00054    
00055    TTree *Level0 =  (TTree*)f-> Get("h2");
00056    TBufferFile Level0_buf(TBuffer::kWrite);
00057    Level0->Streamer(Level0_buf); 
00058 
00059    cout<<"step22222222"<<endl;
00060 
00061    TTree *Level1 =  (TTree*)f-> Get("calibconst");
00062    TBufferFile Level1_buf(TBuffer::kWrite);
00063    Level1->Streamer(Level1_buf); 
00064 
00065 
00066 /*
00067    TH1F* LayerCntMap_1 = (TH1F*)f->Get("LayerCntMap");
00068 //   TH1F* LayerCntMap = new TH1F((TH1F)f->Get("LayerCntMap"));
00069 //   LayerCntMap->Copy(f->Get("LayerCntMap"));
00070 //   const double* con = LayerCntMap_1->GetBuffer();
00071 //   int size = LayerCntMap_1->GetBufferSize();
00072    std::cout<<""step5555555555"<<std::endl;
00073    TAxis* xaxis =  LayerCntMap_1->GetXaxis();
00074     double xmin = xaxis->GetXmin();
00075     double xmax = xaxis->GetXmax();
00076     double xbins = xaxis->GetNbins();
00077     std::cout<<""step6666666"<<std::endl;
00078     std::cout<<"xbins=="<<xbins<<"xmin=="<<xmin<<"xmax=="<<xmax<<std::endl;
00079    TH1F* LayerCntMap = new TH1F("LayerCntMap","LayerCntMap",xbins,xmin,xmax);
00080    for(int i=0;i<size;i++){
00081      LayerCntMap->Fill(con[i]);
00082    }
00083    
00084    TBuffer LayerCntMap_buf(TBuffer::kWrite);
00085    LayerCntMap->Copy(*(f->Get("LayerCntMap")));
00086    LayerCntMap->Streamer(LayerCntMap_buf);
00087    std::cout<<"55555555555555"<<std::endl;
00088    f->Close();
00089    TFile* check = new TFile("check.root","recreate");
00090 //   LayerCntMap->Write();
00091    check->Write();
00092 */
00093 /*   int size = 4096; 
00094    int bins = 10; 
00095    int xmin = 0; 
00096    int xmax = 10; 
00097    TH1F* histogramU16_ = new TH1F ("histogramU16_", "U16 data", bins, xmin, xmax); 
00098    histogramU16_->SetBit (TH1::kCanRebin); // allow automatic rebinning 
00099 
00100    for (int i = 0; i < 10; i++) { 
00101      histogramU16_->Fill(i); 
00102    } 
00103    
00104    char buffer[1024000]; 
00105    TBuffer LayerCntMap_buf(TBuffer::kWrite, 1024000, buffer, true);  
00106    std::cout<<"aaaaaaaaa"<<std::endl;
00107    histogramU16_->Streamer(LayerCntMap_buf); 
00108 
00109    cout<<"step55555555555"<<endl;
00110    TH1F* BoxCntMap = (TH1F*)f->Get("BoxCntMap");
00111    char buffer_1[52400];
00112    TBuffer BoxCntMap_buf(TBuffer::kWrite,524000,buffer_1,true);
00113    BoxCntMap->Streamer(BoxCntMap_buf); 
00114          
00115    cout<<"step66666666"<<std::endl;   
00116    TH1F* StripCntMap = (TH1F*)f->Get("StripCntMap");
00117    char buffer_2[52400];
00118    TBuffer StripCntMap_buf(TBuffer::kWrite,524000,buffer_2,true);
00119    StripCntMap->Streamer(StripCntMap_buf); 
00120     cout<<"step7777777777"<<std::endl;
00121   
00122    TH1F* LayerProMap = (TH1F*)f->Get("LayerProMap");
00123     char buffer_3[52400];
00124    TBuffer LayerProMap_buf(TBuffer::kWrite,524000,buffer_3,true);
00125    LayerProMap->Streamer(LayerProMap_buf); 
00126              
00127    cout<<"step88888888888888"<<std::endl;
00128    
00129    TH1F* BoxProMap = (TH1F*)f->Get("BoxProMap");
00130    char buffer_4[52400];
00131    TBuffer BoxProMap_buf(TBuffer::kWrite,524000,buffer_4,true);
00132    BoxProMap->Streamer(BoxProMap_buf); 
00133 
00134     cout<<"step9999999999999"<<std::endl;
00135    */ 
00136 char  query[5024000],buf[1024*1000],buf1[1024*1000],*p,*p1;
00137 unsigned int from_len,from_len1;
00138 
00139 int status;
00140 int id =60034;
00141 
00142 
00143 sprintf(query,"INSERT INTO  EsTimeCalConst(SerNo,RunFrom,RunTo,EsTimeH2,EsTimeH9) VALUES(%d,'100','1000','",id);
00144 
00145         printf("%s\n",query);
00146         p= query + strlen(query);
00147 p += mysql_escape_string(p,Level0_buf.Buffer(),Level0_buf.BufferSize());
00148 
00149         strcat(p,"','");
00150 cout<<"strlen(query)22222222222="<<strlen(query)<<endl;
00151      
00152      p= query + strlen(query);
00153      p +=mysql_escape_string(p,Level1_buf.Buffer(),Level1_buf.BufferSize());
00154         strcat(p,"')");
00155          status = mysql_query(conn,query);
00156          printf("%d\n",status);
00157 
00158 
00159 
00160 
00161 //cout<<"status================"<<status<<endl;
00162 
00163 unsigned long *lengths;
00164  
00165  MYSQL_RES *res_set;
00166  MYSQL_ROW row;
00167 
00168 //char *p1;
00169  char stmt1[200];//="select context from mytesttable where id = %d,";
00170  int serno =1;
00171 // sprintf(stmt1,"select BarTofPar,EndTofPar,RunFrom,RunTo from TofCalConst where SerNo=%d",serno);
00172  sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo from TofCalConst where SerNo=%d",serno);
00173 
00174 // char stmt1[100]="select  tree1,tree2 from TofCalConst where ser_no = 10026"; 
00175  printf("%s\n",stmt1);
00176  if(mysql_real_query(conn, stmt1, strlen(stmt1)) != 0)
00177   printf("query error\n");
00178  res_set = mysql_store_result (conn);
00179  mysql_field_seek (res_set, 0); 
00180 
00181  row = mysql_fetch_row (res_set);
00182  lengths = mysql_fetch_lengths(res_set);
00183 for(int i=0;i<8;i++){ 
00184 // cout<<"size of row["<<i<<"]"<<sizeof(row[i])<<endl;
00185   cout<<"lengths["<<i<<"]="<<lengths[i]<<endl;
00186   }
00187 /*
00188 //string ss(row[0]);
00189 //const char *pp = ss.c_str();
00190 
00191  TTree* newHist= new TTree(); 
00192   TBuffer rootBuffer2(TBuffer::kRead,lengths[0], row[0], kFALSE); 
00193 //  TBuffer rootBuffer2(TBuffer::kRead,lengths[0], void pp, kFALSE); 
00194  newHist->Streamer(rootBuffer2); 
00195    newHist->Print(); 
00196   int  nentri = newHist -> GetEntries();*/
00197 //  double xtpar;
00198 //  int xtkey;
00199 /*double atten,w3;
00200   newHist -> SetBranchAddress("Atten", &atten);
00201   newHist -> SetBranchAddress("W3", &w3);
00202   cout<<"nentri="<<nentri<<endl;
00203   for(int ii=0;ii<nentri;ii++){
00204     newHist->GetEntry(ii);
00205     cout<<"Atten="<<atten<<"W3="<<w3<<endl;
00206   }
00207   */  
00208 /* TTree* newHist1= new TTree(); 
00209   TBuffer rootBuffer3(TBuffer::kRead,lengths[1], row[1], kFALSE); 
00210   newHist1->Streamer(rootBuffer3); 
00211    newHist1->Print(); 
00212   int  nentri1 = newHist1 -> GetEntries();
00213 //  double xtpar;
00214 //  int xtkey;
00215 //double atten,w3;
00216   double p6;
00217   newHist1 -> SetBranchAddress("Atten", &atten);
00218   newHist1 -> SetBranchAddress("P6", &p6);
00219   cout<<"nentri1="<<nentri1<<endl;
00220   for(int ii=0;ii<nentri1;ii++){
00221     newHist1->GetEntry(ii);
00222     cout<<"Atten="<<atten<<"P6="<<p6<<endl;
00223   }
00224   */  
00225    return StatusCode::SUCCESS;
00226 }

StatusCode CheckMYSQL::finalize (  ) 

Definition at line 227 of file CheckMySQL.cxx.

References Bes_Common::INFO, and msgSvc().

00227                                  {
00228 
00229   MsgStream log(msgSvc(), name());
00230   log << MSG::INFO 
00231       << "        CheckMYSQL FINALIZE!! "
00232       << endreq;
00233   
00234   return StatusCode::SUCCESS;
00235 }

StatusCode CheckMYSQL::initialize (  ) 

Definition at line 13 of file CheckMySQL.cxx.

References Bes_Common::INFO, and msgSvc().

00013                                   {
00014   StatusCode sc;
00015   MsgStream log(msgSvc(), name());
00016   log << MSG::INFO << "Initialize()" << endreq;
00017   
00018 
00019  return StatusCode::SUCCESS;
00020 
00021 }


Generated on Tue Nov 29 23:18:07 2016 for BOSS_7.0.2 by  doxygen 1.4.7