Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4FitMinuitResult.cxx

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

Generated on Fri Nov 28 12:59:12 2008 for Go4-v3.04-1 by  doxygen 1.4.2