//CHOOSE 1keV binning for consistency #include #include #include #include "TCanvas.h" #include "TFitResult.h" #include "TDirectory.h" #include "TAxis.h" #include "TH1D.h" #include "TAxis.h" #include "TStyle.h" //for gStyle decleration #include #include "TF1.h" #include "TFormula.h" #include "TMath.h" #include "Math/DistFuncMathCore.h" #include "TROOT.h" #include "Math/Minimizer.h" #include "Minuit2/MnUserParameterState.h" #include "TMatrixD.h" #include #include #include #include void RangeFromFitting() { TGraph *gr1 = new TGraph ("/Users/spyhunter0066/Library/CloudStorage/OneDrive-harran.edu.tr/MacbookCplusplus/RangeCalculators/Fitting/AlElectronRange.txt", "%lg%*lg%*lg%*lg%lg%*lg%*lg"); gr1->SetName("gr1"); gr1->SetTitle("gr1"); vector KineticEnergy, STPcollision, STPradiative, STPtotal, CSDArange, RadiationYield, DensityEffect ; gr1->SetMarkerSize(0.6); gr1->SetMarkerStyle(20); gr1->SetMarkerColor(kRed); // Get the x-axis TAxis *xAxis = gr1->GetXaxis(); // Get the minimum and maximum x-values double Xmin = xAxis->GetXmin(); double Xmax = xAxis->GetXmax(); cout <<"xmin : " <SetParNames( "a", "b", "c", "d", "e", "f"); //a + bx + cx^2 + dx^3 ... //f1->SetParameters(1.,2.,3); f1->Draw(); gr1->Fit("f1"); gr1->Draw("AP"); // Get the number of parameters of the fitted function int nParams = f1->GetNpar(); double ParStore[nParams]; // Print the parameters for (int i = 0; i < nParams; ++i) { ParStore[i]=f1->GetParameter(i); cout << "Parameter " << i << ": " << ParStore[i] << endl; } double x1 = 10. ; //random selection double y1 = f1->Eval(x1); double gry1 = gr1->Eval(x1); cout << "x1: " << x1 << " y value from fit: " << y1 << " real y value: " << gry1 << endl; }