The function's catalog is a collection of built-in and ([IFunctionCatalog|http://aida.freehep.org/doc/v3.2.1/api/hep/aida/IFunctionCatalog.html
]) is to be used to register user defined functions that have been registered with itso that they can be easily created or cloned through the IFunctionFactory.
Registering User Defined Functions
After defining a function, eigher by scripting or coding it, it is possible to register it with the function's catalog by simply adding it specifying a name that will be used when creating it via the IFunctionFactory.
In the following example a function is registered with the catalog and used by name when creating a new function (the sum of a gaussian with the newly registered function):
Code Block | ||
---|---|---|
| ||
// The AIDA Factories
IAnalysisFactory af = IAnalysisFactory.create();
ITree = af.createTreeFactory().create();
IFunctionFactory ff = af.createFunctionFactory(tree);
// Register the function myFunc with the catalog.
// Note that there are many ways in which myFunc could have been created.
ff.catalog().add("myFunc",myFunc);
IFunction func = ff.createFunctionByName("func","g+myFunc");
|
When registering a coded function with the function's catalog it is imperative to properly define the function's codelet in the function's implementation. For scripted functions the codelet is defined automatically by the underlying implementation.
Codelet
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
The function's codelet is a unique string that is used internally by the function's factory to uniquely identify a function and be able to create it and clone it.
|