24 auto h1 =
new TH1D(
"h1",
"h1",nbins,-3,3);
26 auto c1 =
new TCanvas(
"Fit",
"Fit",800,1000);
31 std::cout <<
"Doing Serial Gaussian Fit " << std::endl;
32 auto f1 =
new TF1(
"f1",
"gaus");
39 std::cout <<
"Doing Vectorized Gaussian Fit " << std::endl;
40 auto f2 =
new TF1(
"f2",
"gaus",-3,3,
"VEC");
57 auto f3 =
new TF1(
"f3",
"[A]*x^2+[B]*x+[C]",0,10);
58 f3->SetParameters(0.5,3,2);
61 auto h2 =
new TH1D(
"h2",
"h2",nbins,0,10);
62 h2->FillRandom(
"f3",10*nbins);
63 std::cout <<
"Doing Serial Polynomial Fit " << std::endl;
64 f3->SetParameters(2,2,2);
70 std::cout <<
"Doing Vectorized Polynomial Fit " << std::endl;
71 auto f4 =
new TF1(
"f4",
"[A]*x*x+[B]*x+[C]",0,10);
72 f4->SetVectorized(
true);
73 f4->SetParameters(2,2,2);
81 h2->Scale(100./nbins);
82 ((
TF1 *)h2->GetListOfFunctions()->At(0))->SetTitle(
"Chi2 Fit");
83 ((
TF1 *)h2->GetListOfFunctions()->At(1))->SetTitle(
"Likelihood Fit");
R__EXTERN TStyle * gStyle
static void SetDefaultMinimizer(const char *type, const char *algo=0)
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
1-D histogram with a double per channel (see TH1 documentation)}
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
TList * GetListOfFunctions() const
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual TH1 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=0)
Rebin this histogram.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...