ATLAS Offline Software
Functions
TFCS1DFunction.cxx File Reference
#include "ISF_FastCaloSimEvent/TFCS1DFunction.h"
#include "TH1.h"
#include "TCanvas.h"
#include "TRandom.h"
#include <string>
#include <iostream>
#include <cmath>
Include dependency graph for TFCS1DFunction.cxx:

Go to the source code of this file.

Functions

TH1 *TFCS1DFunction::generate_histogram_random_slope ATLAS_NOT_THREAD_SAFE (int nbinsx, double xmin, double xmax, double zerothreshold)
 
TH1 *TFCS1DFunction::generate_histogram_random_gauss ATLAS_NOT_THREAD_SAFE (int nbinsx, int ntoy, double xmin, double xmax, double xpeak, double sigma)
 
void TFCS1DFunction::unit_test ATLAS_NOT_THREAD_SAFE (TH1 *hist, TFCS1DFunction *rtof, int nrnd, TH1 *histfine)
 

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/3]

TH1* TFCS1DFunction::generate_histogram_random_slope ATLAS_NOT_THREAD_SAFE ( int  nbinsx,
double  xmin,
double  xmax,
double  zerothreshold 
)

Definition at line 96 of file TFCS1DFunction.cxx.

97  {
98  TH1 *hist = new TH1D("test_slope1D", "test_slope1D", nbinsx, xmin, xmax);
99  hist->Sumw2();
100  for (int ix = 1; ix <= nbinsx; ++ix) {
101  double val = (0.5 + gRandom->Rndm()) * (nbinsx + ix);
102  if (gRandom->Rndm() < zerothreshold)
103  val = 0;
104  hist->SetBinContent(ix, val);
105  hist->SetBinError(ix, 0);
106  }
107  return hist;
108 }

◆ ATLAS_NOT_THREAD_SAFE() [2/3]

TH1* TFCS1DFunction::generate_histogram_random_gauss ATLAS_NOT_THREAD_SAFE ( int  nbinsx,
int  ntoy,
double  xmin,
double  xmax,
double  xpeak,
double  sigma 
)

Definition at line 111 of file TFCS1DFunction.cxx.

112  {
113  TH1 *hist = new TH1D("test_gauss1D", "test_gauss1D", nbinsx, xmin, xmax);
114  hist->Sumw2();
115  for (int i = 1; i <= ntoy; ++i) {
116  double x = gRandom->Gaus(xpeak, sigma);
117  if (x >= xmin && x < xmax)
118  hist->Fill(x);
119  }
120  return hist;
121 }

◆ ATLAS_NOT_THREAD_SAFE() [3/3]

void TFCS1DFunction::unit_test ATLAS_NOT_THREAD_SAFE ( TH1 *  hist,
TFCS1DFunction rtof,
int  nrnd,
TH1 *  histfine 
)

Definition at line 123 of file TFCS1DFunction.cxx.

125  {
127  ATH_MSG_NOCLASS(logger, "========= " << hist->GetName() << " funcsize="
128  << rtof->MemorySize() << " ========");
129  int nbinsx = hist->GetNbinsX();
130  double integral = hist->Integral();
131 
132  float value[2];
133  float rnd[2];
134  //cppcheck-suppress uninitvar
135  for (rnd[0] = 0; rnd[0] < 0.9999; rnd[0] += 0.25) {
136  rtof->rnd_to_fct(value, rnd);
137  ATH_MSG_NOCLASS(logger, "rnd0=" << rnd[0] << " -> x=" << value[0]);
138  }
139 
140  TH1 *hist_val = nullptr;
141  if (histfine)
142  hist_val = (TH1 *)histfine->Clone(TString(hist->GetName()) + "hist_val");
143  else
144  hist_val = (TH1 *)hist->Clone(TString(hist->GetName()) + "hist_val");
145  double weightfine = hist_val->Integral() / nrnd;
146  hist_val->SetTitle("toy simulation");
147  hist_val->Reset();
148  hist_val->SetLineColor(2);
149  hist_val->Sumw2();
150 
151  TH1 *hist_diff = (TH1 *)hist->Clone(TString(hist->GetName()) + "_difference");
152  hist_diff->SetTitle("cut efficiency difference");
153  hist_diff->Reset();
154  hist_diff->Sumw2();
155 
156  double weight = integral / nrnd;
157  for (int i = 0; i < nrnd; ++i) {
158  rnd[0] = gRandom->Rndm();
159  rtof->rnd_to_fct(value, rnd);
160  hist_val->Fill(value[0], weightfine);
161  hist_diff->Fill(value[0], weight);
162  }
163  hist_diff->Add(hist, -1);
164  hist_diff->Scale(1.0 / integral);
165 
166  TH1F *hist_pull =
167  new TH1F(TString(hist->GetName()) + "_pull", "pull", 200, -10, 10);
168  for (int ix = 1; ix <= nbinsx; ++ix) {
169  float val = hist_diff->GetBinContent(ix);
170  float err = hist_diff->GetBinError(ix);
171  if (err > 0)
172  hist_pull->Fill(val / err);
173  }
174 
175 // Screen output in athena won't make sense and would require linking of
176 // additional libraries
177 #if defined(__FastCaloSimStandAlone__)
178  TCanvas *c = new TCanvas(hist->GetName(), hist->GetName());
179  c->Divide(2, 2);
180 
181  c->cd(1);
182  if (histfine) {
183  histfine->SetLineColor(kGray);
184  histfine->DrawClone("hist");
185  hist->DrawClone("same");
186  } else {
187  hist->DrawClone();
188  }
189  hist_val->DrawClone("sameshist");
190 
191  c->cd(2);
192  if (histfine) {
193  histfine->SetLineColor(kGray);
194  histfine->DrawClone("hist");
195  hist->DrawClone("same");
196  } else {
197  hist->DrawClone();
198  }
199  hist_val->DrawClone("sameshist");
200  gPad->SetLogy();
201 
202  c->cd(3);
203  hist_diff->Draw();
204 
205  c->cd(4);
206  hist_pull->Draw();
207 
208  c->SaveAs(".png");
209 #endif
210 }
ISF_FCS::MLogging
Cut down AthMessaging.
Definition: MLogging.h:176
pdg_comparison.sigma
sigma
Definition: pdg_comparison.py:324
integral
double integral(TH1 *h)
Definition: computils.cxx:59
plotmaker.hist
hist
Definition: plotmaker.py:148
TFCS1DFunction::rnd_to_fct
virtual void rnd_to_fct(float value[], const float rnd[]) const
Function gets array of random numbers rnd[] in the range [0,1) as arguments and returns function valu...
Definition: TFCS1DFunction.cxx:18
athena.value
value
Definition: athena.py:124
x
#define x
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:183
lumiFormat.i
int i
Definition: lumiFormat.py:85
xmin
double xmin
Definition: listroot.cxx:60
ATH_MSG_NOCLASS
#define ATH_MSG_NOCLASS(logger_name, x)
Definition: MLogging.h:52
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
xmax
double xmax
Definition: listroot.cxx:61
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
python.compressB64.c
def c
Definition: compressB64.py:93
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14
TFCSFunction::MemorySize
virtual std::size_t MemorySize() const
Gives the total memory size, including the size of additional memory allocated inside the class.
Definition: TFCSFunction.h:19