exec2.C: echo object at mouse position and show a graphics line | Histograms | greyscale.C: Create grey scale of nxn boxes. |
void fillrandom() { //Fill a 1-D histogram from a parametric function // To see the output of this macro, click begin_html <a href="gif/fillrandom.gif">here</a>. end_html //Author: Rene Brun TCanvas *c1 = new TCanvas("c1","The FillRandom example",200,10,700,900); c1->SetFillColor(18); pad1 = new TPad("pad1","The pad with the function",0.05,0.50,0.95,0.95,21); pad2 = new TPad("pad2","The pad with the histogram",0.05,0.05,0.95,0.45,21); pad1->Draw(); pad2->Draw(); pad1->cd(); gBenchmark->Start("fillrandom"); // // A function (any dimension) or a formula may reference // an already defined formula // form1 = new TFormula("form1","abs(sin(x)/x)"); sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10); sqroot->SetParameters(10,4,1,20); pad1->SetGridx(); pad1->SetGridy(); pad1->GetFrame()->SetFillColor(42); pad1->GetFrame()->SetBorderMode(-1); pad1->GetFrame()->SetBorderSize(5); sqroot->SetLineColor(4); sqroot->SetLineWidth(6); sqroot->Draw(); lfunction = new TPaveLabel(5,39,9.8,46,"The sqroot function"); lfunction->SetFillColor(41); lfunction->Draw(); c1->Update(); // // Create a one dimensional histogram (one float per bin) // and fill it following the distribution in function sqroot. // pad2->cd(); pad2->GetFrame()->SetFillColor(42); pad2->GetFrame()->SetBorderMode(-1); pad2->GetFrame()->SetBorderSize(5); h1f = new TH1F("h1f","Test random numbers",200,0,10); h1f->SetFillColor(45); h1f->FillRandom("sqroot",10000); h1f->Draw(); c1->Update(); // // Open a ROOT file and save the formula, function and histogram // TFile myfile("fillrandom.root","RECREATE"); form1->Write(); sqroot->Write(); h1f->Write(); gBenchmark->Show("fillrandom"); } fillrandom.C:1 fillrandom.C:2 fillrandom.C:3 fillrandom.C:4 fillrandom.C:5 fillrandom.C:6 fillrandom.C:7 fillrandom.C:8 fillrandom.C:9 fillrandom.C:10 fillrandom.C:11 fillrandom.C:12 fillrandom.C:13 fillrandom.C:14 fillrandom.C:15 fillrandom.C:16 fillrandom.C:17 fillrandom.C:18 fillrandom.C:19 fillrandom.C:20 fillrandom.C:21 fillrandom.C:22 fillrandom.C:23 fillrandom.C:24 fillrandom.C:25 fillrandom.C:26 fillrandom.C:27 fillrandom.C:28 fillrandom.C:29 fillrandom.C:30 fillrandom.C:31 fillrandom.C:32 fillrandom.C:33 fillrandom.C:34 fillrandom.C:35 fillrandom.C:36 fillrandom.C:37 fillrandom.C:38 fillrandom.C:39 fillrandom.C:40 fillrandom.C:41 fillrandom.C:42 fillrandom.C:43 fillrandom.C:44 fillrandom.C:45 fillrandom.C:46 fillrandom.C:47 fillrandom.C:48 fillrandom.C:49 fillrandom.C:50 fillrandom.C:51 fillrandom.C:52 fillrandom.C:53 fillrandom.C:54 fillrandom.C:55 fillrandom.C:56 fillrandom.C:57 fillrandom.C:58 |
|