GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitModelGauss2.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitModelGauss2.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 "TGo4FitModelGauss2.h"
15 
16 #include "Riostream.h"
17 #include "TMath.h"
18 
19 #include "TGo4FitParameter.h"
20 
21 TGo4FitModelGauss2::TGo4FitModelGauss2() : TGo4FitModel(), fiNaxis1(0), fiNaxis2(1) {
22 }
23 
24 TGo4FitModelGauss2::TGo4FitModelGauss2(const char* iName, Double_t iPos1, Double_t iPos2,
25  Double_t iWidth1, Double_t iWidth2, Double_t iCov12,
26  Int_t iNaxis1, Int_t iNaxis2) :
27  TGo4FitModel(iName,"2-dimensional Gaussian", kTRUE), fiNaxis1(iNaxis1), fiNaxis2(iNaxis2) {
28  NewParameter("Pos0","2D gaussian position 1",iPos1);
29  NewParameter("Pos1","2D gaussian position 2",iPos2);
30  NewParameter("Width0","2D gaussian width 1",iWidth1);
31  NewParameter("Width1","2D gaussian width 2",iWidth2);
32  NewParameter("Cov0_1","2D gaussian covariation",iCov12);
33 }
34 
36 }
37 
38 
39 Bool_t TGo4FitModelGauss2::BeforeEval(Int_t ndim) {
40  Par_mu1 = GetPar(1)->GetValue();
41  Par_mu2 = GetPar(2)->GetValue();
42  Par_sig1 = GetPar(3)->GetValue();
43  if (Par_sig1==0.)
44  { std::cout << " TGo4FitModelGauss2:: invalid Sig0 value" << std::endl; return kFALSE; }
45  Par_sig2 = GetPar(4)->GetValue();
46  if (Par_sig2==0.)
47  { std::cout << " TGo4FitModelGauss2:: invalid Sig1 value" << std::endl; return kFALSE; }
49  Par_mult = -0.5/(1.-Par_ro*Par_ro);
50 
51  if ((fiNaxis1>=ndim) || (fiNaxis2>=ndim))
52  { std::cout << " TGo4FitModelGauss2:: invalid index value" << std::endl; return kFALSE; }
53  return kTRUE;
54 }
55 
56 Double_t TGo4FitModelGauss2::EvalN(const Double_t* v) {
57  Double_t x1 = (v[fiNaxis1]-Par_mu1)/Par_sig1;
58  Double_t x2 = (v[fiNaxis2]-Par_mu2)/Par_sig2;
59  Double_t z = Par_mult*(x1*x1-2*Par_ro*x1*x2+x2*x2);
60  return TMath::Exp(z);
61 }
62 
63 void TGo4FitModelGauss2::Print(Option_t* option) const
64 {
65  TGo4FitModel::Print(option);
66  std::cout << " 2-dimensional Gauss for axis " << fiNaxis1 << " & " << fiNaxis2 << std::endl;
67 }
virtual Double_t EvalN(const Double_t *v)
TGo4FitParameter * GetPar(Int_t n)
TGo4FitParameter * NewParameter(const char *Name, const char *Title, Double_t iValue=0., Bool_t Fixed=kFALSE, Int_t AtIndx=-1)
virtual void Print(Option_t *option) const
virtual void Print(Option_t *option) const
Double_t GetValue() const
virtual Bool_t BeforeEval(Int_t ndim)