Hi @hym!
I have tried this for myself, i.e. plotting the components of a RooAddPdf
that are a RooFFTConvPdf
and something else like a RooGaussian
. Which ROOT version are you using? The version 6.22 is working for me.
One thing that is striking me as suspicious in your code is that you are reusing resPdf
. So first you do the convolution of a histogram with a resolution function, and then you add the same resolution function on top of that? I’m not sure if this is really intended. In any case, this might cause the problem that causes the components to not be recognized correctly.
Can you please modify your code such that the second PDF in the RooAddPdf
is not something that is also used in the convolution?
Here is the example code that works correctly for me:
void example() {
using namespace RooFit;
RooRealVar mes("mes","mes", 0.0, 20.0);
RooRealVar sigmean1("sigmean1","sigmean1", 5.0, 0.0, 10.0);
RooRealVar sigwidth1("sigwidth1","sigwidth1", 1.0, 0.01, 10);
RooGaussian gaus1("gaus1","gaus1", mes, sigmean1, sigwidth1);
RooRealVar sigmean2("sigmean2","sigmean2", 5.0, 0.0, 10.0);
RooRealVar sigwidth2("sigwidth2","sigwidth2", 1.0, 0.01, 10);
RooGaussian gaus2("gaus2","gaus2", mes, sigmean2, sigwidth2);
RooRealVar sigmean3("sigmean3","sigmean3", 5.0, 0.0, 10.0);
RooRealVar sigwidth3("sigwidth3","sigwidth3", 1.0, 0.01, 10);
RooGaussian gaus3("gaus3","gaus3", mes, sigmean3, sigwidth3);
RooFFTConvPdf conv("conv", "conv", mes, gaus1, gaus2);
RooRealVar frac("frac","frac", 0.5, 0.0, 1.0);
RooAddPdf model("model","model",RooArgList(conv, gaus3), RooArgList(frac));
//Plotting of pdf
TCanvas c1("c1","c1",900,700);
RooPlot *mesframe = mes.frame();
model.plotOn(mesframe, LineColor(kBlack));
model.plotOn(mesframe, LineColor(kRed), Components(RooArgSet(conv)));
model.plotOn(mesframe, LineColor(kBlue), Components(RooArgSet(gaus3)));
mesframe->Draw();
c1.SaveAs("plot.png");
}
Please let me know if this approach works for you or if you have further questions!
Cheers,
Jonas