19 Int_t nbinsx =
hist->GetNbinsX();
20 Int_t nbinsy =
hist->GetNbinsY();
21 Int_t
nbins = nbinsx * nbinsy;
28 for (
int iy = 1; iy <= nbinsy; iy++) {
29 for (
int ix = 1; ix <= nbinsx; ix++) {
30 float binval =
hist->GetBinContent(ix, iy);
33 double fraction = binval /
hist->Integral();
34 if (TMath::Abs(fraction) > 1
e-5) {
36 <<
hist->GetName() <<
" : " <<
hist->GetTitle()
37 <<
" binval=" << binval <<
" " << fraction * 100
38 <<
"% of integral=" <<
hist->Integral()
39 <<
". Forcing bin to 0.");
50 <<
" integral=" <<
integral <<
" is <=0");
57 for (
int ix = 1; ix <= nbinsx; ix++)
61 for (
int iy = 1; iy <= nbinsy; iy++)
65 for (ibin = 0; ibin <
nbins; ++ibin)
70 float rnd0,
float rnd1)
const {
82 Int_t biny = ibin / nbinsx;
83 Int_t binx = ibin - nbinsx * biny;
93 (rnd0 - basecont) / dcont;
106 if (
hist ==
nullptr) {
110 hist =
new TH2F(
"test2D",
"test2D", nbinsx, 0, 1, nbinsy, 0, 1);
112 for (
int ix = 1; ix <= nbinsx; ++ix) {
113 for (
int iy = 1; iy <= nbinsy; ++iy) {
114 hist->SetBinContent(ix, iy,
115 (0.5 + gRandom->Rndm()) * (nbinsx + ix) *
116 (nbinsy * nbinsy / 2 + iy * iy));
117 if (gRandom->Rndm() < 0.1)
118 hist->SetBinContent(ix, iy, 0);
119 hist->SetBinError(ix, iy, 0);
124 nbinsx =
hist->GetNbinsX();
125 nbinsy =
hist->GetNbinsY();
130 for (rnd[0] = 0; rnd[0] < 0.9999; rnd[0] += 0.25) {
131 for (rnd[1] = 0; rnd[1] < 0.9999; rnd[1] += 0.25) {
134 <<
" -> x=" <<
value[0]
135 <<
" y=" <<
value[1]);
144 int nrnd = 100000000;
147 for (
int i = 0;
i < nrnd; ++
i) {
148 rnd[0] = gRandom->Rndm();
149 rnd[1] = gRandom->Rndm();
153 hist_val->Add(
hist, -1);
155 TH1F *hist_pull =
new TH1F(
"pull",
"pull", 80, -4, 4);
156 for (
int ix = 1; ix <= nbinsx; ++ix) {
157 for (
int iy = 1; iy <= nbinsy; ++iy) {
158 float val = hist_val->GetBinContent(ix, iy);
159 float err = hist_val->GetBinError(ix, iy);
161 hist_pull->Fill(
val /
err);
167 TFile::Open(
"TFCS2DFunctionHistogram_unit_test.root",
"RECREATE"));
178 #if defined(__FastCaloSimStandAlone__)
179 new TCanvas(
"input",
"Input");
182 new TCanvas(
"validation",
"Validation");
183 hist_val->Draw(
"colz");
185 new TCanvas(
"pull",
"Pull");