ROOT   6.08/07 Reference Guide
spectrumpainter.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_spectrum
3 /// \notebook
4 /// Examples showing how to use TSpectrum2Painter (the SPEC option)
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author: Olivier Couet, Miroslav Morhac
10
11 void spectrumpainter()
12 {
13  TH2 *h2 = new TH2F("h2","h2",40,-8,8,40,-9,9);
14  Float_t px, py;
15  for (Int_t i = 0; i < 50000; i++) {
16  gRandom->Rannor(px,py);
17  h2->Fill(px,py);
18  h2->Fill(px+4,py-4,0.5);
19  h2->Fill(px+4,py+4,0.25);
20  h2->Fill(px-3,py+4,0.125);
21  }
22
23  TCanvas *c1 = new TCanvas("c1","Illustration of 2D graphics",10,10,800,700);
24  c1->Divide(2,2);
25
26  c1->cd(1);
27  h2->Draw("SPEC dm(2,10) zs(1)");
28  c1->cd(2);
29  h2->Draw("SPEC dm(1,10) pa(2,1,1) ci(1,4,8) a(15,45,0)");
30  c1->cd(3);
31  h2->Draw("SPEC dm(2,10) pa(1,1,1) ci(1,1,1) a(15,45,0) s(1,1)");
32  c1->cd(4);
33  h2->Draw("SPEC dm(1,10) pa(2,1,1) ci(1,4,8) a(15,45,0) cm(1,15,4,4,1) cg(1,2)");
34 }
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition: TRandom.cxx:460
float Float_t
Definition: RtypesCore.h:53
return c1
Definition: legend1.C:41
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
int Int_t
Definition: RtypesCore.h:41
Service class for 2-Dim histogram classes.
Definition: TH2.h:36
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2851
R__EXTERN TRandom * gRandom
Definition: TRandom.h:66
The Canvas class.
Definition: TCanvas.h:41
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:1089
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:292
THist< 2, float, THistStatContent, THistStatUncertainty > TH2F
Definition: THist.hxx:308