41 JParser<> zap(
"Program to test ROOT fit.");
45 zap[
'@'] =
make_field(gauss) = JGauss(0.0, 1.0, 1000.0, 100.0);
46 zap[
'e'] =
make_field(precision) = JGauss(0.05, 0.05, 25.0, 25.0);
51 catch(
const exception& error) {
52 FATAL(error.what() << endl);
56 ASSERT(numberOfEvents > 0);
58 TF1 fs(
"fs",
"exp(-0.5 * (x-[0])*(x-[0]) / ([1]*[1]))");
61 fs.FixParameter(0, gauss.mean);
62 fs.FixParameter(1, gauss.sigma);
65 const Double_t xmin = -5.0;
66 const Double_t xmax = +5.0;
68 JQuantile Q[] = { JQuantile(
"mean "),
71 JQuantile(
"background") };
73 TH1D
H[] = { TH1D(
"ha",
"", 101, -0.1, +0.1),
74 TH1D(
"hb",
"", 101, -0.1, +0.1),
75 TH1D(
"hc",
"", 101, -100.0, +100.0),
76 TH1D(
"hd",
"", 101, -100.0, +100.0) };
80 for (
int i = 0; i != numberOfEvents; ++i) {
82 STATUS(
"event: " << setw(10) << i <<
'\r');
DEBUG(endl);
84 TH1D h0(
"h0", NULL, nx, xmin, xmax);
88 h0.FillRandom(
"fs", (Int_t) gauss.signal);
89 h0.FillRandom(
"fb", (Int_t) gauss.background);
91 TF1 f1(
"f1",
"[2]*exp(-0.5 * (x-[0])*(x-[0]) / ([1]*[1])) / (TMath::Sqrt(2.0*TMath::Pi())*[1]) + [3]");
93 f1.SetParameter(0, h0.GetMean());
94 f1.SetParameter(1, h0.GetRMS());
95 f1.SetParameter(2, h0.GetEntries() - h0.GetMinimum() * h0.GetNbinsX());
96 f1.SetParameter(3, h0.GetMinimum());
98 string option =
"NWL";
100 if (
debug <
debug_t && option.find(
'Q') == string::npos) {
106 h0.Fit(&f1, option.c_str());
110 const double Y[] = { f1.GetParameter(0) - gauss.mean,
111 f1.GetParameter(1) - gauss.sigma,
112 f1.GetParameter(2) * nx / (xmax - xmin) - gauss.signal,
113 f1.GetParameter(3) * nx - gauss.background };
115 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
121 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
126 timer.print(cout,
true,
micro_t);
133 for (
int i = 0; i !=
sizeof(
H)/
sizeof(
H[0]); ++i) {
141 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
145 ASSERT(Q[0].getSTDev() < precision.mean);
146 ASSERT(Q[1].getSTDev() < precision.sigma);
147 ASSERT(Q[2].getSTDev() < precision.signal);
148 ASSERT(Q[3].getSTDev() < precision.background);