Stack histogram

I generated four samples
pp > h1 ,h1 > tau tau~
pp > h2 ,h2 > tau tau~
pp > z ,z > tau tau~
pp > tau tau~
I did a code for all samples. A problem is showed when i Stacked these histograms, i found
the signal and one of bkgs not appeared. I used log scale to appear them but unfortunately not appeared. please I wish to find a solution for this problem

Knowing that first is signal and the other three are bkgs the i did a code for all these sample
in signal i used BLSSM model and paramter_card file (within compressed BLSSM) which is attached below and for bkgs i used model sm-full .
BLSSM model signal

dataAnalysis.C (6.7 KB)
dataAnalysis.h (81.4 KB)
h_tata.root (30.1 KB)
h1_e3e3bar.root (41.9 KB)
Stack_Hist.C (4.8 KB)
tata.root (29.2 KB)
tt_plots_log.pdf (244.9 KB) (483.3 KB)
z_tata.root (31.7 KB)

Dear @Ahmed_Sayed ,

Thanks for reaching out on the forum!

It is not clear from your description what the problem is. Are you trying to draw the histograms using THStack perhaps? See this tutorial for a nice starting point. In general, if you can provide us with a minimal code snippet to see the problem it would be greatly beneficial.


1 Like

The main problem w.r.t me the the signal(h1) not apperad and one of background not appreared(h2) even after using log scale

tt_plots_log.pdf (244.9 KB)

Stack_Hist.C (4.8 KB)

1 Like

I am looking at it

I managed to reproduce the problem with the following simpler macro:
(sorry it took a bit of time)

void Stack_Hist() {
   auto rootH2TTbar = new TFile("h1_e3e3bar.root");
   auto rootZTTbar  = new TFile("z_tata.root");
   auto rootTTbar   = new TFile("tata.root");
   auto rootH1TTbar = new TFile("h1_e3e3bar.root");

   TH1F* h0 = (TH1F*)rootH2TTbar->Get("tau1_pt");
   TH1F* h1 = (TH1F*)rootZTTbar->Get("tau1_pt");
   TH1F* h2 = (TH1F*)rootTTbar->Get("tau1_pt");
   TH1F* h3 = (TH1F*)rootH1TTbar->Get("tau1_pt");


   auto C = new TCanvas("","",1000,1500);


   C->cd(1); h0->Draw("HIST");
   C->cd(2); h1->Draw("HIST");
   C->cd(3); h2->Draw("HIST");
   C->cd(4); h3->Draw("HIST");

   auto st1 = new THStack();
   C->cd(5)->SetLogy(); st1->Draw("HIST");

   auto st2 = new THStack();
   C->cd(6)->SetLogy(); st2->Draw("HIST");

It gives the following output:

On this plot, the four first pads show the histograms h0, h1, h2 and h3 (in that order). On pad 5 the stack shows the histograms in the order you have them in your original macro. On pad 6 that’s an other stack in which the histograms with the lower dynamic (h0 and h3) are plotted first (in a stack the histograms are plotted in the order you added them). As you can see in the 1st stack (yours…) you can see h0 but not h3 and in the 2nd stack you can see both.


In the 1st stack (your case) you pile the four histograms this way:

  1. h0 → small Y dynamic
  2. h1 → Very high Y dynamic
  3. h2 → Very high Y dynamic
  4. h3 → small Y dynamic

so the 4th histogram, h3, is on top of two histogram with a very high Y dynamic therefore it is completely negligeable in the decade it shows up. So you should make sure you pile the histograms starting with those having the smallest maximum.

May be we can think of making this ordering (from lowest to highest maximum) automatic when the pad is in log scale ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.