00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00093
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 std::cout << std::endl << "Minuit status:" << std::endl;
00141 std::cout << " The best function value found so far " << FMIN << std::endl;
00142 std::cout << " The estimated vertical distance remaining to minimum " << FEDM << std::endl;
00143 std::cout << " The value of UP defining parameter uncertaintiesd " << ERRDEF << std::endl;
00144 std::cout << " The number of currently variable parameters " << NPARI << std::endl;
00145 std::cout << " The highest defined parameter number " << NPARX << std::endl;
00146 std::cout << " Goodness of covariance matrix: " << std::endl << " ";
00147 switch (ISTAT) {
00148 case 1: std::cout << "Diagonal approximation only, not accurate" << std::endl; break;
00149 case 2: std::cout << "Full matrix, but forced positive-defined" << std::endl; break;
00150 case 3: std::cout << "Full accurate covariance matrix (after MIGRAD)" << std::endl; break;
00151 default: std::cout << "Not calculated at all" << std::endl;
00152 }
00153
00154 if (ParValues && ParError) {
00155 std::cout << "Current parameters valules and errors:" << std::endl;
00156 for(Int_t n=0;n<ParValues->GetSize();n++)
00157 std::cout << " " << n << " " << ParValues->At(n) << " " << ParError->At(n) << std::endl;
00158 }
00159
00160 if (EPLUS && EMINUS && EPARAB && GLOBCC) {
00161 std::cout << "Parameters errors, defined by MINOS routine" << std::endl;
00162 std::cout << " NUM EPLUS EMINUS EPARAB GLOBCC" << std::endl;
00163 for(Int_t n=0;n<EPLUS->GetSize();n++)
00164 std::cout << " " << n << " " << EPLUS->At(n) << " " << EMINUS->At(n) << " " << EPARAB->At(n) << " " << GLOBCC->At(n) << std::endl;
00165 }
00166
00167 if (ERRORMATRIX) {
00168 std::cout << "Error matrix" << std::endl;
00169 ERRORMATRIX->Print();
00170 }
00171
00172 std::cout << std::endl;
00173 }