10MYSQL* ReadBeamInfFromDb::OpenDb()
const {
12 const char host[] =
"202.122.37.70";
13 const char user[] =
"guest";
14 const char passwd[] =
"guestpass";
15 const char db[] =
"run";
16 unsigned int port_num = 3306;
18 MYSQL* mysql = mysql_init(NULL);
19 mysql = mysql_real_connect(mysql, host, user, passwd, db, port_num,
24 fprintf(stderr,
"can not open database: offlinedb\n");
31void ReadBeamInfFromDb::CloseDb(
MYSQL* mysql)
const {
36void ReadBeamInfFromDb::ReadDb(
int run){
41 MYSQL* mysql=OpenDb();
45 "select BER_PRB, BPR_PRB "
46 "from RunParams where run_number = %d", run);
47 if (mysql_real_query(mysql, stmt, strlen(stmt))) {
48 fprintf(stderr,
"query error\n");
53 MYSQL_RES* result_set = mysql_store_result(mysql);
54 MYSQL_ROW row = mysql_fetch_row(result_set);
56 fprintf(stderr,
"cannot find data for RunNo %d\n", run);
63 sscanf(row[0],
"%lf", &E_E);
64 sscanf(row[1],
"%lf", &E_P);
66 m_beamE=(E_E+E_P)/2.0;
69 mysql_free_result(result_set);
75 if (run == -1 || m_run != run) {
85 fprintf(stderr,
"ERROR in ReadBeamInfFromDb: runNo is invalid!\n");
struct st_mysql_res MYSQL_RES