7#include <mysql/mysql.h>
12#include "TBufferFile.h"
16int main(
int argc,
char** argv) {
17 const char *opt_host_name =
"202.122.37.69";
19 const char *opt_user_name =
"maqm";
20 const char *opt_socket_name = NULL;
21 const char *opt_db_name =
"offlinedb";
22 const char *opt_table_name =
"MdcCalConst";
23 static char query[80240000];
24 unsigned int opt_port_num = 3306;
25 unsigned int opt_flags = 0;
31 conn = mysql_init(NULL);
33 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
34 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
37 std::cout<<
"connect the database ok\n"<<std::endl;
39 std::cout<<
"can't connect to the db:"<<std::endl;
43 unsigned long *lengths;
49 sprintf(stmt1,
"select NewXtTrees from MdcCalConst where serno = 414");
52 if(mysql_real_query(conn, stmt1, strlen(stmt1)) != 0)
53 printf(
"query error\n");
54 res_set = mysql_store_result (conn);
55 mysql_field_seek (res_set, 0);
57 row = mysql_fetch_row (res_set);
58 lengths = mysql_fetch_lengths(res_set);
63 TBufferFile rootBuffer2(TBufferFile::kRead,lengths[0], row[0], kFALSE);
65 std::cout <<
"buffer length=" << lengths[0] << std::endl;
68 array.Streamer(rootBuffer2);
69 std::cout<< __FILE__ <<
" " << __LINE__ <<
" array size "<<array.GetSize()
70 <<
" entry="<<array.GetEntries()<<std::endl;
76 for(
int t_layer=0; t_layer<43; t_layer++){
77 for(
int t_entr=0; t_entr<18; t_entr++){
78 for(
int t_lr=0; t_lr<2; t_lr++){
79 std::cout<<
"trNewXt"<<t_layer<<
"_"<<t_entr<<
"_"<<t_lr<<
" "<<iTree<<
" name "<<((TTree*)array.At(iTree))->GetName()<<std::endl;
81 std::cout << ((TTree*)array.At(iTree))->GetName() << std::endl;
struct st_mysql_res MYSQL_RES
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)