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 readvpdTotCorr(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* vpdTotCorr = configNode->addDbTable("vpdTotCorr");
00046
00047 dbManager->fetchDbTable(vpdTotCorr);
00048
00049 cout<<vpdTotCorr->getVersion()<<endl;
00050
00051 cout<<vpdTotCorr->getBeginDateTime()<<endl;
00052 cout<<vpdTotCorr->getEndDateTime()<<endl;
00053
00054
00055 vpdTotCorr_st* totcorr = static_cast<vpdTotCorr_st*>(vpdTotCorr->GetTable());
00056
00057 if(!totcorr) {
00058 cout << " ahhhhhh! " << endl;
00059 return;
00060 }
00061
00062 cout<<"Read out from DataBase-------------->"<<endl;
00063
00064 Int_t nRows = vpdTotCorr->GetNRows();
00065 cout << " NRows = " << nRows << endl;
00066 if(nRows!=2*mNVPD) {
00067 cout << " NRows doesn't match !!! " << endl;
00068 }
00069
00070 ofstream outData;
00071 outData.open("vpdTotCorr_read.dat");
00072 for(int i=0;i<2*mNVPD;i++) {
00073 outData << setw(6) << totcorr[i].tubeId << endl;
00074 cout << totcorr[i].tubeId << " " << totcorr[i].corralgo << endl;
00075 for(int j=0;j<128;j++) {
00076 if(totcorr[i].tot[j]>1.e-4)
00077 outData << setw(15) << totcorr[i].tot[j];
00078 }
00079 outData << endl;
00080 for(int j=0;j<128;j++) {
00081 if(totcorr[i].tot[j]>1.e-4)
00082 outData << setw(15) << totcorr[i].corr[j];
00083 }
00084 outData << endl;
00085 }
00086 outData.close();
00087
00088 }