On Fri, 30 Jun 2000, Kevin M. Rhodes wrote: > Suppose I have a file named tenhistograms.root > In this are ten histograms: { h1,h2,h3,h4,h6,h7,h8,h11,h12,h13 } > > I have a loop that analyses the histograms. > However, I want to add a for/else statement so that if a histogram is not > present, the loop will not execute, and will simply go on to check the > next histogram that does exist. Something like: You want something like char hname[20]; TFile *f = new TFile("tenhistograms.root"); for (i=1;i<20;i++) { sprintf(hname,"h%d",i); TH1F *hist = f->Get(hname); if (!hist) { cout << "No histo " << hname << endl; } else { // Do stuff with hist } Phil
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:29 MET