#include "TH1.h" #include "TH1.h" void multifit() { Double_t par[12]; TF1 *g1 =new TF1("g1","gaus",9200,9700);//primo picco nello spettro TF1 *g2 =new TF1("g2","gaus",9800,10200);//secondo picco dello spettro TF1 *g3 =new TF1("g3","gaus",10100,10500);//terzo picco dello spettro TF1 *g4 =new TF1("g4","pol2",8000,11000);//fondo al segnale nello spettro TF1 *total =new TF1("total","gaus(0)+gaus(3)+gaus(6)+pol2(9)",8000,11000);//funzione fit globale total->SetLineColor(2); g1->SetLineColor(4); g2->SetLineColor(3); g3->SetLineColor(5); g4->SetLineStyle(5); h1->Fit(g1,"R+"); h1->Fit(g2,"R+"); h1->Fit(g3,"R+"); h1->Fit(g4,"R+"); g1->GetParameters(&par[0]); g2->GetParameters(&par[3]); g3->GetParameters(&par[6]); g4->GetParameters(&par[9]); total->SetParameters(par); total->SetLineStyle(1); h1->Fit(total,"R+"); }