1#ifndef PID_SRC_FITHELPER_H_
2#define PID_SRC_FITHELPER_H_
8TH2* cutTH2(std::shared_ptr<TH2D> hFull, TCutG* cut) {
9 std::string name = hFull->GetName();
11 TH2* hCut = (TH2*) hFull->Clone(name.c_str());
12 int nBinsX = hCut->GetNbinsX();
13 int nBinsY = hCut->GetNbinsY();
16 for (
int i = 1; i <= nBinsX; i++) {
17 for (
int j = 1; j <= nBinsY; j++) {
18 x = hCut->GetXaxis()->GetBinCenter(i);
19 y = hCut->GetYaxis()->GetBinCenter(j);
20 if (!cut->IsInside(x, y)) {
21 hCut->SetBinContent(i, j, 0.);
22 hCut->SetBinError(i, j, 0.);
29double asymmGauss(
double x, std::array<double, 4> p) {
39 return amp * exp(-0.5 * (x - mean) * (x - mean) / sig / sig);
44 float xmin{0}, xmax{0}, ymin{0}, ymax{0};
47 std::vector<std::string> func{
"0",
"pol9",
"pol9"};
52 std::string name = params.name;
53 std::cout <<
"\n + " + name +
"\n";
55 tof.SetChi2Max(params.chi2_max);
56 TF1 fit((
"fit_" + name).c_str(),
"gaus", params.ymin, params.ymax);
57 fit.SetParNames(
"p0",
"p1",
"p2");
58 fit.SetParLimits(0, 0., 4.e6);
59 fit.SetParLimits(1, -.25, 0.03);
60 fit.SetParLimits(2, 0., 0.7);
62 TF1 fit_0((name +
"_0").c_str(), params.func.at(0).c_str(), params.xmin, params.xmax);
63 TF1 fit_1((name +
"_1").c_str(), params.func.at(1).c_str(), params.xmin, params.xmax);
64 TF1 fit_2((name +
"_2").c_str(), params.func.at(2).c_str(), params.xmin, params.xmax);
67 particle.SetParametrization({fit_0, fit_1, fit_2});
68 particle.SetFitFunction(fit);
69 particle.SetRange(params.xmin, params.xmax);
70 particle.SetIsFitted();
72 tof.AddParticle(particle, params.pid);
74 tof.SetRangeX(params.xmin, params.xmax);
75 tof.SetRangeY(params.ymin, params.ymax);
76 tof.SetOutputFileName(
"pionpos.root");
78 particle = tof.GetParticle(0);
91 pions.pid = PidParticles::kPionPos;
92 pions.name =
"piplus";
94 return FitParticle(tof, pions, hist);
Class to fit 2D histograms.
Definition Fitter.h:22
void Clear()
Definition Fitter.cpp:155
void Fit()
Definition Fitter.cpp:16
Class to store fit resuls for particle specie.
Definition ParticleFit.h:19
Definition FitHelper.h:42