Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4Fit/TGo4FitModelGauss2.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4FitModelGauss2.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TMath.h"
00021 
00022 #include "TGo4FitParameter.h"
00023 
00024 TGo4FitModelGauss2::TGo4FitModelGauss2() : TGo4FitModel(), fiNaxis1(0), fiNaxis2(1) {
00025 }
00026 
00027 TGo4FitModelGauss2::TGo4FitModelGauss2(const char* iName, Double_t iPos1, Double_t iPos2,
00028                              Double_t iWidth1, Double_t iWidth2, Double_t iCov12,
00029                              Int_t iNaxis1, Int_t iNaxis2) :
00030    TGo4FitModel(iName,"2-dimensional Gaussian", kTRUE), fiNaxis1(iNaxis1), fiNaxis2(iNaxis2) {
00031      NewParameter("Pos0","2D gaussian position 1",iPos1);
00032      NewParameter("Pos1","2D gaussian position 2",iPos2);
00033      NewParameter("Width0","2D gaussian width 1",iWidth1);
00034      NewParameter("Width1","2D gaussian width 2",iWidth2);
00035      NewParameter("Cov0_1","2D gaussian covariation",iCov12);
00036 }
00037 
00038 TGo4FitModelGauss2::~TGo4FitModelGauss2() {
00039 }
00040 
00041 
00042 Bool_t TGo4FitModelGauss2::BeforeEval(Int_t ndim) {
00043    mu1 = GetPar(1)->GetValue();
00044    mu2 = GetPar(2)->GetValue();
00045    sig1 = GetPar(3)->GetValue();
00046    if (sig1==0.)
00047      { cout << " TGo4FitModelGauss2:: invalid Sig0 value" << endl; return kFALSE; }
00048    sig2 = GetPar(4)->GetValue();
00049    if (sig2==0.)
00050      { cout << " TGo4FitModelGauss2:: invalid Sig1 value" << endl; return kFALSE; }
00051    ro = GetPar(5)->GetValue()/sig1/sig2;
00052    mult = -0.5/(1.-ro*ro);
00053 
00054    if ((fiNaxis1>=ndim) || (fiNaxis2>=ndim))
00055      { cout << " TGo4FitModelGauss2:: invalid index value" << endl; return kFALSE; }
00056    return kTRUE;
00057 }
00058 
00059 Double_t TGo4FitModelGauss2::EvalN(const Double_t* v) {
00060    Double_t x1 = (v[fiNaxis1]-mu1)/sig1;
00061    Double_t x2 = (v[fiNaxis2]-mu2)/sig2;
00062    Double_t z = mult*(x1*x1-2*ro*x1*x2+x2*x2);
00063    return TMath::Exp(z);
00064 }
00065 
00066 void TGo4FitModelGauss2::Print(Option_t* option) const {
00067     TGo4FitModel::Print(option);
00068     cout << "   2-dimensional Gauss for axis " << fiNaxis1 << " & " << fiNaxis2 << endl;
00069 }
00070 
00071 ClassImp(TGo4FitModelGauss2)
00072 
00073 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:56 2005 for Go4-v2.10-5 by doxygen1.2.15