Histogram on same canvas

I am unable to understand why I am not able to see both timetest and test histograms on the same canvas?
I am drawing them with the option same but they are not visible to me at the same time???
Can someone please help me out?

Files and data-SwissTransfer.com - Envoi sécurisé et gratuit de gros fichiers

Maybe the y-axis scales are different (edit: supposing they are not empty, as couet points out below). Try adding them to a THStack, which ensures all are visible.

I ran your macro. Your histograms test and timetest are empty.
That’s why nothing is “visible”.

Note also that your original macro had some C++ mistakes producing warnings. I fixed them but, of course, that was not the reason for the empty pad.

I don’t think that the histograms are empty as I am filling them will the value Calorimeter and TimeCalorimeter. It looks like this where I am only able to see one histogram.

I added the code:

 cout << "Number of entries in timetest = " << timetest->GetEntries() << endl;
 cout << "Number of entries in test = " << test->GetEntries() << endl;

And I get:

% root
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Nov 01 2022, 13:41:29                      |
  | From heads/arrow-on-axis@v6-25-02-2657-gcf85b10bb6               |
  | With Apple clang version 14.0.0 (clang-1400.0.29.102)            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |

root [0] .L Playtime.C
root [1] Playtime t
(Playtime &) @0x100a930a0
root [2] t.Loop();
Error in <TFile::TFile>: file /home/hemantika/Documents/GANIL_Exogram/data/run_7_r0.root does not exist
CPU speed  4000 MHz |  Physical RAM 32768 MB

-------------------------------------------------------test5 below ---------------------------------------------------------------------------
Number of entries in timetest = 0
Number of entries in test = 0
Total Entries test : 0
Total Entries test in hist filled with all four cristals : 0
Total Entries test in Calorimeternew hist : 0
Total Entries test1 : 0
Total Entries test2 : 0
Total Entries test3 : 0
Total Entries test4 : 0
Total Entries test6 : 0
root [3] 

Which confirm your histograms are empty.

@couet Error in <TFile::TFile>: file ... does not exist

@Hallie timetest->SetLineStyle(2); test->SetLineStyle(3);

1 Like

Ah damned. … full path name … thanks ! @Wile_E_Coyote

If you change a bit the drawing part of your code you will see that the two histograms overlap exactly with each other:


you can also proceed as @dastudillo suggested and get a similar plot.


Sorry to have not seen the file name path was incorrect.

1 Like

Thank you so much.