GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitMinuitResult.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitMinuitResult.cxx 933 2013-01-29 15:27:58Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4FitMinuitResult.h"
15 #include "Riostream.h"
16 
18  TNamed(),
19  ParValues(0),
20  ParError(0),
21  EPLUS(0),
22  EMINUS(0),
23  EPARAB(0),
24  GLOBCC(0),
25  ERRORMATRIX(0),
26  CONTOX(0),
27  CONTOY(0),
28  CONTOCH(0) {
29 }
30 
31 TGo4FitMinuitResult::TGo4FitMinuitResult(const char* iName, const char* iTitle) :
32  TNamed(iName,iTitle),
33  ParValues(0),
34  ParError(0),
35  EPLUS(0),
36  EMINUS(0),
37  EPARAB(0),
38  GLOBCC(0),
39  ERRORMATRIX(0),
40  CONTOX(0),
41  CONTOY(0),
42  CONTOCH(0) {
43 }
44 
46  if(ParValues) delete ParValues;
47  if(ParError) delete ParError;
48  if(EPLUS) delete EPLUS;
49  if(EMINUS) delete EMINUS;
50  if(EPARAB) delete EPARAB;
51  if(GLOBCC) delete GLOBCC;
52  if(ERRORMATRIX) delete ERRORMATRIX;
53  if(CONTOX) delete CONTOX;
54  if(CONTOY) delete CONTOY;
55  if(CONTOCH) delete CONTOCH;
56 }
57 
58 void TGo4FitMinuitResult::CallMNSTAT(TMinuit* fMinuit) {
59  fMinuit->mnstat(FMIN,FEDM,ERRDEF,NPARI,NPARX,ISTAT);
60 }
61 
62 void TGo4FitMinuitResult::CallMNPOUT(TMinuit* fMinuit, Int_t nPars) {
63  if(ParValues) delete ParValues;
64  if(ParError) delete ParError;
65 
66  ParValues = new TArrayD(nPars);
67  ParError = new TArrayD(nPars);
68  for(Int_t n=0;n<nPars;n++)
69  fMinuit->GetParameter(n, (*ParValues)[n], (*ParError)[n]);
70 }
71 
72 void TGo4FitMinuitResult::CallMNERRS(TMinuit* fMinuit, Int_t nPars) {
73  if(EPLUS) delete EPLUS;
74  if(EMINUS) delete EMINUS;
75  if(EPARAB) delete EPARAB;
76  if(GLOBCC) delete GLOBCC;
77 
78  EPLUS = new TArrayD(nPars);
79  EMINUS = new TArrayD(nPars);
80  EPARAB = new TArrayD(nPars);
81  GLOBCC = new TArrayD(nPars);
82 
83  for(Int_t n=0;n<nPars;n++)
84  fMinuit->mnerrs(n, (*EPLUS)[n], (*EMINUS)[n], (*EPARAB)[n], (*GLOBCC)[n]);
85 
86 }
87 
88 void TGo4FitMinuitResult::CallMNEMAT(TMinuit* fMinuit, Int_t nPars, Bool_t DoTransform)
89 {
90  if(ERRORMATRIX) delete ERRORMATRIX;
91 
92 // ERRORMATRIX = new TMatrixD(nPars,nPars);
93 // fMinuit->mnemat(ERRORMATRIX->GetElements(), nPars);
94 
95  Double_t* matrix = new Double_t[nPars*nPars];
96  fMinuit->mnemat(matrix, nPars);
97  ERRORMATRIX = new TMatrixD(nPars, nPars, matrix);
98 
99  if(DoTransform)
100  for(Int_t npar=0;npar<nPars;npar++) {
101  TString name;
102  Double_t val,err,bnd1,bnd2;
103  Int_t fixed = 0;
104  fMinuit->mnpout(npar,name,val,err,bnd1,bnd2,fixed);
105 
106  if (fixed==0) {
107  for(Int_t n=nPars-2;n>=npar-1;n--)
108  for(Int_t i=0;i<nPars;i++)
109  (*ERRORMATRIX)(i,n+1) = (*ERRORMATRIX)(i,n);
110  for(Int_t i=0;i<nPars;i++)
111  (*ERRORMATRIX)(i,npar-1) = 0;
112 
113  for(Int_t n=nPars-2;n>=npar-1;n--)
114  for(Int_t i=0;i<nPars;i++)
115  (*ERRORMATRIX)(n+1,i) = (*ERRORMATRIX)(n,i);
116  for(Int_t i=0;i<nPars;i++)
117  (*ERRORMATRIX)(npar-1,i) = 0;
118  }
119  }
120 
121  delete[] matrix;
122 }
123 
124 void TGo4FitMinuitResult::GetContourPlot(TMinuit* fMinuit) {
125  Int_t sz = strlen(fMinuit->fChpt);
126  if (sz == 0) return;
127  CONTOX = new TArrayD(sz);
128  CONTOY = new TArrayD(sz);
129  CONTOCH = new TArrayC(sz);
130  for (Int_t i=0;i<sz;i++) {
131  (*CONTOX)[i] = fMinuit->fXpt[i];
132  (*CONTOY)[i] = fMinuit->fYpt[i];
133  (*CONTOCH)[i] = fMinuit->fChpt[i];
134  }
135 
136 }
137 
138 void TGo4FitMinuitResult::Print(Option_t* option) const {
139  TNamed::Print(option);
140  std::cout << std::endl << "Minuit status:" << std::endl;
141  std::cout << " The best function value found so far " << FMIN << std::endl;
142  std::cout << " The estimated vertical distance remaining to minimum " << FEDM << std::endl;
143  std::cout << " The value of UP defining parameter uncertaintiesd " << ERRDEF << std::endl;
144  std::cout << " The number of currently variable parameters " << NPARI << std::endl;
145  std::cout << " The highest defined parameter number " << NPARX << std::endl;
146  std::cout << " Goodness of covariance matrix: " << std::endl << " ";
147  switch (ISTAT) {
148  case 1: std::cout << "Diagonal approximation only, not accurate" << std::endl; break;
149  case 2: std::cout << "Full matrix, but forced positive-defined" << std::endl; break;
150  case 3: std::cout << "Full accurate covariance matrix (after MIGRAD)" << std::endl; break;
151  default: std::cout << "Not calculated at all" << std::endl;
152  }
153 
154  if (ParValues && ParError) {
155  std::cout << "Current parameters valules and errors:" << std::endl;
156  for(Int_t n=0;n<ParValues->GetSize();n++)
157  std::cout << " " << n << " " << ParValues->At(n) << " " << ParError->At(n) << std::endl;
158  }
159 
160  if (EPLUS && EMINUS && EPARAB && GLOBCC) {
161  std::cout << "Parameters errors, defined by MINOS routine" << std::endl;
162  std::cout << " NUM EPLUS EMINUS EPARAB GLOBCC" << std::endl;
163  for(Int_t n=0;n<EPLUS->GetSize();n++)
164  std::cout << " " << n << " " << EPLUS->At(n) << " " << EMINUS->At(n) << " " << EPARAB->At(n) << " " << GLOBCC->At(n) << std::endl;
165  }
166 
167  if (ERRORMATRIX) {
168  std::cout << "Error matrix" << std::endl;
169  ERRORMATRIX->Print();
170  }
171 
172  std::cout << std::endl;
173 }
void GetContourPlot(TMinuit *fMinuit)
virtual void Print(Option_t *option) const
void CallMNERRS(TMinuit *fMinuit, Int_t nPars)
void CallMNEMAT(TMinuit *fMinuit, Int_t nPars, Bool_t DoTransform=kTRUE)
void CallMNSTAT(TMinuit *fMinuit)
void CallMNPOUT(TMinuit *fMinuit, Int_t nPars)