24 {
25 MsgStream log(
msgSvc(), name());
26
27 char *opt_host_name = "bes3db2.ihep.ac.cn";
28
29 char *opt_user_name = "maqm";
30 char *opt_password = "maqm_offline";
31 unsigned int opt_port_num = 3306;
32 char *opt_socket_name =
NULL;
33 char *opt_db_name = "offlinedb";
34 unsigned int opt_flags = 0;
36
37
38
39
40conn = mysql_init(
NULL);
41
42 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
43 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
44 printf("connect the database ok\n");
45
46
47time_t now;
48struct tm *timenow;
49timenow = localtime(&now);
50printf("Local time is %s\n",asctime(timenow));
51
52 TFile *
f =
new TFile(
"/ihepbatch/besd12/max/bBhabha_EsTime_run6018.root");
53 cout<<"step11111111"<<endl;
54
55 TTree *Level0 = (TTree*)
f-> Get(
"h2");
56 TBufferFile Level0_buf(TBuffer::kWrite);
57 Level0->Streamer(Level0_buf);
58
59 cout<<"step22222222"<<endl;
60
61 TTree *Level1 = (TTree*)
f-> Get(
"calibconst");
62 TBufferFile Level1_buf(TBuffer::kWrite);
63 Level1->Streamer(Level1_buf);
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136char query[5024000],buf[1024*1000],buf1[1024*1000],*p,*p1;
137unsigned int from_len,from_len1;
138
139int status;
140int id =60034;
141
142
143sprintf(query,
"INSERT INTO EsTimeCalConst(SerNo,RunFrom,RunTo,EsTimeH2,EsTimeH9) VALUES(%d,'100','1000','",
id);
144
145 printf("%s\n",query);
146 p= query + strlen(query);
147p += mysql_escape_string(p,Level0_buf.Buffer(),Level0_buf.BufferSize());
148
149 strcat(p,"','");
150cout<<"strlen(query)22222222222="<<strlen(query)<<endl;
151
152 p= query + strlen(query);
153 p +=mysql_escape_string(p,Level1_buf.Buffer(),Level1_buf.BufferSize());
154 strcat(p,"')");
155 status = mysql_query(conn,query);
156 printf("%d\n",status);
157
158
159
160
161
162
163unsigned long *lengths;
164
166 MYSQL_ROW row;
167
168
169 char stmt1[200];
170 int serno =1;
171
172 sprintf(stmt1,
"select EsTimeH2,EsTimeH9,RunFrom,RunTo from TofCalConst where SerNo=%d",serno);
173
174
175 printf("%s\n",stmt1);
176 if(mysql_real_query(conn, stmt1, strlen(stmt1)) != 0)
177 printf("query error\n");
178 res_set = mysql_store_result (conn);
179 mysql_field_seek (res_set, 0);
180
181 row = mysql_fetch_row (res_set);
182 lengths = mysql_fetch_lengths(res_set);
183for(int i=0;i<8;i++){
184
185 cout<<"lengths["<<i<<"]="<<lengths[i]<<endl;
186 }
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225 return StatusCode::SUCCESS;
226}
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")
struct st_mysql_res MYSQL_RES