Write more TH1 to a TFile

Hi everyone,
i’m trying to write more histograms to a file.
I’m doing:

TH1D **h=new TH1D*[5];
for (int i=0;i<5;i++){
   h[i]=new TH1D(name,title,nbinsx,xmin,xmax); //all parameters are present, and names are different
}
.. 
..
TFile f("out.root","recreate");
f.cd();
for (int i=0;i<5;i++){
  h[i]->Write();
}
f.Write();
f.Close();

When i open the TFile, and use ls(), i see only the last histogram: how can i save all of them?
Thanks in advance

Andrea

[quote]When i open the TFile, and use ls(), i see only the last histogram: how can i save all of them?
Thanks in advance[/quote]This must mean that the name are not different (your code snippet does use the same name for all histo).

Cheers,
Philippe.

Now it works: it seems that i can’t use the character “/” in a TFile name.

Andrea

Hi Andrea,

That is correct as it is also the delimiter between directory names (and object name).

Cheers,
Philippe