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 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 }