00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <iostream>
00016 #include <fstream>
00017 #include <string>
00018 #include "iomanip.h"
00019 using namespace std;
00020
00021 void readtofZbCorr(const char* time = "2010-01-01 00:00:00")
00022 {
00023 const int mNTray = 120;
00024 const int mNTDIG = 8;
00025 const int mNVPD = 19;
00026
00027
00028 gSystem->Load("St_base");
00029 gSystem->Load("StChain");
00030 gSystem->Load("StUtilities");
00031 gSystem->Load("St_Tables.so");
00032
00033 gSystem->Load("StDbLib.so");
00034 gSystem->Load("libStDb_Tables.so");
00035
00036
00037 StDbManager* dbManager = StDbManager::Instance();
00038
00039
00040 StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
00041
00042 string ZReadTime = time;
00043 dbManager->setRequestTime(ZReadTime.c_str());
00044
00045 StDbTable* tofZbCorr = configNode->addDbTable("tofZbCorr");
00046
00047 dbManager->fetchDbTable(tofZbCorr);
00048
00049 cout<<tofZbCorr->getVersion()<<endl;
00050
00051 cout<<tofZbCorr->getBeginDateTime()<<endl;
00052 cout<<tofZbCorr->getEndDateTime()<<endl;
00053
00054
00055 tofZbCorr_st* zcorr = static_cast<tofZbCorr_st*>(tofZbCorr->GetTable());
00056
00057 if(!zcorr) {
00058 cout << " ahhhhhh! " << endl;
00059 return;
00060 }
00061
00062 cout<<"Read out from DataBase-------------->"<<endl;
00063
00064 Int_t nRows = tofZbCorr->GetNRows();
00065 cout << " NRows = " << nRows << endl;
00066
00067
00068
00069
00070 ofstream outData;
00071 outData.open("zCorr_read.dat");
00072
00073 for(int i=0;i<nRows;i++) {
00074 outData << setw(6) << zcorr[i].trayId << setw(6) << zcorr[i].moduleId << setw(6) << zcorr[i].cellId << endl;
00075 for(int j=0;j<60;j++) {
00076 if(fabs(zcorr[i].z[j])<1.e-4 && fabs(zcorr[i].corr[j])<1.e-4) continue;
00077 outData << setw(15) << zcorr[i].z[j];
00078 }
00079 outData << endl;
00080 for(int j=0;j<60;j++) {
00081 if(fabs(zcorr[i].z[j])<1.e-4 && fabs(zcorr[i].corr[j])<1.e-4) continue;
00082 outData << setw(15) << zcorr[i].corr[j];
00083 }
00084 outData << endl;
00085 }
00086 outData.close();
00087
00088 }