22 TH1D *h_input = (TH1D *)h_input1->Clone(
"h_input");
23 TH1D *h_approx = (TH1D *)h_approx1->Clone(
"h_approx");
28 double integral_input = h_input->Integral();
29 double integral_approx = 0.0;
30 for (
int b = 1;
b <= h_input->GetNbinsX();
b++)
32 h_approx->GetBinContent(h_approx->FindBin(h_input->GetBinCenter(
b)));
33 h_approx->Scale(integral_input / integral_approx);
35 double ymax = h_approx->GetBinContent(h_approx->GetNbinsX()) -
36 h_approx->GetBinContent(h_approx->GetMinimumBin());
37 for (
int i = 1;
i <= h_input->GetNbinsX();
i++) {
38 double val = fabs(h_approx->GetBinContent(
39 h_approx->FindBin(h_input->GetBinCenter(
i))) -
40 h_input->GetBinContent(
i)) /
49 return maxdev * 100.0;
53 const TH1 *
hist, std::vector<double> &integral_vec,
int &
first,
int &last) {
58 integral_vec.resize(
nbins);
59 for (
int ix = 1; ix <=
nbins; ix++) {
60 float binval =
hist->GetBinContent(ix);
63 double fraction = binval /
hist->Integral();
64 if (TMath::Abs(fraction) > 1
e-5) {
66 <<
hist->GetName() <<
" : "
67 <<
hist->GetTitle() <<
" binval=" << binval
68 <<
" " << fraction * 100
69 <<
"% of integral=" <<
hist->Integral()
70 <<
". Forcing bin to 0.");
79 if (integral_vec[
first] != 0)
81 for (last =
nbins - 1; last > 0; last--)
88 <<
hist->GetName() <<
" : " <<
hist->GetTitle()
89 <<
" integral=" <<
integral <<
" is <=0");
94 TH1 *TFCS1DFunction::generate_histogram_random_slope
96 double zerothreshold) {
97 TH1 *
hist =
new TH1D(
"test_slope1D",
"test_slope1D", nbinsx,
xmin,
xmax);
99 for (
int ix = 1; ix <= nbinsx; ++ix) {
100 double val = (0.5 + gRandom->Rndm()) * (nbinsx + ix);
101 if (gRandom->Rndm() < zerothreshold)
104 hist->SetBinError(ix, 0);
109 TH1 *TFCS1DFunction::generate_histogram_random_gauss
111 double xpeak,
double sigma) {
112 TH1 *
hist =
new TH1D(
"test_gauss1D",
"test_gauss1D", nbinsx,
xmin,
xmax);
114 for (
int i = 1;
i <= ntoy; ++
i) {
124 int nrnd, TH1 *histfine) {
128 int nbinsx =
hist->GetNbinsX();
134 for (rnd[0] = 0; rnd[0] < 0.9999; rnd[0] += 0.25) {
139 TH1 *hist_val =
nullptr;
141 hist_val = (TH1 *)histfine->Clone(TString(
hist->GetName()) +
"hist_val");
143 hist_val = (TH1 *)
hist->Clone(TString(
hist->GetName()) +
"hist_val");
144 double weightfine = hist_val->Integral() / nrnd;
145 hist_val->SetTitle(
"toy simulation");
147 hist_val->SetLineColor(2);
150 TH1 *hist_diff = (TH1 *)
hist->Clone(TString(
hist->GetName()) +
"_difference");
151 hist_diff->SetTitle(
"cut efficiency difference");
156 for (
int i = 0;
i < nrnd; ++
i) {
157 rnd[0] = gRandom->Rndm();
159 hist_val->Fill(
value[0], weightfine);
162 hist_diff->Add(
hist, -1);
166 new TH1F(TString(
hist->GetName()) +
"_pull",
"pull", 200, -10, 10);
167 for (
int ix = 1; ix <= nbinsx; ++ix) {
168 float val = hist_diff->GetBinContent(ix);
169 float err = hist_diff->GetBinError(ix);
171 hist_pull->Fill(
val /
err);
176 #if defined(__FastCaloSimStandAlone__)
177 TCanvas *
c =
new TCanvas(
hist->GetName(),
hist->GetName());
182 histfine->SetLineColor(kGray);
183 histfine->DrawClone(
"hist");
184 hist->DrawClone(
"same");
188 hist_val->DrawClone(
"sameshist");
192 histfine->SetLineColor(kGray);
193 histfine->DrawClone(
"hist");
194 hist->DrawClone(
"same");
198 hist_val->DrawClone(
"sameshist");