GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitModelGauss2.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitModelGauss2.cxx 2769 2020-04-16 14:54:23Z 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 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 
40 Bool_t TGo4FitModelGauss2::BeforeEval(Int_t ndim) {
41  Par_mu1 = GetPar(1)->GetValue();
42  Par_mu2 = GetPar(2)->GetValue();
43  Par_sig1 = GetPar(3)->GetValue();
44  if (Par_sig1==0.)
45  { std::cout << " TGo4FitModelGauss2:: invalid Sig0 value" << std::endl; return kFALSE; }
46  Par_sig2 = GetPar(4)->GetValue();
47  if (Par_sig2==0.)
48  { std::cout << " TGo4FitModelGauss2:: invalid Sig1 value" << std::endl; return kFALSE; }
50  Par_mult = -0.5/(1.-Par_ro*Par_ro);
51 
52  if ((fiNaxis1>=ndim) || (fiNaxis2>=ndim))
53  { std::cout << " TGo4FitModelGauss2:: invalid index value" << std::endl; return kFALSE; }
54  return kTRUE;
55 }
56 
57 Double_t TGo4FitModelGauss2::EvalN(const Double_t* v) {
58  Double_t x1 = (v[fiNaxis1]-Par_mu1)/Par_sig1;
59  Double_t x2 = (v[fiNaxis2]-Par_mu2)/Par_sig2;
60  Double_t z = Par_mult*(x1*x1-2*Par_ro*x1*x2+x2*x2);
61  return TMath::Exp(z);
62 }
63 
64 void TGo4FitModelGauss2::Print(Option_t* option) const
65 {
66  TGo4FitModel::Print(option);
67  std::cout << " 2-dimensional Gauss for axis " << fiNaxis1 << " & " << fiNaxis2 << std::endl;
68 }
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)