Logo ROOT  
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
11void candledecay()
12{
13 auto c1 = new TCanvas("c1","Candle Decay",800,600);
14 c1->Divide(2,1);
15 auto rng = new TRandom();
16 auto 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 = rng->Gaus(350+i*8,20+2*i);
22 h1->Fill(myRand,i);
23 }
24 }
25 h1->SetBarWidth(3);
26 h1->SetFillStyle(0);
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 auto h2 = (TH2I*)h1->Clone("h2");
36 h2->SetBarWidth(0.8);
37 h2->DrawCopy("candley2");
38}
@ kGray
Definition: Rtypes.h:65
@ kBlue
Definition: Rtypes.h:66
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
The Canvas class.
Definition: TCanvas.h:23
TAxis * GetXaxis()
Definition: TH1.h:322
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3338
TAxis * GetYaxis()
Definition: TH1.h:323
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition: TH1.cxx:3060
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
Definition: TH1.cxx:2727
virtual void SetBarWidth(Float_t width=0.5)
Set the width of bars as fraction of the bin width for drawing mode "B".
Definition: TH1.h:362
2-D histogram with an int per channel (see TH1 documentation)}
Definition: TH2.h:216
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
return c1
Definition: legend1.C:41
TH1F * h1
Definition: legend1.C:5