BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
test_dedxsim.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 "TH1F.h"
#include "TBufferFile.h"
#include <fstream>

Go to the source code of this file.

Macros

#define TEST_SQL
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ TEST_SQL

#define TEST_SQL

Definition at line 16 of file test_dedxsim.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 19 of file test_dedxsim.cxx.

19 {
20 char *opt_host_name = "202.122.37.69";
21 char *opt_user_name = "maqm";
22 unsigned int opt_port_num = 3306;
23 char *opt_socket_name = NULL;
24 char *opt_db_name = "offlinedb";
25
26 unsigned int opt_flags = 0;
27 MYSQL *conn;
28
29
30
31conn = mysql_init(NULL);
32
33 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
34 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
35 printf("connect the database ok\n");
36
37unsigned long *lengths;
38
39 MYSQL_RES *res_set;
40 MYSQL_ROW row;
41
42
43 //====================================
44 //search in the MYSQL
45 //=====================================
46 char stmt1[200];//="select context from mytesttable where id = %d,";
47 sprintf(stmt1,"select TH1F_col from DedxSim where serno = 38");
48
49 printf("%s\n",stmt1);
50 if(mysql_real_query(conn, stmt1, strlen(stmt1)) != 0)
51 printf("query error\n");
52 res_set = mysql_store_result (conn);
53 mysql_field_seek (res_set, 0);
54
55 row = mysql_fetch_row (res_set);
56 lengths = mysql_fetch_lengths(res_set);
57 for(int i=0;i<5;i++){
58 std::cout<<"lengths["<<i<<"]="<<lengths[i]<<std::endl;
59 }
60
61 //====================================
62 //read the calibdata from the buffer
63 //====================================
64 //TTree* newHist= new TTree();
65 //TBufferFile rootBuffer2(TBufferFile::kRead,lengths[0], row[0], kFALSE);
66 TBufferFile rootBuffer2(TBufferFile::kRead,lengths[0], row[0], kFALSE);
67 TTree tree;
68
69 tree.Streamer(rootBuffer2);
70 //gROOT->cd();
71
72 tree.Print();
73
74
75 // ofstream ofs("out.bin", std::ios::binary);
76 //ofs.write(row[0], lengths[0]);
77 //return 0;
78 /*maqm newHist->Streamer(rootBuffer2);
79 newHist->Print();
80 int nentri = newHist -> GetEntries();
81 std::cout<<"nentri is:"<<nentri<<std::endl;*/
82 //*runcalib
83 int runno;
84 double rungain;
85 /*maqm newHist->SetBranchAddress("runno", &runno);
86 newHist->SetBranchAddress("rungain", &rungain);
87 for ( int i = 0; i < 10; ++i ) {
88 newHist->GetEntry(i);
89 std::cout << "runno: " << runno << " rungain: " << rungain << std::endl;
90 }
91 */
92 //print values of wiregain
93 /* double gwire[6796];
94 newHist->SetBranchAddress("wireg", &gwire);
95 newHist->GetEntry(0);
96 for(int i=0;i<200;i++)
97 std::cout<<"gwire: ["<<i<<"] = "<<gwire[i]<<std::endl;
98 */
99 /* double gwire[7000];
100 gwire=newHist->GetEntry(0);
101 for(int i=0;i<200;i++)
102 std::cout<<"gwire: ["<<i<<"] = "<<gwire[i]<<std::endl;*/
103
104 return 0;
105}
struct st_mysql_res MYSQL_RES
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)