34 auto h1 =
new TH1D(
"h1",
"h1",nbins,-3,3);
35 h1->FillRandom(
"gaus",nbins*50);
36 auto c1 =
new TCanvas(
"Fit",
"Fit",800,1000);
41 std::cout <<
"Doing Serial Gaussian Fit " << std::endl;
42 auto f1 =
new TF1(
"f1",
"gaus");
49 std::cout <<
"Doing Vectorized Gaussian Fit " << std::endl;
50 auto f2 =
new TF1(
"f2",
"gaus",-3,3,
"VEC");
59 h1->Scale(100./nbins);
60 ((
TF1 *)
h1->GetListOfFunctions()->At(0))->SetTitle(
"Chi2 Fit");
61 ((
TF1 *)
h1->GetListOfFunctions()->At(1))->SetTitle(
"Likelihood Fit");
62 ((
TF1 *)
h1->GetListOfFunctions()->At(1))->SetLineColor(
kBlue);
67 auto f3 =
new TF1(
"f3",
"[A]*x^2+[B]*x+[C]",0,10);
68 f3->SetParameters(0.5,3,2);
71 auto h2 =
new TH1D(
"h2",
"h2",nbins,0,10);
72 h2->FillRandom(
"f3",10*nbins);
73 std::cout <<
"Doing Serial Polynomial Fit " << std::endl;
74 f3->SetParameters(2,2,2);
80 std::cout <<
"Doing Vectorized Polynomial Fit " << std::endl;
81 auto f4 =
new TF1(
"f4",
"[A]*x*x+[B]*x+[C]",0,10);
82 f4->SetVectorized(
true);
83 f4->SetParameters(2,2,2);
91 h2->Scale(100./nbins);
92 ((
TF1 *)h2->GetListOfFunctions()->At(0))->SetTitle(
"Chi2 Fit");
93 ((
TF1 *)h2->GetListOfFunctions()->At(1))->SetTitle(
"Likelihood Fit");
94 ((
TF1 *)h2->GetListOfFunctions()->At(1))->SetLineColor(
kBlue);
static void SetDefaultMinimizer(const char *type, const char *algo=nullptr)
Set the default Minimizer type and corresponding algorithms.
1-D histogram with a double per channel (see TH1 documentation)