StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
getBeginTime.C
1 void getBeginTime(int runNumber = 15047028)
2 {
3  const char* database = "mysql://db04.star.bnl.gov:3413/RunLog?timeout=60";
4  const char* user = "zchang";
5  const char* pass = "";
6  TMySQLServer* mysql = TMySQLServer::Connect(database,user,pass);
7  gSystem->mkdir("beginTimes");
8  ofstream of(Form("beginTimes_t/%0.8d.beginTimes.txt", runNumber));
9  if (!mysql) {
10  cerr << "Connection to " << database << " failed" << endl;
11  return;
12  }
13 
14  TString query;
15  TMySQLResult* result;
16 
17  query = Form("select distinct beginTime from `RunLog`.`runDescriptor` where runNumber = %d",runNumber);
18 
19  result = (TMySQLResult*)mysql->Query(query);
20  if (result) {
21  TMySQLRow* row;
22  while (row = (TMySQLRow*)result->Next()) {
23  TString str(Form("%s", row->GetField(0)));
24  cout<<str.Data()<<endl;
25  TString str_new = str;
26  cout<<str_new.Data()<<endl;
27  of<<str_new.Data()<<endl;
28  delete row;
29  }
30  result->Close();
31  }
32  of.close();
33  mysql->Close();
34 }