// 2016.12.28 replace MEA1 file and make all eff = 1 due to the mail. // 2016.12.27 reproduce by using new g-factor files from MEA team on the day. // // to prepare EEPROM data for lookup table used for VM calculation of MEA1&2, // Input files: // MEA1_FM_MCP_Rel_Eff.txt // Mea_1_V2_FM_Properties_1000eV_09_Apr_2015.txt // MEA2_FM_MCP_Rel_Eff.txt // Mea2_V2_FM_Properties_1007eV_18_Feb_2015.txt // // // // ***************************************************************** // MEA1/2 ROM table // -------------------------------------------------------- // Start-address Gd_MEA_RomAdr // Length 1440B(in one file) // ---------------------------------------------- // HK_LIMIT 16B x2 // g-factor1 16ch x5 80B x2 // g-factor2 16ch x5 80B x2 // theta 16ch x5 80B x2 // Phi 16ch x5 80B x2 // Energy T1-3 32en x3 192B x2 // Ch-factor 16ch x5 80B x2 // spare 112B x2 // ---------------------------------------------- // ***************************************************************** #include #include #include #include #define _CONDUCT_MEA1_ //MEA2 at not defining //gf x eff. の最小値を設定する。 #define MEA1_GF0 5.0e-6 #define MEA1_GF1 1.0e-5 #define MEA1_GF2 2.0e-6 #define MEA1_GF3 5.0e-7 #define MEA1_GF4 9.0e-8 //2.0e-7 //<<<<< 2016.12.26 #define MEA2_GF0 5.0e-5 //1.0e-4 //<<<<< 2016.12.26 #define MEA2_GF1 9.0e-5 //1.5e-4 //<<<<< 2016.12.26 #define MEA2_GF2 9.0e-6 //1.5e-5 //<<<<< 2016.12.26 #define MEA2_GF3 4.0e-6 //7.0e-6 //<<<<< 2016.12.26 #define MEA2_GF4 1.0e-6 //2.5e-6 //<<<<< 2016.12.26 //Defined in the file of sweeping voltage table #define MEA_ANLZR_CNST0 8.67 //from app_MPPE-MEA.h #define d_Lcl_MEA_TBL_GF 0xbf //gf&gf2, median (1) #define d_Lcl_MEA_TBL_GF0 0x40 //gf&gf2, minimum、gf += uc_gf #define d_Lcl_MEA_TBL_RAD 0x7f //LOOKUP TABLE RAD. Normalization parameter to make and read the table #define d_Lcl_MEA_MAX_RAD (M_PI/16)//LOOKUP TABLE RAD. Normalization parameter (11.25 deg.) //#define d_Lcl_MEA_TBL_GF 0x27f //gf&gf2, median (1) //#define d_Lcl_MEA_TBL_GF0 0x200 //gf&gf2, minimum, gf += uc_gf #define d_Lcl_MEA_TBL_VF 0x27f//(d_Lcl_MEA_TBL_GF) //vf, median (1) #define d_Lcl_MEA_TBL_VF0 0x200//(d_Lcl_MEA_TBL_GF0) //vf, minimum, vf += uc_vf //1: 3-3k 0xffff //2: 3-25k 0xffff <-> 1.0273e5 km/s(30keV) //3: 2k-25k 0xffff <-> 1.0273e5 km/s(30keV) #define d_Lcl_MEA_2qm 5.931e2 //=sqrt(2*q/m)/1000 #define d_Lcl_MEA_MAX_V32 1.0273e5 //LOOKUP TABLE Velocity32 Normalization parameter (km/s) 30keV typedef unsigned short USHORT; typedef unsigned char UCHAR; typedef struct { //float eff[16]; float en[16]; float ph[16]; float gf[16]; float al[16]; } Charac; void cal_angle(float*, float*, float*, float*); void input_vtable(USHORT*); void outputf(UCHAR*, char*, char*, USHORT*, UCHAR*); main(int argc, char *argv[]) { int i, j, k; #ifdef _CONDUCT_MEA1_ char fn_meaeff[] = "./mea/MEA1_FM_MCP_Rel_Eff.txt"; //char fn_meaprm[] = "./mea/Mea1_FM_Properties_1000eV_03Jul_2012.txt"; //char fn_meaprm[] = "./mea/Mea1_FM_Properties_1000eV_03Jul_2012_A.txt"; char fn_meaprm[] = "./mea/Mea_1_V2_FM_Properties_1000eV_09_Apr_2015.txt"; #else char fn_meaeff[] = "./mea/MEA2_FM_MCP_Rel_Eff.txt"; //char fn_meaprm[] = "./mea/Mea2_FM_Properties_1000eV_19Apr_2012.txt"; //char fn_meaprm[] = "./mea/Mea2_FM_Properties_1000eV_19Apr_2012_A.txt"; char fn_meaprm[] = "./mea/Mea2_V2_FM_Properties_1007eV_18_Feb_2015.txt"; #endif char line[1000]; int i_ch; int i_gf; float f[7]; float f_eff[16]; FILE *fp_in0, *fp_in1; Charac g[5]; UCHAR uc[128]; char c_tmp[80]; float f_gf[5][16]; USHORT us_gf[5][16]; UCHAR uc_gf[5][16]; float f_gf0[5]; UCHAR uc_gf2[5*16]; float f_th[5*16]; float f_th2[5*16]; float f_th0[16]; char c_th[5*16]; float f_pe[5*16]; float f_pe2[5*16]; char c_pe[5*16]; float f_vc[5*16]; float f_vc1[5*16]; UCHAR uc_vc[5*16]; float f_tmp[5*16]; float f_vc_ref; USHORT us_vl[3*32]; #ifdef _CONDUCT_MEA1_ f_gf0[0] = MEA1_GF0; f_gf0[1] = MEA1_GF1; f_gf0[2] = MEA1_GF2; f_gf0[3] = MEA1_GF3; f_gf0[4] = MEA1_GF4; #else f_gf0[0] = MEA2_GF0; f_gf0[1] = MEA2_GF1; f_gf0[2] = MEA2_GF2; f_gf0[3] = MEA2_GF3; f_gf0[4] = MEA2_GF4; #endif printf("START ¥n"); printf("Open %s ¥n", fn_meaeff); printf("Open %s ¥n", fn_meaprm); if(NULL == (fp_in0=fopen(fn_meaeff,"r"))) { printf("cannot open %s ¥n",fn_meaeff); exit(2); } if(NULL == (fp_in1=fopen(fn_meaprm,"r"))) { printf("cannot open %s ¥n",fn_meaprm); exit(2); } //Read input files while(1) { if (NULL == fgets(line, 500, fp_in1)) break; if(line[0] == '#') continue; sscanf(line, " %d %f %d %f %f %f %f %f¥n", &i_gf, &f[0], &i_ch, &f[1], &f[2], &f[3], &f[4], &f[5], &f[6]); g[i_gf].gf[i_ch] = f[1]; g[i_gf].al[i_ch] = f[2]; g[i_gf].ph[i_ch] = f[3]; g[i_gf].en[i_ch] = f[5]; //printf("%s", line); //printf("%d %d %f %e %f %f %f %e¥n", // i_gf, i_ch, f[0], f[1], f[2], f[3], f[4], f[5]); } //Read input files for MCP efficiency while(1) { if (NULL == fgets(line, 500, fp_in0)) break; if(line[0] == 'A' || line[0] == 'D' || line[0] == 'N' || line[0] == 'E' || line[0] == '-' || line[1] == '#') continue; sscanf(line, " %d %f¥n", &i_ch, &f[0]); f_eff[i_ch] = f[0]; } //ALL EFF = 1 due to the fact that g-factor include efficiency. for (i = 0; i < 16; ++i) f_eff[i] = 1.; fclose(fp_in0); fclose(fp_in1); // ####################################################### // // g-factor /eff/g, 1B x 16CH x 5GF = 80B // 1-0xff -> GF0 + 1-0xff // 0 -> 0 // // ####################################################### for (j = 0; j < 5; ++j) { for (i = 0; i < 16; ++i) { //BLIND CHs of MEA1 #ifdef _CONDUCT_MEA1_ if ( i >= 10 && i <= 13) { f_gf[j][i] = 0; us_gf[j][i] = 0; f_eff[i] = 1.; continue; } #endif //#### g-factor無効値による一時的な対応 ####### //#### 改訂版取得後、ここはコメントアウトする。 ####### //if (i == 0) { // f_gf[j][i] = 1/g[j].gf[1]/f_eff[i]; // us_gf[j][i] = f_gf[j][i]*f_gf0[j]*d_Lcl_MEA_TBL_GF; // continue; //} //else if (i == 15) { // f_gf[j][i] = 1/g[j].gf[14]/f_eff[i]; // us_gf[j][i] = f_gf[j][i]*f_gf0[j]*d_Lcl_MEA_TBL_GF; // continue; //} // ############################################ // ############################################ f_gf[j][i] = 1/g[j].gf[i]/f_eff[i]; us_gf[j][i] = f_gf[j][i]*f_gf0[j]*d_Lcl_MEA_TBL_GF; } } //CHECK & PROC. for (j = 0; j < 5; ++j) { for (i = 0; i < 16; ++i) { if (us_gf[j][i] == 0) uc_gf[j][i] = 0; else if (us_gf[j][i] > d_Lcl_MEA_TBL_GF0 + 0xff) { fprintf(stderr, "us_gf[%d][%d] = %x is TOO LARGE¥n", j, i, us_gf[j][i]); uc_gf[j][i] = 0xff; } else if (us_gf[j][i] <= d_Lcl_MEA_TBL_GF0) { fprintf(stderr, "us_gf[%d][%d] = %x is TOO SMALL¥n", j, i, us_gf[j][i]); uc_gf[j][i] = 1; } else uc_gf[j][i] = us_gf[j][i] - d_Lcl_MEA_TBL_GF0; } } printf("1/g-factor/efficiency¥n"); for (j = 0; j < 5; ++j) { for (i = 0; i < 16; ++i) { printf("[%02d][%02d] %.2e %.4f >> %.3f %04x %02x¥n", j, i,g[j].gf[i], f_eff[i], f_gf[j][i], us_gf[j][i], uc_gf[j][i]); uc_gf2[i + 16*j] = uc_gf[j][i]; } } //ASSUMING: // MEA1 SC0 CH0-7 -> -x-axis // MEA2 SC0 CH0-7 -> -y-axis // CH0&15 -> z-axis -> theta=90deg. // theta -> -90 to +90 // // ####################################################### // // theta 1B x 16CH x 5GF = 80B // // ####################################################### //reference for (i = 0; i < 8; ++i) f_th0[i] = 78.75 - 22.5*i; for (i = 8; i < 16; ++i) f_th0[i] = -78.75 + 22.5*(i-8); for (j = 0; j < 5; ++j) { for (i = 0; i < 8; ++i) f_th[j*16 + i] = g[j].al[i] - 90; for (i = 8; i < 16; ++i) f_th[j*16 + i] = -g[j].al[i] - 90; } //BLIND CHs of MEA1 #ifdef _CONDUCT_MEA1_ for (j = 0; j < 5; ++j) for (i = 10; i <= 13; ++i) f_th[j*16 + i] = f_th0[i]; #endif //CHECK for (i = 0; i < 5*16; ++i) if (fabs(f_th[i]) >= 90.) fprintf(stderr, "|f_th[%d][%d]| > 90 deg.¥n", i/16, i); // ####################################################### // // phi 1B x 16CH x 5GF = 80B // // ####################################################### for (j = 0; j < 5; ++j) { for (i = 0; i < 8; ++i) f_pe[j*16 + i] = g[j].ph[i]; for (i = 8; i < 16; ++i) f_pe[j*16 + i] = -g[j].ph[i]; } //BLIND CHs of MEA1 #ifdef _CONDUCT_MEA1_ for (j = 0; j < 5; ++j) for (i = 10; i <= 13; ++i) f_pe[j*16 + i] = 0.; #endif //CHECK // for (i = 0; i < 5*16; ++i) // if (fabs(f_pe[i]) >= 11.25) fprintf(stderr, "|f_pe[%d]| > 11.25 deg.¥n", i); //coordinate transform // Sensor coor. --> S/C coor.(X: sun pulse(maybe), Z: spin axis to north, Y: completing the right hand sys.) cal_angle( f_th, f_pe, //input f_th2, f_pe2); //output //CHECK // for (i = 0; i < 5*16; ++i) { // if (fabs(f_th2[i]) >= 90.) fprintf(stderr, "|f_th2[%d][%d]| > 90 deg.¥n", i/16, i); // if (fabs(f_pe2[i]) >= 11.25) fprintf(stderr, "|f_pe2[%d]| > 11.25 deg.¥n", i); // } //c_th についてはVM計算で反転しているので符号の反転が必要かもしれない 2016.07.04!! //for (i = 0; i < 5*16; ++i) c_th[i] = -(f_th2[i] - f_th0[i%16])*M_PI/180./d_Lcl_MEA_MAX_RAD*d_Lcl_MEA_TBL_RAD; // //ThETA&PHI normalization for (i = 0; i < 5*16; ++i) c_th[i] = (f_th2[i] - f_th0[i%16])*M_PI/180./d_Lcl_MEA_MAX_RAD*d_Lcl_MEA_TBL_RAD; for (i = 0; i < 5*16; ++i) { c_pe[i] = f_pe2[i]/180.*M_PI/d_Lcl_MEA_MAX_RAD*d_Lcl_MEA_TBL_RAD; if (f_pe2[i] > 11.25) c_pe[i] = 0x7f; else if (f_pe2[i] <-11.25) c_pe[i] = -0x7f; } memcpy(uc, c_th, 80); memcpy(c_tmp, uc, 80); for (i = 0; i < 5*16; ++i) { printf("THETA[%02d %02d] %.2f %.2f %.2f %.2f %02x %.2f", i/16, i%16, g[i/16].al[i%16], f_th[i], f_th2[i], f_th2[i] - f_th0[i%16], uc[i], c_tmp[i]*180./M_PI*d_Lcl_MEA_MAX_RAD/d_Lcl_MEA_TBL_RAD); if (abs(f_th2[i] - f_th0[i%16]) > 11.25) printf(" over 11.25 deg.¥n", i); else printf("¥n"); } memcpy(uc, c_pe, 80); memcpy(c_tmp, uc, 80); for (i = 0; i < 5*16; ++i) { printf("PHI[%02d %02d] %.2f %.2f %.2f %02x %.2f", i/16, i%16, g[i/16].ph[i%16], f_pe[i], f_pe2[i], uc[i], c_tmp[i]*180./M_PI*d_Lcl_MEA_MAX_RAD/d_Lcl_MEA_TBL_RAD); if (abs(f_pe2[i]) > 11.25) printf(" over 11.25 deg.¥n", i); else printf("¥n"); } // ####################################################### // // V-ch-factor 1B x 16CH x 5GF = 80B // (= 0.8 + 0.4 x 1B/0xff) // // ####################################################### //Energy -> velocity -> normalized f_vc_ref = sqrt(MEA_ANLZR_CNST0); for (i = 0; i < 5*16; ++i) f_vc[i] = sqrt(g[i/16].en[i%16]); for (i = 0; i < 5*16; ++i) f_vc1[i] = (f_vc[i] - f_vc_ref)/f_vc_ref; //CHECK for (i = 0; i < 5*16; ++i) if (fabs(f_vc1[i]) >= 0.20) fprintf(stderr, "|f_en[%d] - base| > 20%¥n", i); //規格化 for (i = 0; i < 5*16; ++i) uc_vc[i] = f_vc1[i]*d_Lcl_MEA_TBL_VF + 0x7f; // for (i = 0; i < 5*16; ++i) f_tmp[i] = f_vc_ref*(d_Lcl_MEA_TBL_VF0 + uc_vc[i])/d_Lcl_MEA_TBL_VF; for (i = 0; i < 5*16; ++i) printf("CH-f[%02d %02d] %f %f %f %02x %f¥n", i/16, i%16, g[i/16].en[i%16], f_vc[i], f_vc1[i], uc_vc[i], f_tmp[i]); // ####################################################### // Velocity 832B // T0: 3-300 eV 0B Photoelectron, not used for VM cal. // T1: 3-3k eV 2B x [32en] x 3 // T2: 3-25k eV // T3: 2k-25k eV // ####################################################### input_vtable(us_vl); //MEAエクセルファイルから抜粋 outputf(uc_gf2, c_th, c_pe, us_vl, uc_vc); } void outputf(UCHAR uc_gf[], char c_th[], char c_pe[], USHORT us_vl[], UCHAR uc_vc[]) { FILE *fp; int i, j; unsigned char uc[832]; if(NULL == (fp=fopen("app_romTable_MEA_body.txt", "w"))) { printf("cannot open mis.dat¥n"); exit(2); } //OUTPUT fprintf(fp, "//G-factor (1B x 16ch x 5gf = 80B) for Et"); for (i = 0; i < 16*5; ++i) { if (i%16 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, ", uc_gf[i]); } fprintf(fp, "¥n//G-factor (1B x 16ch x 5gf = 80B) for VM"); for (i = 0; i < 16*5; ++i) { if (i%16 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, ", uc_gf[i]); } fprintf(fp, "¥n//THETA (1B x 16ch x 5gf = 80B)"); memcpy(uc, c_th, 16*5); for (i = 0; i < 16*5; ++i) { if (i%16 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, ", uc[i]); } fprintf(fp, "¥n//PHI (1B x 16ch x 5gf = 80B)"); memcpy(uc, c_pe, 16*5); for (i = 0; i < 16*5; ++i) { if (i%16 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, ", uc[i]); } fprintf(fp, "¥n//Velocity (2B x 32en x 3T = 192B)"); memcpy(uc, us_vl, 2*32*3); fprintf(fp, "¥n//T1"); for (i = 0; i < 32; ++i) { if (i%8 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, 0x%02x, ", uc[2*i+1], uc[2*i]); } fprintf(fp, "¥n//T2"); for (i = 32; i < 64; ++i) { if (i%8 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, 0x%02x, ", uc[2*i+1], uc[2*i]); } fprintf(fp, "¥n//T3"); for (i = 64; i < 96; ++i) { if (i%8 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, 0x%02x, ", uc[2*i+1], uc[2*i]); } fprintf(fp, "¥n//V-CH-factorr (1B x 16ch x 5gf = 80B)"); for (i = 0; i < 16*5; ++i) { if (i%16 == 0) fprintf(fp, "¥n"); fprintf(fp, "0x%02x, ", uc_vc[i]); } fclose(fp); } void cal_angle(float f_al[], float f_bt[], float f_outp[], float f_outa[]) { int i; double rad = M_PI/180.; double x, y, z; for (i = 0; i < 5*16; ++i) { y = sin(f_bt[i]*rad); x = cos(f_bt[i]*rad)*cos(f_al[i]*rad); z = cos(f_bt[i]*rad)*sin(f_al[i]*rad); f_outp[i] = atan2(z, sqrt(x*x + y*y))/rad; f_outa[i] = atan2(y, x)/rad; //printf("x y z a b a2 b2 %d| %f %f %f %f %f %f %f¥n", //i,x,y,z,f_al[i], f_bt[i],f_outp[i], f_outa[i]); } } void input_vtable(USHORT us_v32[]) { float f[128*3] = { //Energy(eV) from MEA energy table //T1 26010.00, 26010.00, 26010.00, 24190.02, 22497.39, 20923.19, 19459.14, 18097.54, 16831.21, 15653.49, 14558.18, 13539.51, 12592.12, 11711.02, 10891.57, 10129.46, 9420.68, 8761.49, 8148.43, 7578.26, 7048.00, 6554.83, 6096.17, 5669.61, 5272.89, 4903.94, 4560.80, 4241.67, 3944.87, 3668.84, 3412.12, 3173.36, 2951.32, 2744.81, 2552.75, 2374.12, 2208.00, 2053.50, 1909.81, 1776.18, 1651.90, 1536.31, 1428.81, 1328.83, 1235.85, 1149.38, 1068.95, 994.15, 924.59, 859.89, 799.73, 743.77, 691.72, 643.32, 598.31, 556.44, 517.51, 481.30, 447.62, 416.30, 387.17, 360.08, 334.88, 311.45, 289.66, 269.39, 250.54, 233.01, 216.70, 201.54, 187.44, 174.32, 162.12, 150.78, 140.23, 130.42, 121.29, 112.81, 104.91, 97.57, 90.74, 84.39, 78.49, 73.00, 67.89, 63.14, 58.72, 54.61, 50.79, 47.24, 43.93, 40.86, 38.00, 35.34, 32.87, 30.57, 28.43, 26.44, 24.59, 22.87, 21.27, 19.78, 18.40, 17.11, 15.91, 14.80, 13.76, 12.80, 11.90, 11.07, 10.30, 9.58, 8.91, 8.28, 7.70, 7.16, 6.66, 6.20, 5.76, 5.36, 4.98, 4.64, 4.31, 4.01, 3.73, 3.47, 3.23, 3.00, //T2 3000.00, 3000.00, 3000.00, 2838.71, 2686.09, 2541.68, 2405.03, 2275.73, 2153.38, 2037.61, 1928.06, 1824.41, 1726.32, 1633.51, 1545.69, 1462.59, 1383.95, 1309.55, 1239.14, 1172.52, 1109.48, 1049.84, 993.39, 939.99, 889.45, 841.63, 796.38, 753.57, 713.05, 674.72, 638.44, 604.12, 571.64, 540.91, 511.82, 484.31, 458.27, 433.63, 410.32, 388.26, 367.38, 347.63, 328.94, 311.26, 294.52, 278.69, 263.71, 249.53, 236.11, 223.42, 211.41, 200.04, 189.29, 179.11, 169.48, 160.37, 151.75, 143.59, 135.87, 128.56, 121.65, 115.11, 108.92, 103.07, 97.53, 92.28, 87.32, 82.63, 78.18, 73.98, 70.00, 66.24, 62.68, 59.31, 56.12, 53.10, 50.25, 47.55, 44.99, 42.57, 40.28, 38.12, 36.07, 34.13, 32.29, 30.56, 28.91, 27.36, 25.89, 24.50, 23.18, 21.93, 20.75, 19.64, 18.58, 17.58, 16.64, 15.74, 14.90, 14.10, 13.34, 12.62, 11.94, 11.30, 10.69, 10.12, 9.57, 9.06, 8.57, 8.11, 7.68, 7.26, 6.87, 6.50, 6.15, 5.82, 5.51, 5.21, 4.93, 4.67, 4.42, 4.18, 3.95, 3.74, 3.54, 3.35, 3.17, 3.00, //T3 26010.00, 26010.00, 26010.00, 25564.44, 25126.50, 24696.07, 24273.02, 23857.21, 23448.52, 23046.83, 22652.03, 22263.99, 21882.60, 21507.73, 21139.30, 20777.17, 20421.24, 20071.42, 19727.58, 19389.64, 19057.49, 18731.02, 18410.15, 18094.77, 17784.80, 17480.14, 17180.69, 16886.38, 16597.11, 16312.79, 16033.34, 15758.68, 15488.73, 15223.40, 14962.61, 14706.30, 14454.37, 14206.76, 13963.39, 13724.19, 13489.09, 13258.01, 13030.89, 12807.67, 12588.27, 12372.62, 12160.67, 11952.35, 11747.60, 11546.36, 11348.57, 11154.16, 10963.08, 10775.28, 10590.69, 10409.27, 10230.95, 10055.69, 9883.43, 9714.12, 9547.72, 9384.16, 9223.40, 9065.40, 8910.11, 8757.47, 8607.45, 8460.00, 8315.08, 8172.64, 8032.63, 7895.03, 7759.78, 7626.86, 7496.20, 7367.79, 7241.58, 7117.52, 6995.60, 6875.76, 6757.97, 6642.21, 6528.42, 6416.59, 6306.67, 6198.63, 6092.44, 5988.08, 5885.50, 5784.68, 5685.58, 5588.18, 5492.46, 5398.37, 5305.89, 5215.00, 5125.66, 5037.86, 4951.56, 4866.73, 4783.36, 4701.42, 4620.88, 4541.73, 4463.92, 4387.45, 4312.30, 4238.42, 4165.82, 4094.45, 4024.31, 3955.38, 3887.62, 3821.02, 3755.56, 3691.23, 3628.00, 3565.85, 3504.76, 3444.72, 3385.71, 3327.72, 3270.71, 3214.68, 3159.61, 3105.49, 3052.29, 3000.00 }; int i; float f_e32[3*32], f_v32[3*32]; for (i = 0; i < 3*32; ++i) { if (i%32 == 0) f_e32[i] = (f[4*i + 2] + f[4*i + 3])/2; else f_e32[i] = (f[4*i + 0] + f[4*i + 1] + f[4*i + 2] + f[4*i + 3])/4; } //(eV) -> km/s: sqrt( (eV) ) x sqrt(2*q/m)/1000 for (i = 0; i < 3*32; ++i) f_v32[i] = sqrt(f_e32[i])*d_Lcl_MEA_2qm; //規格化 for (i = 0; i < 3*32; ++i) us_v32[i] = f_v32[i]/d_Lcl_MEA_MAX_V32*0xffff; for (i = 0; i < 3*32; ++i) printf("V[%d %02d]: %.2f %.2f %004x¥n", i/32, i%32, f_e32[i], f_v32[i], us_v32[i]); }