Blank canvas when using THStack and multiple input files

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.16/00 and 6.24/04
Platform: Ubuntu 18.04.6 and Red Hat 4.8.5-44
Compiler: gcc v7.5.0 and gcc v4.8.5

I was trying to plot multiple observables from multiple files using a for-loop over the files and THStack for the histograms to plot in the same canvas. But by doing that I am getting a blank canvas. But instead, if I use only one file (i.e., without the for loop over the files), then it is plotting fine with THStack. I have been trying different things but nothing is working. Could you please help me to find where I have made mistakes?
I have attached a small macro here. Let me know if I need to give the example datafiles.

Thank you for any possible help.


PlotsN.C (1.9 KB)

gROOT->cd(); // newly created histograms should go here
TH1F *histM0 = new TH1F(...);
TH1F *histM1 = new TH1F(...);

Yes, if @Wile_E_Coyote advice does not help.

Thanks a lot, @Wile_E_Coyote. This thing I tried, i.e., while using only one inputfile. Earlier also I followed the same procedure to plot variables from a Delphes output file using Delphes library. I corrected one mistake; the line TH1F *histM0[ii], *histM1[ii]; should be put outside the file loop. But still it is not working. So I have attached the corrected macro and two example datafiles.

Thanks @Wile_E_Coyote and @couet .

PlotsN.C (2.0 KB)
ttjj.root (24.8 KB)
twjj.root (29.1 KB)

1 Like

Thanks a lot, @Wile_E_Coyote. It worked. Earlier I mistook gROOT->cd(); with gSystem->cd();.
Thanks a lot.