00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include <fstream>
00012 #include <string>
00013 #include <iomanip>
00014 using namespace std;
00015
00016 void readtofGeomAlign(const char* time = "2010-01-01 00:00:00")
00017 {
00018
00019 gSystem->Load("St_base");
00020 gSystem->Load("StChain");
00021 gSystem->Load("StUtilities");
00022 gSystem->Load("St_Tables.so");
00023
00024 gSystem->Load("StDbLib.so");
00025 gSystem->Load("libStDb_Tables.so");
00026
00027 const Int_t NTRAY = 94;
00028 const Int_t NVPDTRAY = 2;
00029 const Int_t NMAX = 120;
00030
00031
00032 StDbManager* dbManager = StDbManager::Instance();
00033
00034
00035 StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
00036 string ZReadTime = time;
00037 dbManager->setRequestTime(ZReadTime.c_str());
00038
00039 StDbTable* tofGeomAlign = configNode->addDbTable("tofGeomAlign");
00040 dbManager->fetchDbTable(tofGeomAlign);
00041
00042 cout<< "--- Table properties: ---" << endl;
00043 cout<<tofGeomAlign->getVersion()<<endl;
00044 cout<<tofGeomAlign->getBeginDateTime()<<endl;
00045 cout<<tofGeomAlign->getEndDateTime()<<endl;
00046 cout<< "------------------------" << endl;
00047
00048 tofGeomAlign_st *tofAlign = static_cast<tofGeomAlign_st*>(tofGeomAlign->GetTable());
00049 if (!tofAlign){
00050 cout << "ERROR: no such table" << endl;
00051 return;
00052 }
00053
00054 cout << "Reading out from database ..." << endl;
00055 Int_t nRows = tofGeomAlign->GetNRows();
00056 cout << "Number of rows: " << nRows << endl;
00057 if (nRows != NMAX) {
00058 cout << " WARNING: number of rows does not match " << NMAX << endl;
00059 }
00060
00061 ofstream outData;
00062 outData.open("geomAlign_readback.txt");
00063
00064 for(int i=0;i<nRows;i++) {
00065 int tray = i+1;
00066 cout << " trayId=" << tray
00067 << " phi0=" << tofAlign[i].phi0
00068 << " z0=" << tofAlign[i].z0
00069 << " x0=" << tofAlign[i].x0
00070 << " a0=" << tofAlign[i].angle0 << endl;
00071 outData << setw(6) << tray
00072 << setw(15) << tofAlign[i].phi0
00073 << setw(15) << tofAlign[i].z0
00074 << setw(15) << tofAlign[i].x0
00075 << setw(15) << tofAlign[i].angle0
00076 << endl;
00077 }
00078
00079 outData.close();
00080 cout << "done." << endl;
00081
00082 }