diff --git a/.AD.cxx.swp b/.AD.cxx.swp deleted file mode 100644 index bf9330b..0000000 Binary files a/.AD.cxx.swp and /dev/null differ diff --git a/AD.cxx b/AD.cxx index 162f952..576fa3f 100644 --- a/AD.cxx +++ b/AD.cxx @@ -99,9 +99,9 @@ int main(int argc,char **argv){ } double QD2 = QK2(Energy, detradius, targetdistance, detthickness); ; - //.82;//NEED TO READ FROM ad.txt in the future. + double QD4 = QK4(Energy, detradius, targetdistance, detthickness); ; - //.44; + // cout << "QD2 = " << " " << QD2 << " QD4 = " << " " << QD4 << "\n"; //input data file of Angular Data (theta, Yexp, Yerr) @@ -226,30 +226,7 @@ int main(int argc,char **argv){ // Note, the y data must be scaled by sin(theta) of the given angle. double a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12 = 0.; - /* - for(int i = 0; i< dangler.size(); i++){ - - //eq1 - a1 += 1; //how many data points, not intensional but convientient. - a2 += (1.5 * pow(dangler[i],2) - .5); - a3 += (35./8. * pow(dangler[i],4) - 30./8. * pow(dangler[i],2) + 3./8. ); - a4 += dydata[i]; - //eq2 - a5 += (1.5 * pow(dangler[i],2) - .5); - a6 += (1.5 * pow(dangler[i],2) - .5)*(1.5 * pow(dangler[i],2) - .5); - a7 += (1.5 * pow(dangler[i],2) - .5)*(35./8. * pow(dangler[i],4) - 30./8. * pow(dangler[i],2) + 3./8. ); - a8 += (1.5 * pow(dangler[i],2) - .5)*dydata[i]; - //eq4 - a9 += (35./8. * pow(dangler[i],4) - 30./8. * pow(dangler[i],2) + 3./8. ); - a10 += (1.5 * pow(dangler[i],2) - .5)*(35./8. * pow(dangler[i],4) - 30./8. * pow(dangler[i],2) + 3./8. ); - a11 +=(35./8. * pow(dangler[i],4) - 30./8. * pow(dangler[i],2) + 3./8. )* (35./8. * pow(dangler[i],4) - 30./8. * pow(dangler[i],2) + 3./8. ); - a12 += (35./8. * pow(dangler[i],4) - 30./8. * pow(dangler[i],2) + 3./8. )*dydata[i]; - - - } - -*/ - + for(int i = 0; i< dangler.size(); i++){ //eq1 @@ -335,9 +312,9 @@ int main(int argc,char **argv){ } - cout<<"A0 = "< 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); }