int main(int argc, char *argv[]) { init(); vector<double> params(23,0); params[GLB_THETA_12] = true_theta12; params[GLB_THETA_13] = true_theta13; params[GLB_THETA_23] = true_theta23; params[GLB_DELTA_CP] = true_deltacp; params[GLB_DM_21] = true_sdm; params[GLB_DM_31] = true_ldm; params[GLB_DAMPING_EXPONENT] = true_damping; std::ofstream outp("transition_prob.dat", std::ios_base::app);//Will append to existing file if already present. if (! outp){ //opened failed std::cerr << "cannot open c_JIFS_lep.dat for output\n"; exit(-1); } glbInit(argv[0]); glbInitExperiment("./NFstandard.glb", &glb_experiment_list[0], &glb_num_of_exps); glb_params true_values = glbAllocParams(); glbDefineParams(true_values, true_theta12, true_theta13, true_theta23, true_deltacp, true_sdm, true_ldm); glbSetDensityParams(true_values, 1.0,GLB_ALL); glbSetOscillationParameters(true_values); glbSetRates(); double P_matrix[3][3]; double my_step[10]; double my_density[10]; my_step[0] = 100; my_step[1] = 500; my_density[0]=0.; my_density[1]=0.; Baseline my_baseline(1, my_density, my_step); ProbEngine prob_gen1(params, my_baseline, 0); for(int i = 0; i < 200 ; i++) { my_step[0] = 100 + i*50; int check = prob_gen1.get_probability(P_matrix, 1, 23.); outp << my_step[0] << " " << P_matrix[0][1] << " " << glbVacuumProbability(1,2,1,23.,100+i*50) << std::endl; } /* std::ofstream outp2("transition_prob_glb.dat", std::ios_base::app);//Will append to existing file if already present. if (! outp2){ //opened failed std::cerr << "cannot open c_JIFS_lep.dat for output\n"; exit(-1); } for(int i=0; i<200; i++) { outp2 << glbVacuumProbability(1,2,1,23.,100+i*50) << std::endl; } */ return 0; }
int main(int argc, char *argv[]) { /* Initialize libglobes */ glbInit(argv[0]); glbSelectMinimizer(GLB_MIN_POWELL); /* Initialize experiment */ glbInitExperiment(AEDLFILE,&glb_experiment_list[0],&glb_num_of_exps); //glbInitExperiment(AEDLFILE2,&glb_experiment_list[0],&glb_num_of_exps); /* nuPRISM */ //glbInitExperiment(AEDLFILE3,&glb_experiment_list[0],&glb_num_of_exps); /* Reactor */ /* Intitialize output */ outfile = fopen(MYFILE, "w"); if (outfile == NULL) { printf("Error opening output file.\n"); return -1; } /* Mess with the errors */ //HalfErrors(); //DoubleErrors(); /* Define "true" oscillation parameters */ theta12 = asin(sqrt(0.307)); theta13 = asin(sqrt(0.0241)); theta23 = 0.5; deltacp = 0.0; dm21 = 7.6e-5; dm32 = 2.4e-3; true_values = glbAllocParams(); /* Define "true" oscillation parameter vector */ glbDefineParams(true_values,theta12,theta13,theta23,deltacp,dm21,dm32); glbSetDensityParams(true_values,1.0,GLB_ALL); /* Compute simulated data */ glbSetOscillationParameters(true_values); glbSetRates(); int i; int n_bins = glbGetNumberofBins(0); double *true_rates_N = glgGetRuleRatePtr(0,0); printf("Simulated Rates, experiment 0, rule 0: \n"); for(i=o;i<n_bins;i++){ printf("%g \n", true_rates_N[i]); } /* Destroy parameter and projection vector(s) */ glbFreeParams(true_values); return 0; }
int main(int argc, char *argv[]) { /* Initialize libglobes */ glbInit(argv[0]); /* Initialize experiment */ glbInitExperiment(AEDLFILE,&glb_experiment_list[0],&glb_num_of_exps); //glbInitExperiment(AEDLFILE2,&glb_experiment_list[0],&glb_num_of_exps); /* nuPRISM */ //glbInitExperiment(AEDLFILE3,&glb_experiment_list[0],&glb_num_of_exps); /* Reactor */ /* Intitialize output */ outfile = fopen(MYFILE, "w"); /* Define "true" oscillation parameters */ theta12 = asin(sqrt(0.307)); theta13 = asin(sqrt(0.0241)); theta23 = 0.5; deltacp = asin(0.0); dm21 = 7.6e-5; dm32 = 2.4e-3; dm31 = dm32+dm21; true_values = glbAllocParams(); test_values = glbAllocParams(); input_errors = glbAllocParams(); /* Define "true" oscillation parameter vector */ glbDefineParams(true_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(true_values,1.0,GLB_ALL); /* Define initial guess for the fit values */ glbDefineParams(test_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(test_values,1.0,GLB_ALL); glbDefineParams(input_errors, theta12*0.1, 0, 0, 0, dm21*0.1, 0); glbSetDensityParams(input_errors,0.05,GLB_ALL); glbSetInputErrors(input_errors); glbSetCentralValues(true_values); /* Compute simulated data */ glbSetOscillationParameters(true_values); glbSetRates(); /* Scan the delta plane */ double this_delta; double delta_lower = -M_PI; double delta_upper = M_PI; double delta_steps = 72; double delta_step_size = (delta_upper-delta_lower)/delta_steps; double sig; printf("true delta_cp = %g \n", deltacp); for(this_delta=delta_lower; this_delta<=delta_upper; this_delta+= delta_step_size) { double x = sin(this_delta); double i = this_delta*180.0/M_PI; glbSetOscParams(test_values, asin(x), GLB_DELTA_CP); double chi2=glbChiDelta(test_values, NULL, GLB_ALL); glbSetOscParams(test_values, deltacp, GLB_DELTA_CP); double chitrue=glbChiDelta(test_values, NULL, GLB_ALL); sig = sqrt(abs(chi2 - chitrue)); printf("delta = %g\n", i); fprintf(outfile, "%g %g\n", i, sig); } fclose(outfile); /* Destroy parameter and projection vector(s) */ glbFreeParams(true_values); glbFreeParams(test_values); glbFreeParams(input_errors); outfile2 = fopen(MYFILE2, "w"); dm31 = dm21-dm32; true_values = glbAllocParams(); test_values = glbAllocParams(); input_errors = glbAllocParams(); /* Define "true" oscillation parameter vector */ glbDefineParams(true_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(true_values,1.0,GLB_ALL); /* Define initial guess for the fit values */ glbDefineParams(test_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(test_values,1.0,GLB_ALL); glbDefineParams(input_errors, theta12*0.1, 0, 0, 0, dm21*0.1, 0); glbSetDensityParams(input_errors,0.05,GLB_ALL); glbSetInputErrors(input_errors); glbSetCentralValues(true_values); /* Compute simulated data */ glbSetOscillationParameters(true_values); glbSetRates(); for(this_delta=delta_lower; this_delta<=delta_upper; this_delta+= delta_step_size) { double x = sin(this_delta); double i = this_delta*180.0/M_PI; glbSetOscParams(test_values, asin(x), GLB_DELTA_CP); double chi2=glbChiDelta(test_values, NULL, GLB_ALL); glbSetOscParams(test_values, deltacp, GLB_DELTA_CP); double chitrue=glbChiDelta(test_values, NULL, GLB_ALL); sig = sqrt(abs(chi2 - chitrue)); printf("delta = %g\n", i); fprintf(outfile2, "%g %g\n", i, sig); } fclose(outfile2); return 0; }
int main(int argc, char *argv[]) { double thetheta13, x, y, res; /* Define standard oscillation parameters (cf. hep-ph/0405172v5) */ double true_theta12 = asin(sqrt(0.3)); double true_theta13 = 0.0; double true_theta23 = M_PI/4; double true_deltacp = 0.0; double true_sdm = 7.9e-5; double true_ldm = 2.6e-3; /* Define one non-standard parameter sigma_E (wave packet energy spread * responsible for wave packet decoherence) */ double true_sigma_E = 0.0; /* Initialize libglobes */ glbInit(argv[0]); /* Register non-standard probability engine. This has to be done * before any calls to glbAllocParams() or glbAllocProjections() */ glbRegisterProbabilityEngine(7, /* Number of parameters */ &my_probability_matrix, &my_set_oscillation_parameters, &my_get_oscillation_parameters, NULL); /* Initialize reactor experiment */ glbInitExperiment("Reactor1.glb",&glb_experiment_list[0],&glb_num_of_exps); /* Initialize parameter and projection vector(s) */ glb_params true_values = glbAllocParams(); glb_params test_values = glbAllocParams(); glb_params input_errors = glbAllocParams(); glb_projection th13_sigma_projection = glbAllocProjection(); glbDefineParams(true_values,true_theta12,true_theta13,true_theta23, true_deltacp,true_sdm,true_ldm); glbSetOscParams(true_values,true_sigma_E, GLB_SIGMA_E); /* Non-standard parameter */ glbSetDensityParams(true_values,1.0,GLB_ALL); glbDefineParams(test_values,true_theta12,true_theta13,true_theta23, true_deltacp,true_sdm,true_ldm); glbSetOscParams(test_values,true_sigma_E, GLB_SIGMA_E); /* Non-standard parameter */ glbSetDensityParams(test_values,1.0,GLB_ALL); /* The simulated data are computed */ glbSetOscillationParameters(true_values); glbSetRates(); /* Set starting values and input errors for all projections */ glbDefineParams(input_errors, 0.1*true_theta12, 0.0, 0.15*true_theta23, 0.0, 0.05*true_sdm, 0.05*true_ldm); glbSetOscParams(input_errors, 0.0, GLB_SIGMA_E); /* Non-standard parameter */ glbSetDensityParams(input_errors, 0.05, GLB_ALL); glbSetCentralValues(true_values); glbSetInputErrors(input_errors); /* Compute chi^2 without correlations */ FILE *fp=fopen("osc-data1","w"); for(x=0; x < 0.05+0.001; x+=0.005) /* th13 loop */ { for(y=0.0; y < 0.010+0.001; y+=0.001) /* sigame_E loop */ { /* Set vector of test=fit values */ thetheta13=asin(sqrt(x))/2.0; glbSetOscParams(test_values,thetheta13,GLB_THETA_13); glbSetOscParams(test_values,y,GLB_SIGMA_E); /* Compute Chi^2 with systematics only */ res=glbChiSys(test_values,GLB_ALL,GLB_ALL); fprintf(fp,"%f\t%f\t%f\n",x,y,res); } fprintf(fp,"\n"); } fclose(fp); fp=fopen("osc-data2","w"); /* Set two-parameter projection onto s22th13 and sigma_E, marginalizing * over all other parameters except delta_CP and th23, which do not enter P_ee */ glbDefineProjection(th13_sigma_projection, GLB_FREE, GLB_FIXED, GLB_FIXED, GLB_FIXED, GLB_FREE, GLB_FREE); glbSetDensityProjectionFlag(th13_sigma_projection, GLB_FIXED, GLB_ALL); glbSetProjectionFlag(th13_sigma_projection, GLB_FIXED, GLB_SIGMA_E); /* Non-standard parameter */ glbSetProjection(th13_sigma_projection); for(x=0; x < 0.05+0.001; x+=0.005) /* th13 loop */ { for(y=0.0; y < 0.010+0.001; y+=0.001) /* sigame_E loop */ { /* Set vector of test=fit values */ thetheta13=asin(sqrt(x))/2.0; glbSetOscParams(test_values,thetheta13,GLB_THETA_13); glbSetOscParams(test_values,y,GLB_SIGMA_E); /* Compute Chi^2 with correlations */ res=glbChiNP(test_values,NULL,GLB_ALL); fprintf(fp,"%f\t%f\t%f\n",x,y,res); } fprintf(fp,"\n"); } fclose(fp); /* Destroy parameter and projection vector(s) */ glbFreeParams(true_values); glbFreeParams(test_values); glbFreeParams(input_errors); glbFreeProjection(th13_sigma_projection); exit(0); }
int main(int argc, char *argv[]) { /* Initialize libglobes */ glbInit(argv[0]); glbInitExperiment("T2HK.glb",&glb_experiment_list[0],&glb_num_of_exps); glbSelectMinimizer(GLB_MIN_POWELL); // Use experimental minimizer to speed up things double theta12 = asin(sqrt(0.3)); double theta13 = asin(sqrt(0.1))/2.0; double theta23 = M_PI/4.0; double deltacp = 3*M_PI/2.0; double sdm = 8.0e-5; double ldm = 2.5e-3; /* Parameter is output file name; if empty string, write to screen: */ mioInitOutput("tut1.dat"); glb_params central_values = glbAllocParams(); glb_params fit_values = glbAllocParams(); glb_params true_values = glbAllocParams(); glb_params input_errors = glbAllocParams(); glb_params foundmin = glbAllocParams(); glbDefineParams(true_values,theta12,theta13,theta23,deltacp,sdm,ldm); glbSetDensityParams(true_values,1.0,GLB_ALL); glbDefineParams(input_errors,theta12*0.1,0,0,0,sdm*0.1,0); /* 10% external error for solar parameters */ glbSetDensityParams(input_errors,0.05,GLB_ALL); /* 5% matter density uncertainty */ double res; /* scan parameter space as function of true x = log sin^2 2 theta_13 */ double x; double minx = -4.0; double maxx = -1.0; double steps = 12.0; for(x=minx;x<maxx+0.0001;x+=(maxx-minx)/steps) { glbSetOscParams(true_values,asin(sqrt(pow(10,x))/2),GLB_THETA_13); glbSetOscillationParameters(true_values); glbSetRates(); glbCopyParams(true_values,central_values); /* Educated guess: start minimizer at -dm_31 */ glbSetOscParams(central_values,-glbGetOscParams(true_values,GLB_DM_31),GLB_DM_31); glbCopyParams(central_values,fit_values); glbSetCentralValues(central_values); glbSetInputErrors(input_errors); res=glbChiAll(fit_values,foundmin,GLB_ALL); printf("\nx=%g, Minimum found at %g:\n",x,res); glbPrintParams(stdout,foundmin); /* Write to file */ mioAddToOutput(x,res); } /* Close output stream: */ mioCloseOutput(); glbFreeParams(fit_values); glbFreeParams(central_values); glbFreeParams(true_values); glbFreeParams(input_errors); glbFreeParams(foundmin); exit(0); }
int main(int argc, char *argv[]) { /* Initialize libglobes */ glbInit(argv[0]); /* Initialize experiment */ //glbInitExperiment(AEDLFILE,&glb_experiment_list[0],&glb_num_of_exps); glbInitExperiment(AEDLFILE2,&glb_experiment_list[0],&glb_num_of_exps); /* nuPRISM */ //glbInitExperiment(AEDLFILE3,&glb_experiment_list[0],&glb_num_of_exps); /* Reactor */ /* Intitialize output */ outfile1 = fopen(MYFILE1, "w"); outfile2 = fopen(MYFILE2, "w"); outfile3 = fopen(MYFILE3, "w"); outfile4 = fopen(MYFILE4, "w"); outfile5 = fopen(MYFILE5, "w"); outfile6 = fopen(MYFILE6, "w"); outfile7 = fopen(MYFILE7, "w"); /* Define "true" oscillation parameters */ theta12 = asin(sqrt(0.307)); theta13 = asin(sqrt(0.0241)); theta23 = 0.5; deltacp = 0.0; dm21 = 7.6e-5; dm32 = 2.4e-3; dm31 = dm32 + dm21; /* Needed for scans */ double e_min = 0.0; double e_max = 3.0; double dist = 295.0; double E = 0.0; int bins = glbGetNumberOfBins(0); int polar = +1; int n_bins = 100; int bin; double e_step = (e_max-e_min)/(n_bins); double this_th13, this_delta; double th13_lower = asin(sqrt(0.01)); double th13_upper = asin(sqrt(0.04)); double th13_steps = 15; double delta_lower = -M_PI; double delta_upper = M_PI; double delta_steps = 15; double res, sig, flux; true_values = glbAllocParams(); test_values = glbAllocParams(); input_errors = glbAllocParams(); th13delta_projection = glbAllocProjection(); glbDefineProjection(th13delta_projection,GLB_FIXED,GLB_FIXED,GLB_FREE,GLB_FIXED,GLB_FIXED,GLB_FREE); glbSetDensityProjectionFlag(th13delta_projection, GLB_FIXED, GLB_ALL); glbSetProjection(th13delta_projection); glbDefineParams(true_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(true_values,1.0,GLB_ALL); glbSetOscillationParameters(true_values); glbSetRates(); /*------------------------------------- Initial Fluxes ---------------------------------------------------*/ printf("Initial fluxes \n"); for(E = e_min; E<e_max; E += e_step){ flux = glbFlux(0, 0, E, dist, 1, polar); fprintf(outfile1, "%g %g \n", E, flux); } for(E = e_min; E<e_max; E += e_step){ flux = glbFlux(0, 0, E, dist, 2, polar); fprintf(outfile2, "%g %g \n", E, flux); } fclose(outfile1); fclose(outfile2); /*---------------------------------------- Event Rates ---------------------------------------------------*/ printf("Event Rates \n"); // rule 0 = NU_E_Appearance_QE // rule 2 = NU_MU_Disappearance_QE // rule 4 = NU_MU_Disappearance_CC // rule 5 = NU_E_Appearance_CC double *rates_e = glbGetRuleRatePtr(0,5); double *rates_mu = glbGetRuleRatePtr(0,4); for(bin=0;bin<bins;bin++){ fprintf(outfile3, "%i %g \n", bin, rates_e[bin]); fprintf(outfile4, "%i %g \n", bin, rates_mu[bin]); } fclose(outfile3); fclose(outfile4); /*------------------------------------- Delta CP Significance ----------------------------------------------*/ printf("Delta_cp significance \n"); delta_steps = 40; glbDefineParams(test_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(test_values,1.0,GLB_ALL); glbDefineParams(input_errors, theta12*0.1, 0, 0, 0, dm21*0.1, 0); glbSetDensityParams(input_errors,0.05,GLB_ALL); glbSetInputErrors(input_errors); glbSetCentralValues(true_values); for(this_delta=delta_lower; this_delta<=delta_upper; this_delta+= (delta_upper-delta_lower)/delta_steps) { double x = sin(this_delta); double i = this_delta*180.0/M_PI; glbSetOscParams(test_values, asin(x), GLB_DELTA_CP); double chi2=glbChiDelta(test_values, NULL, GLB_ALL); glbSetOscParams(test_values, deltacp, GLB_DELTA_CP); double chitrue=glbChiDelta(test_values, NULL, GLB_ALL); sig = sqrt(abs(chi2 - chitrue)); printf("delta = %g \n", i); fprintf(outfile5, "%g %g\n", i, sig); } fclose(outfile5); /*------------------------------------- theta13 - delta_cp scan ---------------------------------------------------*/ delta_steps = 15; printf("Initial th13-deltacp scan \n"); for(deltacp = -M_PI/2.0; deltacp < M_PI+0.1; deltacp += M_PI/2.0){ double x = deltacp/M_PI; printf("Delta_CP = %g\n", x); /* Define "true" oscillation parameter vector */ glbDefineParams(true_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(true_values,1.0,GLB_ALL); /* Define initial guess for the fit values */ glbDefineParams(test_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(test_values,1.0,GLB_ALL); glbDefineParams(input_errors, theta12*0.1, 0, 0, 0, dm21*0.1, 0); glbSetDensityParams(input_errors,0.05,GLB_ALL); glbSetInputErrors(input_errors); glbSetCentralValues(true_values); /* Compute simulated data */ glbSetOscillationParameters(true_values); glbSetRates(); for(this_th13=th13_lower; this_th13<=th13_upper; this_th13+=(th13_upper-th13_lower)/th13_steps) { for(this_delta=delta_lower; this_delta<=delta_upper; this_delta+=(delta_upper-delta_lower)/delta_steps) { glbSetOscParams(test_values, this_th13, GLB_THETA_13); glbSetOscParams(test_values, this_delta, GLB_DELTA_CP); double i = sin(2*this_th13)*sin(2*this_th13); double j = this_delta*180.0/M_PI; res=glbChiNP(test_values, NULL, GLB_ALL); fprintf(outfile6, "%g %g %g\n", i, j, res); } fprintf(outfile6, "\n"); } } fclose(outfile6); /*------------------------------------- theta13 - delta_cp scan - Half errors -------------------------------------*/ printf("th13-deltacp scan with half the errors \n"); HalfErrors(); delta_steps = 60; th13_steps = 60; for(deltacp = -M_PI/2.0; deltacp < M_PI+0.1; deltacp += M_PI/2.0){ double x = deltacp/M_PI; printf("Delta_CP = %g\n", x); /* Define "true" oscillation parameter vector */ glbDefineParams(true_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(true_values,1.0,GLB_ALL); /* Define initial guess for the fit values */ glbDefineParams(test_values,theta12,theta13,theta23,deltacp,dm21,dm31); glbSetDensityParams(test_values,1.0,GLB_ALL); glbDefineParams(input_errors, theta12*0.1, 0, 0, 0, dm21*0.1, 0); glbSetDensityParams(input_errors,0.05,GLB_ALL); glbSetInputErrors(input_errors); glbSetCentralValues(true_values); /* Compute simulated data */ glbSetOscillationParameters(true_values); glbSetRates(); for(this_th13=th13_lower; this_th13<=th13_upper; this_th13+=(th13_upper-th13_lower)/th13_steps) { for(this_delta=delta_lower; this_delta<=delta_upper; this_delta+=(delta_upper-delta_lower)/delta_steps) { glbSetOscParams(test_values, this_th13, GLB_THETA_13); glbSetOscParams(test_values, this_delta, GLB_DELTA_CP); double i = sin(2*this_th13)*sin(2*this_th13); double j = this_delta*180.0/M_PI; double res=glbChiNP(test_values, NULL, GLB_ALL); fprintf(outfile7, "%g %g %g\n", i, j, res); } fprintf(outfile7, "\n"); } } fclose(outfile7); glbFreeParams(test_values); glbFreeParams(input_errors); glbFreeProjection(th13delta_projection); glbFreeParams(true_values); return 0; }