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 storetofINLSCorrStep2()
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 = "2009-09-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 *f1 = new TFile("INL_test_0_300.root");
00063 TFile *f2 = new TFile("INL_test_300_600.root");
00064 TFile *f3 = new TFile("INL_test_600_900.root");
00065 TFile *f4 = new TFile("INL_test_900_1200.root");
00066
00067 for(int iboard=0;iboard<NMAX;iboard++) {
00068 if(iboard%100==0) cout << " Processing board Id = " << iboard << endl;
00069
00070 for(int itdc=0;itdc<NTDC;itdc++){
00071 for(int ichan=0;ichan<NCHAN;ichan++) {
00072
00073 char hisname[512];
00074 sprintf(hisname,"b_%d_tdc_%d_chan_%d",iboard,itdc,ichan);
00075
00076 if(iboard<300) {
00077 hINLSCorr[iboard][itdc][ichan] = (TH1S *)f1->Get(hisname);
00078 } else if(iboard<600) {
00079 hINLSCorr[iboard][itdc][ichan] = (TH1S *)f2->Get(hisname);
00080 } else if(iboard<900) {
00081 hINLSCorr[iboard][itdc][ichan] = (TH1S *)f3->Get(hisname);
00082 } else {
00083 hINLSCorr[iboard][itdc][ichan] = (TH1S *)f4->Get(hisname);
00084 }
00085
00086 if(!hINLSCorr[iboard][itdc][ichan]) {
00087
00088 continue;
00089 }
00090
00091 inlcorr[NFILL].tdigId = (Short_t)iboard;
00092 inlcorr[NFILL].tdcChanId = (Short_t)(itdc*NCHAN+ichan);
00093
00094
00095 for(int j=0;j<1024;j++) {
00096 inlcorr[NFILL].INLCorr[j]=(Short_t)(hINLSCorr[iboard][itdc][ichan]->GetBinContent(j+1));
00097 }
00098
00099
00100 NFILL++;
00101 }
00102 }
00103
00104 NBOARD++;
00105 hFlag[iboard] = true;
00106
00107 }
00108 cout<<" prepare to upload data to DB NFILL="<<NFILL<<" NBOARD="<<NBOARD<<endl;
00109
00110 char rootname[100];
00111 sprintf(rootname,"INL_test.root");
00112 TFile *fout = new TFile(rootname,"recreate");
00113 int index = 0;
00114 for(int iboard=0;iboard<NMAX;iboard++) {
00115 if(!hFlag[iboard]) continue;
00116
00117 for(int itdc=0;itdc<NTDC;itdc++){
00118 for(int ichan=0;ichan<NCHAN;ichan++) {
00119 if(!hINLSCorr[iboard][itdc][ichan]) continue;
00120 hINLSCorr[iboard][itdc][ichan]->Write();
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 index++;
00131 }
00132 }
00133 }
00134 fout->Close();
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 }
00148