# Fitting with ConditionalObservables and constraints

Hi,

I am trying to apply a constrain on RooFormulaVar
Using the option ExternalConstraints in RooAbsPdf::fitTo function.
for example :

RooRealVar *a_x_g=new RooRealVar(“a_x_g”,“a_x_g”,50,1,100);
RooRealVar *b_x_g=new RooRealVar(“b_x_g”,“b_x_g”,9,-20,100);
RooRealVar *a_x=new RooRealVar(“a_x”,“a_x”,5,1,10);
RooRealVar *b_x=new RooRealVar(“b_x”,“b_x”,-9.3,-20,10);
RooRealVar *c_x=new RooRealVar(“c_x”,“c_x”,20,15,50);
RooRealVar mass=new RooRealVar(“mass”,“mass”,3,8 );
RooRealVar var=new RooRealVar(“var”,“var”,2,5);
RooFormulaVar coeff=new RooFormulaVar(“coeff”,"Coeff contains a parabola ","c_x+(b_xmass)+ (a_x
mass
mass)",RooArgList(*a_x,*b_x,*c_x,*mass));

RooGaussian fconstraint(“fconstraint”,“fconstraint”,*coeff,*a_x_g,*b_x_g) ;

RooGenericPdf *mass_pdf=new RooGenericPdf(“mass_pdf”,“mass_pdf”,“1/mass^2”,RooArgSet(*mass));

RooDataSet* r_data=(RooDataSet*)mass_pdf->generate(*mass,4000);

RooPolynomial *pdf =new RooPolynomial(“pdf”,“pdf”,*var,RooArgList(coeff));
RooDataSet
Data = pdf->generate(*var,4000,RooFit::ProtoData(*r_data));
Data->Print(“v”);

RooFitResult *result=pdf->fitTo(*Data,RooFit::Save(kTRUE),RooFit::ConditionalObservables(RooArgSet(*mass)),RooFit::ExternalConstraints(fconstraint));

note that the RooRealVar mass is used as a conditional observable (and also part of the RooFormulaVar )
The problem is when doing the fit it treats the mass as a parameter of the fit while it shouldn’t since it is a conditional observable.

Am I missing a basic concept of these constrains ?

Thanks
Nir