double myFunc(double *x, double *par){ double result = par[0]*exp(-((x[0]-par[1])/(2*par[2]))*((x[0]-par[1])/(2*par[2]))) + par[3]; return result; } void riempi5() { TH1F histo("pippo","Segnale con Fondo",100,0.,1.); int num= 10000; for (int i = 0; iGaus(0.5,0.05); histo.Fill(rnd); } int numFondo= 10000; for (int i = 0; iRndm(); histo.Fill(rnd); } gStyle->SetOptStat(111111); gStyle->SetOptFit(111111); histo.SetMinimum(0); TF1 miaFunc("miaFunc",myFunc,0.,1.,4); miaFunc.SetParLimits(2,0,100); miaFunc.SetParameter(0,100); miaFunc.SetParameter(1,0.5); miaFunc.SetParameter(2,0.5); miaFunc.SetParameter(3,10); histo.Fit("miaFunc"); histo.DrawCopy(); // TF1* gaus = (TF1*)( histo.GetFunction("gaus")); // cout << gaus << endl; // float mean = gaus->GetParameter(1); // float meanErr = gaus->GetParError(1); // cout << "mean " << mean << "+/-" << meanErr<< endl; // // TF1 pippo("pp","pol2",0.35,0.65); // // histo.Fit("pp","R"); // // //histo.Fit("pol2"); // // //(histo.GetFunction("pp"))->Draw(); // // histo.DrawCopy("hist"); // // histo.DrawCopy("func same"); // //pippo.Draw(); // cout << histo.GetRMS() << endl; // cout << "under " <