Hi Tohru,
Use the simplified code below:
Rene Brun
TApplication app("appKey",0,0);
TCanvas canvas("canvasKey");
TH1F foo("fooKey", "test histo",1000,-10,10);
foo.FillRandom("gaus",10000);
TF1 func("fitme","gaus");
foo.Draw();
foo.Fit("fitme");
cerr << "ChiSquare: " << func.GetChisquare()<<'\t';
cerr << "NDF: " << func.GetNDF()<<endl;
canvas.Update();
canvas.WaitPrimitive(); //will return with a double click
Float_t mean = func.GetParameter(1);
Float_t sigma = func.GetParameter(2);
foo.Fit("fitme","","",mean - 3 * sigma, mean + 3 * sigma);
cerr << "ChiSquare: " << func.GetChisquare()<<'\t';
cerr << "NDF: " << func.GetNDF()<<endl;
canvas.Update();
canvas.WaitPrimitive();
Tohru Ohnuki wrote:
>
> This used to work with earlier versions, but now it doesn't (got
> bugfixed?). In a compiled application one would get a canvas drawn and be
> able to hold it open by a wait loop until a key was pressed, resuming
> program execution, say for scanning event fitting. I looked in the usual
> places, found out about the TApplication class and tried again with a
> program like:
>
> //15 march 2003 testing tapp hold canvas open functions
>
> #include <iostream>
> #include "TROOT.h"
> #include "TH1F.h"
> #include "TF1.h"
> #include "TCanvas.h"
> #include "TApplication.h"
>
> int main()
> {
> TApplication app("appKey",0,0);
> TCanvas canvas("canvasKey");
> TH1F foo("fooKey", "test histo",1000,-10,10);
> foo.FillRandom("gaus",10000);
> TF1 func("fitme","gaus");
> foo.Draw();
> foo.Fit("fitme");
> cerr << "ChiSquare: " << func.GetChisquare()<<'\t';
> cerr << "NDF: " << func.GetNDF()<<endl;
> app.Run(kTRUE);
> canvas.WaitPrimitive();
> //gPad->WaitPrimitive();
> Float_t mean = func.GetParameter(1);
> Float_t sigma = func.GetParameter(2);
> foo.Fit("fitme","","",mean - 3 * sigma, mean + 3 * sigma);
> cerr << "ChiSquare: " << func.GetChisquare()<<'\t';
> cerr << "NDF: " << func.GetNDF()<<endl;
> app.Run(kTRUE);
> canvas.WaitPrimitive();
>
> return(0);
> }
>
> Unfortunately, this crashes with a segfault and lots of stack traces when
> i try to close the root canvas. Clicking and ctrl-c on the pad doesn't do
> anything. I'm sure i'm doing something dumb, do i really need to
> capturemouseevent or something like that? I'm using root-3.05.03 on RH-7.3
> (pentium III) with gcc-2.96rh. Thanks...
>
> Regards,
>
> Tohru O.
> --
> UCLA Physics & Astronomy Dept.
> GSR-IV Data Monkey
> ohnuki@physics.ucla.edu
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET