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

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Thu Apr 23 1998 - 20:45:34 MEST


Hi Jayoung,

   remove the "a" from the gROOT->Reset("a") call.
If it still gives problems (or if you are running 2.00/05)
let me know.

Cheers, Fons.


Jayoung Wu wrote:
> 
> 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

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET