97 double zerothreshold) {
98 TH1 *hist =
new TH1D(
"test_slope1D",
"test_slope1D", nbinsx,
xmin,
xmax);
100 for (
int ix = 1; ix <= nbinsx; ++ix) {
101 double val = (0.5 + gRandom->Rndm()) * (nbinsx + ix);
102 if (gRandom->Rndm() < zerothreshold)
104 hist->SetBinContent(ix, val);
105 hist->SetBinError(ix, 0);
125 int nrnd, TH1 *histfine) {
129 int nbinsx = hist->GetNbinsX();
135 for (
rnd[0] = 0;
rnd[0] < 0.9999;
rnd[0] += 0.25) {
140 TH1 *hist_val =
nullptr;
142 hist_val = (TH1 *)histfine->Clone(TString(hist->GetName()) +
"hist_val");
144 hist_val = (TH1 *)hist->Clone(TString(hist->GetName()) +
"hist_val");
145 double weightfine = hist_val->Integral() / nrnd;
146 hist_val->SetTitle(
"toy simulation");
148 hist_val->SetLineColor(2);
151 TH1 *hist_diff = (TH1 *)hist->Clone(TString(hist->GetName()) +
"_difference");
152 hist_diff->SetTitle(
"cut efficiency difference");
157 for (
int i = 0; i < nrnd; ++i) {
158 rnd[0] = gRandom->Rndm();
160 hist_val->Fill(value[0], weightfine);
161 hist_diff->Fill(value[0], weight);
163 hist_diff->Add(hist, -1);
167 new TH1F(TString(hist->GetName()) +
"_pull",
"pull", 200, -10, 10);
168 for (
int ix = 1; ix <= nbinsx; ++ix) {
169 float val = hist_diff->GetBinContent(ix);
170 float err = hist_diff->GetBinError(ix);
172 hist_pull->Fill(val / err);
177#if defined(__FastCaloSimStandAlone__)
178 TCanvas *c =
new TCanvas(hist->GetName(), hist->GetName());
183 histfine->SetLineColor(kGray);
184 histfine->DrawClone(
"hist");
185 hist->DrawClone(
"same");
189 hist_val->DrawClone(
"sameshist");
193 histfine->SetLineColor(kGray);
194 histfine->DrawClone(
"hist");
195 hist->DrawClone(
"same");
199 hist_val->DrawClone(
"sameshist");