16 {
17 const char *opt_host_name = "202.122.37.69";
18
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;
26 char *p;
27 int status=-1;
28
29
31 conn = mysql_init(NULL);
32
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);
35
36 if(conn!=0){
37 std::cout<<"connect the database ok\n"<<std::endl;
38 }else{
39 std::cout<<"can't connect to the db:"<<std::endl;
40 return -1;
41 }
42
43 unsigned long *lengths;
44
46 MYSQL_ROW row;
47
48 char stmt1[200];
49 sprintf(stmt1,
"select NewXtTrees from MdcCalConst where serno = 414");
50
51 printf("%s\n",stmt1);
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);
56
57 row = mysql_fetch_row (res_set);
58 lengths = mysql_fetch_lengths(res_set);
59
60
61
62
63 TBufferFile rootBuffer2(TBufferFile::kRead,lengths[0], row[0], kFALSE);
64 gROOT->cd();
65 std::cout << "buffer length=" << lengths[0] << std::endl;
66
67 TObjArray array;
68 array.Streamer(rootBuffer2);
69 std::cout<< __FILE__ << " " << __LINE__ << " array size "<<array.GetSize()
70 <<" entry="<<array.GetEntries()<<std::endl;
71
72
73
74
75 int iTree = 0;
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;
80 iTree++;
81 std::cout << ((TTree*)array.At(iTree))->GetName() << std::endl;
82 }
83 }
84 }
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 return 0;
109}
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)