How can I execute a macro that has a subroutine call?

Jayoung Wu (jayoung@ipst.umd.edu)
Thu, 23 Apr 1998 14:19:28 -0400 (EDT)


Hi,
I am trying executing a macro("ytrack.C") that has a subroutine call.
When I type ".x ytrack.C" in root environment it works:
root[0] .x ytrack.C

Hpwever, if I use controlbar, it gives sigmentation violation:
{
gROOT->Reset("a");
bar = new TControlBar("vertical");

...
bar->AddButton("Track",".x ytrack.C",
"Tracking Incident X(Y) position");

...

bar->Show();
gROOT->SaveContext();
}

---------------- ytrack.C ----------------------
void sfit(Int_t n,Float_t *x,Float_t *y,Float_t *w,Float_t *pb0,Float_t
*pb1);
void sfit(Int_t n,Float_t *x,Float_t *y,Float_t *w,Float_t *pb0,Float_t
*pb1)
{

Float_t tt1,tt2,tt3,tt4,tt5,ss;

tt1 = tt2 = tt3 = tt4 = tt5 = 0.;

for (Int_t i=0; i<n; i++) {
tt1 = tt1 + 1*w[i]*w[i];
tt2 = tt2 + x[i]*x[i]*w[i]*w[i];
tt3 = tt3 + x[i]*w[i]*w[i];
tt4 = tt4 + y[i]*w[i]*w[i];
tt5 = tt5 + y[i]*x[i]*w[i]*w[i];
}

ss = tt1*tt2 - tt3*tt3;

if (ss == 0) {
*pb0 = -999;
*pb1 = -999;
}
else {
*pb0 = (tt2*tt4 - tt5*tt3)/ss;
*pb1 = (tt1*tt5 - tt3*tt4)/ss;
}
}

void ytrack()
{
...

sfit(fbnx,fbxz,fbxx,fbxe,&fbb0x,&fbb1x);

...
}

---------------------------------------------------------------------

Thanks in advance!
Jayoung