Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4FitModelGauss2.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE 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 "Riostream.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    Par_mu1 = GetPar(1)->GetValue();
00044    Par_mu2 = GetPar(2)->GetValue();
00045    Par_sig1 = GetPar(3)->GetValue();
00046    if (Par_sig1==0.)
00047      { cout << " TGo4FitModelGauss2:: invalid Sig0 value" << endl; return kFALSE; }
00048    Par_sig2 = GetPar(4)->GetValue();
00049    if (Par_sig2==0.)
00050      { cout << " TGo4FitModelGauss2:: invalid Sig1 value" << endl; return kFALSE; }
00051    Par_ro = GetPar(5)->GetValue()/Par_sig1/Par_sig2;
00052    Par_mult = -0.5/(1.-Par_ro*Par_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]-Par_mu1)/Par_sig1;
00061    Double_t x2 = (v[fiNaxis2]-Par_mu2)/Par_sig2;
00062    Double_t z = Par_mult*(x1*x1-2*Par_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 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:12 2008 for Go4-v3.04-1 by  doxygen 1.4.2