How to plot RooDataHist as a histogram in RooFit

I use RooFit to analyse my data. Suppose I have a RooDataHist object built from ordinary TH1F object:

    TH1F* hist0 = (TH1F*)f->Get( "AC" );
    TH1F* hist = dynamic_cast<TH1F*> (hist0->Clone());

    RooRealVar integral( "integral", "integral, LSB (0.49V)", 0, 15000 ); 
    RooDataHist data( "data", "Data from CAEN", integral, hist );

This works well. But I also want to draw data as ordinary ROOT histogram (left picture) and not as points with errors (right picture).

Thank you in advance.

Dear p73,

RooDataHist derives from RooAbsData and therefore provides a plotOn method which accepts many visualization options, including the ROOT specific ones via DrawOption(const char* opt).
Please check the available options at RooAbsData::plotOn and the tutorial rf107_plotstyles.C .

G Ganis

I use

data.plotOn( xFrame, DrawOption( "HIST" ) );

but nothing changes.

OK. There is no option “HIST” for TGraph. So it is impossible to draw RooDataHist as histogram in RooFit?

May be option “B” for bars ?

It gives the following picture. And though color is not a problem, there are annoying bars on the edges. How to get rid of them?

I think we will need a small reproducer to investigate further.

Here is all you need. (39.4 KB)

As said here:

DrawOption(const char* opt) Select ROOT draw option for resulting TGraph object.

The TGraphs drawing options are listed here:

Honestly, don’t understand why do you say this. How it helps to get rid of bars on the edges that on picture I provided.

With zip file you sent me I get the following picture. There is no " bars on the edges "

Sorry, they are there, but their color is white. Correct is below.
Sorry for this. (39.4 KB)

With the new one you sent me I get the following picture. What is “wrong” with it ?

Wow. This is my result. Absolutely the same code!!!

Which ROOT version ? on which machine ?

  | Welcome to ROOT 6.10/08       |
  |                               (c) 1995-2017, The ROOT Team |
  | Built for linuxx8664gcc                                    |
  | From tag v6-10-08, 16 October 2017                         |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |

Linux 4.4.0-81-generic #104~14.04.1-Ubuntu SMP Wed Jun 14 12:45:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Ah … 6.10 … it is quite old. I might that there was some fixes since that version. I am using 6.13/03

I thought, the problem appeared in ROOT 6.10/08 and earlier but now I can see it in ROOT 6.12/06, too (some moments ago it was not the case). Unfortunately, valgrind returns the usual huge number of ROOT warnings (so it’s not really possible to get anything useful from its output).

Just for the reference … I get almost 700kB screen output when I try (ROOT 6.12/06 or 6.13/02):

valgrind --tool=memcheck --suppressions=`root-config --etcdir`/valgrind-root.supp `root-config --bindir`/root.exe -l -q CsI.C++g

Yes I see it too with ROOT 6.12/07 on Mac. ROOT 6.13/03 is fine (see the plot I posted). Can you update ?

Actually I did this fix this year on January 12