I can open several root files and overlay the histograms in them. However, I have 50 root files (which I can open simultaneously and access a particular histogram in them), however, I am not sure how best to take 5 files at a time (and therefore 5 histograms) and overlay them, then move onto the next 5 histograms and overlay them. I want to take the first 5 root files, open them, access a histogram and overlay them, then move onto the next 5 root files and repeat.
I am giving a short snippet (i.e only going to list 10 files rather than all 50) of what I have.
You do not open any canvas … you only create an array of pointer to canvases.
You can create a canvas in the loop print it and then delete it when your plot is finished (5 histogram overlayed) unless you want to have the 10 canvases on screen ? You can also open one canvas and used Divide you make several overlaid plots on the same page.
You need to loop on the 50 files and every 5 plots you reset the canvas or you cd() to the next pad if you are using a Divided canvas. But now the code you posted if far to do anything like that. I think your problem is more in the C++ logic of your loop(s) than on ROOT itself.