TGo4FitLinearTrans.cxx

Go to the documentation of this file.
00001 // $Id: TGo4FitLinearTrans.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 "TGo4FitLinearTrans.h"
00015 
00016 #include "Riostream.h"
00017 
00018 #include "TGo4FitParameter.h"
00019 
00020 TGo4FitLinearTrans::TGo4FitLinearTrans() : TGo4FitAxisTrans() {
00021 }
00022 
00023 TGo4FitLinearTrans::TGo4FitLinearTrans(const char* iName, const char* iTitle, Int_t iAxis) :
00024  TGo4FitAxisTrans(iName, iTitle), fiAxis(iAxis) {
00025    TGo4FitParameter* par = new TGo4FitParameter("CoefK","linear coefficient of calibration", 1.);
00026    par->SetFixed(kTRUE);
00027    AddPar(par);
00028 
00029    par = new TGo4FitParameter("CoefB","constant value of calibration", 0.);
00030    par->SetFixed(kTRUE);
00031    AddPar(par);
00032 }
00033 
00034 TGo4FitLinearTrans::~TGo4FitLinearTrans() {
00035 }
00036 
00037 void TGo4FitLinearTrans::SetCoefByRange(Int_t nbins, Double_t y1, Double_t y2) {
00038   Double_t k = (nbins>0) ? (y2-y1) / nbins : 0.;
00039   SetCoef(k,y1);
00040 }
00041 
00042 void TGo4FitLinearTrans::SetCoefByPoints(Double_t n1, Double_t y1, Double_t n2, Double_t y2) {
00043   Double_t k = (n2-n1 != 0.) ? (y2-y1) / (n2 - n1) : 0.;
00044   Double_t b = y1 - fdCoefK * n1;
00045   SetCoef(k,b);
00046 }
00047 
00048 void TGo4FitLinearTrans::Transformation(Double_t* scales, Int_t naxis) {
00049   if ((scales!=0) && (naxis>GetAxis()))
00050     scales[GetAxis()] = GetCoefK() * scales[GetAxis()] + GetCoefB();
00051 }
00052 
00053 void TGo4FitLinearTrans::Print(Option_t* option) const {
00054    cout << "Linear transformation of " << fiAxis << " axis" << endl;
00055    TGo4FitAxisTrans::Print(option);
00056 }

Generated on Thu Oct 28 15:54:12 2010 for Go4-Fitpackagev4.04-2 by  doxygen 1.5.1