Hi,
Can’t one pass a RooFormulaVar the same way as RooRealVar into a pdf as a parameter (e.g. as a sigma to RooGaussian)?
If I try to convolute a simple model (e.g. landau) with a gaussian resolution function which has mean and sigma declared as RooRealVars, everything works fine.
However, if I want to make the sigma of the gaussian a simple function of the observable (as is the case, for one example, in scintillator experiments), the convoluted pdf does not make sense and I get a bunch of problems:
a) if I use RooFFTConvPdf, I get “pdf normalization integral is zero” as a WARNINGs when trying to plot, and ERRORs when trying to generate toy data with the convoluted pdf.
b) if I use RooNumConvPdf, I get “pdf value is not-a-number” as a Warning during plotting, and Error during “generate” command (if I do this on linux with rootv5.24, rather than on cygwin with root5.26, I get Error during plotting, and nothing during generation)
if I declare both mean and sigma as RooFormulaVars, RooNumConvPdf does not complain neither during plotting, not during toy data generation, but the convoluted function does not seem to make sense.
RooFFTConvPdf keeps giving ERRORs and WARNINGS.
But, again, while the details of errors depend on the number of RooFormulaVars I am passing to RooGaussian and the platform (cygwin/linux, root v5.24/26), the convoluted function never makes sense (i.e if it is not null at all, there is neither smearing nor shift present).
I was able to find a poor-man solution by hacking the RooGaussian class. To do so, in constructor I pass pointers to RooFormulaVars for mean and sigma, instead of passing references to RooAbsReal. Consequently, I declare RooFormulaVar pointers for mean and sigma in protected part of the header, instead of RooRealProxies, and make appropriate changes in the .cxx file
If I do that, all my problems disappear. I can convolute my model with a gaussian that has variable mean/sigma and everything works and looks just fine.
But that means giving up the flexibility of universal interface that accepts RooRealVars, RooFormulaVars etc, which I thought is an awesome feature of RooFit.
Could someone please either point out my mistake that was causing the problems in the first place, or, if it is indeed a RooFit issue, suggest a better solution?
Thanks,
Igor
The macro looks like that (the modified RooGaussian class is attached):
RooRealVar e("e","e",0,15); //observable
//version 1. works all the time
//---------------------------------------------------------
RooRealVar mean("mean","mean",0);
RooRealVar sigma("sigma","sigma",0.75);
RooGaussian res("res","res",e,mean,sigma);
RooRealVar m("m","m",4);
RooRealVar s("s","s",0.75);
RooLandau model("model","model",e,m,s);
e.setBins(10000,"cache");
RooFFTConvPdf fconv("fconv","fconv",e,model,res);
fconv.generate(e,1000);
//-----------------------------------------------------------------
//version 2. works only with modified RooGaussian
//------------------------------------------------------------------
RooFormulaVar mean("mean","mean","-0.1*@0",RooArgList(e));
RooFormulaVar sigma("sigma","sigma","0.25*sqrt(@0)",RooArgList(e));
MyGaussian res("res","res",e,&mean,&sigma); //mean and sigma are declared as RooFormulaVars in MyGaussian
e.setBins(10000,"cache");
RooFFTConvPdf fconv("fconv","fconv",e,model,res);
RooNumConvPdf nconv("nconv","nconv",e,model,res);
nconv.setConvolutionWindow(mean,sigma,4);
nconv.generate(e,1000);
fconv.generate(e,1000);
//---------------------------------------------------------------------------
CUgaussianPdf.cxx (3.93 KB)
CUgaussianPdf.h (2.18 KB)