Basic Question Regarding Functions

Hello all,

First, forgive my ignorance I’m going through a self-taught crash course in UNIX, C++, and ROOT all at once. I know this is a simple question, but I’ve searched the documentation and can’t seem to come across a simple answer.

I’m writing a simple “program”, just to basically introduce myself to ROOT. I would like it to define two functions. Then add those functions together, then plot those functions. This is what I have:

[code]{
gROOT->Reset();
gROOT->SetStyle(“Plain”);

TF1 f1(“func1”,“sin(x)”,0,10);
TF1 f2(“func2”,“cos(x)^2”,0,10);
//f1.Draw();
//f2.Draw(“Same”);
TF1 f3(“func3”,“f1+f2”,0,10);
f3.Draw();
}[/code]

I can’t figure out how to ask ROOT to combine functions f1 and f2 into a single function f3. Do I need to call the TF1 Class before defining f3? I basically took the “how to define” f1 and f2 straight out of the documentation, but I can’t seem to get ROOT to compile f1 and f2 into a single function. It works fine if instead of f1+f2 I put “sin(x)+cos(x)^2”… but I would like to know how to work with the defined functions within the TF class.

Thanks for your time and sorry for the low level issues.

Zach

instead of

TF1 f3("func3","f1+f2",0,10); do

TF1 f3("func3","func1+func2",0,10);

ie use the function names, not the C++ object names. It would be better if could have object name = function name

Rene

Rene,

Thanks. It would be the obvious answer. Does CINT Typically compile based on Function name instead object-pointer?

Thanks again,

Zach

Your problem has nothing to do with CINT. The argument must be a const char* and TF1 expects function names and not pointer names or object names.

Rene