Parameters from multiple function fit not reasonable

I have a dE/dX plot I am trying to fit with a 2 landau plus gaussian, all convolved with a noise gaussian. To create the fit, I create a TF1Convolution(landau+landau+gaus,gaus) similar to the root tutorial, Convolution.C, then cast as a TF1 to use for a fit. The fit converges, and the overlayed plot of the fit (Red) to my data seems reasonable.
However, when I use the parameters returned by the fit create individual parts of the fit, LG, LG, G*G (Green, Blue, Orange), created in the same fashion, TF1Convolution then cast as a TF1 and setting parameters using the full fit parameters, they obviously do not sum to the full fit.
This is shown most obviously in the 4-7MeV/cm region, where I want my delta langaus to be. The MPV/sigma seem reasonable, but the norm is too low for the ~300 entries/bin needed to add to the green histogram for the sum to match the red curve.


I provide the code that does the convolution and fitting below. How can I correctly plot the underlying functions such that their sum agrees with the red curve for the combined fit?


// #########################################
// ##                                     ##
// ## Create a (L+L+G) with G convolution ##
// ##                                     ##
// #########################################
TF1Convolution *langaus= new TF1Convolution("landau(0)+landau(3)+gaus(6)","gaus(9)",-10,60,true); //use FFT
langaus->SetRange(0,50);
langaus->SetNofPointsFFT(10000);

// ###########################################
// ##                                       ##
// ## Make TF1 from convolution, set limits ##
// ##                                       ##
// ###########################################
TF1 *langausfunc=new TF1("langausfunc",*langaus,0,50,langaus->GetNpar());
langausfunc->SetParameters(1E2, .5, .3, 1E5, 1.7, .4, 1E4, 4, .00027, 1, .46);
langausfunc->SetParLimits(0,1E1,1E4);
langausfunc->SetParLimits(1,.2,1);
langausfunc->SetParLimits(2,0,.4);
langausfunc->SetParLimits(3,1E4,1E7);
langausfunc->SetParLimits(4,1.7,2.2);
langausfunc->SetParLimits(5,0,2);
langausfunc->SetParLimits(6,1E2,1E4);
langausfunc->SetParLimits(7,3,5);
langausfunc->SetParLimits(8,0,2);
langausfunc->SetParLimits(9,0,2);
langausfunc->SetParLimits(10,0,2);

langausfunc->SetParName(0,"Low Gauss: Norm");
langausfunc->SetParName(1,"Low Gauss: Mean");
langausfunc->SetParName(2,"Low Gauss: Sigma");

langausfunc->SetParName(3,"Pion Landau: Norm");
langausfunc->SetParName(4,"Pion Landau: MPV");
langausfunc->SetParName(5,"Pion Landau: Sigma");

langausfunc->SetParName(6,"Delta Landau: Norm");
langausfunc->SetParName(7,"Delta Landau: MPV");
langausfunc->SetParName(8,"Delta Landau: Sigma");

langausfunc->SetParName(9,"Electronics Gauss: Mean");
langausfunc->SetParName(10,"Electronics Gauss: Sigma");

// ##################################
// ##                              ##
// ## Make individual convolutions ##
// ##                              ##
// ##################################
TF1Convolution *pionlg= new TF1Convolution("landau(0)","gaus(3)",-10,60,true);
TF1Convolution *deltalg= new TF1Convolution("landau(0)","gaus(3)",-10,60,true);
TF1Convolution *elec= new TF1Convolution("gaus(0)","gaus(3)",-10,60,true);
TF1 *pionlgfun=new TF1("pionlgfun",*pionlg,0,50,pionlg->GetNpar());
TF1 *deltalgfun=new TF1("deltalgfun",*deltalg,0,50,deltalg->GetNpar());
TF1 *elecfun=new TF1("elecfun",*elec,0,50,elec->GetNpar());

TCanvas *c =new TCanvas("c","c",800,1000);
c->SetLogy();
TVirtualFitter::SetMaxIterations(10000);

// #############################################
// ##                                         ## 
// ## Do full fit, store fit params           ##
// ## and fix individual fit params with them ##
// ##                                         ##
// #############################################
hPiondEdX->Fit("langausfunc","LL");
pionlgfun->SetParameters(langausfunc->GetParameter(3),langausfunc->GetParameter(4),langausfunc->GetParameter(5),langausfunc->GetParameter(9),langausfunc->GetParameter(10));
deltalgfun->SetParameters(langausfunc->GetParameter(6),langausfunc->GetParameter(7),langausfunc->GetParameter(8),langausfunc->GetParameter(9),langausfunc->GetParameter(10));
elecfun->SetParameters(langausfunc->GetParameter(0),langausfunc->GetParameter(1),langausfunc->GetParameter(2),langausfunc->GetParameter(9),langausfunc->GetParameter(10));

double pionpars[5]={123,123,123,123,123};
double deltapars[5]={123,123,123,123,123};
double elecpars[5]={123,123,123,123,123};

pionlgfun->GetParameters(pionpars);
deltalgfun->GetParameters(deltapars);
elecfun->GetParameters(elecpars);

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