TGo4FitMinuitResult.cxx

Go to the documentation of this file.
00001 // $Id: TGo4FitMinuitResult.cxx 478 2009-10-29 12:26:09Z linev $
00002 //-----------------------------------------------------------------------
00003 //       The GSI Online Offline Object Oriented (Go4) Project
00004 //         Experiment Data Processing at EE department, GSI
00005 //-----------------------------------------------------------------------
00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
00007 //                     Planckstr. 1, 64291 Darmstadt, Germany
00008 // Contact:            http://go4.gsi.de
00009 //-----------------------------------------------------------------------
00010 // This software can be used under the license agreements as stated
00011 // in Go4License.txt file which is part of the distribution.
00012 //-----------------------------------------------------------------------
00013 
00014 #include "TGo4FitMinuitResult.h"
00015 #include "Riostream.h"
00016 
00017 TGo4FitMinuitResult::TGo4FitMinuitResult() :
00018     TNamed(),
00019     ParValues(0),
00020     ParError(0),
00021     EPLUS(0),
00022     EMINUS(0),
00023     EPARAB(0),
00024     GLOBCC(0),
00025     ERRORMATRIX(0),
00026     CONTOX(0),
00027     CONTOY(0),
00028     CONTOCH(0) {
00029 }
00030 
00031 TGo4FitMinuitResult::TGo4FitMinuitResult(const char* iName, const char* iTitle) :
00032     TNamed(iName,iTitle),
00033     ParValues(0),
00034     ParError(0),
00035     EPLUS(0),
00036     EMINUS(0),
00037     EPARAB(0),
00038     GLOBCC(0),
00039     ERRORMATRIX(0),
00040     CONTOX(0),
00041     CONTOY(0),
00042     CONTOCH(0)  {
00043 }
00044 
00045 TGo4FitMinuitResult::~TGo4FitMinuitResult() {
00046    if(ParValues) delete ParValues;
00047    if(ParError) delete  ParError;
00048    if(EPLUS) delete EPLUS;
00049    if(EMINUS) delete EMINUS;
00050    if(EPARAB) delete EPARAB;
00051    if(GLOBCC) delete GLOBCC;
00052    if(ERRORMATRIX) delete ERRORMATRIX;
00053    if(CONTOX) delete CONTOX;
00054    if(CONTOY) delete CONTOY;
00055    if(CONTOCH) delete CONTOCH;
00056 }
00057 
00058 void TGo4FitMinuitResult::CallMNSTAT(TMinuit* fMinuit) {
00059     fMinuit->mnstat(FMIN,FEDM,ERRDEF,NPARI,NPARX,ISTAT);
00060 }
00061 
00062 void TGo4FitMinuitResult::CallMNPOUT(TMinuit* fMinuit, Int_t nPars) {
00063     if(ParValues) delete ParValues;
00064     if(ParError) delete  ParError;
00065 
00066     ParValues = new TArrayD(nPars);
00067     ParError = new TArrayD(nPars);
00068     for(Int_t n=0;n<nPars;n++)
00069        fMinuit->GetParameter(n, (*ParValues)[n], (*ParError)[n]);
00070 }
00071 
00072 void TGo4FitMinuitResult::CallMNERRS(TMinuit* fMinuit, Int_t nPars) {
00073    if(EPLUS) delete EPLUS;
00074    if(EMINUS) delete EMINUS;
00075    if(EPARAB) delete EPARAB;
00076    if(GLOBCC) delete GLOBCC;
00077 
00078    EPLUS = new TArrayD(nPars);
00079    EMINUS = new TArrayD(nPars);
00080    EPARAB = new TArrayD(nPars);
00081    GLOBCC = new TArrayD(nPars);
00082 
00083    for(Int_t n=0;n<nPars;n++)
00084        fMinuit->mnerrs(n, (*EPLUS)[n], (*EMINUS)[n], (*EPARAB)[n], (*GLOBCC)[n]);
00085 
00086 }
00087 
00088 void TGo4FitMinuitResult::CallMNEMAT(TMinuit* fMinuit, Int_t nPars, Bool_t DoTransform)
00089 {
00090    if(ERRORMATRIX) delete ERRORMATRIX;
00091 
00092 //   ERRORMATRIX = new TMatrixD(nPars,nPars);
00093 //   fMinuit->mnemat(ERRORMATRIX->GetElements(), nPars);
00094 
00095    Double_t* matrix = new Double_t[nPars*nPars];
00096    fMinuit->mnemat(matrix, nPars);
00097    ERRORMATRIX = new TMatrixD(nPars, nPars, matrix);
00098 
00099    if(DoTransform)
00100    for(Int_t npar=0;npar<nPars;npar++) {
00101        TString name;
00102        Double_t val,err,bnd1,bnd2;
00103        Int_t fixed = 0;
00104        fMinuit->mnpout(npar,name,val,err,bnd1,bnd2,fixed);
00105 
00106        if (fixed==0) {
00107           for(Int_t n=nPars-2;n>=npar-1;n--)
00108             for(Int_t i=0;i<nPars;i++)
00109                (*ERRORMATRIX)(i,n+1) = (*ERRORMATRIX)(i,n);
00110           for(Int_t i=0;i<nPars;i++)
00111              (*ERRORMATRIX)(i,npar-1) = 0;
00112 
00113           for(Int_t n=nPars-2;n>=npar-1;n--)
00114              for(Int_t i=0;i<nPars;i++)
00115                (*ERRORMATRIX)(n+1,i) = (*ERRORMATRIX)(n,i);
00116           for(Int_t i=0;i<nPars;i++)
00117              (*ERRORMATRIX)(npar-1,i) = 0;
00118        }
00119    }
00120 
00121    delete[] matrix;
00122 }
00123 
00124 void TGo4FitMinuitResult::GetContourPlot(TMinuit* fMinuit) {
00125    Int_t sz = strlen(fMinuit->fChpt);
00126    if (sz == 0) return;
00127    CONTOX = new TArrayD(sz);
00128    CONTOY = new TArrayD(sz);
00129    CONTOCH = new TArrayC(sz);
00130    for (Int_t i=0;i<sz;i++) {
00131       (*CONTOX)[i] = fMinuit->fXpt[i];
00132       (*CONTOY)[i] = fMinuit->fYpt[i];
00133       (*CONTOCH)[i] = fMinuit->fChpt[i];
00134    }
00135 
00136 }
00137 
00138 void TGo4FitMinuitResult::Print(Option_t* option) const {
00139     TNamed::Print(option);
00140     cout << endl << "Minuit status:" << endl;
00141     cout << "  The best function value found so far " << FMIN << endl;
00142     cout << "  The estimated vertical distance remaining to minimum " << FEDM << endl;
00143     cout << "  The value of UP defining parameter uncertaintiesd " << ERRDEF << endl;
00144     cout << "  The number of currently variable parameters " << NPARI << endl;
00145     cout << "  The highest defined parameter number " << NPARX  << endl;
00146     cout << "  Goodness of covariance matrix: " << endl << "    ";
00147     switch (ISTAT) {
00148        case 1: cout << "Diagonal approximation only, not accurate" << endl; break;
00149        case 2: cout << "Full matrix, but forced positive-defined" << endl; break;
00150        case 3: cout << "Full accurate covariance matrix (after MIGRAD)" << endl; break;
00151        default: cout << "Not calculated at all" << endl;
00152     }
00153 
00154     if (ParValues && ParError) {
00155        cout << "Current parameters valules and errors:" << endl;
00156        for(Int_t n=0;n<ParValues->GetSize();n++)
00157          cout << "  " << n << "   " << ParValues->At(n) << "     " << ParError->At(n) << endl;
00158     }
00159 
00160     if (EPLUS && EMINUS && EPARAB && GLOBCC) {
00161        cout << "Parameters errors, defined by MINOS routine" << endl;
00162        cout << "  NUM   EPLUS   EMINUS   EPARAB    GLOBCC" << endl;
00163        for(Int_t n=0;n<EPLUS->GetSize();n++)
00164          cout << "  " << n << "   " << EPLUS->At(n) << "  " << EMINUS->At(n) << "  " << EPARAB->At(n) << "  " << GLOBCC->At(n) << endl;
00165     }
00166 
00167     if (ERRORMATRIX) {
00168        cout << "Error matrix" << endl;
00169        ERRORMATRIX->Print();
00170     }
00171 
00172     cout << endl;
00173 }

Generated on Thu Oct 28 15:54:12 2010 for Go4-Fitpackagev4.04-2 by  doxygen 1.5.1