Tutorial illustrating how to create a TF1 class using C++ functors or class member functions.
Can be run with:
root > .x exampleFunctor.C
root > .x exampleFunctor.C+ with ACLIC
double MyFunc (
double *
x,
double *p ) {
}
struct MyDerivFunc {
MyDerivFunc(
TF1 *
f): fFunc(
f) {}
return fFunc->Derivative(*
x);
}
TF1 * fFunc;
};
struct MyIntegFunc {
MyIntegFunc(TF1 *
f): fFunc(
f) {}
double Integral (
double *
x,
double * )
const {
double a = fFunc->GetXmin();
return fFunc->Integral(
a, *
x);
}
TF1 * fFunc;
};
void exampleFunctor() {
f1->SetParameters(0.,1.);
f1->SetMaximum(3);
f1->SetMinimum(-1);
MyDerivFunc * deriv =
new MyDerivFunc(
f1);
MyIntegFunc * intg =
new MyIntegFunc(
f1);
l->AddEntry(f2,
"Deriv.");
l->AddEntry(f3,
"Integral");
}
TRObject operator()(const T1 &t1) const
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void Draw(Option_t *option="") override
Default Draw method for all objects.
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculates a gaussian function with mean and sigma.
- Author
- Lorenzo Moneta
Definition in file exampleFunctor.C.