Double Sided Crystal Ball Fit

Dear all,

I am trying to fit Higgs mass distribution with double sided Crystal Ball function. However, I am having issues. Do you maybe have some example of implementing it? It seems to be not the easiest fit…

Thank you in advance for your help! It’s my first post here and hope you will see it!


May be you can post some code showing what you ended up so far ?

Have a look here. it should look like what you are trying to do.

Hi @pamputt ,

Thank you for your reply. I already have tried this one and succeeded, however I was told to make explicitly double-sided crystal ball fit …

Hi @couet,

Thank you for your reply. This was my code with just a Crystal ball function fit:

ch->Draw("H_mass>>H_m", tcut);
TH1F *H_m = (TH1F*)gDirectory->Get("H_m");  
double mean = H_m->GetMean();

TF1 *f_cb= new TF1("MyCrystalBall","crystalball",80,160);
f_cb -> SetParameters(1,mean,0.3,2,1.5);

And it worked nice, but I was told to make a double-sided Crystal Ball (CB) function fit and I tried following: i created a file for CB function and then included it in the main file. The code is following (I took it from the root forum):

double DoubleSidedCrystalballFunction(double *x, double *par)
double alpha_l = par[0];
double alpha_h = par[1];
double n_l = par[2];
double n_h = par[3];
double mean = par[4];
double sigma = par[5];
double N = par[6];
float t = (x[0]-mean)/sigma;
double result;
double fact1TLessMinosAlphaL = alpha_l/n_l;
double fact2TLessMinosAlphaL = (n_l/alpha_l) - alpha_l -t;
double fact1THihgerAlphaH = alpha_h/n_h;
double fact2THigherAlphaH = (n_h/alpha_h) - alpha_h +t;

if (-alpha_l <= t && alpha_h >= t)
result = exp(-0.5tt);
else if (t < -alpha_l)

   result = exp(-0.5*alpha_l*alpha_l)*pow(fact1TLessMinosAlphaL*fact2TLessMinosAlphaL, -n_l);

else if (t > alpha_h)
result = exp(-0.5alpha_halpha_h)pow(fact1THihgerAlphaHfact2THigherAlphaH, -n_h);


return N*result;

And I call this function in the main .C file as follows:

TF1 *f_cb= new TF1("DoubleSidedCrystalballFunction",DoubleSidedCrystalballFunction,40,200);
f_cb->SetParameters(1,2,2,1, H_m->GetMean(), H_m->GetRMS(), H_m->Integral(40,200));
f_cb->SetParNames ("alpha_{low}","alpha_{high}","n_{low}", "n_{high}", "mean", "sigma", "Norm");

However this does not work, I do not see any fit… I know that the initial parameters have to be reasonable, however I do not know how to choose “reasonable” parameters for my case…

If you have some example of implementing double sided CB function fit, it would be very helpful!

I hope I managed to explain my problem in detail. Thank you for your time and help!!

Let me know if I can give you any kind of further information that may be helpful.

Thanks for the code. @moneta may have a look.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Sorry for the delay. I would need the data and the macro to see the problem you are having fitting.
First I would suggest trying fitting as a simple gaussian to get the N,Mean,sigma parameters and then do the Crystal Ball Fit.