Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes

TGo4FitModelFunction Class Reference

#include <TGo4FitModelFunction.h>

Inheritance diagram for TGo4FitModelFunction:
TGo4FitModel TGo4FitComponent TGo4FitParsList TGo4FitSlotList TGo4FitNamed

List of all members.

Public Member Functions

 TGo4FitModelFunction ()
 TGo4FitModelFunction (const char *iName, TUserFunction iUserFunction, Int_t iNPars, Bool_t AddAmplitude=kFALSE)
 TGo4FitModelFunction (const char *iName, const char *iLibraryName="libName.so", const char *iFunctionName="Funcname", Int_t iNPars=0, Bool_t AddAmplitude=kFALSE)
virtual ~TGo4FitModelFunction ()
virtual Bool_t CanAmplTouch ()
void SetUserFunction (TUserFunction iUserFunction)
void SetUserFunction (const char *iLibraryName, const char *iFunctionName)
const char * GetLibraryName ()
void SetLibraryName (const char *name)
const char * GetFunctionName ()
void SetFunctionName (const char *name)
Int_t GetNumberOfFuncPar ()
Bool_t SetNumberOfFuncPar (Int_t num)
void SetPosParIndex (Int_t naxis, Int_t indx=-1)
void SetWidthParIndex (Int_t naxis, Int_t indx=-1)
virtual Bool_t BeforeEval (Int_t ndim)
virtual void AfterEval ()
virtual void Print (Option_t *option) const

Protected Member Functions

virtual Bool_t Initialize (Int_t UseBuffers=-1)
virtual void Finalize ()
virtual TString GetFuncParName (Int_t n)
TGo4FitParameterGetFuncPar (Int_t n)
virtual Int_t GetPosParIndex (Int_t naxis)
virtual Int_t GetWidthParIndex (Int_t naxis)
virtual Double_t UserFunction (Double_t *Coordinates, Double_t *Parameters)
Bool_t LoadLibrary (Bool_t CloseFirst)
void CloseLibrary ()

Protected Attributes

TString fxLibraryName
TString fxFunctionName
TArrayI fxPosIndex
TArrayI fxWidthIndex

Private Attributes

TUserFunction fxUserFunction
void * fxLibrary

Detailed Description

Model objects, which uses external user function to calculate model values.

The function should has such signature:

Double_t Func(Double_t* coord, Int_t ncoord, Double_t* pars, Int_t npars) { // coord - array of axis values, ncoord - number of axis values // pars - model parameters values, npars - number of parameters return (coord[0]-pars[0])*(coord[1]-pars[1])*(coord[2]-pars[2]); } In constructer user should define name and title of object, pointer to user function, number of parameters and, optionally, using additional amplitude parameters. For instance, user function with three parameters and amplitude:

TGo4FitModelFunction *f = new TGo4FitModelFunction("func", "user function Func",&Func, 3, kTRUE);

In constructor "Par0", "Par1", "Par2" and "Ampl" parameters will be created. They are accessible in usual way from fitter or model object itself. Important notice - this model object can not be saved to file and restored in proper way, because address of user function may change in between. To correctly use this object after saving and restoring routines, user should directly set address of user function to TGo4FitModelFunction object (SetUserFunction() method) before using it. Otherwise, run-time error will occur. To avoid this user should create it's own model class (see example 4) or put function to shared library (example 2). If shared library is created, it can be used in constructor like:

new TGo4FitModelFunction("Gauss1", "Example8Func.so", "gaussian",3,kTRUE) );

During initialization routine library will be loaded and function will be used for modeling. In this case, if library will be present on the same location, model object can be reused directly after storing to file and reading it back.

Definition at line 43 of file TGo4FitModelFunction.h.


Constructor & Destructor Documentation

TGo4FitModelFunction::TGo4FitModelFunction (  ) 

Default constructor.

Definition at line 26 of file TGo4FitModelFunction.cxx.

TGo4FitModelFunction::TGo4FitModelFunction ( const char *  iName,
TUserFunction  iUserFunction,
Int_t  iNPars,
Bool_t  AddAmplitude = kFALSE 
)

Creates TGo4FitModelFunction object with specified name. Pointer on function and number of parameters should be specified. Additionally usage of amplitude parameter can be invoked. !!! Pointer on function, specidied in this method, can not be correctly restored from streamer. Therefore, object can not be directly reused after streaming. SetUserFunction() should be called before.

