<>Thanks Rene, GetCovarianceMatrixElement is going to be very helpful! I still can't get at it yet, entirely due to python/pyROOT issues with static classes. I've tried several approaches: >>> fitter = ROOT.TVirtualFitter::GetFitter() gives me "TypeError: unbound method GetFitter() must be called with TVirtualFitter instance as first argument (got nothing instead)" >>> ROOT.TVirtualFitter() gives me a null TObject pointer, and crashes if I try to call GetFitter() on it. This nearly works: >>> ROOT.gROOT.ProcessLine("TVirtualFitter *fitter = TVirtualFitter::GetFitter()") >>> tglob = ROOT.gROOT.GetGlobal("fitter") >>> fitter = tglob.GetAddress() Here I get a valid fitter variable in CINT's global memory, but I can't locate it as a python object. Further ProcessLine calls manipulating "fitter" work well but only write to stdout. gROOT.GetGlobal(...) returns a null pointer. The third line probably wouldn't work either because it returns void*, not TObject*, so pyROOT can't use reflection to get the object's class. If I try the same thing in CINT, GetGlobal("fitter") works fine -- I have no idea why it doesn't want to work in pyROOT. Finally, gDiretory->Get(...) doesn't seem to work because the TVirtualFitter object does not get stored that way. Oh, that and I can't get gDirectory in the first place. Argh! Here's my list of hang-ups so far with pyROOT: * Can't call methods of static classes * Can't find certain globals: gDirectory, gMinuit, or anything I create with ProcessLine(). * Can't work with c structures such as double vec[] or matrix[][] and thus any Root methods that use these as parameters. Even methods like GetParLimits(Int_t ipar, Double_t& parmin, Double_t& parmax) can't be used. * Can't use C++ overloaded operators. I can't see a way around this problem either, since Python doesn't allow such hijinks. In spite of all this, I've been able to do almost everything I need to with pyROOT. I just can't find my way into Minuit's covariance matrix! - Topher Rene Brun wrote: >Hi Topher, > >I assume that Wim Lavrijsen will answer your points concerning directly pyroot. > >Concerning access to the covariance matrix following a fit, >I have added a new method in TVirtualFitter, TFitter, TFumili, etc >TVirtualFitter::GetCovarianceMatrixElement(int i, int j); > >you can access it as indicated in the comments of TH1::Fit > >// Access to the fit covariance matrix >// =================================== >// Example1: >// TH1F h("h","test",100,-2,2); >// h.FillRandom("gaus",1000); >// h.Fit("gaus"); >// Double_t matrix[3][3]; >// gMinuit->mnemat(&matrix[0][0],3); >// Example2: >// TH1F h("h","test",100,-2,2); >// h.FillRandom("gaus",1000); >// h.Fit("gaus"); >// TMatrixD matrix(npar,npar,gMinuit->GetCovarianceMatrix()); >// matrix.Print(); >// matrix.Draw("text"); >// Example3: via the TVirtualFitter interface (works with TMinuit, TFumili, >etc) >// TH1F h("h","test",100,-2,2); >// h.FillRandom("gaus",1000); >// h.Fit("gaus"); >// TVirtualfitter *fitter = TVirtualFitter::GetFitter(); >// TMatrixD matrix(npar,npar,fitter->GetCovarianceMatrix()); >// Double_t errorFirstPar = fitter->GetCovarianceMatrixElement(0,0); > >Also note that in the class TmatrixD, you can use > TMatrixD::GetMatrixArray >to get a pointer to the matrix elements directly. > >There is no point in adding a function to TF1 to return the covariance matrix >or one of its elements. TF1 does not store a copy of the covariance matrix. >Accesd to the matrix can only be done (via TMinuit or TVirtualFitter) >immediatly after the fit as shown in the comments above. > >Rene Brun > > ...
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET