GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitLinearTrans.cxx
Go to the documentation of this file.
1 // $Id$
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 fuer 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 <iostream>
17 
18 #include "TGo4FitParameter.h"
19 
21 
22 TGo4FitLinearTrans::TGo4FitLinearTrans(const char *iName, const char *iTitle, Int_t iAxis) :
23  TGo4FitAxisTrans(iName, iTitle), fiAxis(iAxis)
24 {
25  TGo4FitParameter *par = new TGo4FitParameter("CoefK","linear coefficient of calibration", 1.);
26  par->SetFixed(kTRUE);
27  AddPar(par);
28 
29  par = new TGo4FitParameter("CoefB","constant value of calibration", 0.);
30  par->SetFixed(kTRUE);
31  AddPar(par);
32 }
33 
35 }
36 
37 void TGo4FitLinearTrans::SetCoefByRange(Int_t nbins, Double_t y1, Double_t y2) {
38  Double_t k = (nbins>0) ? (y2-y1) / nbins : 0.;
39  SetCoef(k,y1);
40 }
41 
42 void TGo4FitLinearTrans::SetCoefByPoints(Double_t n1, Double_t y1, Double_t n2, Double_t y2) {
43  Double_t k = (n2-n1 != 0.) ? (y2-y1) / (n2 - n1) : 0.;
44  Double_t b = y1 - fdCoefK * n1;
45  SetCoef(k,b);
46 }
47 
48 void TGo4FitLinearTrans::Transformation(Double_t *scales, Int_t naxis)
49 {
50  if (scales && (naxis > GetAxis()))
51  scales[GetAxis()] = GetCoefK() * scales[GetAxis()] + GetCoefB();
52 }
53 
54 void TGo4FitLinearTrans::Print(Option_t *option) const
55 {
56  std::cout << "Linear transformation of " << fiAxis << " axis" << std::endl;
58 }
void Transformation(Double_t *scales, Int_t naxis) override
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 Print(Option_t *option="") const override
void Print(Option_t *option="") const override
void SetFixed(Bool_t iFixed)
TGo4FitParameter * AddPar(TGo4FitParameter *par)