Re: How to draw a series of TF1 curves?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 30 Jan 2008 08:30:56 +0100


see TF1::SetParameters API.
I have modified your function below. Note that you should modify your function testfunc to avoid evaluating x**y where x is negative and y is odd.

Rene Brun

void fieldraw() {
TF1* vectorfunc = new TF1("vectorfunc",&testfunc,-5,5,1); for (double Ci=1;Ci<100;Ci++) {
vectorfunc->SetParameter(0,Ci);
if (Ci <= 1) vectorfunc->Draw("L");
else vectorfunc->Draw("Lsame");
}
}

osirixu-root_at_yahoo.com.cn wrote:
> Hi all,
>
> I expect to plot a series of curves (or vectors of a field) on one single canvas, e.g. such
> functions: f(x)=x^2+Ci, where Ci is a constant varies from 1 to 100. I tried to use codes below
> but failed.
>
> //++++++++++++++++++++++start+++++++++++++++++++++++++++++++
> double testfunc(double* x, double* par) {
> double c = par[0];
> return x[0]**x[0]+c;
> }
>
> void fieldraw() {
> for (double Ci=1;Ci<=100;Ci++)
> {
> TF1* vectorfunc = new TF1("vectorfunc",&testfunc,-5,5,1);
> vectorfunc->SetParameters(Ci);
> vectorfunc->Draw("L");
> }
> return;
> }
> //++++++++++++++++++++++end++++++++++++++++++++++++++++++
> //++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> // OR
> //++++++++++++++++++++++start+++++++++++++++++++++++++++++++
> double testfunc(double* x, double* par) {
> double c = par[0];
> return x[0]**x[0]+c;
> }
>
> void fieldraw() {
> TF1* vectorfunc = new TF1("vectorfunc",&testfunc,-5,5,1);
> for (double Ci=1;Ci<=100;Ci++)
> {
> vectorfunc->SetParameters(Ci);
> vectorfunc->Draw("L");
> }
> return;
> }
> //++++++++++++++++++++++end++++++++++++++++++++++++++++++
>
> Thr error message both are: "Error: Can't call TF1::SetParameters(Ci) in current scope"
>
> I am puzzled what is going wrong?
>
> Any tips will be greatly appreciated. Thanks and have a nice day!
>
> Sincerely,
> Shrinking
>
>
> ___________________________________________________________
> ÑÅ»¢ÓÊÏä´«µÝÐÂÄê×£¸££¬¸öÐԺؿ¨ËÍÇ×Åó£¡
> http://cn.mail.yahoo.com/gc/index.html?entry=5&souce=mail_mailletter_tagline
>
>
Received on Wed Jan 30 2008 - 08:28:04 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 30 2008 - 11:50:01 CET