TGo4FitModelGauss2.cxx

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

Generated on Thu Oct 28 15:54:12 2010 for Go4-Fitpackagev4.04-2 by  doxygen 1.5.1