GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
24
25TGo4FitModelGauss2::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
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
64Double_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
72void TGo4FitModelGauss2::Print(Option_t *option) const
73{
74 TGo4FitModel::Print(option);
75 std::cout << " 2-dimensional Gauss for axis " << fiNaxis1 << " & " << fiNaxis2 << std::endl;
76}
TGo4FitParameter * NewParameter(const char *Name, const char *Title, Double_t iValue=0., Bool_t Fixed=kFALSE, Int_t AtIndx=-1)
Create new parameter with provided properties and add to parameters list.
void Print(Option_t *option="") const override
Prints information to standard output.
Double_t Par_sig2
Temporary variable for EvalN() function.
Double_t Par_mu2
Temporary variable for EvalN() function.
Double_t Par_ro
Temporary variable for EvalN() function.
Double_t Par_sig1
Temporary variable for EvalN() function.
Int_t fiNaxis2
Number of second selected axis.
Bool_t BeforeEval(Int_t ndim) override
Prepares (if necessary) some intermediate variables to be able calculate values of model via EvalN() ...
TGo4FitModelGauss2()
Default constructor.
Int_t fiNaxis1
Number of first selected axis.
virtual ~TGo4FitModelGauss2()
Destroys TGo4FitModelGauss2 object.
Double_t Par_mu1
Temporary variable for EvalN() function.
Double_t EvalN(const Double_t *v) override
Calculates value of model according current parameters values and provided axes values.
Double_t Par_mult
Temporary variable for EvalN() function.
void Print(Option_t *option="") const override
Print information about model object on standard output.
TGo4FitModel()
Default constructor.
Double_t GetValue() const
Return parameter value.
TGo4FitParameter * GetPar(Int_t n)
Return parameter according given index.