00001 // $Id: TGo4FitMatrixTrans.cxx 933 2013-01-29 15:27:58Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "TGo4FitMatrixTrans.h" 00015 00016 #include "Riostream.h" 00017 #include "TArrayD.h" 00018 #include "TString.h" 00019 #include "TMath.h" 00020 00021 #include "TGo4FitParameter.h" 00022 00023 TGo4FitMatrixTrans::TGo4FitMatrixTrans() : TGo4FitAxisTrans() { 00024 00025 } 00026 00027 TGo4FitMatrixTrans::TGo4FitMatrixTrans(const char* iName, const char* iTitle, Int_t NumAxis) : 00028 TGo4FitAxisTrans(iName, iTitle) 00029 { 00030 SetNumAxis(NumAxis); 00031 } 00032 00033 TGo4FitMatrixTrans::~TGo4FitMatrixTrans() 00034 { 00035 } 00036 00037 Int_t TGo4FitMatrixTrans::GetNumAxis() 00038 { 00039 return Int_t(TMath::Sqrt(1.*NumPars())); 00040 } 00041 00042 00043 void TGo4FitMatrixTrans::SetNumAxis(Int_t NumAxis) { 00044 Int_t oldnum = GetNumAxis(); 00045 TArrayD oldzn(NumPars()); 00046 GetParsValues(oldzn.GetArray()); 00047 00048 ClearPars(); 00049 00050 for(Int_t n1=0;n1<NumAxis;n1++) 00051 for(Int_t n2=0;n2<NumAxis;n2++) { 00052 TString name("Matr"); 00053 name+="_"; name+=n1; 00054 name+="_"; name+=n2; 00055 Double_t zn = 0.; 00056 if((n1<oldnum) && (n2<oldnum)) zn = oldzn[n1*oldnum+n2]; 00057 CreatePar(name.Data(),"matrix element",zn); 00058 } 00059 } 00060 00061 void TGo4FitMatrixTrans::Transformation(Double_t* scales, Int_t naxis) { 00062 Int_t num = GetNumAxis(); 00063 if ((scales==0) || (num==0) || (naxis==0)) return; 00064 Int_t limit = num<naxis ? num : naxis; 00065 TArrayD oldscales(naxis, scales); 00066 for (Int_t n1=0;n1<limit;n1++) { 00067 Double_t sum = 0.; 00068 for (Int_t n2=0;n2<limit;n2++) 00069 sum += oldscales[n2] * GetPar(n1*num + n2)->GetValue(); 00070 scales[n1] = sum; 00071 } 00072 } 00073 00074 void TGo4FitMatrixTrans::Print(Option_t* option) const 00075 { 00076 std::cout << "Matrix transformation of scale values " << std::endl; 00077 TGo4FitAxisTrans::Print(option); 00078 }