Logo ROOT  
Reference Guide
candlehisto.C File Reference

Detailed Description

View in nbviewer Open in SWAN Example showing how to combine the various candle plot options.

void candlehisto()
{
TCanvas *c1 = new TCanvas("c1", "Candle Presets", 800, 600);
c1->Divide(3, 2);
TRandom *rng = new TRandom();
TH2I *h1 = new TH2I("h1", "Sin", 18, 0, 360, 100, -1.5, 1.5);
h1->GetXaxis()->SetTitle("Deg");
float myRand;
for (int i = 0; i < 360; i+= 10) {
for (int j = 0; j < 100; j++) {
myRand = rng->Gaus(sin(i * 3.14 / 180), 0.2);
h1->Fill(i, myRand);
}
}
for (int i = 1; i < 7; i++) {
c1->cd(i);
TString title = TString::Format("CANDLEX%d", i);
TH2I *myhist = (TH2I*)h1->DrawCopy(title);
myhist->SetTitle(title);
}
TCanvas *c2 = new TCanvas("c2", "Violin Presets", 800, 300);
c2->Divide(2, 1);
for (int i = 1; i < 3; i++) {
c2->cd(i);
TString title = TString::Format("VIOLINX%d", i);
TH2I *myhist = (TH2I*)h1->DrawCopy(title);
myhist->SetFillColor(kGray + 2);
}
TCanvas *c3 = new TCanvas("c3", "Playing with candle and violin-options", 800, 600);
c3->Divide(3, 2);
TString myopt[6] = {"1000000", "2000000", "3000000", "1112111", "112111", "112111"};
for (int i = 0; i < 6; i++) {
c3->cd(i + 1);
TString title = TString::Format("candlex(%s)", myopt[i].Data());
TH2I *myhist = (TH2I*)h1->DrawCopy(title);
myhist->SetFillColor(kYellow);
if (i == 4) {
TH2I *myhist2 = (TH2I*)h1->DrawCopy("candlex(1000000) same");
myhist2->SetFillColor(kRed);
}
if (i == 5) {
myhist->SetBarWidth(0.2);
myhist->SetBarOffset(0.25);
TH2I *myhist2 = (TH2I*)h1->DrawCopy("candlex(2000000) same");
myhist2->SetFillColor(kRed);
myhist2->SetBarWidth(0.6);
myhist2->SetBarOffset(-0.5);
}
myhist->SetTitle(title);
}
}
Author
Georg Troska

Definition in file candlehisto.C.

TRandom::Gaus
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:263
c3
return c3
Definition: legend3.C:15
TH1::DrawCopy
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:3044
sin
double sin(double)
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
TString
Definition: TString.h:136
h1
TH1F * h1
Definition: legend1.C:5
TH1::SetTitle
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
Definition: TH1.cxx:6344
TRandom
Definition: TRandom.h:27
TH2I
2-D histogram with an int per channel (see TH1 documentation)}
Definition: TH2.h:212
TH1::Fill
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3274
kRed
@ kRed
Definition: Rtypes.h:66
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TCanvas
Definition: TCanvas.h:23
c2
return c2
Definition: legend2.C:14
kGray
@ kGray
Definition: Rtypes.h:65
TH1::GetXaxis
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:317
kYellow
@ kYellow
Definition: Rtypes.h:66
TH1::SetBarWidth
virtual void SetBarWidth(Float_t width=0.5)
Definition: TH1.h:357
TH1::SetBarOffset
virtual void SetBarOffset(Float_t offset=0.25)
Definition: TH1.h:356
c1
return c1
Definition: legend1.C:41