Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4Fit/TGo4FitLinearTrans.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4FitLinearTrans.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TGo4FitParameter.h"
00021 
00022 TGo4FitLinearTrans::TGo4FitLinearTrans() : TGo4FitAxisTrans() {
00023 }
00024 
00025 TGo4FitLinearTrans::TGo4FitLinearTrans(const char* iName, const char* iTitle, Int_t iAxis) :
00026  TGo4FitAxisTrans(iName, iTitle), fiAxis(iAxis) {
00027    TGo4FitParameter* par = new TGo4FitParameter("CoefK","linear coefficient of calibration", 1.);
00028    par->SetFixed(kTRUE);
00029    AddPar(par);
00030 
00031    par = new TGo4FitParameter("CoefB","constant value of calibration", 0.);
00032    par->SetFixed(kTRUE);
00033    AddPar(par);
00034 }
00035 
00036 TGo4FitLinearTrans::~TGo4FitLinearTrans() {
00037 }
00038 
00039 void TGo4FitLinearTrans::SetCoefByRange(Int_t nbins, Double_t y1, Double_t y2) {
00040   Double_t k = (nbins>0) ? (y2-y1) / nbins : 0.;
00041   SetCoef(k,y1);
00042 }
00043 
00044 void TGo4FitLinearTrans::SetCoefByPoints(Double_t n1, Double_t y1, Double_t n2, Double_t y2) {
00045   Double_t k = (n2-n1 != 0.) ? (y2-y1) / (n2 - n1) : 0.;
00046   Double_t b = y1 - fdCoefK * n1;
00047   SetCoef(k,b);
00048 }
00049 
00050 void TGo4FitLinearTrans::Transformation(Double_t* scales, Int_t naxis) {
00051   if ((scales!=0) && (naxis>GetAxis()))
00052     scales[GetAxis()] = GetCoefK() * scales[GetAxis()] + GetCoefB();
00053 }
00054 
00055 void TGo4FitLinearTrans::Print(Option_t* option) const {
00056    cout << "Linear transformation of " << fiAxis << " axis" << endl;
00057    TGo4FitAxisTrans::Print(option);
00058 }
00059 
00060 ClassImp(TGo4FitLinearTrans)
00061 
00062 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:56 2005 for Go4-v2.10-5 by doxygen1.2.15