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