#include #include #include #include #include "TFile.h" #include "TMath.h" #include "TTree.h" #include "TRandom.h" #include #include #include #include #include using namespace std; void histogram1() { //gROOT->Reset(); double_t MACS2_sum=0.; double_t MACS1_sum=0.; double_t MACS_sum=0.; auto c1 = new TCanvas ("c1","c1",0,0,700,250); c1->SetGrid(); c1->SetLogy(); c1->SetLogx(); auto mg = new TMultiGraph(); auto Xaxis = mg->GetXaxis(); Xaxis->SetTickLength(0.02); Xaxis->SetTitle("Neutron Energy [eV]"); Xaxis->SetLimits(0.0001,10000000000); TGraph *gr1 = new TGraph("test.txt"); mg->Add(gr1); mg->Draw("AL"); // TSpline3 *s = new TSpline3("Test",gr1,"b1e1",0,0); TSpline5 *s = new TSpline5("Test",gr1); for(int k=10000;k<=100000;k=k+5000){ for (double_t i=0; i<100000; i=i+1) { double E=i*209./210.; double CS=gr1->Eval(E); //double T1=CS; // double T2=E*exp(-E/50000)*10; // double T_total= (E)*CS*exp(-E/50000)*10; double_t MACS=(E)*CS*exp(-E/k)*1; MACS_sum=MACS+MACS_sum; // cout<SetNpx(5 * gr1->GetN() ); s->SetLineColor(kRed); s->Draw("same"); // add ROOT interpolator std::vector xp(gr1->GetX(), gr1->GetX() + gr1->GetN() ); std::vector yp(gr1->GetY(), gr1->GetY() + gr1->GetN() ); ROOT::Math::Interpolator itp(xp.size(), ROOT::Math::Interpolation::kCSPLINE); itp.SetData(xp,yp); // compute points to interpolate std::vector x2(xp.size()-1); std::vector y2(xp.size()-1); for (size_t i = 0; i < xp.size()-1 ; ++i) { x2[i] = xp[i] + 0.5*(xp[i+1]-xp[i]); y2[i] = itp.Eval(x2[i] ); } TGraph * gr2 = new TGraph(x2.size(), x2.data(), y2.data() ); gr2->SetLineColor(kGreen); gr2->Draw("L SAME"); }