From 434dd482969177f94c9583d7bfcc19f2bd5c7901 Mon Sep 17 00:00:00 2001 From: Peter DeRosa <54421997+MagnusSnowleopard@users.noreply.github.com> Date: Mon, 18 Jul 2022 19:40:43 -0400 Subject: [PATCH] fixed AD fit, chi-squared wrong --- .AD.cxx.swp | Bin 16384 -> 0 bytes AD.cxx | 112 ++++++++++++++++++++++++++++++++-------------------- GUI_AD.h | 84 ++++++++++++++++++++++----------------- 3 files changed, 117 insertions(+), 79 deletions(-) delete mode 100644 .AD.cxx.swp diff --git a/.AD.cxx.swp b/.AD.cxx.swp deleted file mode 100644 index bf9330b3fb1ef70e328bc26146e0a33ff81a4364..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3Uu+yl9mkiJrgho^Dnh)$)DiBTd%pEuYzVbul={wJkoZQU)13DmZXT-C*8O1B z^_sXW+8Z0$!ul_*fL7owDsZ#0zg(ImBl|{gW$(V_2vD)Z3Ex0s<5u&&kv+uQR!V3ZzuzaomW))=T&-lApK>P zp6>dULrM9|Dn0RUV<7!nWp{s4zluo8C(-&_E1(t73TOqi0$KsBfL1^&pcT*xXa%$a z|Bnh-j$yn94PT=DG~WLw`|B6qX&5hn=fE$(cfh0I9QZ7F5F7^2zr!&84t@`Q4t@q6 z178DQ1rLGq;2iM4G#CXpfq&m@82; z1^g5I1N;Vj8+;Dj2fE;6paSN>7}x`zzY+C;r@=+=L-06w7|es0_Zr4!@DjKPE`ZN~ z2S5bI!B0jEqXkZZ8^K<1=?25-02|an3ETo+y52CJ1y6w|!38i4M!*f=Z+i^mui$BL z7DONflVBX=!C$UJ+rX#5Nw61;fM?#0wt#PeFMv(30qzAAkOS`pS8yKkNAPR#EARyP zBDes~fGWs?J>WX+xI|1qDXg3hcJRZTWmQFH-R%5`1#2!|;`( zGJ^)GO1sUiAlILgt)_uG3!-p-EA__mnl(zOMgA)H*g;n6wa513Xm*y3vWbZacF1eS zZ7X0EE3()EO0c_q%i)elJnfCjVs0Zx){1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`Ibt- chisqr; vector tdelta; + + double YT0,YT2,YT4,YT,YE = 0.; + double Y_err = 10.; + + //delta loop; for(int i = 0; i< points; i++){ - atan_delta = i*step + delta_min; - delta = tan(atan_delta); - rd2T = (rk01 + 2*delta*rk11 + pow(delta,2)*rk21)/(1+pow(delta,2)); + delta = i*step + delta_min; + // delta = tan(atan_delta); + //now sum over all theta; + + for(int j = 0; j < dangler.size(); j++){ + Tangle = dangler[j]; + //calculate Y_intensity_theory and and experiment and sum over theta + + // rd0T = (rk01 + 2*delta*rk11 + pow(delta,2)*rk21)/(1+pow(delta,2)); + + rd2T = (rk01 + 2*delta*rk11 + pow(delta,2)*rk21)/(1+pow(delta,2)); + + rd4T = (rk02 + 2*delta*rk12 + pow(delta,2)*rk22)/(1+pow(delta,2)); + + YT0 = 1; // P0(cos(theta)) = 1 + + YT2 = QD2*Bk11*rd2T*((1.5*pow(cos(Tangle),2)-.5)); + + YT4 = QD4*Bk12*rd4T*(35./8.* pow(cos(Tangle),4) - 30./8.*pow(cos(Tangle),2) + 3./8.); + + YT = YT0 + YT2 + YT4; + + YE = 1 + a2E*(1.5*pow(cos(Tangle),2)-.5) + a4E*(35./8.* pow(cos(Tangle),4) - 30./8.*pow(cos(Tangle),2) + 3./8.); + + X2_total += pow((YT- YE),2)/(200.); + } + //Figure out denominator. + + chisqr.push_back(log(X2_total)); + + tdelta.push_back(delta); + + X2_total = 0.; + + } +/* A2T = QD2*Bk11*rd2T; a2T = A2T/A0E; //using the idea that A0E is our normalizer. @@ -655,15 +686,10 @@ int main(int argc,char **argv){ A4T = QD4*Bk12*rd4T; a4T = A4T/A0E; - X22 = pow(abs(a2E -a2T),2)/(abs(a2T)); - X24 = pow(abs(a4E -a4T),2)/(abs(a4T)); + X22 = pow((a2E -a2T),2)/(a2T); + X24 = pow((a4E -a4T),2)/(a4T); X2_total = (X22 + X24)/2; - - chisqr.push_back(-log(X2_total)); - tdelta.push_back(atan_delta); - - } - +*/ vector Theta; vector AD_I; double ad_start = 0.; diff --git a/GUI_AD.h b/GUI_AD.h index 2d03445..3377f4d 100644 --- a/GUI_AD.h +++ b/GUI_AD.h @@ -239,18 +239,22 @@ int HistoGUIad::Draw_Fit(double x_low_win, double y_low_win, double x_hi_win, do if(x_low_win == -1 and y_low_win == -1 and x_hi_win == -1 and y_hi_win == -1){ // Audomatically decide data postition - max_x = x[0]; - max_y = y[0]; - min_x = x[0]; - min_y = y[0]; - - for(int i=0; i max_x) max_x = x[i]; if(x[i] < min_x) min_x = x[i]; if(y[i] > max_y) max_y = y[i]; if(y[i] < min_y) min_y = y[i]; } - +*/ width_scale = (max_x - min_x) / (0.8 * width); x_offset = 0.5 * ((max_x - min_x) / 0.8) - 0.5 * (min_x + max_x); @@ -327,21 +331,28 @@ int HistoGUIad::DrawData(double x_low_win, double y_low_win, double x_hi_win, do if(x_low_win == -1 and y_low_win == -1 and x_hi_win == -1 and y_hi_win == -1){ // Audomatically decide data postition - max_x = x[0]; - max_y = y[0]; - min_x = x[0]; - min_y = y[0]; - for(int i=0; i max_x) max_x = x[i]; if(x[i] < min_x) min_x = x[i]; if(y[i] > max_y) max_y = y[i]; if(y[i] < min_y) min_y = y[i]; } - //printf(" max_x = %f\n", max_x ); - //printf(" max_y = %f\n", max_y ); - //printf(" min_x = %f\n", min_x ); - //printf(" min_y = %f\n", min_y ); +*/ + + // printf(" max_x = %f\n", max_x ); + // printf(" max_y = %f\n", max_y ); + // printf(" min_x = %f\n", min_x ); + // printf(" min_y = %f\n", min_y ); width_scale = (max_x - min_x) / (0.8 * width); x_offset = 0.5 * ((max_x - min_x) / 0.8) - 0.5 * (min_x + max_x); @@ -352,7 +363,7 @@ int HistoGUIad::DrawData(double x_low_win, double y_low_win, double x_hi_win, do //printf("width scale = %f\n", width_scale); //printf("x_offset = %f\n", x_offset); //printf("height scale = %f\n", height_scale); - //printf("y_offset = %f\n", y_offset); + //printf("y_offset = %f\n", y_offst); double axis_x = (0. + x_offset) / width_scale; double axis_y = (0. + y_offset) / height_scale; @@ -387,15 +398,16 @@ int HistoGUIad::DrawData(double x_low_win, double y_low_win, double x_hi_win, do x_wid = (x[i] + x_offset) / width_scale; y_wid = (y[i] + y_offset) / height_scale; y_errors_wid = ((y_errors[i]/A0) / height_scale); - // x_wid2 = (x[i + 1] + x_offset) / width_scale; - // y_wid2 = (y[i + 1] + y_offset) / height_scale; - //printf("(%f, %f), (%f,%f)\n", x_wid,y_wid,x_wid2,y_wid2); - // XDrawLine(disp, wind, DefaultGC(disp, screen), x_wid, y_wid, x_wid2, y_wid2); - XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -3, y_wid -3, 6, 6); - XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid + y_errors_wid, 2, y_errors_wid); - XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid - y_errors_wid, 2, y_errors_wid); -//error bar testing - XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -4, y_wid + y_errors_wid, 8, 2); + + //draws the point + XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -3, y_wid -3, 6, 6); + + //these are the vertical error bars. + // XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid + y_errors_wid, 2, y_errors_wid); + // XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid - y_errors_wid, 2, y_errors_wid); + + // these are the caps of the error bars ; + XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -4, y_wid + y_errors_wid, 8, 2); XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -4, y_wid - y_errors_wid, 8, 2); } // XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid2 -2, y_wid2 -2, 4, 4); @@ -425,14 +437,14 @@ int HistoGUIad::DrawData(double x_low_win, double y_low_win, double x_hi_win, do for(int i=0; i < (int) width; i += w_step){ double x_val = i * width_scale - x_offset; sprintf(axis_val, "%.1f", x_val); - XDrawString(disp, wind, DefaultGC(disp, screen), i, axis_y + 10/A0, axis_val, strlen(axis_val)); + XDrawString(disp, wind, DefaultGC(disp, screen), i, axis_y + 10, axis_val, strlen(axis_val)); } int h_step = height / 10; for(int i=0; i < (int) height; i += h_step){ double y_val = i * height_scale - y_offset; sprintf(axis_val, "%.1f", y_val); - XDrawString(disp, wind, DefaultGC(disp, screen), axis_x + 10/A0, i, axis_val, strlen(axis_val)); + XDrawString(disp, wind, DefaultGC(disp, screen), axis_x + 10, i, axis_val, strlen(axis_val)); } @@ -449,15 +461,15 @@ int HistoGUIad::DrawData(double x_low_win, double y_low_win, double x_hi_win, do y_wid = (y[i] + y_offset) / height_scale; y_errors_wid = ((y_errors[i]/A0) / height_scale); - - // x_wid2 = (x[i + 1] + x_offset) / width_scale; - // y_wid2 = (y[i + 1] + y_offset) / height_scale; - // printf("(%f, %f), (%f,%f)\n", x_wid,y_wid,x_wid2,y_wid2); - // XDrawLine(disp, wind, DefaultGC(disp, screen), x_wid, y_wid, x_wid2, y_wid2); + + //draws the point XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -3, y_wid -3, 6, 6); - XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid , 2, y_errors_wid); - XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid - y_errors_wid, 2, y_errors_wid); -//testig for error bars. + + //these are the vertical error bars + // XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid +y_errors_wid , 2, y_errors_wid); + // XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -1, y_wid - y_errors_wid, 2, y_errors_wid); + + //These are the error bar caps;. XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -4, y_wid + y_errors_wid, 8, 2); XFillRectangle(disp, wind, DefaultGC(disp, screen), x_wid -4, y_wid - y_errors_wid, 8, 2); }