[Notes] ROOT User Guide (2)

2 篇文章 0 订阅
2 篇文章 0 订阅

 

Chapter 3. Histograms

 

Wikipedia: In statistics, a histogram is a graphical display of tabulated frequencies, shown as bars. It shows what proportion of cases fall into each of several categories: it is a form of data binning.

 

Classes:

1-D: TH1C, TH1S, TH1I, TH1F, TH1D

2-D: TH2C, TH2S, TH2I, TH2F, TH2D

3-D: TH3C, TH3S, TH3I, TH3F, TH3D

Profile Histogram: TProfile, TProfile2D

where C denotes char(1 byte), S short(2 bytes), I int(4 bytes), F float(4 bytes), D double(8 bytes).

 

Creating Historgrams

TH1F *h1 = new TH1F("h1","h1 title",100,0,4.4);

TH2F *h2 = new TH2F("h2","h2 title",40,0,4,30,-3,3);

 

Fixed or Variable Bin Size

TH1(const char name,const *title,Int_t nbins, Float_t *xbins)

TH1(const char name,const *title,Int_t nbins, Double_t *xbins)

where xbins is an array of low-edges for each bin. It is an array of size nbins+1.

 

Bin Numbering 

For 1-D, Bin#0 contains the underflow, The last bin contains the overflow.

For 2-D and 3-D, a "global bin" number is defined. Take 3-D for example,  

Int_t bin = h->GetBin(binx,biny,binz);

 

GetBinContent(...) : get the number of items in a specified bin

SetBinContent(..., ...) : set the number of items in a specified bin

 

Filling Histograms

The Fill method computes the bin number corresponding to the given x, y or z argument and increments this bin by the given weight. 

 

Fill Histograms with a function or a histrograms

Fill with a function:

 

Fill with another histrograms:

 

 

Scaling, Adding, Dividing and Multiplying

 

Draw Options: 

There are enormous draw options to display histrograms in different styles. See User Guide for details.

 

Remember these:

  • gRandom->Uniform()
  • gRandom->Gaus(0, 1)
  • kRed
  • kGreen

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值