Logo ROOT  
Reference Guide
No Matches
testSmooth.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Histogram smoothing.

int ipad = 1;
TCanvas * c1 = 0;
void smooth_hist(const char * fname, double xmin, double xmax, int n1, int n2) {
std::cout << "smoothing a " << fname << " histogram" << std::endl;
TH1D * h1 = new TH1D("h1","h1",100,xmin,xmax);
TH1D * h2 = new TH1D("h2","h2",100,xmin,xmax);
TH1D * h1_s = new TH1D(*h1);
double p1 = h1->Chi2Test(h2,"");
double p2 = h1_s->Chi2Test(h2,"UU");
if (p2 < p1) Error("testSmooth","TH1::Smooth is not working correctly - a worst chi2 is obtained");
std::cout << " chi2 test non-smoothed histo " << p1 << std::endl;
std::cout << " chi2 test smoothed histo " << p2 << std::endl;
double a1 = h1->AndersonDarlingTest(h2);
double a2 = h1_s->AndersonDarlingTest(h2);
std::cout << " AD test non-smoothed histo " << a1 << std::endl;
std::cout << " AD test smoothed histo " << a2 << std::endl;
double k1 = h1->KolmogorovTest(h2);
double k2 = h1_s->KolmogorovTest(h2);
std::cout << " KS test non-smoothed histo " << k1 << std::endl;
std::cout << " KS test smoothed histo " << k2 << std::endl;
void testSmooth(int n1 = 1000, int n2 = 1000000) {
c1 = new TCanvas();
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
float xmin
float xmax
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a double per channel (see TH1 documentation)}
Definition TH1.h:621
virtual void Smooth(Int_t ntimes=1, Option_t *option="")
Smooth bin contents of this histogram.
Definition TH1.cxx:6828
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition TH1.cxx:1282
virtual void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
Definition TH1.cxx:3500
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3047
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:8787
virtual Double_t AndersonDarlingTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using the Anderson-Darling ...
Definition TH1.cxx:7933
virtual Double_t Chi2Test(const TH1 *h2, Option_t *option="UU", Double_t *res=nullptr) const
test for comparing weighted and unweighted histograms
Definition TH1.cxx:1995
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition TH1.cxx:6553
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using Kolmogorov test.
Definition TH1.cxx:8047
return c1
Definition legend1.C:41
TH1F * h1
Definition legend1.C:5
Rene Brun

Definition in file testSmooth.C.