GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitMatrixTrans.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 "TGo4FitMatrixTrans.h"
15 
16 #include <iostream>
17 #include "TArrayD.h"
18 #include "TString.h"
19 #include "TMath.h"
20 
21 #include "TGo4FitParameter.h"
22 
24 
25 TGo4FitMatrixTrans::TGo4FitMatrixTrans(const char *iName, const char *iTitle, Int_t NumAxis)
26  : TGo4FitAxisTrans(iName, iTitle)
27 {
28  SetNumAxis(NumAxis);
29 }
30 
32 
34 {
35  return Int_t(TMath::Sqrt(1. * NumPars()));
36 }
37 
38 void TGo4FitMatrixTrans::SetNumAxis(Int_t NumAxis)
39 {
40  Int_t oldnum = GetNumAxis();
41  TArrayD oldzn(NumPars());
42  GetParsValues(oldzn.GetArray());
43 
44  ClearPars();
45 
46  for (Int_t n1 = 0; n1 < NumAxis; n1++)
47  for (Int_t n2 = 0; n2 < NumAxis; n2++) {
48  TString name("Matr");
49  name += "_";
50  name += n1;
51  name += "_";
52  name += n2;
53  Double_t zn = 0.;
54  if ((n1 < oldnum) && (n2 < oldnum))
55  zn = oldzn[n1 * oldnum + n2];
56  CreatePar(name.Data(), "matrix element", zn);
57  }
58 }
59 
60 void TGo4FitMatrixTrans::Transformation(Double_t *scales, Int_t naxis)
61 {
62  Int_t num = GetNumAxis();
63  if (!scales || (num == 0) || (naxis == 0))
64  return;
65  Int_t limit = num < naxis ? num : naxis;
66  TArrayD oldscales(naxis, scales);
67  for (Int_t n1 = 0; n1 < limit; n1++) {
68  Double_t sum = 0.;
69  for (Int_t n2 = 0; n2 < limit; n2++)
70  sum += oldscales[n2] * GetPar(n1 * num + n2)->GetValue();
71  scales[n1] = sum;
72  }
73 }
74 
75 void TGo4FitMatrixTrans::Print(Option_t *option) const
76 {
77  std::cout << "Matrix transformation of scale values " << std::endl;
79 }
Double_t GetValue() const
void Print(Option_t *option="") const override
void SetNumAxis(Int_t NumAxis)
TGo4FitParameter * CreatePar(const char *ParName, const char *Title, Double_t iValue=0)
TGo4FitParameter * GetPar(Int_t n)
virtual Int_t NumPars()
void Transformation(Double_t *scales, Int_t naxis) override
void Print(Option_t *option="") const override
void GetParsValues(Double_t *pars)