7#include <mysql/mysql.h>
14#include "TBufferFile.h"
16#define CALCONSTSQLHELPER
20int main(
int argc,
char** argv) {
22 printf(
"error, wrong argument number!\n");
26 TFile *
f=
new TFile(argv[2]);
28 static char query[80240000];
31 std::cout <<
"-3-3-3" << std::endl;
32 if(
f->IsZombie())
return 0;
33 std::cout <<
"-2-3-2" << std::endl;
35 const char host[] =
"bes3db1.ihep.ac.cn";
36 const char user[] =
"ets";
37 const char passwd[] =
"ets3400";
38 const char db[] =
"offlinedb";
39 char opt_table_name[16] =
"CorrectedETS";
40 unsigned int port = 3306;
41 const char *unix_socket = NULL;
42 unsigned long client_flag = 0;
43 std::cout <<
"-1-1-1" << std::endl;
44 if (mysql_init(&conn) == NULL) {
45 std::cout <<
"init db error" << std::endl;
47 if (!mysql_real_connect(&conn, host, user, passwd, db, port, unix_socket, client_flag))
49 std::cout <<
"db link error" << std::endl;
51 std::cout <<
"0000" << std::endl;
53 std::cout <<
"1111" << std::endl;
54 TTree *
event = (TTree*)
f-> Get(
"event");
55 TTree *event_copy =
event->CloneTree();
56 TBufferFile event_buf(TBufferFile::kWrite);
57 event_copy->Streamer(event_buf);
60 sprintf(query,
"UPDATE %s SET FinalETS='",opt_table_name);
62 p= query + strlen(query);
64 p +=mysql_escape_string(p,event_buf.Buffer(),event_buf.BufferSize());
66 strcat(p,
"' WHERE SerNo = ");
69 if (mysql_query(&conn,query))
71 cout<<
"Failed to update SerNo:"<<opt_id<<endl;
74 printf(
"status=%d\n",status);
75 int kkkk=mysql_errno(&conn);
76 printf(
"err=%d\n",kkkk);
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")