TRatioPlot interference

You should set the error properly and may be set the error ro 0 hone your computation leads to a wrong result.
It is up to you to decide what is the best solution in that case.

Dear Couet,

  • on the top pad, do you understand why it draws the error bars only for the 1st hist while there is not “e” option in the Draw (1)?
  • I modified a the code, you can see the new one here (2).
    Regards

(1)
image

(2)
http://calpas.web.cern.ch/calpas/plot.cc

If you do not want the errors bars draw the histogram with the option hist

Yes, I’m already using “hist”, but it draw still the error bars.
Regards

Indeed you are using the option hist for the histograms you are drawing in the top pad on top of the ratio plot (as I told your earlier). But the errors bars you see are coming from the histogram drawn via the ratio plot itself. If you look at the documentation, you will find out that it is possible to change the drawing option of both histograms used to make the ratio plot. In your case: ratio->SetH2DrawOpt("hist"); is the command to be added before ratio->Draw();

Dear Couet,

  • Thank you it works fine.
  • I still want to plot several ratio plots on the lower pad. I saw a suggestion here (1) but it did not work, so I just use something like (2) but it seems to plot the entire frame each time instead of just the curve only, see (3). The complete code is here (4). Do you see what is wrong?
    Regards

(1)

(2)
auto ratio_noniso = new TRatioPlot(hist_prompt, hist_fake_noniso);
auto ratio_hadron = new TRatioPlot(hist_prompt, hist_fake_hadron);
auto ratio_other = new TRatioPlot(hist_prompt, hist_fake_other);
//
ratio_noniso -> SetH2DrawOpt(“hist”);
ratio_noniso -> Draw();
//
ratio_noniso -> GetLowerPad()->cd();
ratio_hadron -> Draw(“same”);
ratio_other -> Draw(“same”);

(3)
image

(4)
http://calpas.web.cern.ch/calpas/plot.cc

… I am not completely sure I understand what you are trying to do … let me see…

I just want to plot several ratio plots on the lower pad.
Regards

But if you want the ratio of two other histograms why do you need a new TRatioPLot ? you just need to divide the two histograms, do a cd() to the lower pad of the TRatioPlot and plot (with option same) the result of the division you just did ?

Dear Couet,

  • thank you, it works fine.
  • which option should I use to do not draw the error bars of Tratio? As you can see here (1), there are error bar for the black hist on the bottom pad, as I use it to make the TRatio?
  • Is it possible to plot only the Tratio frame (pad, axis, etc…) and not the graph? Then I could add the hist that I made myself?
    Regards

(1)
image

The ratio on the bottom pad is a TGraphAsymmErrors it makes no sense to plot it with errors bars.

Dear Couet,
sorry, do you mean that I shoud not use error bars?
Regards

I mean that you use TRatioPlot, the bottom is produced automatically from the two histograms you gave. The bottom plot is generated via a TGraphAsymmErrors, which, obviously, has errors bars.

Is it possible to “delete” the TGraphAsymmErrors, but to keep the frame (lower pad, axis etc…)?
Regards

I am wondering why you are using TRatioPLot as you are trying to remove or bypass all the features it provides !! :frowning: … You better make two pads on top of each other and draw whatever you want inside.

For now everything is ok, except the “nan” large error bars when the denominator hist is empty I guess. Above you said (1), but I used " TH1::SetDefaultSumw2()" before creating the hist, so the errors should be set properly right? if yes why should I intervene in TRatio error computation?
Regards

(1)
“You should set the error properly and may be set the error ro 0 hone your computation leads to a wrong result.
It is up to you to decide what is the best solution in that case.”

I if you comment:

ratio_noniso -> GetLowerRefGraph() -> SetMinimum(0.);

The large errors on empty bins go away (at least for me)

It does not work for me.
Regards

To make it easier to debug I have created a smaller version of your macro properly formatted and intended having only (I guess) the necessary code showing the problem. It is attached here. Can you tell me if that macro shows the problem you are talking about ? if yes I propose we stick to this one for further debugging.

calbet4.C (10.6 KB)

  • Ok, thank you.
  • I just run your code and I have this (1), so for the last ratio bin, you have the large error bar too.
    Regards

(1)
image