#include #include #include #include #include using namespace std; const int obbits=16; const int obnumb=8; // input is bin data 1-32, binerror 1-32, inital fit parameter R0-kb as input, outout fit parameter R0-kb int fw_binned(ap_ufixed aob1, ap_ufixed aob2, ap_ufixed aob3, ap_ufixed aob4, ap_ufixed aob5, ap_ufixed aob6, ap_ufixed aob7, ap_ufixed aob8, ap_ufixed aob9, ap_ufixed aob10, ap_ufixed aob11, ap_ufixed aob12, ap_ufixed aob13, ap_ufixed aob14, ap_ufixed aob15, ap_ufixed aob16, ap_ufixed aob17, ap_ufixed aob18, ap_ufixed aob19, ap_ufixed aob20, ap_ufixed aob21, ap_ufixed aob22, ap_ufixed aob23, ap_ufixed aob24, ap_ufixed aob25, ap_ufixed aob26, ap_ufixed aob27, ap_ufixed aob28, ap_ufixed aob29, ap_ufixed aob30, ap_ufixed aob31, ap_ufixed aob32, ap_ufixed aobe1, ap_ufixed aobe2, ap_ufixed aobe3, ap_ufixed aobe4, ap_ufixed aobe5, ap_ufixed aobe6, ap_ufixed aobe7, ap_ufixed aobe8, ap_ufixed aobe9, ap_ufixed aobe10, ap_ufixed aobe11, ap_ufixed aobe12, ap_ufixed aobe13, ap_ufixed aobe14, ap_ufixed aobe15, ap_ufixed aobe16, ap_ufixed aobe17, ap_ufixed aobe18, ap_ufixed aobe19, ap_ufixed aobe20, ap_ufixed aobe21, ap_ufixed aobe22, ap_ufixed aobe23, ap_ufixed aobe24, ap_ufixed aobe25, ap_ufixed aobe26, ap_ufixed aobe27, ap_ufixed aobe28, ap_ufixed aobe29, ap_ufixed aobe30, ap_ufixed aobe31, ap_ufixed aobe32, ap_ufixed inR0, ap_ufixed insigma, ap_ufixed inphi0, ap_ufixed inkb, ap_ufixed *outR0, ap_ufixed *outsigma, ap_ufixed *outphi0, ap_ufixed *outkb ){ // *outR0=inR0; *outsigma=insigma; *outphi0=inphi0; *outkb=inkb; float aob[32]={aob1, aob2, aob3, aob4, aob5, aob6, aob7, aob8, aob9, aob10, aob11, aob12, aob13, aob14, aob15, aob16, aob17, aob18, aob19, aob20, aob21, aob22, aob23, aob24, aob25, aob26, aob27, aob28, aob29, aob30, aob31, aob32}; float aobe[32]={aobe1, aobe2, aobe3, aobe4, aobe5, aobe6, aobe7, aobe8, aobe9, aobe10, aobe11, aobe12, aobe13, aobe14, aobe15, aobe16, aobe17, aobe18, aobe19, aobe20, aobe21, aobe22, aobe23, aobe24, aobe25, aobe26, aobe27, aobe28, aobe29, aobe30, aobe31, aobe32}; //int fw_binned(float *aob, float *aobe, float &R0, float &sigma, float &phi0, float &birks, float initR0){ int my_precision=16; // NODIF IN 6 DIG for integ1 //def int fw_nintegbin=4; // def But dont use calc by hand float fw_precision = 1e-4; // a parameter for numerical integration, reduce to speed up calculation int fw_nbin=32; //just number of bin of data //HHHH LUT gen HHHHH// // hist infor e.g. layer widht of detector float bins_lut[33]= { 0, 2.90158, 5.7519, 8.78677, 11.6986, 14.5387, 17.5428, 20.4444, 23.3152, 26.3193, 29.2209, 32.1122, 35.1061, 38.0179, 40.899, 43.8723, 46.7739, 49.6755, 52.8437, 55.6837, 58.5033, 61.4561, 64.3885, 67.2798, 70.2224, 73.1445, 75.9538, 78.6606, 81.3879, 84.4125, 87.109, 89.785, 92.4508}; // Calc from bin width divided by # of division to average in a bin for expected float binw_lut[32]= { 0.580316, 0.570064, 0.606974, 0.582366, 0.56802, 0.60082, 0.58032, 0.57416, 0.60082, 0.58032, 0.57826, 0.59878, 0.58236, 0.57622, 0.59466, 0.58032, 0.58032, 0.63364, 0.568, 0.56392, 0.59056, 0.58648, 0.57826, 0.58852, 0.58442, 0.56186, 0.54136, 0.54546, 0.60492, 0.5393, 0.5352, 0.53316}; //HHHH Minimize parameters HHHH// int debug_lv=0; float rx=0; int max_test=128;// high enough // int max_test=64; //mid 32 also minimize almost // int max_test=32; //min //temp to compile... //HHHHH parameter min max setting float cR0=inR0; //current val float rR0=20; //range float minR0=inR0; //current R0 of minimum -2logL float csigma=insigma; //current val float rsigma=1; //range float minsigma=2; //current sigma of minimum -2logL float cphi0=inphi0; //current val *1e-7 float rphi0=20; //range float minphi0=20; //current phi0 of minimum -2logL float cbirks=inkb; //current val float rbirks=0.03; //range float minbirks=0.07; //current birks of minimum -2logL int tlv=0, stagelv=0, paran=0; float minLogL=9999999; int npar=4; for(int t=0; t0){ logP=(ob-ex)*(ob-ex)/(obe*obe)+2*log(obe*2.507); } logL+=logP; } // end loop for bins for minL // if(debug_lv>3){ // cout<