Roofit - variable seen as constant

Hello,
I’ve used the makepdf function to create my own piece-wise pdf in roofit. However, one of the floating variables I pass it is being treated as a constant even though I define a range for it. The call to makepdf is:

RooClassFactory::makePdf(“RooMesBG”,“x,l,A0,a1,a2,a3,b1,b2,b3”);

The contents of evalute() are then written as:

Double_t RooMesBG::evaluate() const
{
// ENTER EXPRESSION IN TERMS OF VARIABLE ARGUMENTS HERE
Double_t y = 5.29;
Double_t num = 0;
Double_t den = 0;
Double_t fun = 0;
if( x<=p )
{
fun = a0 + a1*(x-p) + a2*(pow(x-p,2)) + a3*(pow(x-p,3));
}
else if( x>p && x<=5.29 )
{
num = (b1*(x-p) + b2pow(x-p,2) + b3pow(x-p,3));
den = (b1*(y-p) + b2pow(y-p,2) + b3pow(y-p,3));
fun = a0-a0*(num/den);
}
else
{
fun = 0;
}
return fun;
}

The macro which calls the pdf defines the floats as:

    RooRealVar a0("a0","coefficient a0 Mes", 0.001,0.0,10.0);
    RooRealVar a1("a1","coefficient a1 Mes", 1.0,-100.0,300.0);
    RooRealVar a2("a2","coefficient a2 Mes", 3.0,-100.0,300.0);
    RooRealVar a3("a3","coefficient a3 Mes", 1.0,0.0,500.0);
    RooRealVar b1("b1","coefficient b1 Mes", 1.0);
    RooRealVar b2("b2","coefficient b2 Mes", 0.5,0.0,5000.0);
    RooRealVar b3("b3","coefficient b3 Mes", 0.5,-20000.0,500.0);
    RooRealVar p("p","p", 5.279,5.25,2.285);
    RooMesBG bkgMes("bkgMes","Mes background",mES,p,a0,a1,a2,a3,b1,b2,b3);

However, when the code is run roofit treats p as if it were a constant:

1 a0 7.65948e+00 7.28040e-01 0.00000e+00 8.83488e+02
2 a1 8.71611e+01 6.54852e+00 0.00000e+00 -3.75726e+03
3 a2 7.33424e+01 2.76963e+01 0.00000e+00 1.48507e+02
4 a3 4.99859e+02 1.04085e+02 3.04268e+00 2.08664e-01
5 b2 3.30563e+03 2.81105e+02 0.00000e+00 -4.13123e+00
6 b3 -8.07811e+02 6.61922e+02 0.00000e+00 -1.42050e+00
7 p 5.27900e+00 constant

p is always kept at the initial guess value and never varies during the fit. Am I missing something in my call to makepdf or my use of the pdf in my macro?

Thanks,
Brandon Drummond