#include "ISF_FastCaloSimEvent/TFCS2DFunctionHistogram.h"
#include <algorithm>
#include <iostream>
#include "TMath.h"
#include "TCanvas.h"
#include "TH2F.h"
#include "TRandom.h"
#include "TFile.h"
Go to the source code of this file.
◆ ATLAS_NOT_THREAD_SAFE()
void TFCS2DFunctionHistogram::unit_test ATLAS_NOT_THREAD_SAFE |
( |
TH2 * |
hist | ) |
|
Definition at line 102 of file TFCS2DFunctionHistogram.cxx.
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) {
132 rtof.rnd_to_fct(
value, rnd);
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();
150 rtof.rnd_to_fct(
value, rnd);
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");
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)