TF1* myfunc1 = new TF1("myfunc1", func, -90., 90., 2);
TF1* myfunc2 = new TF1("myfunc2", func, -90., 90., 2);
to
TF1* myfunc1 = new TF1("myfunc1", (void*)func, -90., 90., 2);
TF1* myfunc2 = new TF1("myfunc2", (void*)func, -90., 90., 2);
and your macro will work nicely.
Rene Brun
Mario Deile wrote:
>
> Hello,
>
> My name is Mario Deile, I work for ATLAS.
> I am doing my first steps with ROOT and have the following problem:
>
> I am trying to plot 2 functions into 1 frame.
> Since the functions only differ in parameter values, I use the same
> function subroutine. Using the tutorial and the class reference guide on
> the web, I ended up with the following macro "test.C":
>
> Double_t func(Double_t *x, Double_t *par) {
> Double_t PI = 3.141592653589793;
> Float_t xx = x[0] / 180. * PI;
> return (par[0] * sqrt(3) * sin(xx) - (2 * par[1] + 1) * par[0] * cos(xx));
> }
>
> //**********************************************************************
>
> void main() {
> gROOT->Reset();
> TCanvas* c1 = new TCanvas("c1", "Radius Correlation", 200, 10, 700, 700);
> c1->SetGridx();
> c1->SetGridy();
>
> TF1* myfunc1 = new TF1("myfunc1", func, -90., 90., 2);
> myfunc1->SetParameters(3., 1.);
> myfunc1->Draw();
>
> c1->Update();
>
> TF1* myfunc2 = new TF1("myfunc2", func, -90., 90., 2);
> myfunc2->SetParameters(3., 0.);
> myfunc2->Draw("SAME");
>
> c1->Update();
> }
>
> I start the macro with
> .L test.C
> main()
>
> After correctly plotting the first function ROOT crashes with many
> subsequent
> "*** Break *** segmentation violation"
>
> Swapping the order of the functions doesn't change anything. It is
> always the second which causes the crash.
> Plotting only 1 of the functions works well (for either of the 2).
>
> Could I ask you to be so kind and look at the macro and tell me my
> mistake?