GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitLinearTrans.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitLinearTrans.cxx 933 2013-01-29 15:27:58Z 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 für 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 "TGo4FitLinearTrans.h"
15 
16 #include "Riostream.h"
17 #include "TGo4FitParameter.h"
18 
20 
21 TGo4FitLinearTrans::TGo4FitLinearTrans(const char* iName, const char* iTitle, Int_t iAxis) :
22  TGo4FitAxisTrans(iName, iTitle), fiAxis(iAxis)
23 {
24  TGo4FitParameter* par = new TGo4FitParameter("CoefK","linear coefficient of calibration", 1.);
25  par->SetFixed(kTRUE);
26  AddPar(par);
27 
28  par = new TGo4FitParameter("CoefB","constant value of calibration", 0.);
29  par->SetFixed(kTRUE);
30  AddPar(par);
31 }
32 
34 }
35 
36 void TGo4FitLinearTrans::SetCoefByRange(Int_t nbins, Double_t y1, Double_t y2) {
37  Double_t k = (nbins>0) ? (y2-y1) / nbins : 0.;
38  SetCoef(k,y1);
39 }
40 
41 void TGo4FitLinearTrans::SetCoefByPoints(Double_t n1, Double_t y1, Double_t n2, Double_t y2) {
42  Double_t k = (n2-n1 != 0.) ? (y2-y1) / (n2 - n1) : 0.;
43  Double_t b = y1 - fdCoefK * n1;
44  SetCoef(k,b);
45 }
46 
47 void TGo4FitLinearTrans::Transformation(Double_t* scales, Int_t naxis) {
48  if ((scales!=0) && (naxis>GetAxis()))
49  scales[GetAxis()] = GetCoefK() * scales[GetAxis()] + GetCoefB();
50 }
51 
52 void TGo4FitLinearTrans::Print(Option_t* option) const {
53  std::cout << "Linear transformation of " << fiAxis << " axis" << std::endl;
55 }
virtual void Transformation(Double_t *scales, Int_t naxis)
virtual void Print(Option_t *option) const
void SetCoef(Double_t iCoefK, Double_t iCoefB)
void SetCoefByPoints(Double_t n1, Double_t y1, Double_t n2, Double_t y2)
void SetCoefByRange(Int_t nbins, Double_t y1, Double_t y2)
void SetFixed(Bool_t iFixed)
virtual void Print(Option_t *option) const
TGo4FitParameter * AddPar(TGo4FitParameter *par)