ATLAS Offline Software
Functions
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 }
ISF_FCS::MLogging
Cut down AthMessaging.
Definition: MLogging.h:176
plotmaker.hist
hist
Definition: plotmaker.py:148
TH1D
Definition: rootspy.cxx:342
athena.value
value
Definition: athena.py:122
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
lumiFormat.i
int i
Definition: lumiFormat.py:92
TFCS1DFunctionInt32Histogram
Definition: TFCS1DFunctionInt32Histogram.h:15
TH1::Fill
int Fill(double)
Definition: rootspy.cxx:285
TH1::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:298
TH1::Sumw2
void Sumw2()
Definition: rootspy.cxx:284
ATH_MSG_NOCLASS
#define ATH_MSG_NOCLASS(logger_name, x)
Definition: MLogging.h:52
TH1F
Definition: rootspy.cxx:320
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TH1
Definition: rootspy.cxx:268
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14