Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4FitModelGauss2.h"
00015
00016 #include "Riostream.h"
00017 #include "TMath.h"
00018
00019 #include "TGo4FitParameter.h"
00020
00021 TGo4FitModelGauss2::TGo4FitModelGauss2() : TGo4FitModel(), fiNaxis1(0), fiNaxis2(1) {
00022 }
00023
00024 TGo4FitModelGauss2::TGo4FitModelGauss2(const char* iName, Double_t iPos1, Double_t iPos2,
00025 Double_t iWidth1, Double_t iWidth2, Double_t iCov12,
00026 Int_t iNaxis1, Int_t iNaxis2) :
00027 TGo4FitModel(iName,"2-dimensional Gaussian", kTRUE), fiNaxis1(iNaxis1), fiNaxis2(iNaxis2) {
00028 NewParameter("Pos0","2D gaussian position 1",iPos1);
00029 NewParameter("Pos1","2D gaussian position 2",iPos2);
00030 NewParameter("Width0","2D gaussian width 1",iWidth1);
00031 NewParameter("Width1","2D gaussian width 2",iWidth2);
00032 NewParameter("Cov0_1","2D gaussian covariation",iCov12);
00033 }
00034
00035 TGo4FitModelGauss2::~TGo4FitModelGauss2() {
00036 }
00037
00038
00039 Bool_t TGo4FitModelGauss2::BeforeEval(Int_t ndim) {
00040 Par_mu1 = GetPar(1)->GetValue();
00041 Par_mu2 = GetPar(2)->GetValue();
00042 Par_sig1 = GetPar(3)->GetValue();
00043 if (Par_sig1==0.)
00044 { std::cout << " TGo4FitModelGauss2:: invalid Sig0 value" << std::endl; return kFALSE; }
00045 Par_sig2 = GetPar(4)->GetValue();
00046 if (Par_sig2==0.)
00047 { std::cout << " TGo4FitModelGauss2:: invalid Sig1 value" << std::endl; return kFALSE; }
00048 Par_ro = GetPar(5)->GetValue()/Par_sig1/Par_sig2;
00049 Par_mult = -0.5/(1.-Par_ro*Par_ro);
00050
00051 if ((fiNaxis1>=ndim) || (fiNaxis2>=ndim))
00052 { std::cout << " TGo4FitModelGauss2:: invalid index value" << std::endl; return kFALSE; }
00053 return kTRUE;
00054 }
00055
00056 Double_t TGo4FitModelGauss2::EvalN(const Double_t* v) {
00057 Double_t x1 = (v[fiNaxis1]-Par_mu1)/Par_sig1;
00058 Double_t x2 = (v[fiNaxis2]-Par_mu2)/Par_sig2;
00059 Double_t z = Par_mult*(x1*x1-2*Par_ro*x1*x2+x2*x2);
00060 return TMath::Exp(z);
00061 }
00062
00063 void TGo4FitModelGauss2::Print(Option_t* option) const
00064 {
00065 TGo4FitModel::Print(option);
00066 std::cout << " 2-dimensional Gauss for axis " << fiNaxis1 << " & " << fiNaxis2 << std::endl;
00067 }