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