Problem with Beeston Barlow light method

Dear RooFit experts,
I am trying to do a signal+bkg fit to data. I construct signal template and background template from monte carlo histograms using RooParamHistFunc. In some cases (meaning in some pT bins), I am getting good fit, but in some other pT bins, fit is really bad. Moreover, I print nsig and nbkg in my canvas, and I am getting fractional values for them in some cases which is unreasonable. The relevant part from my code is given below. Please suggest where I am doing wrong.

RooRealVar x("x","Inv Mass in GeV",60, 120) ;
x.setBins(60) ;

/// Import the contents of ROOT histogram into a RooDataHist object ///
  RooDataHist data("data_hist", "data", x, RooFit::Import(*mydata)) ;
  RooDataHist mc_sig("mc_hist_sig", "sig_mc", x, RooFit::Import(*MC_signal_hist)) ;
  RooDataHist mc_bkg("mc_hist_bkg", "bkg_mc", x, RooFit::Import(*MC_bkg_hist)) ;

/// BB light ///  
  RooParamHistFunc model_sig("sig","sig", mc_sig) ;
  RooParamHistFunc model_bkg("bkg","bkg", mc_bkg, model_sig, kTRUE) ;
  
  RooPlot* myframe = x.frame(RooFit::Name("Histo_Fit"), RooFit::Title("Inv Mass in GeV")) ;
  data.plotOn(myframe,RooFit::Name("hist_data")) ;
  myframe->SetXTitle(mass.c_str());
  
  RooRealVar nsig("nsig", "number of signal", 100.0, 0.00, 100000000.0) ;
  RooRealVar nbkg("nbkg", "number of bkg",      1.0, 0.00, 100000000.0) ;
  RooRealSumPdf model0("model0","sig+bkg",RooArgList(model_sig,model_bkg),RooArgList(nsig,nbkg),kTRUE) ;
 
 // Construct the subsidiary poisson measurements constraining the histogram parameters
  RooHistConstraint h_sigbkg("h_sigbkg","h_sigbkg",RooArgSet(model_sig,model_bkg)) ;
  // Construct the joint model
   RooProdPdf total_model("tot_model","TotalModel", h_sigbkg, RooFit::Conditional(model0,x)) ;

  total_model.fitTo(data) ;  
  total_model.plotOn(myframe, RooFit::Name(mass.c_str()), RooFit::LineColor(kBlue)) ;
  total_model.paramOn(myframe,RooFit::Layout(0.82,0.99,0.99)) ;
  myframe->getAttText()->SetTextSize(0.018);
  double N_fitted = nsig.getVal() ;
  double N_err = nsig.getError() ;
  double N_fitted_bkg = nbkg.getVal() ;
  Double_t chi2 = myframe->chiSquare();
  TPaveLabel *t1 = new TPaveLabel(0.1,0.75,0.5,0.9,Form("#chi^{2}=%f , Nsig=%f , Nbkg=%f",chi2,N_fitted, N_fitted_bkg),"brNDC");
  t1->Draw();
  myframe->addObject(t1);
  
  char name_Z[200] ;
  sprintf(name_Z,"Fit_%s_%s_%i" ,type.c_str(),mass.c_str(), mn) ;
  canv1 = new TCanvas(name_Z, "fit", 800, 600) ;
  canv1->cd() ;
  myframe->Draw() ;
  canv1->SetLogy();

Regards,
Swagata.


I would really like to know about this too.