Definition at line 30 of file TGo4FitModelFunction.cxx.

References GetFuncParName(), and TGo4FitComponent::NewParameter().

TGo4FitModelFunction::TGo4FitModelFunction ( const char *  iName,
const char *  iLibraryName = "libName.so",
const char *  iFunctionName = "Funcname",
Int_t  iNPars = 0,
Bool_t  AddAmplitude = kFALSE 
)

Creates TGo4FitModelFunction object with specified name. Library and function name can be specified. Additionally usage of amplitude parameter can be invoked.

Definition at line 39 of file TGo4FitModelFunction.cxx.

References GetFuncParName(), and TGo4FitComponent::NewParameter().

TGo4FitModelFunction::~TGo4FitModelFunction (  )  [virtual]

Destroys TGo4FitModelFunction object.

Definition at line 48 of file TGo4FitModelFunction.cxx.

References CloseLibrary().


Member Function Documentation

void TGo4FitModelFunction::AfterEval (  )  [virtual]

Clear buffers, which were created by BeforeEval() method.

Reimplemented from TGo4FitModel.

Definition at line 157 of file TGo4FitModelFunction.cxx.

Bool_t TGo4FitModelFunction::BeforeEval ( Int_t  ndim  )  [virtual]

Preapre object to evaluations. When usage of function from library is specified, library will be loaded at this time.

Reimplemented from TGo4FitModel.

Definition at line 151 of file TGo4FitModelFunction.cxx.

References TGo4FitModel::BeforeEval(), and LoadLibrary().

virtual Bool_t TGo4FitModelFunction::CanAmplTouch (  )  [inline, virtual]

Signals, that amplitude parameter can be removed from or introduced to object.

Reimplemented from TGo4FitComponent.

Definition at line 73 of file TGo4FitModelFunction.h.

void TGo4FitModelFunction::CloseLibrary (  )  [protected]

Definition at line 197 of file TGo4FitModelFunction.cxx.

References fxLibrary.

Referenced by Finalize(), LoadLibrary(), SetUserFunction(), and ~TGo4FitModelFunction().

void TGo4FitModelFunction::Finalize (  )  [protected, virtual]

Finalize object. Close library, if it was opened.

Reimplemented from TGo4FitModel.

Definition at line 145 of file TGo4FitModelFunction.cxx.

References CloseLibrary().

TGo4FitParameter * TGo4FitModelFunction::GetFuncPar ( Int_t  n  )  [protected]
TString TGo4FitModelFunction::GetFuncParName ( Int_t  n  )  [protected, virtual]

Definition at line 132 of file TGo4FitModelFunction.cxx.

Referenced by SetNumberOfFuncPar(), and TGo4FitModelFunction().

const char* TGo4FitModelFunction::GetFunctionName (  )  [inline]

Returns function name in library.

Definition at line 99 of file TGo4FitModelFunction.h.

References fxFunctionName.

Referenced by TGo4FitPanel::Wiz_GetModelInfo().

const char* TGo4FitModelFunction::GetLibraryName (  )  [inline]

Returns libraray name.

Definition at line 89 of file TGo4FitModelFunction.h.

References fxLibraryName.

Referenced by TGo4FitPanel::Wiz_GetModelInfo().

Int_t TGo4FitModelFunction::GetNumberOfFuncPar (  ) 

Returns number of parameter, which can be used by function.

Definition at line 69 of file TGo4FitModelFunction.cxx.

References TGo4FitComponent::GetAmplPar(), and TGo4FitModel::NumPars().

Referenced by GetFuncPar(), and SetNumberOfFuncPar().

Int_t TGo4FitModelFunction::GetPosParIndex ( Int_t   )  [protected, virtual]

Return index of parameter (if exist), which represent position of model for given axis.

Reimplemented from TGo4FitModel.

Definition at line 120 of file TGo4FitModelFunction.cxx.

References fxPosIndex, GetFuncPar(), and TGo4FitParsList::GetParIndex().

Int_t TGo4FitModelFunction::GetWidthParIndex ( Int_t   )  [protected, virtual]

Return index of parameter (if exist), which represent width of model component for given axis.

Reimplemented from TGo4FitModel.

Definition at line 126 of file TGo4FitModelFunction.cxx.

References fxWidthIndex, GetFuncPar(), and TGo4FitParsList::GetParIndex().

Bool_t TGo4FitModelFunction::Initialize ( Int_t  UseBuffers = -1  )  [protected, virtual]

