ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qa2.C
Go to the documentation of this file.
1 void qa2() {
2  //Fill a 1-D histogram from a parametric function
3  TCanvas *c1 = new TCanvas("c1","The FillRandom example",0,0,700,500);
4  c1->SetFillColor(18);
5 
6  gBenchmark->Start("fillrandom");
7  //
8  // A function (any dimension) or a formula may reference
9  // an already defined formula
10  //
11  TFormula *form1 = new TFormula("form1","abs(sin(x)/x)");
12  TF1 *sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
13  sqroot->SetParameters(10,4,1,20);
14 
15  //
16  // Create a one dimensional histogram (one float per bin)
17  // and fill it following the distribution in function sqroot.
18  //
19  TH1F *h1f = new TH1F("h1f","Test random numbers",200,0,10);
20  h1f->SetFillColor(45);
21  h1f->FillRandom("sqroot",100000);
22  h1f->Draw();
23  TPaveLabel *lfunction = new TPaveLabel(5,39,9.8,46,"The sqroot function");
24  lfunction->SetFillColor(41);
25 
26  c1->SetGridx();
27  c1->SetGridy();
28  c1->GetFrame()->SetFillColor(42);
29  c1->GetFrame()->SetBorderMode(-1);
30  c1->GetFrame()->SetBorderSize(5);
31 
32  h1f->SetDirectory(0);
33 
34  c1->Update();
35 
36  sqroot->SetParameters(200,4,1,20);
37 }
virtual void SetGridx(Int_t value=1)
Definition: TPad.h:327
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:432
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
Definition: TH1.cxx:8266
virtual void SetBorderMode(Short_t bordermode)
Definition: TWbox.h:62
TCanvas * c1
Definition: legend1.C:2
tuple lfunction
Definition: fillrandom.py:35
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
tuple h1f
Definition: fillrandom.py:48
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:172
TFrame * GetFrame()
Get frame.
Definition: TPad.cxx:2729
virtual void SetBorderSize(Short_t bordersize)
Definition: TWbox.h:63
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:32
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3330
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
tuple form1
Definition: fillrandom.py:24
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:63
The F O R M U L A class.
Definition: TFormula.h:89
The Canvas class.
Definition: TCanvas.h:48
virtual void SetGridy(Int_t value=1)
Definition: TPad.h:328
void qa2()
Definition: qa2.C:1
1-Dim function class
Definition: TF1.h:149
tuple sqroot
Definition: fillrandom.py:25
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2179