TGo4FitModelFunction Class Reference

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

#include <TGo4FitModelFunction.h>

Inheritance diagram for TGo4FitModelFunction:

TGo4FitModel TGo4FitComponent TGo4FitParsList TGo4FitSlotList TGo4FitNamed List of all members.

Public Member Functions

 TGo4FitModelFunction ()
 Default constructor.
 TGo4FitModelFunction (const char *iName, TUserFunction iUserFunction, Int_t iNPars, Bool_t AddAmplitude=kFALSE)
 Creates TGo4FitModelFunction object with specified name.
 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.
virtual ~TGo4FitModelFunction ()
 Destroys TGo4FitModelFunction object.
virtual Bool_t CanAmplTouch ()
 Signals, that amplitude parameter can be removed from or introduced to object.
void SetUserFunction (TUserFunction iUserFunction)
 Set address to user function.
void SetUserFunction (const char *iLibraryName, const char *iFunctionName)
 Set library file name and function name.
const char * GetLibraryName ()
 Returns libraray name.
void SetLibraryName (const char *name)
 Sets libraray name.
const char * GetFunctionName ()
 Returns function name in library.
void SetFunctionName (const char *name)
 Sets function name in library.
Int_t GetNumberOfFuncPar ()
 Returns number of parameter, which can be used by function.
Bool_t SetNumberOfFuncPar (Int_t num)
 Sets number of parameters, which can be used by function.
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)
 Preapre object to evaluations.
virtual void AfterEval ()
 Clear buffers, which were created by BeforeEval() method.
virtual void Print (Option_t *option) const
 Print information about model object on standard output.

Protected Member Functions

virtual Bool_t Initialize (Int_t UseBuffers=-1)
 Initialize object.
virtual void Finalize ()
 Finalize object.
virtual TString GetFuncParName (Int_t n)
TGo4FitParameterGetFuncPar (Int_t n)
virtual Int_t GetPosParIndex (Int_t naxis)
 Return index of parameter (if exist), which represent position of model for given axis.
virtual Int_t GetWidthParIndex (Int_t naxis)
 Return index of parameter (if exist), which represent width of model component for given axis.
virtual Double_t UserFunction (Double_t *Coordinates, Double_t *Parameters)
 Another place, where user specific code can be placed for model values calculation.
Bool_t LoadLibrary (Bool_t CloseFirst)
void CloseLibrary ()

Protected Attributes

TString fxLibraryName
 String with library name, where function is situated.
TString fxFunctionName
 Function name.
TArrayI fxPosIndex
TArrayI fxWidthIndex

Private Attributes

TUserFunction fxUserFunction
 Direct pointer on function.
void * fxLibrary
 Pointer on loaded library descriptor.

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

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::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.

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

Returns libraray name.

Definition at line 89 of file TGo4FitModelFunction.h.

References fxLibraryName.

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

Sets libraray name.

Definition at line 94 of file TGo4FitModelFunction.h.

References fxLibraryName.

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

Returns function name in library.

Definition at line 99 of file TGo4FitModelFunction.h.

References fxFunctionName.

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

Sets function name in library.

Definition at line 104 of file TGo4FitModelFunction.h.

References fxFunctionName.

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 TGo4FitParsList::NumPars().

Referenced by GetFuncPar(), and SetNumberOfFuncPar().

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::SetWidthParIndex ( Int_t  naxis,
Int_t  indx = -1 
)

Definition at line 109 of file TGo4FitModelFunction.cxx.

References fxWidthIndex.

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().

void TGo4FitModelFunction::AfterEval (  )  [virtual]

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

Reimplemented from TGo4FitModel.

Definition at line 157 of file TGo4FitModelFunction.cxx.

References TGo4FitModel::AfterEval().

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, fxWidthIndex, and TGo4FitModel::Print().

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 TGo4FitModel::Initialize(), and LoadLibrary().

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(), and TGo4FitModel::Finalize().

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

Definition at line 132 of file TGo4FitModelFunction.cxx.

Referenced by SetNumberOfFuncPar(), and TGo4FitModelFunction().

TGo4FitParameter * TGo4FitModelFunction::GetFuncPar ( Int_t  n  )  [protected]

Definition at line 76 of file TGo4FitModelFunction.cxx.

References TGo4FitComponent::GetAmplIndex(), GetNumberOfFuncPar(), and TGo4FitParsList::GetPar().

Referenced by GetPosParIndex(), GetWidthParIndex(), and SetNumberOfFuncPar().

Int_t TGo4FitModelFunction::GetPosParIndex ( Int_t  naxis  )  [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  naxis  )  [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().

Double_t TGo4FitModelFunction::UserFunction ( Double_t *  Coordinates,
Double_t *  Parameters 
) [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.

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::CloseLibrary (  )  [protected]

Definition at line 197 of file TGo4FitModelFunction.cxx.

References fxLibrary.

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


Member Data Documentation

TString TGo4FitModelFunction::fxLibraryName [protected]

String with library name, where function is situated.

Definition at line 156 of file TGo4FitModelFunction.h.

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

TString TGo4FitModelFunction::fxFunctionName [protected]

Function name.

Definition at line 161 of file TGo4FitModelFunction.h.

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

TArrayI TGo4FitModelFunction::fxPosIndex [protected]

Definition at line 163 of file TGo4FitModelFunction.h.

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

TArrayI TGo4FitModelFunction::fxWidthIndex [protected]

Definition at line 165 of file TGo4FitModelFunction.h.

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

TUserFunction TGo4FitModelFunction::fxUserFunction [private]

Direct pointer on function.

Definition at line 172 of file TGo4FitModelFunction.h.

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

void* TGo4FitModelFunction::fxLibrary [private]

Pointer on loaded library descriptor.

Definition at line 177 of file TGo4FitModelFunction.h.

Referenced by CloseLibrary(), and LoadLibrary().


The documentation for this class was generated from the following files:
Generated on Thu Oct 28 15:54:21 2010 for Go4-Fitpackagev4.04-2 by  doxygen 1.5.1