Logo ROOT   6.12/07
Reference Guide
candledecay.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// \notebook
4 /// Candle Decay, illustrate a time development of a certain value.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Georg Troska
10 
11 void candledecay()
12 {
13  TCanvas *c1 = new TCanvas("c1","Candle Decay",800,600);
14  c1->Divide(2,1);
15  TRandom *rand = new TRandom();
16  TH2I *h1 = new TH2I("h1","Decay",1000,0,1000,20,0,20);
17 
18  float myRand;
19  for (int i = 0; i < 19; i++) {
20  for (int j = 0; j < 1000000; j++) {
21  myRand = rand->Gaus(350+i*8,20+2*i);
22  h1->Fill(myRand,i);
23  }
24  }
25  h1->SetBarWidth(3);
26  h1->SetFillStyle(0);
27  h1->SetFillColor(kGray);
28  h1->SetLineColor(kBlue);
29  h1->GetYaxis()->SetTitle("time");
30  h1->GetXaxis()->SetTitle("probability density");
31 
32  c1->cd(1);
33  h1->Draw("violiny(112000000)");
34  c1->cd(2);
35  TH2I *h2 = (TH2I*)h1->Clone("h2");
36  h2->SetBarWidth(0.8);
37  h2->DrawCopy("candley2");
38 }
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:256
return c1
Definition: legend1.C:41
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:688
Definition: Rtypes.h:58
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:3016
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void SetBarWidth(Float_t width=0.5)
Definition: TH1.h:353
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TH1F * h1
Definition: legend1.C:5
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2969
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
TAxis * GetYaxis()
Definition: TH1.h:316
The Canvas class.
Definition: TCanvas.h:31
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Definition: TPad.cxx:1153
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2662
THist< 2, int, THistStatContent > TH2I
Definition: THist.hxx:293
Definition: Rtypes.h:59
2-D histogram with an int per channel (see TH1 documentation)}
Definition: TH2.h:210
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:292
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:315