v2.10-0 (21000JUN2005)

Go4Fit
Class TGo4FitModelFunction


class TGo4FitModelFunction
derived from TGo4FitModel

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.


Field Summary
 protected TStringfxFunctionName
          Function name.
 private void *fxLibrary
          Pointer on loaded library descriptor.
 protected TStringfxLibraryName
          String with library name, where function is situated.
 protected TArrayIfxPosIndex
           
 private TUserFunctionfxUserFunction
          Direct pointer on function.
 protected TArrayIfxWidthIndex
           

Fields inherited from class Go4Fit.TGo4FitModel
fbAbsoluteEps, fbIntegrScaling, fdIntegrEps, fiMaxIntegrDepth, fiMinIntegrDepth

Fields inherited from class TNamed
fName, fTitle

Fields inherited from class Go4Fit.TGo4FitSlotList
fbUpdateSlotList, fxSlotList

Constructor Summary
TGo4FitModelFunction()
          Default constructor.
TGo4FitModelFunction(const char * iName, TUserFunction iUserFunction, Int_t iNPars, Bool_t AddAmplitude)
          Creates TGo4FitModelFunction object with specified name.
TGo4FitModelFunction(const char * iName, const char * iLibraryName, const char * iFunctionName, Int_t iNPars, Bool_t AddAmplitude)
          Creates TGo4FitModelFunction object with specified name.

Destructor Summary
 virtual synchronized ~TGo4FitModelFunction()
          Destroys TGo4FitModelFunction object.

Method Summary
 virtual voidAfterEval()
           
 virtual Bool_tBeforeEval(Int_t ndim)
          Preapre object to evaluations.
 virtual Bool_tCanAmplTouch()
          Signals, that amplitude parameter can be removed from or introduced to object.
 protected voidCloseLibrary()
           
 protected virtual voidFinalize()
          Finalize object.
 protected TGo4FitParameter*GetFuncPar(Int_t n)
           
 protected virtual TStringGetFuncParName(Int_t n)
           
 const const char *GetFunctionName()
          Returns function name in library.
 const const char *GetLibraryName()
          Returns libraray name.
 Int_tGetNumberOfFuncPar()
          Returns number of parameter, which can be used by function.
 protected virtual Int_tGetPosParIndex(Int_t naxis)
           
 protected virtual Int_tGetWidthParIndex(Int_t naxis)
           
 protected virtual Bool_tInitialize(Int_t UseBuffers)
          Initialize object.
 protected Bool_tLoadLibrary(Bool_t CloseFirst)
           
 virtual const voidPrint(Option_t* option)
           
 voidSetFunctionName(const char * name)
          Sets function name in library.
 voidSetLibraryName(const char * name)
          Sets libraray name.
 Bool_tSetNumberOfFuncPar(Int_t num)
          Sets number of parameters, which can be used by function.
 voidSetPosParIndex(Int_t naxis, Int_t indx)
           
 voidSetUserFunction(TUserFunction iUserFunction)
          Set address to user function.
 voidSetUserFunction(const char * iLibraryName, const char * iFunctionName)
          Set library file name and function name.
 voidSetWidthParIndex(Int_t naxis, Int_t indx)
           
 protected virtual Double_tUserFunction(Double_t* Coordinates, Double_t* Parameters)
           

Methods inherited from class Go4Fit.TGo4FitModel
AddModelToDataResult, AssignmentName, AssignToData, BuffersAllocated, ChangeDataNameInAssignments, ClearAssigmentTo, ClearAssignments, ClearAssignmentTo, ConnectToDataIfAssigned, EvalN, Evaluate, Evaluate, Evaluate, Evaluate, EvaluateAndIntegrate, EvaluateAtPoint, EvaluateAtPoint, Get, GetAssignedConnection, GetDataFullIndex, GetDataIndexesSize, GetGroupIndex, GetModelBins, GetPosition, GetPosPar, GetRatioValueFor, GetWidth, GetWidthPar, Integral, IsAssignTo, NeedIntegration, NumAssigments, NumPars, RebuildShape, SetBackgroundGroupIndex, SetGroupIndex, SetIntegrationsProperty, SetNeedToRebuild, SetPosition, SetWidth

Methods inherited from class Go4Fit.TGo4FitComponent
AddRangeCondition, AddRangeCut, CheckRangeConditions, ClearRanges, CollectParsTo, ExcludeRange, GetAmplError, GetAmplFullName, GetAmplIndex, GetAmplName, GetAmplPar, GetAmplValue, GetNumRangeCondition, GetNumRangeCut, GetRangeCondition, GetRangeCut, GetRangeMax, GetRangeMin, GetUseBuffers, IsAnyRangeLimits, IsRangeCutExcluding, MakeAmpl, NewAmplitude, NewParameter, RemoveAmpl, RemoveRangeCondition, RemoveRangeCut, SetAmplError, SetAmplIndex, SetAmplValue, SetRange, SetRangeCondition, SetRangeCutExcluding, SetRangeMax, SetRangeMin, SetUseBuffers

