ATLAS Offline Software
Loading...
Searching...
No Matches
TFCS1DFunctionInt32Histogram.cxx File Reference
#include "ISF_FastCaloSimEvent/TFCS1DFunctionInt32Histogram.h"
#include <algorithm>
#include <iostream>
#include "TMath.h"
#include "TCanvas.h"
#include "TH2F.h"
#include "TRandom.h"
#include "TFile.h"
#include "TClass.h"
Include dependency graph for TFCS1DFunctionInt32Histogram.cxx:

Go to the source code of this file.

Functions

void TFCS1DFunctionInt32Histogram::unit_test ATLAS_NOT_THREAD_SAFE (TH1 *hist)

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

void TFCS1DFunctionInt32Histogram::unit_test ATLAS_NOT_THREAD_SAFE ( TH1 * hist)

Definition at line 107 of file TFCS1DFunctionInt32Histogram.cxx.

107 {
109 int nbinsx;
110 if (hist == nullptr) {
111 nbinsx = 400;
112 hist = new TH1D("test1D", "test1D", nbinsx, 0, 1);
113 hist->Sumw2();
114 for (int ix = 1; ix <= nbinsx; ++ix) {
115 double val = (0.5 + gRandom->Rndm()) * (nbinsx + ix);
116 if (gRandom->Rndm() < 0.1)
117 val = 0;
118 hist->SetBinContent(ix, val);
119 hist->SetBinError(ix, 0);
120 }
121 }
123 nbinsx = hist->GetNbinsX();
124
125 float value[2];
126 float rnd[2];
127 //cppcheck-suppress uninitvar
128 for (rnd[0] = 0; rnd[0] < 0.9999; rnd[0] += 0.25) {
129 rtof.rnd_to_fct(value, rnd);
130 ATH_MSG_NOCLASS(logger, "rnd0=" << rnd[0] << " -> x=" << value[0]);
131 }
132
133 TH1 *hist_val = (TH1 *)hist->Clone("hist_val");
134 hist_val->SetTitle("difference");
135 hist_val->Reset();
136 int nrnd = 10000000;
137 double weight = hist->Integral() / nrnd;
138 hist_val->Sumw2();
139 for (int i = 0; i < nrnd; ++i) {
140 rnd[0] = gRandom->Rndm();
141 rtof.rnd_to_fct(value, rnd);
142 hist_val->Fill(value[0], weight);
143 }
144 hist_val->Add(hist, -1);
145
146 TH1F *hist_pull = new TH1F("pull", "pull", 200, -10, 10);
147 for (int ix = 1; ix <= nbinsx; ++ix) {
148 float val = hist_val->GetBinContent(ix);
149 float err = hist_val->GetBinError(ix);
150 if (err > 0)
151 hist_pull->Fill(val / err);
152 ATH_MSG_NOCLASS(logger, "val=" << val << " err=" << err);
153 }
154
155// Screen output in athena won't make sense and would require linking of
156// additional libraries
157#if defined(__FastCaloSimStandAlone__)
158 new TCanvas("input", "Input");
159 hist->Draw();
160
161 new TCanvas("validation", "Validation");
162 hist_val->Draw();
163
164 new TCanvas("pull", "Pull");
165 hist_pull->Draw();
166#endif
167}
static TRandom * rnd
#define ATH_MSG_NOCLASS(logger_name, x)
Definition MLogging.h:52
Cut down AthMessaging.
Definition MLogging.h:176
static Root::TMsgLogger logger("iLumiCalc")
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)