StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
trgDsmReg_read.C
1 {
2 
3  // generic libraries, nothing special here
4  gSystem->Load("St_base");
5  gSystem->Load("StChain");
6  gSystem->Load("StBFChain");
7  gSystem->Load("StUtilities");
8  gSystem->Load("StIOMaker");
9  gSystem->Load("StarClassLibrary");
10 
11  // db-related libraries
12  gSystem->Load("St_Tables");
13  gSystem->Load("StDbLib");
14  gSystem->Load("StDbBroker");
15  gSystem->Load("St_db_Maker");
16 
17 
18 // this will be in chain
19 St_db_Maker *dbMk=new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
20 dbMk->SetDebug();
21 dbMk->SetDateTime(20090425,55558); // run start time
22 dbMk->SetFlavor("ofl"); // for offline calibrations/mapping
23 // dbMk->SetFlavor("simu"); // for simulations
24 dbMk->Init();
25 int runNumber = 10115007;
26 dbMk->InitRun(runNumber); // run number
27 dbMk->Make();
28 
29 // this is usually done inside ::Make method
30 TDataSet *DB = 0;
31 // "dbMk->" will NOT be needed, if done inside your Maker. Simply use DB = GetInputDb("RunLog/onl/triggerID")
32 DB = dbMk->GetInputDB("RunLog/onl/trgDsmReg");
33 if (!DB) { std::cout << "ERROR: no db maker constructed?" << std::endl; }
34 
35 //
36 // c-struct headers, produced from .idl files, reside here :
37 // less $STAR_LIB/../include/triggerID.h
38 // and here:
39 // less $STAR_LIB/../include/tables/St_triggerID_Table.h
40 //
41 
42 // fetch ROOT descriptor of db table
43 St_trgDsmReg *desc = 0;
44 desc = (St_trgDsmReg*) DB->Find("trgDsmReg");
45 // fetch data and place it to appropriate structure
46 if (desc) {
47  trgDsmReg_st *table = desc->GetTable();
48  Int_t numrows = desc->GetNRows();
49  std::cout << "total rows for trgDsmReg, run " << runNumber << " found: " << numrows << std::endl;
50  // display data
51  for (int i = 0; i < numrows; i++) {
52  std::cout << table[i].runNumber << ", "
53  << (unsigned)table[i].dcObject << ", "
54  << (unsigned)table[i].dcIndex << ", "
55  << table[i].dcRegister << ", "
56  << table[i].dcLabel << ", "
57  << table[i].dcValue << ", "
58  << table[i].dcDefaultvalue << "\n";
59  }
60 } else {
61  std::cout << "WARNING: No data in trgDsmReg table (wrong timestamp?). Nothing to return, then.\n";
62 }
63 
64 } // end of macro
virtual Int_t Make()
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362