23 double MyFunc (
double *x,
double *p ) {
24 return TMath::Gaus(x[0],p[0],p[1] );
29 MyDerivFunc(TF1 * f): fFunc(f) {}
30 double operator() (
double *x,
double * )
const {
31 return fFunc->Derivative(*x);
37 MyIntegFunc(TF1 * f): fFunc(f) {}
38 double Integral (
double *x,
double * )
const {
39 double a = fFunc->GetXmin();
40 return fFunc->Integral(a, *x);
47 void exampleFunctor() {
49 double xmin = -10;
double xmax = 10;
52 TF1 * f1 =
new TF1(
"f1",MyFunc,xmin,xmax,2);
53 f1->SetParameters(0.,1.);
54 f1->SetMaximum(3); f1->SetMinimum(-1);
66 MyDerivFunc * deriv =
new MyDerivFunc(f1);
67 TF1 * f2 =
new TF1(
"f2",deriv, xmin, xmax, 0);
69 f2->SetLineColor(kBlue);
82 MyIntegFunc * intg =
new MyIntegFunc(f1);
83 TF1 * f3 =
new TF1(
"f3",intg,&MyIntegFunc::Integral, xmin, xmax, 0);
85 f3->SetLineColor(kRed);
88 TLegend * l =
new TLegend(0.78, 0.25, 0.97 ,0.45);
89 l->AddEntry(f1,
"Func");
90 l->AddEntry(f2,
"Deriv.");
91 l->AddEntry(f3,
"Integral");