babintsev@mx.ihep.su, 18-FEB-2001 Hello rooters. >What does it mean: I take script from tutorials (below): >and have the following result (Root Version 2.25/03) > >root [1] .x fitexample.C > > *** Break *** floating point exception >Root > Function fitf() busy flag cleared >Function fitexample() busy flag cleared > >.... >>Probably you didnt run the tutorial script that was creating >>"hsimple.root" (I think it's hsimple.C), so hpx is not defined. >> >>Btw, the script could easily check this, with something like >>if (!hpx) {puts("hpx doesnt exist ! Run hsimple.C first.");delete >>f;return;} >> >> Yannick Yes, "hsimple.root" is present. Another version of the run: root [0] .L fitexample.C root [1] .b fitexample Break point set to line 10 /scratch/babintsev/tmp/./fitexample.C root [2] fitexample() # /scratch/babintsev/tmp/./fitexample.C 10 fitexample() 11 { 12 TFile *f = new TFile("hsimple.root"); !!!Calling constructor 0x0.TFile for new TFile !!!Calling compiled function TFile() arg1 = (char* 0x14092a6a0)"hsimple.root" FILE:fitexample.C LINE:12 cint> 13 14 TH1F *hpx = (TH1F*)f->Get("hpx"); !!!Calling compiled function Get() arg1 = (char* 0x14095a100)"hpx" FILE:fitexample.C LINE:14 cint> 15 16 TF1 *func = new TF1("fit",fitf,-3,3,3); !!!Calling constructor 0x0.TF1 for new TF1 !!!Calling compiled function TF1() arg1 = (char* 0x14095a900)"fit" arg2 = (char* 0x140911fc4)"fitf" arg3 = (int)(-3) arg4 = (int)3 arg5 = (int)3 FILE:fitexample.C LINE:16 cint> 17 func->SetParameters(500,hpx->GetMean(),hpx->GetRMS()); FILE:fitexample.C LINE:17 cint> *** Break *** floating point exception Root > Function fitf() busy flag cleared Function fitexample() busy flag cleared -------------- //_____________________macro fitexample.C______ Double_t fitf(Double_t *x, Double_t *par) { Double_t arg = 0; if (par[2]) arg = (x[0] - par[1])/par[2]; Double_t fitval = par[0]*TMath::Exp(-0.5*arg*arg); return fitval; } void fitexample() { TFile *f = new TFile("hsimple.root"); TH1F *hpx = (TH1F*)f->Get("hpx"); TF1 *func = new TF1("fit",fitf,-3,3,3); func->SetParameters(500,hpx->GetMean(),hpx->GetRMS()); func->SetParNames("Constant","Mean_value","Sigma"); hpx->Fit("fit"); } -------------- Thanks a lot. Volodja Babintsev
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:36 MET