9#include <cdc/calibration/CDCdEdx/HadronBgPrep.h>
29 double lowerinj,
double upperinj,
int nhitbins,
double lowernhit,
double uppernhit,
double cut)
47 const std::string& bgcurvefile,
48 const std::string& bgsigmafile,
const std::string& pdg,
bool ismakePlots)
51 std::vector<TH1F*> hdedx_bg, hchi_bg, hionzsigma_bg;
52 std::map<int, std::vector<TH1F*>> hchi_inj, hchicos_allbg, hchicos_1by3bg, hchicos_2by3bg, hchicos_3by3bg;
57 defineHisto(hionzsigma_bg,
"ionzsigma",
"bg", pdg.data());
58 for (
int i = 0; i < 2; ++i) {
60 defineHisto(hchi_inj[i],
"chi", Form(
"inj_%d", i), pdg.data());
62 std::string charge =
"pos";
63 if (i == 1) charge =
"neg";
65 defineHisto(hchicos_allbg[i],
"chi", Form(
"%s_allbg_cos", charge.data()), pdg.data());
66 defineHisto(hchicos_1by3bg[i],
"chi", Form(
"%s_1b3bg_cos", charge.data()), pdg.data());
67 defineHisto(hchicos_2by3bg[i],
"chi", Form(
"%s_2b3bg_cos", charge.data()), pdg.data());
68 defineHisto(hchicos_3by3bg[i],
"chi", Form(
"%s_3b3bg_cos", charge.data()), pdg.data());
101 hadron->SetBranchAddress(
"dedxnosat", &dedxnosat);
102 hadron->SetBranchAddress(
"p", &p);
103 hadron->SetBranchAddress(
"costh", &costh);
104 hadron->SetBranchAddress(
"timereso", &timereso);
105 hadron->SetBranchAddress(
"nhits", &nhit);
106 hadron->SetBranchAddress(
"injtime", &injtime);
107 hadron->SetBranchAddress(
"injring", &isher);
108 hadron->SetBranchAddress(
"charge", &charge);
111 if (mass == 0.0) B2FATAL(
"Mass of particle " << pdg.data() <<
" is zero");
124 unsigned int entries = hadron->GetEntries();
126 for (
unsigned int index = 0; index < entries; ++index) {
128 hadron->GetEntry(index);
130 int chg = (charge < 0) ? 1 : 0;
131 double bg = fabs(p) / mass;
134 if (nhit < 0 || nhit > 100)
continue;
135 if (injtime <= 0 || isher < 0)
continue;
137 if (dedxnosat <= 0)
continue;
138 if (costh != costh)
continue;
139 if (bg < m_bgMin || bg >
m_bgMax)
continue;
141 if (fabs(p) > 7.0)
continue;
143 if (pdg ==
"proton")
if ((dedxnosat - 0.45) * abs(p) * abs(p) <
m_cut)
continue;
146 bgBin = std::min(
m_bgBins - 1, std::max(0, bgBin));
149 B2WARNING(
"bgBin out of range: " << bgBin
150 <<
" (valid range: 0-" << (
m_bgBins - 1) <<
")");
153 double dedx_new = had.
D2I(costh, had.
I2D(costh, 1.0) * dedxnosat);
155 hdedx_bg[bgBin]->Fill(dedx_new);
158 double dedx_cur = mbg.
getMean(bg);
159 double dedx_res = sbg.
getSigma(dedx_new, nhit, costh, timereso);
162 B2INFO(
"RESOLUTION IS ZERO!!!");
167 double chi_new = (dedx_new - dedx_cur) / dedx_res;
169 hchi_bg[bgBin]->Fill(chi_new);
174 B2INFO(
"RESOLUTION costh * nhit * timereso IS ZERO!!!");
178 hionzsigma_bg[bgBin]->Fill((dedx_new - dedx_cur) / ionz_res);
186 int icos =
static_cast<int>((costh + 1) / cosstep);
188 B2WARNING(
"cosBin (icos) out of range: " << icos
189 <<
" (valid range: 0-" << (
m_cosBins - 1) <<
")");
193 hchicos_allbg[chg][icos]->Fill(chi_new);
195 if (bgBin <=
int(
m_bgBins / 3)) hchicos_1by3bg[chg][icos]->Fill(chi_new);
196 else if (bgBin <=
int(2 *
m_bgBins / 3)) hchicos_2by3bg[chg][icos]->Fill(chi_new);
197 else hchicos_3by3bg[chg][icos]->Fill(chi_new);
201 if (isher > 0.5) wr = 1;
202 int injBin =
static_cast<int>((injtime -
m_injMin) / tstep);
204 B2WARNING(
"injBin out of range: " << injBin
205 <<
" (valid range: 0-" << (
m_injBins - 1) <<
")");
207 injBin = std::min(
m_injBins - 1, std::max(0, injBin));
208 hchi_inj[wr][injBin]->Fill(chi_new);
221 setPars(outfile, pdg, hdedx_bg, hchi_bg, hionzsigma_bg, hchi_inj);
226 plotDist(hdedx_bg, Form(
"fits_dedx_inbg_%s_%s", suffix.data(), pdg.data()),
m_bgBins);
227 plotDist(hchi_bg, Form(
"fits_chi_inbg_%s_%s", suffix.data(), pdg.data()),
m_bgBins);
228 plotDist(hionzsigma_bg, Form(
"fits_ionzreso_inbg_%s_%s", suffix.data(), pdg.data()),
m_bgBins);
229 plotDist(hchi_inj, Form(
"fits_chi_ininj_%s_%s", suffix.data(), pdg.data()),
m_injBins);
230 printCanvasCos(hchicos_allbg, hchicos_1by3bg, hchicos_2by3bg, hchicos_3by3bg, pdg, suffix);
238 for (
int i = 0; i < 2; ++i) {
251 int nbdEdx = 200, nbchi = 200;
252 double dedxMax = 20.0;
255 nbdEdx = 400, dedxMax = 4.0;
256 }
else if (pdg ==
"kaon") {
257 nbdEdx = 500, dedxMax = 5.0;
258 }
else if (pdg ==
"proton") {
259 nbdEdx = 1500, dedxMax = 30.0;
261 }
else if (pdg ==
"muon") {
262 nbdEdx = 300, dedxMax = 3.0;
263 }
else if (pdg ==
"electron") {
264 nbdEdx = 200, dedxMax = 2.0;
275 double step = (max - min) / bins;
276 if (stype ==
"nhit") step = (max - min + 1) / bins;
278 for (
int j = 0; j < bins; ++j) {
280 double start = min + j * step;
281 double end = start + step;
282 if (stype ==
"nhit") end = int((start + step) * 0.99999);
285 std::string histname = Form(
"%s_%s_%s_%d", pdg.data(), svar.data(), stype.data(), j);
286 std::string title = Form(
"%s_%s_%s (%.02f, %.02f)", pdg.data(), svar.data(), stype.data(), start, end);
289 htemp.push_back(
new TH1F(histname.data(), title.data(), nbdEdx, 0, dedxMax));
290 else if (svar ==
"chi")
291 htemp.push_back(
new TH1F(histname.data(), title.data(), nbchi, -10.0, 10.0));
293 htemp.push_back(
new TH1F(histname.data(), title.data(), 300, -3.0, 3.0));
295 htemp[j]->GetXaxis()->SetTitle(Form(
"%s", svar.data()));
296 htemp[j]->GetYaxis()->SetTitle(
"Entries");
304 TCanvas ctmp(Form(
"cdcdedx_%s", sname.data()),
"", 1200, 600);
306 ctmp.SetBatch(kTRUE);
308 std::stringstream psname;
309 psname << Form(
"plots/HadronPrep/%s.pdf[", sname.data());
310 ctmp.Print(psname.str().c_str());
312 psname << Form(
"plots/HadronPrep/%s.pdf", sname.data());
313 for (
int j = 0; j < bins; ++j) {
315 for (
int i = 0 ; i < 2; ++i) {
317 hist[i][j]->SetFillColorAlpha(i + 5, 0.25);
320 ctmp.Print(psname.str().c_str());
323 psname << Form(
"plots/HadronPrep/%s.pdf]", sname.data());
324 ctmp.Print(psname.str().c_str());
331 TCanvas ctmp(Form(
"cdcdedx_%s", sname.data()),
"", 1200, 1200);
333 ctmp.SetBatch(kTRUE);
335 std::stringstream psname;
336 psname << Form(
"plots/HadronPrep/%s.pdf[", sname.data());
337 ctmp.Print(psname.str().c_str());
339 psname << Form(
"plots/HadronPrep/%s.pdf", sname.data());
341 for (
int i = 0 ; i < nbins; ++i) {
343 hist[i]->SetFillColor(kYellow - 9);
346 if ((i + 1) % 4 == 0 || (i + 1) == nbins) {
347 ctmp.Print(psname.str().c_str());
352 psname << Form(
"plots/HadronPrep/%s.pdf]", sname.data());
353 ctmp.Print(psname.str().c_str());
357void HadronBgPrep::setPars(TFile*& outfile, std::string pdg, std::vector<TH1F*>& hdedx_bg, std::vector<TH1F*>& hchi_bg,
358 std::vector<TH1F*>& hionzsigma_bg, std::map<
int, std::vector<TH1F*>>& hchi_inj)
362 TTree* satTree =
new TTree(Form(
"%s", pdg.data()),
"dE/dx m_means and m_errors");
372 double satchiwidth_err;
377 double satdedxres_avg;
379 satTree->Branch(
"bg", &satbg,
"bg/D");
380 satTree->Branch(
"costh", &satcosth,
"costh/D");
383 satTree->Branch(
"dedx", &satdedx,
"dedx/D");
384 satTree->Branch(
"dedxerr", &satdedxerr,
"dedxerr/D");
385 satTree->Branch(
"dedxwidth", &satdedxwidth,
"dedxwidth/D");
388 satTree->Branch(
"chimean", &satchi,
"chimean/D");
389 satTree->Branch(
"chimean_err", &satchierr,
"chimean_err/D");
390 satTree->Branch(
"chisigma", &satchiwidth,
"chisigma/D");
391 satTree->Branch(
"chisigma_err", &satchiwidth_err,
"chisigma_err/D");
393 satTree->Branch(
"ionzres", &sationzres,
"ionzres/D");
396 satTree->Branch(
"bg_avg", &satbg_avg,
"bg_avg/D");
397 satTree->Branch(
"costh_avg", &satcosth_avg,
"costh_avg/D");
398 satTree->Branch(
"dedxres_avg", &satdedxres_avg,
"dedxres_avg/D");
402 for (
int i = 0; i <
m_bgBins; ++i) {
405 satbg =
m_bgMin + 0.5 * bgstep + i * bgstep;
415 fit(hdedx_bg[i], pdg.data(), bgstat);
416 TF1* f = hdedx_bg[i]->GetFunction(
"gaus");
417 if (bgstat == OK && f) {
418 const auto mean = f->GetParameter(1);
421 const auto err = f->GetParError(1);
424 satdedxwidth = f->GetParameter(2);
425 }
else { satdedx = 0.0; satdedxerr = 0.0; satdedxwidth = 0.0;}
430 fit(hchi_bg[i], pdg.data(), chistat);
431 f = hchi_bg[i]->GetFunction(
"gaus");
432 if (chistat == OK && f) {
433 satchi = f->GetParameter(1);
434 satchierr = f->GetParError(1);
435 satchiwidth = f->GetParameter(2);
436 satchiwidth_err = f->GetParError(2);
437 }
else { satchi = 0.0; satchierr = 0.0; satchiwidth = 0.0; satchiwidth_err = 0.0;}
443 fit(hionzsigma_bg[i], pdg.data(), ionstat);
445 sationzres = hionzsigma_bg[i]->GetFunction(
"gaus")->GetParameter(2);
446 }
else sationzres = 0.0;
458 std::string svar =
"ler";
459 for (
int ir = 0; ir < 2; ir++) {
461 if (ir == 1) svar =
"her";
463 TTree* injTree =
new TTree(Form(
"%s_%s", pdg.data(), svar.data()),
"chi m_means and m_errors");
470 injTree->Branch(
"inj_avg", &inj_avg,
"inj_avg/D");
471 injTree->Branch(
"chimean", &mean,
"chimean/D");
472 injTree->Branch(
"chimean_err", &mean_err,
"chimean_err/D");
473 injTree->Branch(
"chisigma", &sigma,
"chisigma/D");
474 injTree->Branch(
"chisigma_err", &sigma_err,
"chisigma_err/D");
483 fit(hchi_inj[ir][i], pdg.data(), injstat);
485 mean = hchi_inj[ir][i]->GetFunction(
"gaus")->GetParameter(1);
486 mean_err = hchi_inj[ir][i]->GetFunction(
"gaus")->GetParError(1);
487 sigma = hchi_inj[ir][i]->GetFunction(
"gaus")->GetParameter(2);
488 sigma_err = hchi_inj[ir][i]->GetFunction(
"gaus")->GetParError(2);
490 mean = 0.0; mean_err = 0.0; sigma = 0.0; sigma_err = 0.0;
507 hist->SetFillColorAlpha(kAzure + 1, 0.30);
510 double mean = hist->GetFunction(
"gaus")->GetParameter(1);
511 double meanerr = hist->GetFunction(
"gaus")->GetParError(1);
512 double width = hist->GetFunction(
"gaus")->GetParameter(2);
514 std::string title = Form(
"#mu_{fit}: %0.03f #pm %0.03f, #sigma_{fit}: %0.03f", mean, meanerr, width);
515 hist->SetTitle(Form(
"%s, %s", hist->GetTitle(), title.data()));
523 double histmean = temphist->GetMean();
524 double histrms = temphist->GetRMS();
525 temphist->GetXaxis()->SetRangeUser(histmean - 5.0 * histrms, histmean + 5.0 * histrms);
527 int fs = temphist->Fit(
"gaus",
"Q");
529 B2INFO(Form(
"\tFit (round 1) for hist (%s) failed (status = %d)", temphist->GetName(), fs));
533 double mean = temphist->GetFunction(
"gaus")->GetParameter(1);
534 double width = temphist->GetFunction(
"gaus")->GetParameter(2);
535 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
536 fs = temphist->Fit(
"gaus",
"QR",
"", mean - sigmaR * width, mean + sigmaR * width);
538 B2INFO(Form(
"\tFit (round 2) for hist (%s) failed (status = %d)", temphist->GetName(), fs));
542 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
543 B2INFO(Form(
"\tFit for hist (%s) sucessfull (status = %d)", temphist->GetName(), fs));
554 std::map<
int, std::vector<TH1F*>>& hchicos_1by3bg, std::map<
int, std::vector<TH1F*>>& hchicos_2by3bg,
555 std::map<
int, std::vector<TH1F*>>& hchicos_3by3bg,
const std::string& pdg,
const std::string& suffix)
558 std::vector<std::vector<double>> chicos(2, std::vector<double>(
m_cosBins));
559 std::vector<std::vector<double>> sigmacos(2, std::vector<double>(
m_cosBins));
560 std::vector<std::vector<double>> chicoserr(2, std::vector<double>(
m_cosBins));
561 std::vector<std::vector<double>> sigmacoserr(2, std::vector<double>(
m_cosBins));
563 std::vector<std::vector<double>> chicos_1b3bg(2, std::vector<double>(
m_cosBins));
564 std::vector<std::vector<double>> sigmacos_1b3bg(2, std::vector<double>(
m_cosBins));
565 std::vector<std::vector<double>> chicos_1b3bgerr(2, std::vector<double>(
m_cosBins));
566 std::vector<std::vector<double>> sigmacos_1b3bgerr(2, std::vector<double>(
m_cosBins));
568 std::vector<std::vector<double>> chicos_2b3bg(2, std::vector<double>(
m_cosBins));
569 std::vector<std::vector<double>> sigmacos_2b3bg(2, std::vector<double>(
m_cosBins));
570 std::vector<std::vector<double>> chicos_2b3bgerr(2, std::vector<double>(
m_cosBins));
571 std::vector<std::vector<double>> sigmacos_2b3bgerr(2, std::vector<double>(
m_cosBins));
573 std::vector<std::vector<double>> chicos2(2, std::vector<double>(
m_cosBins));
574 std::vector<std::vector<double>> sigmacos2(2, std::vector<double>(
m_cosBins));
575 std::vector<std::vector<double>> chicos2err(2, std::vector<double>(
m_cosBins));
576 std::vector<std::vector<double>> sigmacos2err(2, std::vector<double>(
m_cosBins));
578 for (
int c = 0; c < 2; ++c) {
580 if (hchicos_allbg[c][i]->Integral() > 100) {
582 fit(hchicos_allbg[c][i], pdg.data(), allbgstat);
583 if (allbgstat == OK) {
584 chicos[c][i] = hchicos_allbg[c][i]->GetFunction(
"gaus")->GetParameter(1);
585 chicoserr[c][i] = hchicos_allbg[c][i]->GetFunction(
"gaus")->GetParError(1);
586 sigmacos[c][i] = hchicos_allbg[c][i]->GetFunction(
"gaus")->GetParameter(2);
587 sigmacoserr[c][i] = hchicos_allbg[c][i]->GetFunction(
"gaus")->GetParError(2);
588 }
else { chicos[c][i] = 0.0; chicoserr[c][i] = 0.0; sigmacos[c][i] = 0.0; sigmacoserr[c][i] = 0.0;}
591 if (hchicos_1by3bg[c][i]->Integral() > 100) {
594 fit(hchicos_1by3bg[c][i], pdg.data(), all1bgstat);
595 if (all1bgstat == OK) {
596 chicos_1b3bg[c][i] = hchicos_1by3bg[c][i]->GetFunction(
"gaus")->GetParameter(1);
597 chicos_1b3bgerr[c][i] = hchicos_1by3bg[c][i]->GetFunction(
"gaus")->GetParError(1);
598 sigmacos_1b3bg[c][i] = hchicos_1by3bg[c][i]->GetFunction(
"gaus")->GetParameter(2);
599 sigmacos_1b3bgerr[c][i] = hchicos_1by3bg[c][i]->GetFunction(
"gaus")->GetParError(2);
600 }
else { chicos_1b3bg[c][i] = 0.0; chicos_1b3bgerr[c][i] = 0.0; sigmacos_1b3bg[c][i] = 0.0; sigmacos_1b3bgerr[c][i] = 0.0;}
604 if (hchicos_2by3bg[c][i]->Integral() > 100) {
606 fit(hchicos_2by3bg[c][i], pdg.data(), all2bgstat);
607 if (all2bgstat == OK) {
608 chicos_2b3bg[c][i] = hchicos_2by3bg[c][i]->GetFunction(
"gaus")->GetParameter(1);
609 chicos_2b3bgerr[c][i] = hchicos_2by3bg[c][i]->GetFunction(
"gaus")->GetParError(1);
610 sigmacos_2b3bg[c][i] = hchicos_2by3bg[c][i]->GetFunction(
"gaus")->GetParameter(2);
611 sigmacos_2b3bgerr[c][i] = hchicos_2by3bg[c][i]->GetFunction(
"gaus")->GetParError(2);
612 }
else { chicos_2b3bg[c][i] = 0.0; chicos_2b3bgerr[c][i] = 0.0; sigmacos_2b3bg[c][i] = 0.0; sigmacos_2b3bgerr[c][i] = 0.0;}
616 if (hchicos_3by3bg[c][i]->Integral() > 100) {
618 fit(hchicos_3by3bg[c][i], pdg.data(), all3bgstat);
619 if (all3bgstat == OK) {
620 chicos2[c][i] = hchicos_3by3bg[c][i]->GetFunction(
"gaus")->GetParameter(1);
621 chicos2err[c][i] = hchicos_3by3bg[c][i]->GetFunction(
"gaus")->GetParError(1);
622 sigmacos2[c][i] = hchicos_3by3bg[c][i]->GetFunction(
"gaus")->GetParameter(2);
623 sigmacos2err[c][i] = hchicos_3by3bg[c][i]->GetFunction(
"gaus")->GetParError(2);
624 }
else { chicos2[c][i] = 0.0; chicos2err[c][i] = 0.0; sigmacos2[c][i] = 0.0; sigmacos2err[c][i] = 0.0;}
630 plotDist(hchicos_allbg, Form(
"fits_chi_vscos_allbg_%s_%s", pdg.data(), suffix.data()),
m_cosBins);
631 plotDist(hchicos_1by3bg, Form(
"fits_chi_vscos_1by3bg_%s_%s", pdg.data(), suffix.data()),
m_cosBins);
632 plotDist(hchicos_2by3bg, Form(
"fits_chi_vscos_2by3bg_%s_%s", pdg.data(), suffix.data()),
m_cosBins);
633 plotDist(hchicos_3by3bg, Form(
"fits_chi_vscos_3by3bg_%s_%s", pdg.data(), suffix.data()),
m_cosBins);
638 cosArray[i] = -1.0 + (i * cosstep + cosstep / 2.0);
639 cosArrayErr[i] = 0.0;
642 TGraphErrors grchicos(
m_cosBins, cosArray.data(), chicos[0].data(), cosArrayErr.data(), chicoserr[0].data());
643 TGraphErrors grchicos_1b3bg(
m_cosBins, cosArray.data(), chicos_1b3bg[0].data(), cosArrayErr.data(), chicos_1b3bgerr[0].data());
644 TGraphErrors grchicos_2b3bg(
m_cosBins, cosArray.data(), chicos_2b3bg[0].data(), cosArrayErr.data(), chicos_2b3bgerr[0].data());
645 TGraphErrors grchicos2(
m_cosBins, cosArray.data(), chicos2[0].data(), cosArrayErr.data(), chicos2err[0].data());
647 TGraphErrors grchicosn(
m_cosBins, cosArray.data(), chicos[1].data(), cosArrayErr.data(), chicoserr[1].data());
648 TGraphErrors grchicos_1b3bgn(
m_cosBins, cosArray.data(), chicos_1b3bg[1].data(), cosArrayErr.data(), chicos_1b3bgerr[1].data());
649 TGraphErrors grchicos_2b3bgn(
m_cosBins, cosArray.data(), chicos_2b3bg[1].data(), cosArrayErr.data(), chicos_2b3bgerr[1].data());
650 TGraphErrors grchicos2n(
m_cosBins, cosArray.data(), chicos2[1].data(), cosArrayErr.data(), chicos2err[1].data());
652 TGraphErrors grsigmacos(
m_cosBins, cosArray.data(), sigmacos[0].data(), cosArrayErr.data(), sigmacoserr[0].data());
653 TGraphErrors grsigmacos_1b3bg(
m_cosBins, cosArray.data(), sigmacos_1b3bg[0].data(), cosArrayErr.data(),
654 sigmacos_1b3bgerr[0].data());
655 TGraphErrors grsigmacos_2b3bg(
m_cosBins, cosArray.data(), sigmacos_2b3bg[0].data(), cosArrayErr.data(),
656 sigmacos_2b3bgerr[0].data());
657 TGraphErrors grsigmacos2(
m_cosBins, cosArray.data(), sigmacos2[0].data(), cosArrayErr.data(), sigmacos2err[0].data());
659 TGraphErrors grsigmacosn(
m_cosBins, cosArray.data(), sigmacos[1].data(), cosArrayErr.data(), sigmacoserr[1].data());
660 TGraphErrors grsigmacos_1b3bgn(
m_cosBins, cosArray.data(), sigmacos_1b3bg[1].data(), cosArrayErr.data(),
661 sigmacos_1b3bgerr[1].data());
662 TGraphErrors grsigmacos_2b3bgn(
m_cosBins, cosArray.data(), sigmacos_2b3bg[1].data(), cosArrayErr.data(),
663 sigmacos_2b3bgerr[1].data());
664 TGraphErrors grsigmacos2n(
m_cosBins, cosArray.data(), sigmacos2[1].data(), cosArrayErr.data(), sigmacos2err[1].data());
666 TLine line0(-1, 0, 1, 0);
667 line0.SetLineStyle(kDashed);
668 line0.SetLineColor(kRed);
670 TLine line1(-1, 1, 1, 1);
671 line1.SetLineStyle(kDashed);
672 line1.SetLineColor(kRed);
681 if (mass == 0.0) B2FATAL(
"Mass of particle " << pdg.data() <<
" is zero");
683 int bglow = 0, bghigh = 0;
686 TLegend lchi(0.7, 0.75, 0.8, 0.85);
687 lchi.SetBorderSize(0);
688 lchi.SetFillColor(kYellow);
689 lchi.AddEntry(&grchicos, ptype +
"^{+}",
"pc");
690 lchi.AddEntry(&grchicosn, ptype +
"^{-}",
"pc");
692 TCanvas cchi(Form(
"cchi_%s", suffix.data()),
"cchi", 700, 600);
698 grchicosn.Draw(
"P,same");
704 FormatGraph(grchicos_1b3bg, 0, Form(
"first 1/3 bg bins, p =(%0.02f, %0.02f)",
m_bgMin * mass, bghigh * bgstep * mass));
706 grchicos_1b3bg.Draw(
"AP");
707 grchicos_1b3bgn.Draw(
"P,same");
714 FormatGraph(grchicos_2b3bg, 0, Form(
"second 1/3 bg bins, p =(%0.02f, %0.02f)", bglow * bgstep * mass, bghigh * bgstep * mass));
716 grchicos_2b3bg.Draw(
"AP");
717 grchicos_2b3bgn.Draw(
"P,same");
723 FormatGraph(grchicos2, 0, Form(
"third 1/3 bg bins, p =(%0.02f, %0.02f)", bglow * bgstep * mass,
m_bgMax * mass));
725 grchicos2.Draw(
"AP");
726 grchicos2n.Draw(
"P,same");
729 cchi.SaveAs(Form(
"plots/HadronCal/Monitoring/mean_chi_vscos_inbg_%s_%s.pdf", pdg.data(), suffix.data()));
734 grsigmacos.Draw(
"AP");
735 grsigmacosn.Draw(
"P,same");
741 FormatGraph(grsigmacos_1b3bg, 2, Form(
"first 1/3 bg bins, p =(%0.02f, %0.02f)",
m_bgMin * mass, bghigh * bgstep * mass));
743 grsigmacos_1b3bg.Draw(
"AP");
744 grsigmacos_1b3bgn.Draw(
"P,same");
751 FormatGraph(grsigmacos_2b3bg, 2, Form(
"second 1/3 bg bins, p =(%0.02f, %0.02f)", bglow * bgstep * mass, bghigh * bgstep * mass));
753 grsigmacos_2b3bg.Draw(
"AP");
754 grsigmacos_2b3bgn.Draw(
"P,same");
760 FormatGraph(grsigmacos2, 2, Form(
"third 1/3 bg bins, p =(%0.02f, %0.02f)", bglow * bgstep * mass,
m_bgMax * mass));
762 grsigmacos2.Draw(
"AP");
763 grsigmacos2n.Draw(
"P,same");
766 cchi.SaveAs(Form(
"plots/HadronCal/Monitoring/sigma_chi_vscos_inbg_%s_%s.pdf", pdg.data(), suffix.data()));
Class to hold the hadron saturation functions.
double I2D(double cosTheta, double I) const
hadron saturation parameterization part 2
double D2I(double cosTheta, double D) const
hadron saturation parameterization part 1
void setParameters()
set the parameters
Class to hold the prediction of mean as a function of beta-gamma (bg)
double getMean(double bg)
Return the predicted mean value as a function of beta-gamma (bg)
void setParameters(std::string infile)
set the parameters from file
Class to hold the prediction of resolution depending dE/dx, nhit, and cos(theta)
double getSigma(double dedx, double nhit, double cos, double timereso)
Return the predicted resolution depending on dE/dx, nhit, and cos(theta)
double cosPrediction(double cos)
Return sigma from the cos parameterization.
double nhitPrediction(double nhit)
Return sigma from the nhit parameterization.
void setParameters(std::string infile)
set the parameters from file
double getMass() const
Particle mass.
static const ChargedStable muon
muon particle
static const ChargedStable pion
charged pion particle
static const ChargedStable proton
proton particle
static const ChargedStable kaon
charged kaon particle
static const ChargedStable electron
electron particle
void fit(TH1F *&hist, const std::string &pdg, gstatus &status)
function to fit the histograms
void clearVars()
function to clear the variables
void defineHisto(std::vector< TH1F * > &htemp, const std::string &svar, const std::string &stype, const std::string &pdg)
function to define histograms
std::vector< double > m_sumcos
variables to add cos values
std::vector< double > m_suminj
variables to add injection time
int m_nhitBins
bins for nhits
int m_injBins
bins for injection time
int m_cosBins
bins for cosine
double getParticleMass(const std::string &particle)
function to get the particle mass
void deleteHistos(std::vector< TH1F * > &htemp)
function to delete the histograms
double m_cosMax
max range of cosine
void printCanvasCos(std::map< int, std::vector< TH1F * > > &hchicos_allbg, std::map< int, std::vector< TH1F * > > &hchicos_1by3bg, std::map< int, std::vector< TH1F * > > &hchicos_2by3bg, std::map< int, std::vector< TH1F * > > &hchicos_3by3bg, const std::string &particle, const std::string &suffix)
function to draw the dedx vs costh histograms
std::vector< double > m_means
mean variable
std::vector< double > m_errors
error variable
std::vector< int > m_sumsize
size of the bg bins
void plotDist(std::map< int, std::vector< TH1F * > > &hist, const std::string &suffix, int bins)
function to plot the map of histograms
HadronBgPrep()
Constructor: Sets the description, the properties and the parameters of the algorithm.
void FormatGraph(TGraphErrors &gr, int flag, const std::string &name="")
function to set graph cosmetics
double m_injMax
max range of injection time
double m_nhitMax
max range of nhits
std::vector< double > m_sumres_square
variables to add square of resolution
double m_injMin
min range of injection time
void setPars(TFile *&outfile, std::string pdg, std::vector< TH1F * > &hdedx_bg, std::vector< TH1F * > &hchi_bg, std::vector< TH1F * > &hionzsigma_bg, std::map< int, std::vector< TH1F * > > &hchi_inj)
function to fill the parameters like mean and reso in the tree
double m_bgMax
max range of bg
std::vector< int > m_injsize
size of the injection bins
double m_bgMin
min range of bg
double m_cosMin
min range of cosine
double m_cut
cut to clean protons
std::vector< double > m_sumbg
variables to add bg values
void fitGaussianWRange(TH1F *&temphist, gstatus &status, double sigmaR)
function to perform gauss fit for input histogram
double m_nhitMin
min range of nhits
void prepareSample(std::shared_ptr< TTree > hadron, TFile *&outfile, const std::string &suffix, const std::string &bgcurvefile, const std::string &bgsigmafile, const std::string &pdg, bool ismakePlots)
function to prepare sample for monitoring plots, bg curve fitting and sigma vs ionz fitting
Abstract base class for different kinds of events.