Only last histo is plottet when looping over histos in a fil

Hi all,

I have a small problem with plotting histos.
I have a simple macro which goes through the histos of a file
and (should) plot them.
However, it always only draws the last histogram.
It ignores the canv->divide(3,3) and canv->cd(i) completely.

I just cannot figure out how to do it.
It should plot the histos one by one into the pads of
the canvas.

Any suggestions?
Thanks!
Andi

P.S.: I also wanted to compile it (because it gives me a “safer” feeling … but I cannot find the right include for the TIter, does anybody know where that is?)

{
TCanvas* canv = new TCanvas(“m_canv”, “”, 200, 200, 700,320);
canv->Divide(3,3);

TString dir("/afs/cern.ch/user/w/wildauer/atlas/analysis/ntuple/");
TFile* fsig = new TFile(dir+“Sig_ref.root”);
fsig->cd(“REF/t3333”);

// the variable gDirectory always points to the current directory of the file
TIter next(gDirectory->GetListOfKeys());
TKey* myKey;
TH1F* hsig(0);
int i(0);
while (myKey=(TKey*)next())
{
canv->cd(i);
std::cout << "Plotting: " << myKey->GetName() << std::endl;
hsig = (TH1F*)gDirectory->Get(myKey->GetName());
hsig->Scale(1./hsig->Integral());
hsig->SetLineColor(2);
hsig->Draw();
++i;
}

The first subpad is number 1, not 0.
The mother pad is number 0.

Rene

Thanks, that was it …
There is still the question of compiling:

What’s the include for TIter?
I looked in the class reference but some how cannot find it.

Andi

#include “TCollection.h”

When you have a problem of this type, do a grep in $ROOTSYS/include

Rene