52 if (TMath::Prob(redchi2 * 8, 8) < 0.99) {
68 double resid_sum = 0.;
69 double resid_sum2 = 0.;
76 double weight = 1. / redchi2;
81 if (fabs(residual) < 10.) {
82 resid_sum +=
weight * residual;
83 resid_sum2 +=
weight * residual * residual;
90 double resid_mean = resid_sum / resid_N;
91 double resid_stdev =
sqrt(resid_sum2 / resid_N -
pow(resid_sum / resid_N, 2));
100 double weight = 1. / redchi2;
105 if (fabs(residual - resid_mean) < 2.5 * resid_stdev) {
106 resid_sum +=
weight * residual;
107 resid_sum2 +=
weight * residual * residual;
113 resid_mean = resid_sum / resid_N;
114 resid_stdev =
sqrt(resid_sum2 / resid_N -
pow(resid_sum / resid_N, 2));
116 std::vector<int>
num;
117 std::vector<std::string>
name;
118 std::vector<double>
start;
119 std::vector<double>
step;
120 std::vector<double>
low;
121 std::vector<double>
high;
127 step.push_back(0.01 * resid_stdev);
133 start.push_back(resid_mean);
134 step.push_back(0.01 * resid_stdev);
140 start.push_back(resid_stdev);
141 step.push_back(0.01 * resid_stdev);
147 start.push_back(0.1 * resid_stdev);
148 step.push_back(0.01 * resid_stdev);
159 std::stringstream name_residual, name_residual_raw;
160 name_residual <<
name <<
"_residual";
161 name_residual_raw <<
name <<
"_residual_raw";
163 double min_residual = -100.;
164 double max_residual = 100.;
165 TH1F *hist_residual =
dir->make<TH1F>(name_residual.str().c_str(),
"", 100, min_residual, max_residual);
166 TH1F *hist_residual_raw =
dir->make<TH1F>(name_residual_raw.str().c_str(),
"", 100, min_residual, max_residual);
168 name_residual <<
"_fit";
169 TF1 *fit_residual =
nullptr;
200 fit_residual->SetLineColor(2);
201 fit_residual->SetLineWidth(2);
202 fit_residual->Write();
207 double weight = 1. / redchi2;
215 hist_residual_raw->Fill(10. * resid);
220 for (
int i = 1;
i <= hist_residual->GetNbinsX();
i++) {
221 double xi = hist_residual->GetBinCenter(
i);
222 double yi = hist_residual->GetBinContent(
i);
223 double yerri = hist_residual->GetBinError(
i);
224 double yth = fit_residual->Eval(
xi);
226 chi2 +=
pow((yth - yi) / yerri, 2);