Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
macro7.C
Go to the documentation of this file.
1// Draw a Bidimensional Histogram in many ways
2// together with its profiles and projections
3
4void macro7(){
5 gStyle->SetPalette(kBird);
6 gStyle->SetOptStat(0);
7 gStyle->SetOptTitle(0);
8
9 auto bidi_h = new TH2F("bidi_h","2D Histo;Gaussian Vals;Exp. Vals",
10 30,-5,5, // X axis
11 30,0,10); // Y axis
12
13 TRandom3 rgen;
14 for (int i=0;i<500000;i++) {
15 bidi_h->Fill(rgen.Gaus(0,2),10-rgen.Exp(4),.1);
16 }
17
18 auto c=new TCanvas("Canvas","Canvas",800,800);
19 c->Divide(2,2);
20 c->cd(1); bidi_h->Draw("Cont1");
21 c->cd(2); bidi_h->Draw("Colz");
22 c->cd(3); bidi_h->Draw("Lego2");
23 c->cd(4); bidi_h->Draw("Surf3");
24
25 // Profiles and Projections
26 auto c2=new TCanvas("Canvas2","Canvas2",800,800);
27 c2->Divide(2,2);
28 c2->cd(1); bidi_h->ProjectionX()->Draw();
29 c2->cd(2); bidi_h->ProjectionY()->Draw();
30 c2->cd(3); bidi_h->ProfileX()->Draw();
31 c2->cd(4); bidi_h->ProfileY()->Draw();
32}
#define c(i)
Definition RSha256.hxx:101
@ kBird
Definition TColor.h:121
externTStyle * gStyle
Definition TStyle.h:442
The Canvas class.
Definition TCanvas.h:23
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:345
Random number generator class based on M.
Definition TRandom3.h:27
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:274
virtual Double_t Exp(Double_t tau)
Returns an exponential deviate.
Definition TRandom.cxx:251
return c2
Definition legend2.C:14
void macro7()
Definition macro7.C:4