00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4FitMinuitResult.h"
00017 #include <iostream.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 if(ERRORMATRIX) delete ERRORMATRIX;
00092
00093
00094
00095
00096 Double_t matrix[nPars*nPars];
00097 fMinuit->mnemat(matrix, nPars);
00098 ERRORMATRIX = new TMatrixD(nPars, nPars, matrix);
00099
00100 if(DoTransform)
00101 for(Int_t npar=0;npar<nPars;npar++) {
00102 TString name;
00103 Double_t val,err,bnd1,bnd2;
00104 Int_t fixed = 0;
00105 fMinuit->mnpout(npar,name,val,err,bnd1,bnd2,fixed);
00106
00107 if (fixed==0) {
00108 for(Int_t n=nPars-2;n>=npar-1;n--)
00109 for(Int_t i=0;i<nPars;i++)
00110 (*ERRORMATRIX)(i,n+1) = (*ERRORMATRIX)(i,n);
00111 for(Int_t i=0;i<nPars;i++)
00112 (*ERRORMATRIX)(i,npar-1) = 0;
00113
00114 for(Int_t n=nPars-2;n>=npar-1;n--)
00115 for(Int_t i=0;i<nPars;i++)
00116 (*ERRORMATRIX)(n+1,i) = (*ERRORMATRIX)(n,i);
00117 for(Int_t i=0;i<nPars;i++)
00118 (*ERRORMATRIX)(npar-1,i) = 0;
00119 }
00120 }
00121 }
00122
00123 void TGo4FitMinuitResult::GetContourPlot(TMinuit* fMinuit) {
00124 Int_t sz = strlen(fMinuit->fChpt);
00125 if (sz == 0) return;
00126 CONTOX = new TArrayD(sz);
00127 CONTOY = new TArrayD(sz);
00128 CONTOCH = new TArrayC(sz);
00129 for (Int_t i=0;i<sz;i++) {
00130 (*CONTOX)[i] = fMinuit->fXpt[i];
00131 (*CONTOY)[i] = fMinuit->fYpt[i];
00132 (*CONTOCH)[i] = fMinuit->fChpt[i];
00133 }
00134
00135 }
00136
00137 void TGo4FitMinuitResult::Print(Option_t* option) const {
00138 TNamed::Print(option);
00139 cout << endl << "Minuit status:" << endl;
00140 cout << " The best function value found so far " << FMIN << endl;
00141 cout << " The estimated vertical distance remaining to minimum " << FEDM << endl;
00142 cout << " The value of UP defining parameter uncertaintiesd " << ERRDEF << endl;
00143 cout << " The number of currently variable parameters " << NPARI << endl;
00144 cout << " The highest defined parameter number " << NPARX << endl;
00145 cout << " Goodness of covariance matrix: " << endl << " ";
00146 switch (ISTAT) {
00147 case 1: cout << "Diagonal approximation only, not accurate" << endl; break;
00148 case 2: cout << "Full matrix, but forced positive-defined" << endl; break;
00149 case 3: cout << "Full accurate covariance matrix (after MIGRAD)" << endl; break;
00150 default: cout << "Not calculated at all" << endl;
00151 }
00152
00153 if (ParValues && ParError) {
00154 cout << "Current parameters valules and errors:" << endl;
00155 for(Int_t n=0;n<ParValues->GetSize();n++)
00156 cout << " " << n << " " << ParValues->At(n) << " " << ParError->At(n) << endl;
00157 }
00158
00159 if (EPLUS && EMINUS && EPARAB && GLOBCC) {
00160 cout << "Parameters errors, defined by MINOS routine" << endl;
00161 cout << " NUM EPLUS EMINUS EPARAB GLOBCC" << endl;
00162 for(Int_t n=0;n<EPLUS->GetSize();n++)
00163 cout << " " << n << " " << EPLUS->At(n) << " " << EMINUS->At(n) << " " << EPARAB->At(n) << " " << GLOBCC->At(n) << endl;
00164 }
00165
00166 if (ERRORMATRIX) {
00167 cout << "Error matrix" << endl;
00168 ERRORMATRIX->Print();
00169 }
00170
00171 cout << endl;
00172
00173
00174
00175
00176
00177 }
00178
00179 ClassImp(TGo4FitMinuitResult)
00180
00181