StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
uploadToDB.C
1 #include <iostream>
2 #include <fstream>
3 
4 // Macro to upload BEMC trigger DB tables after completion of data taking.
5 // The user must specify :
6 // 1) a list of DB files to upload
7 // eg. ls /ldaphome/onlmon/bemctrgdb2011/tables.emconline_trg/StarDb/Calibrations/emc/trigger/bemcTriggerPed* > bemcTriggerPed.lis
8 // 2) path to the files (needed to convert timestamp from filename)
9 // 3) table type to be uploaded
10 
11 void uploadToDB(const char* filelist="bemcTriggerPed.lis", TString tableType = "bemcTriggerPed", TString path = "/ldaphome/onlmon/bemctrgdb2011/tables.emconline_trg/StarDb/Calibrations/emc/trigger/") {
12 
13  gROOT->Macro("loadMuDst.C");
14  gSystem->Load("StDbBroker");
15  gSystem->Load("St_db_Maker");
16  gSystem->Load("StDaqLib");
17 
18  ifstream list(filelist);
19  char file[200];
20 
21  // loop over list of files to upload
22  while(1){
23  list>>file;
24  if(!list.good())break;
25  //cout<<file<<endl;
26  TFile *dbfile = new TFile(file,"READ");
27 
28  // convert timestamp from filename
29  TString time;
30  time += file;
31  time.ReplaceAll(path,"");
32  time.ReplaceAll(tableType+".","");
33  time.ReplaceAll(".root","");
34  time.ReplaceAll("."," ");
35  time.Insert(4,"-");
36  time.Insert(7,"-");
37  time.Insert(13,":");
38  time.Insert(16,":");
39  cout<<time<<endl;
40 
41  // upload tables to DB
43  w.loadTables(time.Data());
44  w.loadTableFromFile(dbfile);
45  w.writeToDb(tableType.Data(), time.Data());
46  }
47 
48  return;
49 }
void loadTables(const char *sqlTime, const char *flavor="ofl")
load directly from DB, no Maker needed