378 {
380 int nbinsx;
381 TH1 *histfine = nullptr;
382 if (hist == nullptr) {
383 nbinsx = 50;
385 double xpeak = 1.5;
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);
394
396 if (histfine)
397 histfine->Fill(
x, 10);
398 }
399 }
400 }
401 if (!histfine)
404 nbinsx =
hist->GetNbinsX();
405
408
409 for (
rnd[0] = 0;
rnd[0] < 0.9999;
rnd[0] += 0.25) {
410 rtof.rnd_to_fct(value,
rnd);
412 }
413
414 TH1 *hist_val = (TH1 *)histfine->Clone("hist_val");
415 hist_val->SetTitle("toy simulation");
416 hist_val->Reset();
417 hist_val->SetLineColor(2);
418 TH1 *hist_diff = (TH1 *)
hist->Clone(
"hist_diff");
419 hist_diff->SetTitle("difference");
420 hist_diff->Reset();
421 int nrnd = 5000000;
422 double weight = histfine->Integral() / nrnd;
423 double weightdiff =
hist->Integral() / nrnd;
424 hist_val->Sumw2();
425 hist_diff->Sumw2();
426 for (
int i = 0;
i < nrnd; ++
i) {
427 rnd[0] = gRandom->Rndm();
428 rtof.rnd_to_fct(value,
rnd);
429 hist_val->Fill(value[0], weight);
430 hist_diff->Fill(value[0], weightdiff);
431 }
432 hist_diff->Add(hist, -1);
433
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);
438 if (err > 0)
439 hist_pull->Fill(val / err);
440
441 }
442
443
444
445#if defined(__FastCaloSimStandAlone__)
446 new TCanvas("input", "Input");
447 histfine->SetLineColor(kGray);
448 histfine->Draw("hist");
450 hist_val->Draw("sameshist");
451
452 new TCanvas("spline", "spline");
454 int ngr = 101;
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));
459 }
460 gr->SetMarkerStyle(7);
462 TSpline3 *
sp =
new TSpline3(rtof.spline());
464 sp->SetMarkerColor(2);
465 sp->SetMarkerStyle(2);
467
468 new TCanvas("difference", "difference");
469 hist_diff->Draw();
470
471 new TCanvas("pull", "Pull");
472 hist_pull->Draw();
473#endif
474}
#define ATH_MSG_NOCLASS(logger_name, x)
static Root::TMsgLogger logger("iLumiCalc")
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)