10#include <mysql/mysql.h>
13#include "TBufferFile.h"
16int main(
int argc,
char** argv) {
22 char *opt_host_name=argv[1];
23 unsigned int opt_port_num = 3306;
25 char *opt_socket_name = NULL;
26 char *opt_db_name = argv[3];
27 char *opt_user_name = argv[4];
28 char *opt_password = argv[5];
30 char *opt_table_name = argv[7];
32 unsigned int opt_flags = 0;
37conn = mysql_init(NULL);
39 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
40 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
41 printf(
"connect the database ok\n");
45timenow = localtime(&now);
46printf(
"Local time is %s\n",asctime(timenow));
53 std::cout<<
"host="<<argv[1]<<std::endl;
54 std::cout<<
"path ="<<argv[6]<<std::endl;
56 std::cout<<
"11111111"<<std::endl;
57 TFile *
f=
new TFile(argv[6]);
58 TTree *qttree = (TTree*)
f-> Get(
"QtTree");
59 TBufferFile qttree_buf(TBufferFile::kWrite);
60 qttree->Streamer(qttree_buf);
62 TTree *sdtree = (TTree*)
f-> Get(
"SdTree");
63 TBufferFile sdtree_buf(TBufferFile::kWrite);
64 sdtree->Streamer(sdtree_buf);
66 TTree *t0tree = (TTree*)
f-> Get(
"T0Tree");
67 TBufferFile t0tree_buf(TBufferFile::kWrite);
68 t0tree->Streamer(t0tree_buf);
70 TTree *xttree = (TTree*)
f-> Get(
"XtTree");
71 TBufferFile xttree_buf(TBufferFile::kWrite);
72 xttree->Streamer(xttree_buf);
75char query[5024000],buf[1024*1000],buf1[1024*1000],*p,*p1;
77unsigned int from_len,from_len1;
81std::cout<<
"qttreesize"<<qttree_buf.BufferSize()<<std::endl;
82std::cout<<
"sdtree====="<<sdtree_buf.BufferSize()<<std::endl;
83std::cout<<
"t0tree====="<<t0tree_buf.BufferSize()<<std::endl;
84std::cout<<
"xttree====="<<xttree_buf.BufferSize()<<std::endl;
92 sprintf(query,
"UPDATE %s SET QtTree='",opt_table_name);
95 p= query + strlen(query);
96p += mysql_escape_string(p,qttree_buf.Buffer(),qttree_buf.BufferSize());
98 strcat(p,
"',XtTree='");
101 p= query + strlen(query);
102 p +=mysql_escape_string(p,xttree_buf.Buffer(),xttree_buf.BufferSize());
103 strcat(p,
"',T0Tree='");
105 p= query + strlen(query);
106 p +=mysql_escape_string(p,t0tree_buf.Buffer(),t0tree_buf.BufferSize());
107 strcat(p,
"',SdTree='");
109 p= query + strlen(query);
110 p +=mysql_escape_string(p,sdtree_buf.Buffer(),sdtree_buf.BufferSize());
111 strcat(p,
"' WHERE SerNo = ");
112 p= query + strlen(query);
117 status = mysql_query(conn,query);
118 printf(
"status==%d\n",status);
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)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")