11 #include "TGraphErrors.h"
12 #include "TGraphAsymmErrors.h"
23 m_graph_stat->GetXaxis()->SetTitle(GetXaxis()->GetTitle());
24 m_graph_stat->GetYaxis()->SetTitle(GetYaxis()->GetTitle());
26 m_graph_syst->GetXaxis()->SetTitle(GetXaxis()->GetTitle());
27 m_graph_syst->GetYaxis()->SetTitle(GetYaxis()->GetTitle());
48 double w =
weight->GetExpectancy();
51 AddBinContent(
bin,
w);
52 if (fSumw2.fN) fSumw2.fArray[
bin] +=
w *
w;
53 if (
bin == 0 ||
bin > fXaxis.GetNbins()) {
54 if (!GetStatOverflowsBehaviour())
return -1;
56 Double_t
z = (
w > 0 ?
w : -
w);
70 vector< TH1D* > original_dists = vector< TH1D* >(fXaxis.GetNbins());
73 for (
int j = 0; j < fXaxis.GetNbins(); ++j) {
76 double sig_low_o = (
max((
double) 0.0, (unweighted_content - 5 * sqrt(unweighted_content))));
77 double sig_high_o = (unweighted_content + 5 * sqrt(unweighted_content));
78 double step = (sig_high_o - sig_low_o) * 1
e-3;
80 original_dists[j] =
new TH1D(
"",
"", 1000, sig_low_o, sig_high_o);
84 for (
double lambda = sig_low_o; lambda < sig_high_o; lambda +=
step) {
85 double value =
exp(-lambda + unweighted_content *
log(lambda) - curr_fact);
87 (original_dists[j])->SetBinContent(bin_no,
value);
90 (original_dists[j])->
Scale(1. / (original_dists[j])->GetSum());
91 const double old_mode = (original_dists[j])->GetBinCenter((original_dists[j])->GetMaximumBin());
92 const double inv_old_mode = 1. / old_mode;
95 vector< double > bin_sumw(
prec, 0.);
96 double max_value = 1.e-100;
97 double min_value = 1.e100;
99 for (
vector<double>::iterator it_hist = bin_sumw.begin(), it_histE = bin_sumw.end(); it_hist != it_histE; ++it_hist) {
101 *it_hist += (*it_func)->GetRandom();
103 double cur_val = *it_hist;
104 if (cur_val < min_value) {
106 }
else if (cur_val > max_value) {
112 TH1D* scaled_hist_l = (TH1D*) (original_dists[j])->Clone(
"");
113 TH1D* scaled_hist_h = (TH1D*) (original_dists[j])->Clone(
"");
114 double scale = min_value * inv_old_mode;
115 scaled_hist_l->GetXaxis()->SetLimits(
scale * sig_low_o,
scale * sig_high_o);
116 scale = max_value * inv_old_mode;
117 scaled_hist_h->GetXaxis()->SetLimits(
scale * sig_low_o,
scale * sig_high_o);
120 double prob[1] = {0.001};
122 scaled_hist_l->GetQuantiles(1, quant,
prob);
123 double sig_low = quant[0];
125 scaled_hist_h->GetQuantiles(1, quant,
prob);
126 double sig_high = quant[0];
128 m_bin_dists[j] =
new TH1D(
"",
"", 1000, sig_low, sig_high);
131 if (unweighted_content > 0.) {
132 for (
int k = 0;
k <
prec; ++
k) {
133 double new_val = bin_sumw[
k];
134 TH1D* scaled_hist = (TH1D*) (original_dists[j])->Clone(
"");
135 double temp_scale = new_val * inv_old_mode;
136 scaled_hist->GetXaxis()->SetLimits(temp_scale * sig_low_o, temp_scale * sig_high_o);
137 for (
int l = 1;
l < 1001; ++
l) {
138 (
m_bin_dists[j])->AddBinContent(
l, scaled_hist->GetBinContent(scaled_hist->FindBin((
m_bin_dists[j])->GetBinCenter(
l))));
142 double local_value = sig_low + (
m_bin_dists[j])->GetMaximumBin() * ((sig_high - sig_low) * 1
e-3);
143 m_graph_stat->SetPoint(point_count, (GetXaxis()->GetXmin() + j * GetBinWidth(j + 1) + GetBinWidth(j + 1) / 2), local_value);
144 m_graph_syst->SetPoint(point_count, (GetXaxis()->GetXmin() + j * GetBinWidth(j + 1) + GetBinWidth(j + 1) / 2), local_value);
145 double quantile[ 2 ];
146 double conf[ 2 ] = {0.1585, 0.8415};
148 m_graph_stat->SetPointError(point_count, GetBinWidth(j + 1) / 2, GetBinWidth(j + 1) / 2, local_value - quantile[0], quantile[1] - local_value);
149 m_graph_syst->SetPointError(point_count, GetBinWidth(j + 1) / 2, local_value * (sqrt(
m_SumSys2[j]) / GetBinContent(j + 1)));
165 for (
int j = 0; j < fXaxis.GetNbins(); ++j) {
167 m_graph_syst->SetPoint(point_count, (GetXaxis()->GetXmin() + j * GetBinWidth(j + 1) + GetBinWidth(j + 1) / 2), GetBinContent(j + 1));