00001 // $Id: TGo4FitMatrixTrans.cxx 478 2009-10-29 12:26:09Z 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 00018 #include "TArrayD.h" 00019 #include "TString.h" 00020 #include "TMath.h" 00021 00022 #include "TGo4FitParameter.h" 00023 00024 TGo4FitMatrixTrans::TGo4FitMatrixTrans() : TGo4FitAxisTrans() { 00025 00026 } 00027 00028 TGo4FitMatrixTrans::TGo4FitMatrixTrans(const char* iName, const char* iTitle, Int_t NumAxis) : 00029 TGo4FitAxisTrans(iName, iTitle) 00030 { 00031 SetNumAxis(NumAxis); 00032 } 00033 00034 TGo4FitMatrixTrans::~TGo4FitMatrixTrans() 00035 { 00036 } 00037 00038 Int_t TGo4FitMatrixTrans::GetNumAxis() 00039 { 00040 return Int_t(TMath::Sqrt(1.*NumPars())); 00041 } 00042 00043 00044 void TGo4FitMatrixTrans::SetNumAxis(Int_t NumAxis) { 00045 Int_t oldnum = GetNumAxis(); 00046 TArrayD oldzn(NumPars()); 00047 GetParsValues(oldzn.GetArray()); 00048 00049 ClearPars(); 00050 00051 for(Int_t n1=0;n1<NumAxis;n1++) 00052 for(Int_t n2=0;n2<NumAxis;n2++) { 00053 TString name("Matr"); 00054 name+="_"; name+=n1; 00055 name+="_"; name+=n2; 00056 Double_t zn = 0.; 00057 if((n1<oldnum) && (n2<oldnum)) zn = oldzn[n1*oldnum+n2]; 00058 CreatePar(name.Data(),"matrix element",zn); 00059 } 00060 } 00061 00062 void TGo4FitMatrixTrans::Transformation(Double_t* scales, Int_t naxis) { 00063 Int_t num = GetNumAxis(); 00064 if ((scales==0) || (num==0) || (naxis==0)) return; 00065 Int_t limit = num<naxis ? num : naxis; 00066 TArrayD oldscales(naxis, scales); 00067 for (Int_t n1=0;n1<limit;n1++) { 00068 Double_t sum = 0.; 00069 for (Int_t n2=0;n2<limit;n2++) 00070 sum += oldscales[n2] * GetPar(n1*num + n2)->GetValue(); 00071 scales[n1] = sum; 00072 } 00073 } 00074 00075 void TGo4FitMatrixTrans::Print(Option_t* option) const { 00076 cout << "Matrix transformation of scale values " << endl; 00077 TGo4FitAxisTrans::Print(option); 00078 }