00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <iostream>
00016 #include <fstream>
00017 using namespace std;
00018
00019 void readtofTOffset(const char* time = "2010-01-01 00:00:00")
00020 {
00021 const int mNTray = 120;
00022 const Int_t mNTOF = 192;
00023 const Int_t mNModule = 32;
00024 const Int_t mNCell = 6;
00025
00026
00027 gSystem->Load("St_base");
00028 gSystem->Load("StChain");
00029 gSystem->Load("StUtilities");
00030 gSystem->Load("St_Tables.so");
00031
00032 gSystem->Load("StDbLib.so");
00033 gSystem->Load("libStDb_Tables.so");
00034
00035
00036 StDbManager* dbManager = StDbManager::Instance();
00037
00038
00039 StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
00040
00041 string ZReadTime = time;
00042 dbManager->setRequestTime(ZReadTime.c_str());
00043
00044 StDbTable* tofTOffset = configNode->addDbTable("tofTOffset");
00045
00046 dbManager->fetchDbTable(tofTOffset);
00047
00048 cout<<tofTOffset->getVersion()<<endl;
00049
00050 cout<<tofTOffset->getBeginDateTime()<<endl;
00051 cout<<tofTOffset->getEndDateTime()<<endl;
00052
00053
00054
00055 tofTOffset_st* tZero = static_cast<tofTOffset_st*>(tofTOffset->GetTable());
00056
00057 if(!tZero) {
00058 cout << " ahhhhhh! " << endl;
00059 return;
00060 }
00061
00062 Int_t nRows = tofTOffset->GetNRows();
00063 cout << " NRows = " << nRows << endl;
00064 if(nRows!=mNTray) {
00065 cout << " NRows doesn't match !!! " << endl;
00066 }
00067
00068 Double_t mTofTZero[120][32][6];
00069 for(int i=0;i<120;i++) {
00070 for(int j=0;j<32;j++) {
00071 for(int k=0;k<6;k++) {
00072 mTofTZero[i][j][k] = 0.0;
00073 }
00074 }
00075 }
00076
00077 cout<<"Read out from DataBase-------------->"<<endl;
00078
00079 ofstream outData;
00080 outData.open("TOffset_read.dat");
00081 for (Int_t i=0;i<mNTray;i++) {
00082 for(int j=0;j<mNModule;j++) {
00083 for(int k=0;k<mNCell;k++) {
00084 short trayId, moduleId, cellId;
00085 trayId = tZero[i].trayId;
00086 moduleId = j+1;
00087 cellId = k+1;
00088 int index = j*mNCell+k;
00089 outData << " " << trayId << " " << moduleId << " " << cellId << endl;
00090 outData << tZero[i].T0[index] << endl;
00091 }
00092 }
00093 }
00094 outData.close();
00095
00096 cout<<tofTOffset->getVersion()<<endl;
00097
00098 cout<<tofTOffset->getBeginDateTime()<<endl;
00099 cout<<tofTOffset->getEndDateTime()<<endl;
00100
00101
00102
00103 }