{ delete gRandom; gRandom = new TRandom(123456); // Setting the seed TH1F *gauss = new TH1F("gauss", "Gauss Distribution", 200, 0, 20) ; for(int i=0; i<100000; ++i) { double a=gRandom->Gaus(10, 2); gauss->Fill(a); } TF1 *f1 = new TF1("f1", "gaus",0,20); // Orismos tis synartisis fl f1->SetLineColor(2); gStyle->SetOptStat(0); // Kamia ektypwsi twn statistikwn toy istogrammatos gStyle->SetOptFit(0); // Kamia ektypwsi toy apotelesmatos tis prosarnoghs TCanvas *c1 = new TCanvas("c1", "Gauss", 700, 400); c1->SetGrid(); c1->SetFillColor(42); c1->cd(); gauss->Fit(f1,"","",4,16); // Prosarmogh istogrammatos stin fi apo to 4 ews to 16 double p0 = f1->GetParameter(0); //Diavasma tou apotelesmatwn tis prosarmogis double p1 = f1->GetParameter(1) ; double p2 = f1->GetParameter(2) ; double ep0 = f1->GetParError(0) ; double ep1 = f1->GetParError(1) ; double ep2 = f1->GetParError(2); char tit[256]; txt = new TPaveText(0.6,0.6,0.89,0.89, "NDC"); sprintf (tit, "#color[4]{ #font[42]{ Constant = %.1f #pm %.1f} }",p0, ep0); cout << tit << endl; txt->AddText(tit); sprintf (tit, "#color[4]{ #font[42]{ Mean = %.1f #pm %.1f} }",p1, ep1); txt->AddText(tit); sprintf (tit, "#color[4]{ #font[42]{ #sigma = %.1f #pm %.1f} }",p2, ep2); txt->AddText(tit); txt->SetFillColor(42) ; txt->Draw(); }