StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
readvpdDelay.C
1 // macro to read VPD delay
2 //
3 //
4 
5 #include <iostream>
6 #include <fstream>
7 using namespace std;
8 
9 void readvpdDelay(string ZReadTime = "2029-12-31 23:59:59") {
10 
11  const Int_t NVPD = 38;
12 
13  //-- load dBase and Table definition libraries
14  gSystem->Load("St_base");
15  gSystem->Load("StChain");
16  gSystem->Load("StUtilities");
17  gSystem->Load("St_Tables.so");
18 
19  gSystem->Load("StDbLib.so");
20  gSystem->Load("libStDb_Tables.so");
21 
22  //-- get the singleton manager
23  StDbManager* dbManager = StDbManager::Instance();
24 
25  //-- connect to the db & get an empty container
26  StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
27 
28  dbManager->setRequestTime(ZReadTime.c_str());
29 
30  //-- add table to the container with descriptor given by Database
31  StDbTable* vpdDelayTable = configNode->addDbTable("vpdDelay");
32 
33  dbManager->fetchDbTable(vpdDelayTable);
34 
35  cout << "version : " << vpdDelayTable->getVersion() <<endl;
36  cout << "begin data/time : "<< vpdDelayTable->getBeginDateTime() <<endl;
37  cout << "end data/time : " << vpdDelayTable->getEndDateTime() <<endl;
38 
39 
40  vpdDelay_st* vpddelay = static_cast<vpdDelay_st*>(vpdDelayTable->GetTable());
41 
42  if (!vpddelay) {
43  cout << " Oops ... no pointer to table. Exiting" << endl;
44  return;
45  }
46 
47 
48  Int_t nRows = vpdDelayTable->GetNRows();
49  cout << " NRows = " << nRows << endl;
50  if(nRows!=1) {
51  cout << " NRows doesn't match !!! " << endl;
52  }
53 
54 
55  cout << "read out from database ..." << endl;
56  //ofstream outData;
57  //outData.open("TrgWindow_read.dat");
58  for (int i=0;i<NVPD;i++){
59  cout << "tubedId = " << i+1 << " delay = " << vpddelay.delay[i] << endl;
60  }
61 
62 
63 }
static StDbManager * Instance()
strdup(..) is not ANSI
Definition: StDbManager.cc:155