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
00021 void storetofINLSCorr()
00022
00023
00024 {
00025
00026 const Int_t NMAX = 1200;
00027 const Int_t NTDC = 3;
00028 const Int_t NCHAN = 8;
00029
00030
00031 gSystem->Load("St_base");
00032 gSystem->Load("StChain");
00033 gSystem->Load("StUtilities");
00034 gSystem->Load("St_Tables.so");
00035
00036 gSystem->Load("StDbLib.so");
00037 gSystem->Load("libStDb_Tables.so");
00038
00039
00040 StDbManager* dbManager = StDbManager::Instance();
00041
00042
00043 StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
00044
00045
00046 TString ZStoreTime = "2008-11-01 00:00:00";
00047
00048
00049 StDbTable* tofINLSCorr = configNode->addDbTable("tofINLSCorr");
00050
00051
00052 tofINLSCorr_st *inlcorr= new tofINLSCorr_st[NMAX*NTDC*NCHAN];
00053
00054 Int_t NFILL = 0;
00055 Int_t NBOARD = 0;
00056
00057
00058 TH1S *hINLSCorr[NMAX][NTDC][NCHAN];
00059 Bool_t *hFlag[NMAX];
00060 for(int i=0;i<NMAX;i++) hFlag[i] = false;
00061
00062 TFile *f = new TFile("INL_test.root");
00063
00064 for(int iboard=0;iboard<NMAX;iboard++) {
00065 if(iboard%100==0) cout << " Processing board Id = " << iboard << endl;
00066
00067 for(int itdc=0;itdc<NTDC;itdc++){
00068 for(int ichan=0;ichan<NCHAN;ichan++) {
00069
00070 char hisname[512];
00071 sprintf(hisname,"b_%d_tdc_%d_chan_%d",iboard,itdc,ichan);
00072
00073 hINLSCorr[iboard][itdc][ichan] = (TH1S *)f->Get(hisname);
00074
00075 if(!hINLSCorr[iboard][itdc][ichan]) {
00076
00077 continue;
00078 }
00079
00080 inlcorr[NFILL].tdigId = (Short_t)iboard;
00081 inlcorr[NFILL].tdcChanId = (Short_t)(itdc*NCHAN+ichan);
00082
00083 for(int j=0;j<1024;j++) {
00084 inlcorr[NFILL].INLCorr[j]=(Short_t)(hINLSCorr[iboard][itdc][ichan]->GetBinContent(j+1));
00085 }
00086
00087
00088 NFILL++;
00089 }
00090 }
00091
00092 NBOARD++;
00093 hFlag[iboard] = true;
00094
00095 }
00096 cout<<" prepare to upload data to DB NFILL="<<NFILL<<" NBOARD="<<NBOARD<<endl;
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 tofINLSCorr->SetTable((char*)inlcorr, NFILL);
00126
00127 dbManager->setStoreTime(ZStoreTime.Data());
00128
00129 cout<<" here "<<endl;
00130 dbManager->storeDbTable(tofINLSCorr);
00131 cout<<"uploaded"<<endl;
00132
00133 }
00134