To execute a macro("ytrack.C"), I typed
root [0] .x ytrack.C
Is there something wrong with handling pointers in my function "sfit"?
In the sense of C it should be no problem.
Or is there something wrong with handling function inside ROOT
interpreter? My function "sfit" does not return any value. It assigns a
value on variable that is in "ytrack.C" using pointer.
^^^^^^^^^^^^^^
Stand alone version of "ytrack.C" had no problem.
======================== Error message ==============================
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:10
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:10
* Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:11
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:11
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:11
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:11
Error: Illegal pointer operation (tovalue) FILE:ytrack.C LINE:11
* Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:12
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:12
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:12
Error: Illegal pointer operation (tovalue) FILE:ytrack.C LINE:12
* Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:13
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:13
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:13
Error: Illegal pointer operation (tovalue) FILE:ytrack.C LINE:13
* Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:14
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:14
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:14
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:14
Error: Illegal pointer operation (tovalue) FILE:ytrack.C LINE:14
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
@ Error: Illegal pointer operation (bstore:3) FILE:ytrack.C LINE:9
================================ "ytrack.C" is ================
// function declaration
void sfit(Int_t n,Float_t *x,Float_t *y,Float_t *w,Float_t *pb0,Float_t
*pb1);
// function definition
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;
}
}
// main function
void ytrack()
{
Int_t noy;
Float_t szzy[5];
Float_t sypos[5];
Float_t syesum[5];
Float_t silyin;
Float_t b0,b1;
... processing data & assign values on noy,szzy,sypos,syesum
//call function "sfit"
sfit(noy,szzy,sypos,syesum,&b0,&b1);
silyin = b0 + b1*46.764;
printf("%g\n",silyin);
}
==========================================================================
--- Thanks a lot! Jayoung Wu