Logo ROOT   6.14/05
Reference Guide
candleplotoption.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// \notebook
4 /// Example showing how to combine the various candle plot options.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Georg Troska
10 
11 void candleplotoption()
12 {
13  TCanvas *c1 = new TCanvas("c1","Candle Presets",800,600);
14  c1->Divide(3,2);
15 
16  TRandom *rng = new TRandom();
17  TH2I *h1 = new TH2I("h1","Sin",18,0,360,300,-1.5,1.5);
18  h1->GetXaxis()->SetTitle("Deg");
19  float myRand;
20  for (int i = 0; i < 360; i+=10) {
21  for (int j = 0; j < 100; j++) {
22  myRand = rng->Gaus(sin(i*3.14/180),0.2);
23  h1->Fill(i,myRand);
24  }
25  }
26  for (int i = 1; i < 7; i++) {
27  c1->cd(i);
28  char str[16];
29  sprintf(str,"candlex%d",i);
30  TH2I * myhist = (TH2I*)h1->DrawCopy(str);
31  myhist->SetTitle(str);
32  }
33 
34  TCanvas *c2 = new TCanvas("c2","Candle Individual",800,600);
35  c2->Divide(4,4);
36  char myopt[16][8] = {"0","1","11","21","31","30","111","311","301","1111","2321","12111","112111","212111","312111"};
37  for (int i = 0; i < 15; i++) {
38  c2->cd(i+1);
39  char str[16];
40  sprintf(str, "candlex(%s)",myopt[i]);
41  TH2I * myhist = (TH2I*)h1->DrawCopy(str);
42  myhist->SetTitle(str);
43  }
44 }
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
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:3021
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TH1F * h1
Definition: legend1.C:5
double sin(double)
The Canvas class.
Definition: TCanvas.h:31
return c2
Definition: legend2.C:14
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:1162
THist< 2, int, THistStatContent > TH2I
Definition: THist.hxx:293
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
Definition: TH1.cxx:6192
2-D histogram with an int per channel (see TH1 documentation)}
Definition: TH2.h:211
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