#include "TCanvas.h" #include "TPad.h" #include "TFile.h" #include "TMultiGraph.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TAxis.h" #include "TLegend.h" #include "TLatex.h" #include "TROOT.h" #include "TF1.h" #include double x0; double Gamma1; double Gamma2; double a; double b; double maxval; double max1; double max2; void lorfun() { ofstream results; results.open("Results.txt", ios::out); printf("Gamma1= "); scanf("%lf", &Gamma1); printf("Gamma2= "); scanf("%lf", &Gamma2); printf("x0= "); scanf("%lf", &x0); printf("a= "); scanf("%lf", &a); printf("b= "); scanf("%lf", &b); //printf("Max= "); //scanf("%lf", &maxval); TCanvas *c01 = new TCanvas("c01","c01",1280,1024); TMultiGraph *mg = new TMultiGraph(); TF1 *f1 = new TF1("lorentzian1", "[0]/(2*(TMath::Pi()))*(1/(([0]*[0])/4+(x-[1])*(x-[1])))", a,b); TF1 *f2 = new TF1("lorentzian2", "[0]/(2*(TMath::Pi()))*(1/(([0]*[0])/4+(x-[1])*(x-[1])))", a,b); f1->SetParameter(0,Gamma1); f1->SetParameter(1,x0); f2->SetParameter(0,Gamma2); f2->SetParameter(1,x0); f1->SetLineColor(kBlue); f2->SetLineColor(kRed); f1->SetTitle(""); f2->SetTitle(""); gPad->Update(); //f1->SetMaximum(maxval); //f2->SetMaximum(maxval); max1=f1->GetMaximum(); max2=f2->GetMaximum(); f1->Draw(); f2->Draw("SAME"); TLegend* leg = new TLegend(0.15, 0.75, .25, .85); leg->SetHeader(""); leg->SetNColumns(1); leg->AddEntry(f1, "Lorentzian 1", "l"); leg->AddEntry(f2, "Lorentzian 2", "l"); leg->SetBorderSize(0); leg->Draw(); c01->Print("lorentzian.png"); results << "**************************************** "<< endl; results << "Gamma 1= " << Gamma1 <