16 {
17
18
19
20
21
22 char *opt_host_name=argv[1];
23 unsigned int opt_port_num = 3306;
24
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];
29
30 char *opt_table_name = argv[7];
31
32 unsigned int opt_flags = 0;
34
35
36
37conn = mysql_init(NULL);
38
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");
42
43time_t now;
44struct tm *timenow;
45timenow = localtime(&now);
46printf("Local time is %s\n",asctime(timenow));
47
48
49
50
51
52
53 std::cout<<"host="<<argv[1]<<std::endl;
54 std::cout<<"path ="<<argv[6]<<std::endl;
55
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);
61
62 TTree *sdtree = (TTree*)
f-> Get(
"SdTree");
63 TBufferFile sdtree_buf(TBufferFile::kWrite);
64 sdtree->Streamer(sdtree_buf);
65
66 TTree *t0tree = (TTree*)
f-> Get(
"T0Tree");
67 TBufferFile t0tree_buf(TBufferFile::kWrite);
68 t0tree->Streamer(t0tree_buf);
69
70 TTree *xttree = (TTree*)
f-> Get(
"XtTree");
71 TBufferFile xttree_buf(TBufferFile::kWrite);
72 xttree->Streamer(xttree_buf);
73
74
75char query[5024000],buf[1024*1000],buf1[1024*1000],*p,*p1;
76char query1[5024];
77unsigned int from_len,from_len1;
78
79int status=-1;
80int id =10;
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;
85
86
87
88
89
90
91
92 sprintf(query,
"UPDATE %s SET QtTree='",opt_table_name);
93
94 printf("%s\n",query);
95 p= query + strlen(query);
96p += mysql_escape_string(p,qttree_buf.Buffer(),qttree_buf.BufferSize());
97
98 strcat(p,"',XtTree='");
99
100
101 p= query + strlen(query);
102 p +=mysql_escape_string(p,xttree_buf.Buffer(),xttree_buf.BufferSize());
103 strcat(p,"',T0Tree='");
104
105 p= query + strlen(query);
106 p +=mysql_escape_string(p,t0tree_buf.Buffer(),t0tree_buf.BufferSize());
107 strcat(p,"',SdTree='");
108
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);
114 strcat(p,query1);
115
116
117 status = mysql_query(conn,query);
118 printf("status==%d\n",status);
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 return 0;
160}
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")