Hi Ray, Could you send me a working macro that I can execute? Instead of Data *d, pass the 4 objects as arguments to FitAll or any other similar mods such that I can execute the code. Rene Brun Ray Fliller III wrote: > > Hello Rooters, > > I am using ROOT version 2.23/12 on Linux > > Is there a reason why when I call TGraph::Fit, in a loop, to fit > different TGraphs with different functions I get a segmentation fault in > my code?? > > Example > > FitAll(Data *d) > { > int i; > TString title; > char n[2]; > float chisq,diff,ddiff; > > for(i=0;i<4;i++){ > title="collin4"; > sprintf(&n,"%i",i); > title+=n; > d->canvas->cd(i+1); > d->func[i]->SetRange(11,300); > d->graph[i]->Fit(title,"RB"); > } > } > > in my class data this is an array of 4 TGraphErrorss and 4 TF1s (named > collin40,collin41,collin42,collin43) If I do this by hand, all is > happy. Put it in a macro I get: > > root [8] FitAll(move4) > ********** > ** 1 **SET ERR 1 > ********** > ********** > ** 5 **MIGRAD 5000 0.01 > ********** > MIGRAD MINIMIZATION HAS CONVERGED. > MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. > FCN=1135.12 FROM MIGRAD STATUS=CONVERGED 346 CALLS 347 > TOTAL > EDM=2.94214e-08 STRATEGY= 1 ERROR MATRIX > ACCURATE > EXT PARAMETER STEP FIRST > NO. NAME VALUE ERROR SIZE DERIVATIVE > 1 Amplitude 1.00000e-00 1.80924e-10 5.00000e-01 4.54747e-12 > 2 Movement(m) 7.37671e+00 3.42481e+00 1.28569e-03 -1.61017e-03 > 3 Diffusion Rate(mm-mrad/s)^2 9.03821e-06 8.37974e-06 > 3.15019e-09 6.57012e+02 > 4 Zero time(s) 1.10661e+01 3.48938e-03 3.45107e-05 -3.02434e-02 > 5 Constant 1.95906e+03 4.29638e+00 4.44481e-02 -4.41191e-05 > FCN=1135.12 FROM MIGRAD STATUS=CONVERGED 346 CALLS 347 > TOTAL > EDM=2.94214e-08 STRATEGY= 1 ERROR MATRIX > ACCURATE > EXT PARAMETER STEP FIRST > NO. NAME VALUE ERROR SIZE DERIVATIVE > 1 Amplitude 1.00000e-00 1.80924e-10 5.00000e-01 4.54747e-12 > 2 Movement(m) 7.37671e+00 3.42481e+00 1.28569e-03 -1.61017e-03 > 3 Diffusion Rate(mm-mrad/s)^2 9.03821e-06 8.37974e-06 > 3.15019e-09 6.57012e+02 > 4 Zero time(s) 1.10661e+01 3.48938e-03 3.45107e-05 -3.02434e-02 > 5 Constant 1.95906e+03 4.29638e+00 4.44481e-02 -4.41191e-05 > > *** Break *** segmentation violation > Root > Function FitAll() busy flag cleared > > It crashes at the i=1 call data->graph[i]->Fit(title,"RB") > > All ranges, bounardaries, etc., are properly initialized. Like I said, > if I do this by hand (ie, I am the for statement), all is good, if ROOT > is the for statment, all is anti-good. > > Thanks for your help > > ============================================================================== > Ray Fliller: rfliller@bnl.gov Office Phone: (631)-344-6124 > C-A Accelerator Physics > Building 911 > Brookhaven National Lab > Upton, NY 11973 Office: Room 211 > ==============================================================================
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET