Dear Root experts,
I am trying to do a fitting using user defined functions.
I have a file (FitFunctions.h) that contains the definition of a crystalball and an exponential function.
It also includes the “FinalFitFunction” which is the sum of these functions.
In my fitting code (CrystalBallFitter.h) a histogram is passed to the code as an input argument and the FinalFittingFunction is called.
I can successfully compile my codes but when I run on data, I receive the following:
Unknown function: FinalFitFunction
Any help is appreciated as always.
Here is my “FitFunctions.h” code:
#include “ResultAnalyzer.h”
double ResultAnalyzer::CryatalBallSignal(double* x, double* Parameters) {
double Alpha = Parameters[0];
double N = Parameters[1];
double Sigma = Parameters[2];
double Mean = Parameters[3];
if (Sigma<0.0)
return 0.0;
else {
double Z = (x[0]-Mean)/Sigma;
if (Z>-Alpha)
return exp(-pow(Z,2)/2);
else {
double P = abs(Alpha);
double Q = N/P;
double A = pow(Q,N)*exp(-pow(P,2)/2);
double B = Q-P;
return A*(pow((B-Z),-N));
}
}
}
double ResultAnalyzer::ExponentialBackground(double* x, double* Parameters) {
double Lambda = Parameters[0];
double x0 = Parameters[1];
if ((x[0]-x0)<0)
return 0.0;
else
return Lambda*exp(-Lambda*(x[0]-x0));
}
double ResultAnalyzer::FinalFitFunction(double* x, double* Parameters) {
return CryatalBallSignal(x,&Parameters[0])+CryatalBallSignal(x,&Parameters[4])+ExponentialBackground(x,&Parameters[8]);
}
and here is my “CrystalBallfitter.h” :
#include “ResultAnalyzer.h”
void ResultAnalyzer::CrystalBallFitter(TH1D* h_JPsiPsiMass)
{
h_JPsiPsiMass->Fit(“FinalFitFunction”);
}
Thank you in advance for the help.
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided