...
Writing your own function
Oftentimes you will have to perform more complicated computations than can be put in a string. Use this template to
Code Block |
---|
from hep.aida import IFunction
import AIDATutorial
import math
class MyFunc(IFunction):
def __init__(self, track):
self.title = "My Own Function"
return
def providesGradient(self):
return false
# This Function returns the value f(x)
# x can be multi-dimensional
def value(self, x):
y = x[0] + math.exp(x[1]) + x[0]*x[1]
externalValue = AIDATutorial.someExternalFunction(y, x)
return externalValue-y
# This tells AIDA the dimension of the function
def dimension(self):
return 2
def annotation(self):
ann = IAnnotation()
ann.addItem('Title', self.title)
return ann
|