Initialize object. When usage of function from library is specified, library will be loaded at this time.

Reimplemented from TGo4FitModel.

Definition at line 139 of file TGo4FitModelFunction.cxx.

References LoadLibrary().

Bool_t TGo4FitModelFunction::LoadLibrary ( Bool_t  CloseFirst  )  [protected]

Definition at line 170 of file TGo4FitModelFunction.cxx.

References CloseLibrary(), fxFunctionName, fxLibrary, fxLibraryName, and fxUserFunction.

Referenced by BeforeEval(), and Initialize().

void TGo4FitModelFunction::Print ( Option_t *  option  )  const [virtual]

Print information about model object on standard output.

Reimplemented from TGo4FitModel.

Definition at line 224 of file TGo4FitModelFunction.cxx.

References fxFunctionName, fxLibraryName, fxPosIndex, fxUserFunction, and fxWidthIndex.

void TGo4FitModelFunction::SetFunctionName ( const char *  name  )  [inline]

Sets function name in library.

Definition at line 104 of file TGo4FitModelFunction.h.

References fxFunctionName.

Referenced by QFitModelFunctionWidget::FuncNameEdt_textChanged().

void TGo4FitModelFunction::SetLibraryName ( const char *  name  )  [inline]

Sets libraray name.

Definition at line 94 of file TGo4FitModelFunction.h.

References fxLibraryName.

Referenced by QFitModelFunctionWidget::LibNameEdt_textChanged().

Bool_t TGo4FitModelFunction::SetNumberOfFuncPar ( Int_t  num  ) 

Sets number of parameters, which can be used by function.

Definition at line 83 of file TGo4FitModelFunction.cxx.

References GetFuncPar(), GetFuncParName(), GetNumberOfFuncPar(), TGo4FitComponent::NewParameter(), and TGo4FitParsList::RemovePar().

void TGo4FitModelFunction::SetPosParIndex ( Int_t  naxis,
Int_t  indx = -1 
)

Definition at line 98 of file TGo4FitModelFunction.cxx.

References fxPosIndex.

void TGo4FitModelFunction::SetUserFunction ( TUserFunction  iUserFunction  ) 

Set address to user function.

Definition at line 53 of file TGo4FitModelFunction.cxx.

References CloseLibrary(), fxFunctionName, fxLibraryName, and fxUserFunction.

void TGo4FitModelFunction::SetUserFunction ( const char *  iLibraryName,
const char *  iFunctionName 
)

Set library file name and function name. Libraray will be loaded during initialization.

Definition at line 61 of file TGo4FitModelFunction.cxx.

References CloseLibrary(), fxFunctionName, fxLibraryName, and fxUserFunction.

void TGo4FitModelFunction::SetWidthParIndex ( Int_t  naxis,
Int_t  indx = -1 
)

Definition at line 109 of file TGo4FitModelFunction.cxx.

References fxWidthIndex.

Double_t TGo4FitModelFunction::UserFunction ( Double_t *  ,
Double_t *   
) [protected, virtual]

Another place, where user specific code can be placed for model values calculation. Function gets as parameter array of Coordinates and array of Parameters values. Only user-specific calculation should be done and result value should be return.

Reimplemented from TGo4FitModel.

Definition at line 162 of file TGo4FitModelFunction.cxx.

References fxUserFunction.


Member Data Documentation

Function name.

Definition at line 161 of file TGo4FitModelFunction.h.

Referenced by GetFunctionName(), LoadLibrary(), Print(), SetFunctionName(), and SetUserFunction().

Pointer on loaded library descriptor.

Definition at line 177 of file TGo4FitModelFunction.h.

Referenced by CloseLibrary(), and LoadLibrary().

String with library name, where function is situated.

Definition at line 156 of file TGo4FitModelFunction.h.

Referenced by GetLibraryName(), LoadLibrary(), Print(), SetLibraryName(), and SetUserFunction().

TArrayI TGo4FitModelFunction::fxPosIndex [protected]

Definition at line 163 of file TGo4FitModelFunction.h.

Referenced by GetPosParIndex(), Print(), and SetPosParIndex().

Direct pointer on function.

Definition at line 172 of file TGo4FitModelFunction.h.

Referenced by LoadLibrary(), Print(), SetUserFunction(), and UserFunction().

Definition at line 165 of file TGo4FitModelFunction.h.

Referenced by GetWidthParIndex(), Print(), and SetWidthParIndex().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines