15void smooth_hist(
const char *fname,
double xmin,
double xmax,
int n1,
int n2)
18 std::cout <<
"smoothing a " << fname <<
" histogram" << std::endl;
22 h1->FillRandom(fname, n1);
30 double p1 =
h1->Chi2Test(h2,
"");
31 double p2 = h1_s->
Chi2Test(h2,
"UU");
33 Error(
"testSmooth",
"TH1::Smooth is not working correctly - a worst chi2 is obtained");
35 std::cout <<
" chi2 test non-smoothed histo " << p1 << std::endl;
36 std::cout <<
" chi2 test smoothed histo " << p2 << std::endl;
38 double a1 =
h1->AndersonDarlingTest(h2);
41 std::cout <<
" AD test non-smoothed histo " << a1 << std::endl;
42 std::cout <<
" AD test smoothed histo " << a2 << std::endl;
44 double k1 =
h1->KolmogorovTest(h2);
47 std::cout <<
" KS test non-smoothed histo " << k1 << std::endl;
48 std::cout <<
" KS test smoothed histo " << k2 << std::endl;
54 h2->
Scale(
double(n1) / n2);
59void hist017_TH1_smooth(
int n1 = 1000,
int n2 = 1000000)
67 smooth_hist(
"gaus", -5, 5, n1, n2);
68 smooth_hist(
"landau", -5, 15, n1, n2);
69 smooth_hist(
"expo", -5, 0, n1, n2);
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
virtual void SetLineColor(Color_t lcolor)
Set the line color.
TDirectory::TContext keeps track and restore the current directory.
1-D histogram with a double per channel (see TH1 documentation)
virtual void Smooth(Int_t ntimes=1, Option_t *option="")
Smooth bin contents of this histogram.
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
void Draw(Option_t *option="") override
Draw this histogram with options.
void SetName(const char *name) override
Change the name of this histogram.
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 ...
virtual Double_t Chi2Test(const TH1 *h2, Option_t *option="UU", Double_t *res=nullptr) const
test for comparing weighted and unweighted histograms.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
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.