use it for fitting an histogram
To create a vectorized function (if ROOT has been compiled with support for vectorization) is very easy. One needs to create the TF1 object with the option "VEC" or call the method TF1::SetVectorized
output
void vectorizedFit() {
int nbins = 40000;
auto h1 =
new TH1D(
"h1",
"h1",nbins,-3,3);
auto c1 =
new TCanvas(
"Fit",
"Fit",800,1000);
std::cout << "Doing Serial Gaussian Fit " << std::endl;
auto f1 =
new TF1(
"f1",
"gaus");
std::cout << "Doing Vectorized Gaussian Fit " << std::endl;
auto f2 =
new TF1(
"f2",
"gaus",-3,3,
"VEC");
auto f3 =
new TF1(
"f3",
"[A]*x^2+[B]*x+[C]",0,10);
auto h2 =
new TH1D(
"h2",
"h2",nbins,0,10);
std::cout << "Doing Serial Polynomial Fit " << std::endl;
std::cout << "Doing Vectorized Polynomial Fit " << std::endl;
auto f4 =
new TF1(
"f4",
"[A]*x*x+[B]*x+[C]",0,10);
}
- Author
- Lorenzo Moneta
Definition in file vectorizedFit.C.