TGraph for each bin

Dear experts,

in a TH1 frame, I want to draw a TGraph by category (or bin the histogram bin), so:

  • I defined the TH1 [1].
  • I set the TH1 bin label [2].
  • I defined the TVectorD to be parse to the TGraph [3].
  • I defined the TGraph[4].

then I got this plot: calpas.web.cern.ch/calpas/h2taus/limit.png

But that is not exactly what I want. Indeed, it make a continues line btw the categories, while it should be discontinues. I want to fill each category with a value. For example, for the comb bin, we should have a vertical line which should correspond to the 1st element that I put in the graph vector parameter. Do you see how I can do that?

Regards

[1]
TH1D *dummy = new TH1D(“dummy”,“dummy”, 4, 120, 135);
dummy->GetXaxis()->SetTitle(“Channel”);
dummy->GetYaxis()->SetTitle("#sigma/#sigma_{SM}");

[2]
vector vlabel{“comb.”, “#mu#tau”, “e#tau”, “e#mu”};
for (int i=0; iGetNbinsX(); i++) dummy->GetXaxis()->SetBinLabel(i+1, vlabel[i].c_str());

[3]
array amass=(120, 125, 130, 135);
array azero=(0, 0, 0, 0);

int ndir=amass.size();
TVectorD v_dir (ndir, amass);
TVectorD v_zeros (ndir, azero);
TVectorD v_exp_p2(ndir, aexp_p2);
TVectorD v_exp (ndir, aexp);
TVectorD v_exp_m2(ndir, aexp_m2);

[4]
TGraphAsymmErrors *gr_exp2 = new TGraphAsymmErrors(v_dir, v_exp, v_zeros, v_zeros, v_exp_m2, v_exp_p2);
gr_exp2->SetLineColor(kYellow);
gr_exp2->SetFillColor(kYellow);
gr_exp2->Draw(“e3same”);

Dear experts,
an ideas?
regards

Can you pst a picture showing the kind of plot you want ?

Dear Couet,
I want a plot like this one:
calpas.web.cern.ch/calpas/h2taus/plot.pdf
This only difference is that I want the category (4l, 2l…) to be
on the x axis.
Regards

The way you proceed cannot work …
That plot is quiet complex … I see boxes like in the COL option or errors plotted as boxes …
Then error bars on top … then some other lines (dotted) … That sort of plot can be done with root but it really depends on the data you have … There is bot singe recipe to do it. Do you have a macro producing this plot ?

Dear Couet,

the only macro that I have:
calpas.web.cern.ch/calpas/h2taus/plotlimit.cc
run on the root file:
calpas.web.cern.ch/calpas/h2taus … mH125.root
calpas.web.cern.ch/calpas/h2taus … mH125.root

makes plot for this one:
calpas.web.cern.ch/calpas/h2taus/limit.png

So do you see how I can change plotlimit.cc to make:
calpas.web.cern.ch/calpas/h2taus/plot.pdf

PS: For me the only difference is that I want to plot the value
bin by bin while my current plotlimit.cc plot it point by point,
and then make a continus line… As TGraph is not histogram,
I can’t do “Fill(bin, value)”…

Regards

So why don’t you use a TH1F instead of a TGraph ?

Dear Couet,

my problem is that when I use TH1, I have this:
calpas.web.cern.ch/calpas/h2taus/plot.png

I do not see how I can fill the area in an elegant way. What I did here is that for each category, and for each value, I fill an histogram, then I draw all of them in the save canvas. Now I want to fill the area with color like here: calpas.web.cern.ch/calpas/h2taus/limit.png

Do you know if it would be possible to:
TH1-> SetBinErrorUp();
TH1-> SetBinErrorDown();
Then fill the error area?

Regards

May be this option will help:

root.cern/doc/master/classTGrap … html#GP03b

Dear Couet,
I’m confused. This is for TGraphError right? Here I have histograms…
Regards

Yes but before you had graphs. TGraphErrors allows to draw these error boxes and I think that is what you are looking for.

But I’m using histogram now as you advice me to do it yesterday, right?
So right now I’m not using TGraph. Do you mean that I should used TGraph instead of TH1?
Regards

You said :

This mean you want to have some kind of error boxes … right ? … in that case the TGraphAssymErros example I send you does it. TH1 does not have the concept.

But then this will be a mix of Tgraph and histograms, would I be able to plot all this togeter on the TH1 axis?
Regards

Yes

Dear Couet,

I managed to do that with histograms:
calpas.web.cern.ch/calpas/h2taus/plot.png

but I wonder why the dotted line are draw on the axis?
To draw the dotted histogram I used:
hlimits-> SetLineWidth(2);
hlimits-> SetLineStyle(2);

Do you know how I can remove the dot on the axis?

Regards

I need to see ( and run) the macro to see where they are coming from.

Dear Couet,

I code is: calpas.web.cern.ch/calpas/h2taus … it_hist.cc

the root files:
calpas.web.cern.ch/calpas/h2taus … mH125.root
calpas.web.cern.ch/calpas/h2taus … mH125.root

Do you see what is wrong?

Regards

$ root plotlimit_hist.C
   -----------------------------------------------------------------
  | Welcome to ROOT 6.09/01                     http://root.cern.ch |
  |                                    (c) 1995-2016, The ROOT Team |
  | Built for macosx64                                              |
  | From heads/master@v6-09-01-1155-g4e2fa30, Jan 24 2017, 17:32:53 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'      |
   -----------------------------------------------------------------

root [0] 
Processing plotlimit_hist.C...
In file included from input_line_12:1:
/Users/couet/roottest/plotlimit_hist.C:2:10: fatal error: 'tdrLimitStyle.cc' file not found
#include "tdrLimitStyle.cc"
         ^
root [1] 

Dear Couet,

sorry, I posted it here:
calpas.web.cern.ch/calpas/h2taus … itStyle.cc

Regards