Transposing a Function

Hi there,

I have a histogram and 2 functions (one is the fitted function and one describes the background).
I want to transpose them horizontally by 100 bins and then draw them.

There are 2 ways to transpose the histogram, but not the function:

  • I can move the x-axis along using TAxis::Set(). The histogram stays where it is (which I want), but the function moves with the axis (which I don’t want).

  • Or I can copy the histogram into a new histogram, changing the bin numbers by 100. I can’t find any way to do this for the function. The function cannot be described analytically so I can’t transpose it myself that way.

Is there a way of transposing the function horizontally?

I’m using version 5.14/00e
Thanks,
Kim

see example below in file translate.C

Rene

[code]//file translate.C showing how to translate a function
TF1 *f1;
double ftrans(double *x, double *par) {
return f1->Eval(x[0] - par[0]);
}

void translate() {
f1 = new TF1(“f1”,"[0]*sin(x)",0,3.14);
f1->SetParameter(0,10);
double xtrans = 100;
TF1 *ft = new TF1(“ft”,ftrans,xtrans+f1->GetXmin(),xtrans+f1->GetXmax(),1);
ft->SetParameter(0,xtrans);
TCanvas *c1 = new TCanvas(“c1”,“test translate”,600,800);
c1->Divide(1,2);
c1->cd(1);
f1->Draw();
c1->cd(2);
ft->Draw();
}

[/code]