00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <iostream>
00016 #include <fstream>
00017 #include <string>
00018 using namespace std;
00019
00020 void storetofTOffset(const Bool_t mTest = 1)
00021 {
00022
00023 const Int_t mNTray = 120;
00024 const Int_t mNTOF = 192;
00025 const Int_t mNModule = 32;
00026 const Int_t mNCell = 6;
00027
00028
00029 gSystem->Load("St_base");
00030 gSystem->Load("StChain");
00031 gSystem->Load("StUtilities");
00032 gSystem->Load("St_Tables.so");
00033
00034 gSystem->Load("StDbLib.so");
00035 gSystem->Load("libStDb_Tables.so");
00036
00037
00038 StDbManager* dbManager = StDbManager::Instance();
00039
00040
00041 StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
00042
00043
00044
00045
00046
00047
00048
00049
00050 ifstream inTime;
00051 inTime.open("input/timestamp");
00052 string time;
00053 if (inTime.is_open()) {
00054 getline(inTime, time);
00055 inTime.close();
00056 } else {
00057 cout << " Unable to open the TimeStamp file! EXIT! " << endl;
00058 return;
00059 }
00060 TString StoreTime = time;
00061 cout << " Store Time " << StoreTime.Data() << endl;
00062
00063
00064 StDbTable* tofTOffset = configNode->addDbTable("tofTOffset");
00065
00066
00067 tofTOffset_st *tZero = new tofTOffset_st[mNTray];
00068
00069
00070
00071 ifstream inData;
00072 inData.open("input/t0_4DB.dat");
00073
00074 for (Int_t i=0;i<mNTray;i++) {
00075 for (Int_t j=0;j<mNModule;j++) {
00076 for (Int_t k=0;k<mNCell;k++) {
00077 short trayId, moduleId, cellId;
00078 inData>>trayId>>moduleId>>cellId;
00079
00080 double t0;
00081 inData >> t0;
00082 tZero[i].trayId = (Short_t)trayId;
00083 tZero[i].T0[j*mNCell+k] = (Float_t)t0;
00084 }
00085 }
00086 }
00087 inData.close();
00088
00089
00090 ofstream outData;
00091 outData.open("TOffset_test.dat");
00092 for(int i=0;i<mNTray;i++) {
00093 for(int j=0;j<mNModule;j++) {
00094 for(int k=0;k<mNCell;k++) {
00095 short trayId, moduleId, cellId;
00096 trayId = tZero[i].trayId;
00097 moduleId = j+1;
00098 cellId = k+1;
00099 int index = j*mNCell+k;
00100 outData << " " << trayId << " " << moduleId << " " << cellId << endl;
00101 outData << tZero[i].T0[index] << endl;
00102 }
00103 }
00104 }
00105 outData.close();
00106
00107 if(!mTest) {
00108 cout<<" prepare to upload data to DB"<<endl;
00109
00110 tofTOffset->SetTable((char*)tZero, mNTray);
00111
00112 dbManager->setStoreTime(StoreTime.Data());
00113
00114 cout<<" here "<<endl;
00115 dbManager->storeDbTable(tofTOffset);
00116 cout<<"uploaded"<<endl;
00117
00118 }
00119 }