fluka_gfortran7_hit/proton/plots.C
Blake Leverington 090051977b first push
2021-08-30 16:15:26 +02:00

66 lines
3.1 KiB
C

{
Double_t beta_proton[30] = {0.308525262, 0.340993523, 0.366173485, 0.386743776, 0.404197708, 0.4194131, 0.43294541, 0.445179695, 0.456345494, 0.466616582, 0.476154213, 0.48502264, 0.493348242, 0.501186212, 0.50863865, 0.515744144, 0.522562549, 0.52911069, 0.535379917, 0.541397728, 0.549575745, 0.557428612, 0.564849395, 0.571867977, 0.578541117, 0.584900169};
Double_t beta_helium[30] = {0.316661966, 0.34727202, 0.371222186, 0.391037227, 0.408018455, 0.422922098, 0.436235455, 0.44827542, 0.459299095, 0.469441244, 0.478845524, 0.487649369, 0.495886825, 0.503656244, 0.510990953, 0.517959457, 0.52457247, 0.530888884, 0.536925849, 0.54269899, 0.550671248, 0.55845178, 0.565814653, 0.572798702, 0.579448698, 0.585785313};
Double_t beta_carbon[30] = {0.407931067, 0.448122448, 0.479020432, 0.504000457, 0.524971648, 0.543076553, 0.559041917, 0.573329576, 0.586254563, 0.598061846, 0.608917559, 0.618952311, 0.62829287, 0.637039726, 0.645286945, 0.65311609, 0.660570813, 0.667689852, 0.67446932, 0.680943928, 0.689677353, 0.698000799, 0.70580765, 0.71315081, 0.720086739, 0.726650602};
Double_t beta_oxygen[30] = {0.43638582, 0.479000679, 0.51134888, 0.537325331, 0.559061572, 0.57764689, 0.594123989, 0.608730698, 0.621997639, 0.63402408, 0.645050809, 0.655226738, 0.664724227, 0.673475951, 0.681810969, 0.689681788, 0.697243281, 0.704219104, 0.710968918, 0.717442538, 0.726111033, 0.734356548, 0.742073831, 0.749383281, 0.756156282, 0.762562424};
TGraph * gr_letratio = new TGraph();
char finname[50] = "";
char fout_mean_name[50] = "";
char fout_median_name[50] = "";
char fout_mpv_name[50] = "";
ofstream fout_mean, fout_median;
int j = 1;
sprintf(fout_mean_name, "jobs%i/plots/mean.txt",j);
sprintf(fout_median_name, "jobs%i/plots/median.txt",j);
sprintf(fout_mpv_name, "jobs%i/plots/mpv.txt",j);
fout_median.open (fout_median_name);
fout_mean.open (fout_mean_name);
Double_t x, q;
q = 0.5; // 0.5 for "median"
// for (int j = 0; j<5;j++){
for (int i = 0; i<26;i++){
sprintf(finname, "jobs%i/runjob%i001_eventdata_out.root",j,i);
TFile * f = new TFile(finname,"OPEN");
TH1F * h = (TH1F*)f->Get("h_spratio");
cout << i << " " << h->GetMean() << " +/- " << h->GetRMS() << endl;
fout_mean << beta_proton[i] << " " << h->GetMean() << " " << 0.012*h->GetMean() << endl;
h->ComputeIntegral(); // just a precaution
h->GetQuantiles(1, &x, &q);
std::cout << "median = " << x << std::endl;
fout_median << beta_proton[i] << " " << x << " " << 0.012*x << endl;
h->Delete();
f->Close();
}
// }
TGraphErrors * graph_1 = new TGraphErrors(fout_mean_name,"%lg %lg %lg" );
TGraphErrors * graph_2 = new TGraphErrors(fout_median_name,"%lg %lg %lg" );
TGraphErrors * graph_3 = new TGraphErrors(fout_mpv_name,"%lg %lg %lg" );
TCanvas * c2 = new TCanvas("c2","c2", 800, 600);
c2->cd();
graph_3->Draw("A*");
graph_1->Draw("*");
graph_2->Draw("*");
fout_mean.close();
fout_median.close();
}