RooPlot draw with poisson errors?

Dear Root experts,

I am trying to plot data points into a binned histogram using RooPlot. Some bins are empty and error bars in these bins seems to give wrong error bars (1.2 instead of 1.8 ). I tried passing DataError(RooAbsData::Poisson) option, but no luck. Is there any way to manually enter errors in these bins?
Please find minimum example below.

gSystem->Load("libRooFit") ;
void UpsilonMinimal()
{
  RooRealVar MuMuMin("MuMuMin", "M_{#mu#mu} GeV", 8.5, 11.) ;
  RooArgSet variables;
  variables.add(MuMuMin);

  RooDataSet * data= &(RooDataSet::read("MinimalExample.txt", variables ,"Q"));
  RooDataSet dataSet("dataSet","",variables,Import(*data));

  TCanvas * cx=new TCanvas("cx","cx",50,50,800,600);
  RooPlot *framex = MuMuMin.frame(50);
  framex->SetTitle("");
  framex->GetYaxis()->SetTitle("Candidates / 50 MeV");
  
  dataSet.plotOn(framex,Name("dataX"),DataError(RooAbsData::Poisson));
  framex->Draw();
}

Also .txt file is on attachment.

Thanks,
Maksat
MinimalExample.txt (2.42 KB)

HI,

You cannot do it manually easily. The only way to do it I think is to extract the RooCurve and modify it by hand. It is a TGraphAsymmErrors so you can change the point errors using SetPointError.

Lorenzo

Hi Lorenzo,

Thank you very much for prompt reply and help.
I was trying to follow this post:
[url]RooDataHist: Setting my own error bars
But, did not have luck…

Nevertheless, I will post add-hoc solution I found and maybe it will be useful for other users.

  1. Add following lines in $ROOTDIRECTORY/roofit/roofitcore/src/RooHist.cxx
    Line 405.
ym  =  (n==0) ? 0  : (ROOT::Math::gamma_quantile((1 - 0.6827)/2,n,1.));
yp =  ROOT::Math::gamma_quantile_c((1 - 0.6827)/2,n+1,1) ;

just after…

if(!RooHistError::instance().getPoissonInterval(Int_t(n),ym,yp,_nSigma)) {
      coutE(Plotting) << "RooHist::addBin: unable to add bin with " << n << " events" << endl;
      return;}
  1. Also added necessary headers into same file to be safe.
#include "TROOT.h"
#include "Math/QuantFuncMathCore.h"

Then, compile and run. It should give you “correct” errors for zero entries (1.8 instead of 1.2). Call your dataSet with either Poisson or Idle. it worked for me same as my data is unweighted…

dataSet.plotOn(framex,Name(“dataX”));
or
dataSet.plotOn(framex,Name(“dataX”),DataError(RooAbsData::Poisson));

Hope this will be helpful to somebody.
Maksat

Hi,
Thank you. Yes, this is the correct solution if you modify by hand the code

Lorenzo