Histograms
Histograms
http://root.cern.ch
ROOT courses 1
ROOT corses 2
R.Brun LCG
The Histogram Package
ROOT courses 3
The Histogram Classes
Structure
1-Dim
2-Dim
3-Dim
ROOT corses 4
R.Brun LCG
Filling Histograms
If TH1::Sumw2 has been called before filling, the sum of squares of weights is also
stored.
One can also increment directly a bin number via TH1::AddBinContent or replace the
existing content via TH1::SetBinContent.
To access the bin content of a given bin, do:
Double_t binContent = h->GetBinContent(bin);
ROOT corses 5
R.Brun LCG
Automatic binning
#include "TH1.h"
#include "TF1.h"
No limits
void demoauto() {
TF1 *f1 = new TF1("f1","gaus",0,30);
f1->SetParameters(1,10,3);
TH1F *h = new TH1F("h","Automatic binning demo",100,0,0);
for (Int_t i=0;i<1000000;i++) {
h->Fill(f1->GetRandom());
}
h->Draw();
}
ROOT corses 6
R.Brun LCG
Filling with strings
See tutorials
-hlabels1.C
-hlabels2.C
-cernstaff.C
ROOT corses 7
R.Brun LCG
Histograms
ROOT corses 8
R.Brun LCG
Peak Finder + Deconvolutions
by Miroslav Morach
TSpectrum
ROOT corses 9
R.Brun LCG
Fitting TMinuit
TFumili TFitter
TVirtualFitter
User
ROOT corses 10
R.Brun LCG
Fitting histograms
Histograms (1-D,2-D,3-D and Profiles) can be fitted with a user specified function via TH1::Fit.
Two Fitting algorithms are supported: Chisquare method and Log Likelihood
An option is provided to compute the integral of the function bin by bin instead of simply
compute the function value at the center of the bin.
When an histogram is fitted, the resulting function with its parameters is added to the list of
functions of this histogram. If the histogram is made persistent, the list of associated functions
is also persistent.
One can retrieve the function/fit parameters with calls such as:
Double_t chi2 = myfunc->GetChisquare();
Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
Double_t err0 = myfunc->GetParError(0); //error on first parameter
ROOT corses 11
R.Brun LCG
Associated functions
One or more object (typically a TF1*) can be added to the list of functions
associated to each histogram.
When TF1::Fit is invoked, the fitted function is added to this list.
Given an histogram h, one can retrieve an associated function with:
TF1 *myfunc = h->GetFunction("myfunc");
ROOT corses 12
R.Brun LCG
RooFit
A general purpose tool kit
for data modeling
Wouter Verkerke (UC Santa
Barbara)
David Kirkby (UC Irvine)
ftp://root.cern.ch/root/R2002/verkerke.ppt
ROOT courses 13
Operations on histograms
ROOT corses 14
R.Brun LCG
Random Numbers and Histograms
TH1::FillRandom can be used to randomly fill an histogram using
the contents of an existing TF1 analytic function
another histogram (for all dimensions).
For example the following two statements create and fill an histogram
10000 times with a default gaussian distribution of mean 0 and sigma 1:
TH1F h1("h1","histo from a gaussian",100,-3,3);
h1.FillRandom("gaus",10000);
ROOT corses 15
R.Brun LCG
Drawing Histograms
When you call the Draw method of a histogram for the first time
(TH1::Draw), it creates a THistPainter object and saves a pointer to painter
as a data member of the histogram.
The THistPainter class specializes in the drawing of histograms. It is
separate from the histogram so that one can have histograms without the
graphics overhead, for example in a batch program. The choice to give
each histogram have its own painter rather than a central singleton painter,
allows two histograms to be drawn in two threads without overwriting the
painter's values.
When a displayed histogram is filled again you do not have to call the Draw
method again. The image is refreshed the next time the pad is updated.
The same histogram can be drawn with different graphics options in
different pads.
When a displayed histogram is deleted, its image is automatically removed
from the pad.
ROOT corses 16
R.Brun LCG
1-D drawing Options
ROOT corses 17
R.Brun LCG
ROOT corses 18
R.Brun LCG
2-D drawing options
ROOT corses 19
R.Brun LCG
2-D drawing options
ROOT corses 20
R.Brun LCG
2-D drawing Options
All these
plots can
be rotated
with the
mouse
ROOT corses 21
R.Brun LCG
2-D drawing Options
Same output
on the screen and with
vector Postscript
ROOT corses 22
R.Brun LCG
THStack examples
ROOT corses 23
R.Brun LCG
Filling with string variables
ROOT corses 24
R.Brun LCG
Math Libs & Statistics
Can generate random numbers
from basic distributions; gaus, poisson, etc
In ROOT today
GRID TVector2,3 DAQ from parametric analytic functions 1,2,3-d
Event Models
Online from histograms, 1,2,3-d
middleware
TLorentzRotation Folders
Event
TLorentzVector
RDBMS Matrix package maintained by E. Offermann (Rentec)
Object Generators
TRandom,2,3
Object
run/file persistency A collection of many algorithms
TMatrix
persistency
catalogs CERNLIB, Numerical Recipes in C/C++
TMath Event Display
TFeldmanCousins Detector
Many algorithms classes
System
TPrincipal developed by a huge user Simulation
community
services
Histograming
TMultidimFit See recent FNAL meeting
2-d, 3-d
Fitting and effort organized within ACAT
TConfidenceLevel graphics
Ntuple
TFractionFitter Would like to see an interface Detector
analysis to GSL Geometry
Math Libs GUIin C++
to Numerical Recipes
Statistics Toolkits
Collaboration with
Interpreters
Fred James, Louis Lyons, Sherry Towers
ROOT corses 25
R.Brun LCG