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