GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitMatrixTrans.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitMatrixTrans.cxx 2749 2020-04-16 10:05:15Z 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 "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 }
26 
27 TGo4FitMatrixTrans::TGo4FitMatrixTrans(const char* iName, const char* iTitle, Int_t NumAxis) :
28  TGo4FitAxisTrans(iName, iTitle)
29 {
30  SetNumAxis(NumAxis);
31 }
32 
34 {
35 }
36 
38 {
39  return Int_t(TMath::Sqrt(1.*NumPars()));
40 }
41 
42 
43 void TGo4FitMatrixTrans::SetNumAxis(Int_t NumAxis) {
44  Int_t oldnum = GetNumAxis();
45  TArrayD oldzn(NumPars());
46  GetParsValues(oldzn.GetArray());
47 
48  ClearPars();
49 
50  for(Int_t n1=0;n1<NumAxis;n1++)
51  for(Int_t n2=0;n2<NumAxis;n2++) {
52  TString name("Matr");
53  name+="_"; name+=n1;
54  name+="_"; name+=n2;
55  Double_t zn = 0.;
56  if((n1<oldnum) && (n2<oldnum)) zn = oldzn[n1*oldnum+n2];
57  CreatePar(name.Data(),"matrix element",zn);
58  }
59 }
60 
61 void TGo4FitMatrixTrans::Transformation(Double_t* scales, Int_t naxis) {
62  Int_t num = GetNumAxis();
63  if ((scales==0) || (num==0) || (naxis==0)) return;
64  Int_t limit = num<naxis ? num : naxis;
65  TArrayD oldscales(naxis, scales);
66  for (Int_t n1=0;n1<limit;n1++) {
67  Double_t sum = 0.;
68  for (Int_t n2=0;n2<limit;n2++)
69  sum += oldscales[n2] * GetPar(n1*num + n2)->GetValue();
70  scales[n1] = sum;
71  }
72 }
73 
74 void TGo4FitMatrixTrans::Print(Option_t* option) const
75 {
76  std::cout << "Matrix transformation of scale values " << std::endl;
78 }
virtual void Transformation(Double_t *scales, Int_t naxis)
void SetNumAxis(Int_t NumAxis)
TGo4FitParameter * CreatePar(const char *ParName, const char *Title, Double_t iValue=0)
TGo4FitParameter * GetPar(Int_t n)
virtual void Print(Option_t *option) const
virtual Int_t NumPars()
virtual void Print(Option_t *option) const
Double_t GetValue() const
void GetParsValues(Double_t *pars)