17 {
18 MsgStream log(
msgSvc(), name() );
19
20 char* opt_host_name = "bes3db2.ihep.ac.cn";
21
22 char* opt_user_name = "maqm";
23 char* opt_password = "maqm_offline";
24 unsigned int opt_port_num = 3306;
25 char* opt_socket_name = NULL;
26 char* opt_db_name = "offlinedb";
27 unsigned int opt_flags = 0;
29
30
31 conn = mysql_init( NULL );
32
33 mysql_real_connect( conn, opt_host_name, opt_user_name, opt_password, opt_db_name,
34 opt_port_num, opt_socket_name, opt_flags );
35 printf( "connect the database ok\n" );
36
37 time_t now;
38 struct tm* timenow;
39 timenow = localtime( &now );
40 printf( "Local time is %s\n", asctime( timenow ) );
41
42 TFile*
f =
new TFile(
"/ihepbatch/besd12/max/bBhabha_EsTime_run6018.root" );
43 cout << "step11111111" << endl;
44
45 TTree* Level0 = (TTree*)
f->Get(
"h2" );
46 TBufferFile Level0_buf( TBuffer::kWrite );
47 Level0->Streamer( Level0_buf );
48
49 cout << "step22222222" << endl;
50
51 TTree* Level1 = (TTree*)
f->Get(
"calibconst" );
52 TBufferFile Level1_buf( TBuffer::kWrite );
53 Level1->Streamer( Level1_buf );
54
55
56
57
58
59
60
61
62
63
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 char query[5024000], buf[1024 * 1000], buf1[1024 * 1000], *p, *
p1;
126 unsigned int from_len, from_len1;
127
128 int status;
129 int id = 60034;
130
132 "INSERT INTO EsTimeCalConst(SerNo,RunFrom,RunTo,EsTimeH2,EsTimeH9) "
133 "VALUES(%d,'100','1000','",
134 id );
135
136 printf( "%s\n", query );
137 p = query + strlen( query );
138 p += mysql_escape_string( p, Level0_buf.Buffer(), Level0_buf.BufferSize() );
139
140 strcat( p, "','" );
141 cout << "strlen(query)22222222222=" << strlen( query ) << endl;
142
143 p = query + strlen( query );
144 p += mysql_escape_string( p, Level1_buf.Buffer(), Level1_buf.BufferSize() );
145 strcat( p, "')" );
146 status = mysql_query( conn, query );
147 printf( "%d\n", status );
148
149
150
151 unsigned long* lengths;
152
154 MYSQL_ROW row;
155
156
157 char stmt1[200];
158 int serno = 1;
159
160
161 sprintf( stmt1,
"select EsTimeH2,EsTimeH9,RunFrom,RunTo from TofCalConst where SerNo=%d",
162 serno );
163
164
165 printf( "%s\n", stmt1 );
166 if ( mysql_real_query( conn, stmt1, strlen( stmt1 ) ) != 0 ) printf( "query error\n" );
167 res_set = mysql_store_result( conn );
168 mysql_field_seek( res_set, 0 );
169
170 row = mysql_fetch_row( res_set );
171 lengths = mysql_fetch_lengths( res_set );
172 for ( int i = 0; i < 8; i++ )
173 {
174
175 cout << "lengths[" << i << "]=" << lengths[i] << endl;
176 }
177
178
179
180
181
182
183
184
185
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 return StatusCode::SUCCESS;
216}
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)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")