// histograms filled and drawn in a loop void gaussex2() { // // To see the output of this macro, click begin_html here end_html // Simple example illustrating how to use the C++ interpreter // to fill histograms in a loop and show the graphics results //Author: Rene Brun TCanvas *c1 = new TCanvas("c1","Primer Gauss",200,10,600,400); c1->SetGrid(); // Create some histograms. main = new TH1F("Gauss","Gaussova distribucija 2 - samogenerirana spremenljivka",200,-5.5,5.5); main->SetFillColor(41); // Fill histograms randomly gRandom->SetSeed(4444); Int_t niter=1000000; Float_t xmu=0.; Float_t xsig=1.; Float_t rho1=0.; Float_t rho2=0.; for ( Int_t i=0; iUniform(); rho2 = gRandom->Uniform(); xmain = sin(2*TMath::Pi()*rho1)*sqrt(-2.*log(rho2)); main->Fill(xmain); } gStyle->SetOptFit(0111); main->Fit("gaus","ME"); main->GetYaxis()->SetTitle("N"); main->GetXaxis()->SetTitle("x"); main->Draw(); c1->Update(); TPaveStats *stats1 = (TPaveStats*)main->GetListOfFunctions()->FindObject("stats"); main->GetFunction("gaus")->SetLineColor(2); stats1->SetTextColor(2); stats1->SetX1NDC(0.70); stats1->SetX2NDC(0.90); stats1->SetY1NDC(0.70); c1->Update(); c1->Modified(); }