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 readtofINLSCorr()
00020 {
00021
00022 gSystem->Load("St_base");
00023 gSystem->Load("StChain");
00024 gSystem->Load("StUtilities");
00025 gSystem->Load("St_Tables.so");
00026
00027 gSystem->Load("StDbLib.so");
00028 gSystem->Load("libStDb_Tables.so");
00029
00030
00031 StDbManager* dbManager = StDbManager::Instance();
00032
00033
00034 StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
00035
00036 string ZReadTime = "2010-12-31 00:00:00";
00037 dbManager->setRequestTime(ZReadTime.c_str());
00038
00039 StDbTable* tofinlcorr = configNode->addDbTable("tofINLSCorr");
00040
00041 dbManager->fetchDbTable(tofinlcorr);
00042
00043 cout<<tofinlcorr->getVersion()<<endl;
00044
00045 cout<<tofinlcorr->getBeginDateTime()<<endl;
00046 cout<<tofinlcorr->getEndDateTime()<<endl;
00047
00048 tofINLSCorr_st* inlcorr = static_cast<tofINLSCorr_st*>(tofinlcorr->GetTable());
00049
00050 const Int_t mNTDIGMAX = 1200;
00051 const Int_t mNChanOnTDIG = 24;
00052 const Int_t mNChanMAX = 1024;
00053 const Int_t mNBoardIdMAX = 4800;
00054 Short_t mINLCorr[mNTDIGMAX][mNChanOnTDIG][mNChanMAX];
00055 Int_t mBoardId[mNTDIGMAX];
00056
00057 cout<<"Read out from DataBase-------------->"<<endl;
00058 Int_t nRows = tofinlcorr->GetNRows();
00059 cout << " nRows = " << nRows << endl;
00060 Int_t NTdig = 0;
00061 Int_t tdigId_old = 0;
00062 for(int i=0;i<nRows;i++) {
00063 if(NTdig>=mNTDIGMAX) {
00064 cout << " exceed the limit! " << endl;
00065 NTdig = mNTDIGMAX;
00066 break;
00067 }
00068
00069 int tdigId = (Int_t)(inlcorr[i].tdigId);
00070 int tdcChanId = (Int_t)(inlcorr[i].tdcChanId);
00071 if(tdigId!=tdigId_old) {
00072 mBoardId[NTdig] = tdigId;
00073 NTdig++;
00074 }
00075
00076 tdigId_old = tdigId;
00077
00078 for(Int_t j=0;j<mNChanMAX;j++) {
00079 Short_t corr = (Short_t)(inlcorr[i].INLCorr[j]);
00080 mINLCorr[NTdig-1][tdcChanId][j] = corr;
00081 }
00082 }
00083
00084 cout << " Total # of boards read in : " << NTdig << endl;
00085
00086
00087 for(int i=0;i<NTdig;i++){cout << mBoardId[i] << endl;}
00088
00089 }