void ErgResn2() { gROOT->SetStyle("Plain"); TCanvas *c1(new TCanvas()); bool sqr(false); const unsigned ne(11); double e[ne],p[ne][15],q[ne][15]; TF1 *func=new TF1("func","sqrt([0]*[0]+[1]*[1]*x*x)",0.0,2.0); func->SetParameters(0.01,0.2); ifstream fin("ErgResn.txt"); for(unsigned ii(0);ii> e[ii]; for(int j(0);j<15;j++) { fin >> p[ii][j] >> q[ii][j]; } } TGraphErrors *tg[5]; for(int i(0);i<5;i++) { tg[i]=new TGraphErrors(ne); for(int j(0);j<(int)ne;j++) { if(sqr) { tg[i]->SetPoint(j,1/e[j],p[j][3*i+2]*p[j][3*i+2]/(e[j]*e[j])); tg[i]->SetPointError(j,0,2.0*p[j][3*i+2]*q[j][3*i+2]/(e[j]*e[j])); } else { tg[i]->SetPoint(j,1/sqrt(e[j]),p[j][3*i+2]/e[j]); tg[i]->SetPointError(j,0,q[j][3*i+2]/e[j]); } } if((i%2)==0) { tg[i]->SetMarkerStyle(20); tg[i]->SetMarkerColor(2); tg[i]->SetLineColor(2); } if((i%2)==1) { tg[i]->SetMarkerStyle(21); tg[i]->SetMarkerColor(3); tg[i]->SetLineColor(3); } if(sqr) { tg[i]->Fit("pol1"); if((i%2)==0) tg[i]->GetFunction("pol1")->SetLineColor(2); if((i%2)==1) tg[i]->GetFunction("pol1")->SetLineColor(3); } else { tg[i]->Fit("func"); if((i%2)==0) tg[i]->GetFunction("func")->SetLineColor(2); if((i%2)==1) tg[i]->GetFunction("func")->SetLineColor(3); } if(sqr) { tg[i]->SetTitle(";1/Photon energy (1/GeV);#sigma_{E}^{2}/E^{2}"); } else { tg[i]->SetTitle(";1/#surd(Photon energy) (GeV^{-1/2});#sigma_{E}/E"); } if(sqr) { tg[i]->GetYaxis()->SetRangeUser(0,0.05); } else { tg[i]->GetYaxis()->SetRangeUser(0,0.2); } tg[i]->GetXaxis()->SetRangeUser(0,1.2); } tg[0]->Draw("AP"); tg[1]->Draw("P same"); c1->Update(); c1->Print("ErgResn1.png"); tg[2]->Draw("AP"); tg[3]->Draw("P same"); c1->Update(); c1->Print("ErgResn2.png"); tg[2]->Draw("AP"); if(sqr) { tg[0]->GetFunction("pol1")->SetLineStyle(2); } else { tg[0]->GetFunction("func")->SetLineStyle(2); } tg[0]->Draw("P same"); c1->Update(); c1->Print("ErgResn3.png"); tg[4]->Draw("AP"); if(sqr) { tg[4]->GetFunction("pol1")->SetLineStyle(2); } else { tg[4]->GetFunction("func")->SetLineStyle(2); } tg[2]->Draw("P same"); c1->Update(); c1->Print("ErgResn4.png"); }