qa2.C

Go to the documentation of this file.
00001 void qa2() {
00002    //Fill a 1-D histogram from a parametric function
00003    TCanvas *c1 = new TCanvas("c1","The FillRandom example",0,0,700,500);
00004    c1->SetFillColor(18);
00005 
00006    gBenchmark->Start("fillrandom");
00007    //
00008    // A function (any dimension) or a formula may reference
00009    // an already defined formula
00010    //
00011    form1 = new TFormula("form1","abs(sin(x)/x)");
00012    sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
00013    sqroot->SetParameters(10,4,1,20);
00014 
00015    //
00016    // Create a one dimensional histogram (one float per bin)
00017    // and fill it following the distribution in function sqroot.
00018    //
00019    h1f = new TH1F("h1f","Test random numbers",200,0,10);
00020    h1f->SetFillColor(45);
00021    h1f->FillRandom("sqroot",100000);
00022    h1f->Draw();
00023    lfunction = new TPaveLabel(5,39,9.8,46,"The sqroot function");
00024    lfunction->SetFillColor(41);
00025 
00026    c1->SetGridx();
00027    c1->SetGridy();
00028    c1->GetFrame()->SetFillColor(42);
00029    c1->GetFrame()->SetBorderMode(-1);
00030    c1->GetFrame()->SetBorderSize(5);
00031 
00032    h1f->SetDirectory(0);
00033 
00034    c1->Update();
00035 
00036    sqroot->SetParameters(200,4,1,20);
00037 }

Generated on Tue Jul 5 15:44:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1