BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
CorrectedETS.cxx File Reference
#include <iostream>
#include <string>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <mysql/mysql.h>
#include "TFile.h"
#include "TTree.h"
#include "TROOT.h"
#include "TH1F.h"
#include "TAxis.h"
#include "TH1.h"
#include "TBufferFile.h"
#include <fstream>

Go to the source code of this file.

Macros

#define CALCONSTSQLHELPER
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ CALCONSTSQLHELPER

#define CALCONSTSQLHELPER

Definition at line 16 of file CorrectedETS.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file CorrectedETS.cxx.

20 {
21 if(argc!=3) {
22 printf("error, wrong argument number!\n");
23 return 0;
24 }
25 char *opt_id=argv[1];
26 TFile *f= new TFile(argv[2]);
27 cout<<"start "<<endl;
28 static char query[80240000];
29 char *p;
30 int status=-1;
31 std::cout << "-3-3-3" << std::endl;
32 if(f->IsZombie()) return 0;
33 std::cout << "-2-3-2" << std::endl;
34 MYSQL conn;
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;
46 }
47 if (!mysql_real_connect(&conn, host, user, passwd, db, port, unix_socket, client_flag))
48 {
49 std::cout << "db link error" << std::endl;
50 }
51 std::cout << "0000" << std::endl;
52 gROOT->cd();
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);
58 cout<<"hahaha"<<endl;
59 //p = strmov(query,"UPDATE %s SET CorrectedETS='",opt_table_name);
60 sprintf(query,"UPDATE %s SET FinalETS='",opt_table_name);
61 cout<<query<<endl;
62 p= query + strlen(query);
63 cout<<"111"<<p<<endl;
64 p +=mysql_escape_string(p,event_buf.Buffer(),event_buf.BufferSize());
65 cout<<"222"<<p<<endl;
66 strcat(p,"' WHERE SerNo = ");
67 strcat(p,opt_id);
68 cout<<p<<endl;
69 if (mysql_query(&conn,query))
70 {
71 cout<< "Failed to update SerNo:"<<opt_id<<endl;
72 }
73 //status = mysql_query(conn,p);
74 printf("status=%d\n",status);
75 int kkkk=mysql_errno(&conn);
76 printf("err=%d\n",kkkk);
77
78 mysql_close(&conn);
79 f->Close();
80 return 0;
81}
struct st_mysql MYSQL
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")