#include "ISF_FastCaloSimEvent/TFCS1DFunctionSpline.h"
#include "ISF_FastCaloSimEvent/TFCS1DFunctionInt32Histogram.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 TFCS1DFunctionSpline::unit_test ATLAS_NOT_THREAD_SAFE |
( |
TH1 * |
hist | ) |
|
Definition at line 378 of file TFCS1DFunctionSpline.cxx.
381 TH1 *histfine =
nullptr;
382 if (
hist ==
nullptr) {
388 hist =
new TH1D(
"test1D",
"test1D", nbinsx,
xmin,
xmax);
389 histfine =
new TH1D(
"test1Dfine",
"test1Dfine", 10 * nbinsx,
xmin,
xmax);
391 for (
int i = 1;
i <= 100000; ++
i) {
392 double x = gRandom->Gaus(xpeak,
sigma);
397 histfine->Fill(
x, 10);
404 nbinsx =
hist->GetNbinsX();
409 for (rnd[0] = 0; rnd[0] < 0.9999; rnd[0] += 0.25) {
410 rtof.rnd_to_fct(
value, rnd);
414 TH1 *hist_val = (TH1 *)histfine->Clone(
"hist_val");
415 hist_val->SetTitle(
"toy simulation");
417 hist_val->SetLineColor(2);
418 TH1 *hist_diff = (TH1 *)
hist->Clone(
"hist_diff");
419 hist_diff->SetTitle(
"difference");
422 double weight = histfine->Integral() / nrnd;
423 double weightdiff =
hist->Integral() / nrnd;
426 for (
int i = 0;
i < nrnd; ++
i) {
427 rnd[0] = gRandom->Rndm();
428 rtof.rnd_to_fct(
value, rnd);
430 hist_diff->Fill(
value[0], weightdiff);
432 hist_diff->Add(
hist, -1);
434 TH1F *hist_pull =
new TH1F(
"pull",
"pull", 200, -10, 10);
435 for (
int ix = 1; ix <= nbinsx; ++ix) {
436 float val = hist_diff->GetBinContent(ix);
437 float err = hist_diff->GetBinError(ix);
439 hist_pull->Fill(
val /
err);
445 #if defined(__FastCaloSimStandAlone__)
446 new TCanvas(
"input",
"Input");
447 histfine->SetLineColor(kGray);
448 histfine->Draw(
"hist");
450 hist_val->Draw(
"sameshist");
452 new TCanvas(
"spline",
"spline");
455 TGraph *
gr =
new TGraph();
456 for (
int i = 0;
i < ngr; ++
i) {
457 double r =
i * 1.0 / (ngr - 1);
458 gr->SetPoint(
i,
r, hist_fct.rnd_to_fct(
r));
460 gr->SetMarkerStyle(7);
462 TSpline3 *sp =
new TSpline3(rtof.spline());
464 sp->SetMarkerColor(2);
465 sp->SetMarkerStyle(2);
468 new TCanvas(
"difference",
"difference");
471 new TCanvas(
"pull",
"Pull");