StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
read_fgtSimuParams.C
1 read_fgtSimuParams(){
2  // base libraries
3  gSystem->Load("St_base");
4  gSystem->Load("StChain");
5  gSystem->Load("StUtilities");
6  gSystem->Load("StIOMaker");
7  gSystem->Load("StarClassLibrary");
8 
9  // db-related libraries
10  gSystem->Load("St_Tables");
11  gSystem->Load("StDbLib");
12  gSystem->Load("StDbBroker");
13  gSystem->Load("St_db_Maker");
14 
15  St_db_Maker *dbMk=new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
16  dbMk->SetDebug();
17  dbMk->SetDateTime(20120301,0); // event or run start time, set to your liking
18  dbMk->SetFlavor("ofl");
19 
20  dbMk->Init();
21  dbMk->Make();
22 
23  TDataSet *DB = 0;
24  DB = dbMk->GetDataBase("Calibrations/fgt/fgtSimuParams");
25  if (!DB) {
26  std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl;
27  }
28 
29  St_fgtSimuParams *dataset = 0;
30  dataset = (St_fgtSimuParams*) DB->Find("fgtSimuParams");
31  Int_t rows = dataset->GetNRows();
32  if (rows > 1) {
33  std::cout << "BAD INFO: found INDEXED table with " << rows << " rows, abort" << std::endl;
34  return;
35  }
36 
37  if (dataset) {
38  fgtSimuParams_st *table = dataset->GetTable();
39  int irow=0;
40  printf(" print fgtSimuParams: comment=%s=\n", table[irow].comment);
41  for (Int_t i = 0; i < 15; i++) {
42  // sample output of few params
43  std::cout << i << "th param : " << table[irow].param[i] << std::endl;
44  }
45  } else {
46  std::cout << "ERROR: dataset does not contain requested table" << std::endl;
47  return;
48  }
49 
50 }
virtual Int_t Make()
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362