BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
CheckMYSQL Class Reference

#include <CheckMySQL.h>

Inheritance diagram for CheckMYSQL:

Public Member Functions

 CheckMYSQL (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()

Detailed Description

Definition at line 49 of file CheckMySQL.h.

Constructor & Destructor Documentation

◆ CheckMYSQL()

CheckMYSQL::CheckMYSQL ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 4 of file CheckMySQL.cxx.

5 : Algorithm( name, pSvcLocator ) {
6 // Declare properties here.
7}

Member Function Documentation

◆ execute()

StatusCode CheckMYSQL::execute ( )

Definition at line 17 of file CheckMySQL.cxx.

17 {
18 MsgStream log( msgSvc(), name() );
19 // int i;
20 char* opt_host_name = "bes3db2.ihep.ac.cn";
21 // char *opt_host_name = "koala.ihep.ac.cn";
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;
28 MYSQL* conn;
29
30 // calibUtil::Metadata *meta = new calibUtil::Metadata(opt_host_name, "*",opt_db_name);
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 TH1F* LayerCntMap_1 = (TH1F*)f->Get("LayerCntMap");
57 // TH1F* LayerCntMap = new TH1F((TH1F)f->Get("LayerCntMap"));
58 // LayerCntMap->Copy(f->Get("LayerCntMap"));
59 // const double* con = LayerCntMap_1->GetBuffer();
60 // int size = LayerCntMap_1->GetBufferSize();
61 std::cout<<""step5555555555"<<std::endl;
62 TAxis* xaxis = LayerCntMap_1->GetXaxis();
63 double xmin = xaxis->GetXmin();
64 double xmax = xaxis->GetXmax();
65 double xbins = xaxis->GetNbins();
66 std::cout<<""step6666666"<<std::endl;
67 std::cout<<"xbins=="<<xbins<<"xmin=="<<xmin<<"xmax=="<<xmax<<std::endl;
68 TH1F* LayerCntMap = new TH1F("LayerCntMap","LayerCntMap",xbins,xmin,xmax);
69 for(int i=0;i<size;i++){
70 LayerCntMap->Fill(con[i]);
71 }
72
73 TBuffer LayerCntMap_buf(TBuffer::kWrite);
74 LayerCntMap->Copy(*(f->Get("LayerCntMap")));
75 LayerCntMap->Streamer(LayerCntMap_buf);
76 std::cout<<"55555555555555"<<std::endl;
77 f->Close();
78 TFile* check = new TFile("check.root","recreate");
79 // LayerCntMap->Write();
80 check->Write();
81 */
82 /* int size = 4096;
83 int bins = 10;
84 int xmin = 0;
85 int xmax = 10;
86 TH1F* histogramU16_ = new TH1F ("histogramU16_", "U16 data", bins, xmin, xmax);
87 histogramU16_->SetBit (TH1::kCanRebin); // allow automatic rebinning
88
89 for (int i = 0; i < 10; i++) {
90 histogramU16_->Fill(i);
91 }
92
93 char buffer[1024000];
94 TBuffer LayerCntMap_buf(TBuffer::kWrite, 1024000, buffer, true);
95 std::cout<<"aaaaaaaaa"<<std::endl;
96 histogramU16_->Streamer(LayerCntMap_buf);
97
98 cout<<"step55555555555"<<endl;
99 TH1F* BoxCntMap = (TH1F*)f->Get("BoxCntMap");
100 char buffer_1[52400];
101 TBuffer BoxCntMap_buf(TBuffer::kWrite,524000,buffer_1,true);
102 BoxCntMap->Streamer(BoxCntMap_buf);
103
104 cout<<"step66666666"<<std::endl;
105 TH1F* StripCntMap = (TH1F*)f->Get("StripCntMap");
106 char buffer_2[52400];
107 TBuffer StripCntMap_buf(TBuffer::kWrite,524000,buffer_2,true);
108 StripCntMap->Streamer(StripCntMap_buf);
109 cout<<"step7777777777"<<std::endl;
110
111 TH1F* LayerProMap = (TH1F*)f->Get("LayerProMap");
112 char buffer_3[52400];
113 TBuffer LayerProMap_buf(TBuffer::kWrite,524000,buffer_3,true);
114 LayerProMap->Streamer(LayerProMap_buf);
115
116 cout<<"step88888888888888"<<std::endl;
117
118 TH1F* BoxProMap = (TH1F*)f->Get("BoxProMap");
119 char buffer_4[52400];
120 TBuffer BoxProMap_buf(TBuffer::kWrite,524000,buffer_4,true);
121 BoxProMap->Streamer(BoxProMap_buf);
122
123 cout<<"step9999999999999"<<std::endl;
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
131 sprintf( query,
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 // cout<<"status================"<<status<<endl;
150
151 unsigned long* lengths;
152
153 MYSQL_RES* res_set;
154 MYSQL_ROW row;
155
156 // char *p1;
157 char stmt1[200]; //="select context from mytesttable where id = %d,";
158 int serno = 1;
159 // sprintf(stmt1,"select BarTofPar,EndTofPar,RunFrom,RunTo from TofCalConst where
160 // SerNo=%d",serno);
161 sprintf( stmt1, "select EsTimeH2,EsTimeH9,RunFrom,RunTo from TofCalConst where SerNo=%d",
162 serno );
163
164 // char stmt1[100]="select tree1,tree2 from TofCalConst where ser_no = 10026";
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 // cout<<"size of row["<<i<<"]"<<sizeof(row[i])<<endl;
175 cout << "lengths[" << i << "]=" << lengths[i] << endl;
176 }
177 /*
178 //string ss(row[0]);
179 //const char *pp = ss.c_str();
180
181 TTree* newHist= new TTree();
182 TBuffer rootBuffer2(TBuffer::kRead,lengths[0], row[0], kFALSE);
183 // TBuffer rootBuffer2(TBuffer::kRead,lengths[0], void pp, kFALSE);
184 newHist->Streamer(rootBuffer2);
185 newHist->Print();
186 int nentri = newHist -> GetEntries();*/
187 // double xtpar;
188 // int xtkey;
189 /*double atten,w3;
190 newHist -> SetBranchAddress("Atten", &atten);
191 newHist -> SetBranchAddress("W3", &w3);
192 cout<<"nentri="<<nentri<<endl;
193 for(int ii=0;ii<nentri;ii++){
194 newHist->GetEntry(ii);
195 cout<<"Atten="<<atten<<"W3="<<w3<<endl;
196 }
197 */
198 /* TTree* newHist1= new TTree();
199 TBuffer rootBuffer3(TBuffer::kRead,lengths[1], row[1], kFALSE);
200 newHist1->Streamer(rootBuffer3);
201 newHist1->Print();
202 int nentri1 = newHist1 -> GetEntries();
203 // double xtpar;
204 // int xtkey;
205 //double atten,w3;
206 double p6;
207 newHist1 -> SetBranchAddress("Atten", &atten);
208 newHist1 -> SetBranchAddress("P6", &p6);
209 cout<<"nentri1="<<nentri1<<endl;
210 for(int ii=0;ii<nentri1;ii++){
211 newHist1->GetEntry(ii);
212 cout<<"Atten="<<atten<<"P6="<<p6<<endl;
213 }
214 */
215 return StatusCode::SUCCESS;
216}
double p1[4]
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")
IMessageSvc * msgSvc()

◆ finalize()

StatusCode CheckMYSQL::finalize ( )

Definition at line 217 of file CheckMySQL.cxx.

217 {
218
219 MsgStream log( msgSvc(), name() );
220 log << MSG::INFO << " CheckMYSQL FINALIZE!! " << endmsg;
221
222 return StatusCode::SUCCESS;
223}

◆ initialize()

StatusCode CheckMYSQL::initialize ( )

Definition at line 9 of file CheckMySQL.cxx.

9 {
10 StatusCode sc;
11 MsgStream log( msgSvc(), name() );
12 log << MSG::INFO << "Initialize()" << endmsg;
13
14 return StatusCode::SUCCESS;
15}

The documentation for this class was generated from the following files: