Hello.
I have a problem with creating hstack. I have a bunch of histograms in different .root files and I want to add them. I know how to do that, but because there is so many of them and they all look like zmumu1.root, zmumu2.root etc, I would like to make a for loop. As I am fairly new to programming, I found a piece of program from stackoverflow.com that should work, I got some ideas from couple posts here, and tried to make it work for me:
char zmumu[14];
for(Int_t i=1; i<13; i++){
sprintf(zmumu, "%s%d","zmumu",i);
TFile *zmumu = TFile::Open("zmumu[i].root");
TH1F *h = (TH1F*)gDirectory->Get("h_muon0_pt");
h0->Add(h);
}
(Not that I would really understand it. To be honest, I have no idea what sprintf ought to do.) I keep getting error message “Error in TFile::TFile: file zmumu[i].root does not exist”. Apparently, it does not do anything. Any ideas how to solve this?
Thank you very much.