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