// Input completed calibration files for (StXXXX). // Output global parameter file StXXXX_TofOfflineA.txt // void translate(char * store){ const char outpath[] = "/cdf/scratch/piedra/r2offline/tof/Calibration/test/files"; const char inpath[] = "/cdf/scratch/piedra/r2offline/tof/Calibration/test/files"; char alphaname [100]; char timeOffsetname[100]; char lambdaname [100]; char residname [100]; char resolname [100]; ifstream alphaInput; ifstream timeOffsetInput; ifstream lambdaInput; ifstream residInput; ifstream resolInput; char outname[100]; double L = 279.5; double ew; //parameters obtained from fits: double dummy; double lightSpeed; double alpha; double timeOffset; double lambda; double resid[4]; double resol[4]; lightSpeed = 0.; alpha = 0.; timeOffset = 0.; resid[0] = resid[1] = resid[2] = resid[3] = 0; resol[0] = resol[1] = resol[2] = resol[3] = 0; //output: double A,B,C,D,E,F,G,H,I,J; printf("Translating TofChannels to new format:\n"); //open the output file: sprintf(outname,"%s/%s_TofOfflineA.txt",outpath,store); printf("opening output file: %s\n",outname); ofstream output(outname); for (int pmt=0;pmt<432;pmt++){ if(pmt==0){ sprintf(alphaname,"%s/%s_timew-calib_e.txt",inpath,store); sprintf(timeOffsetname,"%s/%s_T0-calib_e.txt",inpath,store); sprintf(residname,"%s/%s_Zres-calib_e.txt",inpath,store); sprintf(resolname,"%s/%s_PmtRes-calib_e.txt",inpath,store); sprintf(lambdaname,"%s/%s_Att-calib_r.txt",inpath,store); alphaInput .open(alphaname); timeOffsetInput .open(timeOffsetname); lambdaInput .open(lambdaname); residInput .open(residname); resolInput .open(resolname); } if (pmt==216) { sprintf(alphaname,"%s/%s_timew-calib_w.txt",inpath,store); sprintf(timeOffsetname,"%s/%s_T0-calib_w.txt",inpath,store); sprintf(residname,"%s/%s_Zres-calib_w.txt",inpath,store); sprintf(resolname,"%s/%s_PmtRes-calib_w.txt",inpath,store); alphaInput .close(); timeOffsetInput .close(); residInput .close(); resolInput .close(); alphaInput .open(alphaname); timeOffsetInput .open(timeOffsetname); residInput .open(residname); resolInput .open(resolname); } if (pmt<216) ew = -1; else ew = 1; //LIGHT SPEED / TIME OFFSET: timeOffsetInput >> dummy; timeOffsetInput >> timeOffset; timeOffsetInput >> lightSpeed; timeOffsetInput >> dummy; timeOffsetInput >> dummy; //TIMEWALK: alphaInput >> dummy; alphaInput >> alpha; for (int i=0; i<7; i++) alphaInput >> dummy; //RESID: residInput >> dummy; for (int i=0; i<4; i++){ residInput >> resid[i]; residInput >> dummy; } //RESOL: resolInput >> dummy; for (int i=0; i<2; i++){ resolInput >> resol[i]; resolInput >> dummy; } resol[2] = resol[3] = 0.; //LAMBDA: don't bother reading right now. lambda = 300.; //check for validity of constants: if (lightSpeed == 0){ printf("WARNING: pmt %d uncalibrated\n",pmt); output << pmt << " 0.0"; for (int i=0; i<39; i++) output << "0 "; output << "\n"; continue; } //Now Translate: A = timeOffset - resid[0] - L/2.*resid[1] - L*L/4.*resid[2] - L*L*L/8.*resid[3] - L/2./lightSpeed; B = -ew/lightSpeed - resid[1] - L*resid[2] - .75*L*L*resid[3]; C = -alpha; D = -resid[2] - 1.5*L*resid[3]; E = 0; F = 0; G = - resid[3]; H = 0; I = 0; J = 0; output << pmt << " "; // pmt is o.k. output << "1.0 "; // timing model parameters: output << A << " " << B << " " << C << " " << D << " " << E << " "; output << F << " " << G << " " << H << " " << I << " " << J << " "; // charge parameters: A = 0; B = 1; C = ew/lambda; D = 0; output << A << " " << B << " " << C << " " << D << " "; // resolution parameters: A = resol[0] + L/2*fabs(resol[2]); B = ew*fabs(resol[2]); C = 0; D = 0; output << A << " " << B << " " << C << " " << D << " "; for (int i=0;i<21;i++) output << "0 "; output << "\n"; } // for..pmt alphaInput .close(); timeOffsetInput .close(); lambdaInput .close(); residInput .close(); resolInput .close(); output.close(); }