StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
readtofINLSCorr.C
1 // macro to read tofr5 MAP table from database
2 //
3 // based on
4 // http://www.star.bnl.gov/STAR/comp/db/StoreDbTable.cc.html
5 //
6 // Jing Liu, 03/10/2005
7 //
8 
9 
10 // #include "StDbLib/StDbManager.hh"
11 // #include "StDbLib/StDbConfigNode.hh"
12 // #include "StDbLib/StDbTable.h"
13 // #include "StDbLib/StDbDefs.hh"
14 
15 #include <iostream>
16 #include <fstream>
17 using namespace std;
18 
19 void readtofINLSCorr(string ZReadTime = "2029-12-31 23:59:59")
20 {
21  //-- load dBase and Table definition libraries
22  gSystem->Load("St_base");
23  gSystem->Load("StChain");
24  gSystem->Load("StUtilities");
25  gSystem->Load("St_Tables.so");
26 
27  gSystem->Load("StDbLib.so");
28  gSystem->Load("libStDb_Tables.so");
29 
30  //-- get the singleton manager
31  StDbManager* dbManager = StDbManager::Instance();
32 
33  //-- connect to the db & get an empty container
34  StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
35 
36  dbManager->setRequestTime(ZReadTime.c_str());
37 
38  StDbTable* tofinlcorr = configNode->addDbTable("tofINLSCorr");
39 
40  dbManager->fetchDbTable(tofinlcorr);
41 
42  cout<<tofinlcorr->getVersion()<<endl;
43  //cout<<tofinlcorr->getTableName()<<endl;
44  cout<<tofinlcorr->getBeginDateTime()<<endl;
45  cout<<tofinlcorr->getEndDateTime()<<endl;
46 
47  tofINLSCorr_st* inlcorr = static_cast<tofINLSCorr_st*>(tofinlcorr->GetTable());
48 
49  const Int_t mNTDIGMAX = 1400; //1200
50  const Int_t mNChanOnTDIG = 24;
51  const Int_t mNChanMAX = 1024;
52  const Int_t mNBoardIdMAX = 4800;
53  Short_t mINLCorr[mNTDIGMAX][mNChanOnTDIG][mNChanMAX];
54  Int_t mBoardId[mNTDIGMAX];
55 
56  cout<<"Read out from DataBase-------------->"<<endl;
57  Int_t nRows = tofinlcorr->GetNRows();
58  cout << " nRows = " << nRows << endl;
59  Int_t NTdig = 0;
60  Int_t tdigId_old = 0;
61  for(int i=0;i<nRows;i++) {
62  if(NTdig>=mNTDIGMAX) {
63  cout << " exceed the limit! " << endl;
64  NTdig = mNTDIGMAX;
65  break;
66  }
67 
68  int tdigId = (Int_t)(inlcorr[i].tdigId);
69  int tdcChanId = (Int_t)(inlcorr[i].tdcChanId);
70  if(tdigId!=tdigId_old) {
71  mBoardId[NTdig] = tdigId;
72  NTdig++;
73  }
74 
75  tdigId_old = tdigId;
76 
77  for(Int_t j=0;j<mNChanMAX;j++) {
78  Short_t corr = (Short_t)(inlcorr[i].INLCorr[j]);
79  mINLCorr[NTdig-1][tdcChanId][j] = corr;
80  }
81  }
82 
83  cout << " Total # of boards read in : " << NTdig << endl;
84 
85  // list the TDIG board IDs
86  for(int i=0;i<NTdig;i++){cout << mBoardId[i] << endl;}
87 
88 }
static StDbManager * Instance()
strdup(..) is not ANSI
Definition: StDbManager.cc:155