- define range of values we are interpreted in;
- divide the entire range of values into a series of intervals (with fixed or variable sizes;
- count how many values fall into each interval
Let us illustrate how to create a histogram for a variable in the range [0,1] using fixed bin size, and variable bin size
from ROOT import TH1D from array import array # histogram with fixed number of bins h1=TH1D('test1','test1',100,0,1) # use 100 bins # variable bins as array mbins=array("d",[0,0.1,0.2,0.4,1.0]) h2=TH1D('test2','test2',len(mbins)-1,mbins)
We have prepared two histogram objects, and we can do some manipulation. The first thing is to fill there two histograms with some random data.