22 void storetofINLSCorrStep1(
int i1=0,
int i2=300)
27 const Int_t NMAX = 1400;
29 const Int_t NCHAN = 8;
32 gSystem->Load(
"St_base");
33 gSystem->Load(
"StChain");
34 gSystem->Load(
"StUtilities");
35 gSystem->Load(
"St_Tables.so");
37 gSystem->Load(
"StDbLib.so");
38 gSystem->Load(
"libStDb_Tables.so");
44 StDbConfigNode* configNode = dbManager->initConfig(
"Calibrations_tof");
47 TString ZStoreTime =
"2009-09-01 00:00:00";
50 StDbTable* tofINLSCorr = configNode->addDbTable(
"tofINLSCorr");
53 tofINLSCorr_st *inlcorr=
new tofINLSCorr_st[NMAX*NTDC*NCHAN];
59 TH1S *hINLSCorr[NMAX][NTDC][NCHAN];
61 for(
int i=0;i<NMAX;i++) hFlag[i] =
false;
65 sprintf(testname,
"write_%d_%d.list",i1,i2);
66 testData.open(testname);
70 sprintf(inputname,
"input_%d_%d.list",i1,i2);
71 inputData.open(inputname);
73 for(
int iboard=i1;iboard<i2;iboard++) {
77 char *dirpfx =
"/gpfs01/star/i_rice/geurts/database/Run15/";
80 char sfx[9][10] = {
"",
".R",
".RC",
".RRC",
".redo",
".n",
"redo",
"n",
".RRR"};
83 for(
int j=0;j<9;j++) {
84 sprintf(dirname,
"tdig-ser%d%s",iboard,sfx[j]);
85 sprintf(fulldir,
"%s/%s",dirpfx,dirname);
86 void *dir = gSystem->OpenDirectory(gSystem->ExpandPathName(fulldir));
94 cout <<
" No available table for board # " << iboard << endl;
97 sprintf(dirname,
"tdig-ser%d%s",iboard,sfx[iv]);
98 sprintf(fulldir,
"%s/%s",dirpfx,dirname);
100 cout <<
" Opening directory " << dirname <<
" for input... " << endl;
101 inputData << iboard <<
"\t" << dirname << endl;
103 Short_t corr[NTDC*NCHAN*1024];
105 for(
int itdc=0;itdc<NTDC;itdc++){
106 for(
int ichan=0;ichan<NCHAN;ichan++) {
109 sprintf(filename,
"%s/inl/%s.tdc%d.ch%d.inl",fulldir,dirname,itdc,ichan);
112 sprintf(hisname,
"b_%d_tdc_%d_chan_%d",iboard,itdc,ichan);
113 hINLSCorr[iboard][itdc][ichan] =
new TH1S(hisname,hisname,1024,0.,1024.);
115 inlcorr[NFILL].tdigId = (Short_t)iboard;
116 inlcorr[NFILL].tdcChanId = (Short_t)(itdc*NCHAN+ichan);
118 ifstream infile(filename);
120 cout<<
"Can not open "<<filename<<
" Please check!!!"<<endl;
123 cout <<
" +++ Open file " << filename <<
" for input " << endl;
125 for(
int j=0;j<1024;j++) {
127 infile >> bin >> data;
128 inlcorr[NFILL].INLCorr[j]=(Short_t)(data*100.);
129 corr[itdc*NCHAN*1024+ichan*1024+j] = (Short_t)(data*100.);
130 if(fabs(j-bin)>0.6) {
131 cout <<
" weird!!! " << endl;
135 hINLSCorr[iboard][itdc][ichan]->SetBinContent(j+1,inlcorr[NFILL].INLCorr[j]);
145 sprintf(outname,
"%s/inl/%s_24.inl",fulldir,dirname);
146 ofstream outfile(outname);
147 cout <<
" Writing to file " << outname << endl;
148 for(
int ic=0;ic<1024;ic++) {
149 for(
int it=0;it<NTDC*NCHAN;it++) {
150 outfile << setw(10) << corr[it*1024+ic];
157 cout<<
"================================================="<<endl;
159 hFlag[iboard] =
true;
160 testData << iboard <<
"\t" << dirname << endl;
165 cout<<
" prepare to upload data to DB NFILL="<<NFILL<<
" NBOARD="<<NBOARD<<endl;
168 sprintf(rootname,
"INL_test_%d_%d.root",i1,i2);
169 TFile *fout =
new TFile(rootname,
"recreate");
171 for(
int iboard=0;iboard<NMAX;iboard++) {
172 if(!hFlag[iboard])
continue;
174 for(
int itdc=0;itdc<NTDC;itdc++){
175 for(
int ichan=0;ichan<NCHAN;ichan++) {
176 if(!hINLSCorr[iboard][itdc][ichan])
continue;
177 hINLSCorr[iboard][itdc][ichan]->Write();
static StDbManager * Instance()
strdup(..) is not ANSI