Methods inherited from class Go4Fit.TGo4FitParsList
AddPar, CanRollbackPars, ClearPars, ClearParsBlocking, CreatePar, Find, Find, Find, FindPar, FindPar, FindPar, GetPar, GetParEpsilon, GetParError, GetParFixed, GetParFullName, GetParIndex, GetParName, GetParRange, GetParsValues, GetParValue, InsertPar, IsAllParsFixed, MemorizePars, NumFixedPars, NumFreePars, PrintPars, RememberPars, RemovePar, RemovePar, RemoveParByIndex, SetParEpsilon, SetParError, SetParFixed, SetParName, SetParRange, SetParsNames, SetParsOwner, SetParsValues, SetParsValues, SetParValue

Methods inherited from class Go4Fit.TGo4FitNamed
GetFullName, GetOwner, GetOwnerFullName, SetOwner

Methods inherited from class TNamed
operator=, Clear, Clone, Compare, Copy, FillBuffer, GetName, GetTitle, Hash, IsSortable, SetName, SetNameTitle, SetTitle, ls, Sizeof, Class, Class_Name, Class_Version, Dictionary, IsA, ShowMembers, Streamer, StreamerNVirtual, DeclFileName, ImplFileLine, ImplFileName, DeclFileLine

Methods inherited from class Go4Fit.TGo4FitSlotList
CheckDuplicatesOnSlot, CheckObjects, ClearObjects, ClearSlot, ConnectSlots, ConnectSlots, FillSlotList, FindSlot, GetSlot, GetSlotList, IsEmptySlots, IsObjectInSlots, NumSlots, PrepareSlotsForWriting, SetObject, SetObject, SetSaveFlagForObjects, SetUpdateSlotList

Field Detail

fxFunctionName

protected TString fxFunctionName
Function name.

fxLibrary

private void * fxLibrary
Pointer on loaded library descriptor.

fxLibraryName

protected TString fxLibraryName
String with library name, where function is situated.

fxPosIndex

protected TArrayI fxPosIndex

fxUserFunction

private TUserFunction fxUserFunction
Direct pointer on function.

fxWidthIndex

protected TArrayI fxWidthIndex
Constructor Detail

TGo4FitModelFunction

public TGo4FitModelFunction()
Default constructor.

TGo4FitModelFunction

public TGo4FitModelFunction(const char * iName, TUserFunction iUserFunction, Int_t iNPars, Bool_t AddAmplitude)
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.

TGo4FitModelFunction

public TGo4FitModelFunction(const char * iName, const char * iLibraryName, const char * iFunctionName, Int_t iNPars, Bool_t AddAmplitude)
Creates TGo4FitModelFunction object with specified name.
Library and function name can be specified. Additionally usage of amplitude parameter can be invoked.
Method Detail

~TGo4FitModelFunction

public virtual synchronized ~TGo4FitModelFunction()
Destroys TGo4FitModelFunction object.
Method Detail

AfterEval

public virtual void AfterEval()

BeforeEval

public virtual Bool_t BeforeEval(Int_t ndim)
Preapre object to evaluations.
When usage of function from library is specified, library will be loaded at this time.

CanAmplTouch

public virtual Bool_t CanAmplTouch()
Signals, that amplitude parameter can be removed from or introduced to object.

CloseLibrary

protected void CloseLibrary()

Finalize

protected virtual void Finalize()
Finalize object.
Close library, if it was opened.

GetFuncPar

protected TGo4FitParameter* GetFuncPar(Int_t n)

GetFuncParName

protected virtual TString GetFuncParName(Int_t n)

GetFunctionName

public const const char * GetFunctionName()
Returns function name in library.

GetLibraryName

public const const char * GetLibraryName()
Returns libraray name.

GetNumberOfFuncPar

public Int_t GetNumberOfFuncPar()
Returns number of parameter, which can be used by function.

GetPosParIndex

protected virtual Int_t GetPosParIndex(Int_t naxis)

GetWidthParIndex

protected virtual Int_t GetWidthParIndex(Int_t naxis)

Initialize

protected virtual Bool_t Initialize(Int_t UseBuffers)
Initialize object.
When usage of function from library is specified, library will be loaded at this time.

LoadLibrary

protected Bool_t LoadLibrary(Bool_t CloseFirst)

Print

public virtual const void Print(Option_t* option)

SetFunctionName

public void SetFunctionName(const char * name)
Sets function name in library.

SetLibraryName

public void SetLibraryName(const char * name)
Sets libraray name.

SetNumberOfFuncPar

public Bool_t SetNumberOfFuncPar(Int_t num)
Sets number of parameters, which can be used by function.

SetPosParIndex

public void SetPosParIndex(Int_t naxis, Int_t indx)

SetUserFunction

public void SetUserFunction(TUserFunction iUserFunction)
Set address to user function.

SetUserFunction

public void SetUserFunction(const char * iLibraryName, const char * iFunctionName)
Set library file name and function name.
Libraray will be loaded during initialization.

SetWidthParIndex

public void SetWidthParIndex(Int_t naxis, Int_t indx)

UserFunction

protected virtual Double_t UserFunction(Double_t* Coordinates, Double_t* Parameters)

Association Links

to Class TArrayI

to Class TArrayI


J.Adamczewski, M.Al-Turany, D.Bertini, H.G.Essel, S.Linev

30-06-2005