TTrees with same name in one file

Dear root users

I’ve noticed that in many of my root files in which there is a TTree stored, the same TTree appears several times with a ; and a number added to the name of the TTree. An example would be:
ntuple;1
ntuple;2

I would be thankful is somebody could briefly explain to me when and why these multiple instances of the same TTree appear. By doing ntuple->Draw(parameter) do I then get all entries from both trees?

Cheers,
Bjarte

Hi,

Those are ‘revisions’ of the same tree. See the User’s Guide for some details. When producing the file you can select whether those ‘revisions’ are kept in the file or not.

[quote]By doing ntuple->Draw(parameter) do I then get all entries from both trees? [/quote]No. You get info only from the ‘last one’ (unless you explicitly retrieve an older one).

Cheers,
Philippe

Hi

I have a related question. I have a ROOT file which contains a lot of TH1D histograms in a TList. If I do a “.ls” in an interactive session I get this output (but lots more)
KEY: TH1D catwd;5 catwd
KEY: TH1D catwd;4 catwd
KEY: TH1D catwd;3 catwd
KEY: TH1D catwd;2 catwd
KEY: TH1D catwd;1 catwd

My question is : How can I plot each of them separately? If I do catwd->Draw() , I plot only the last one as you said. But I cannot do catwd;5-> Draw().
Is there a way to use this “;” to draw these histograms?

I have already tried TH1D *h1 = (TH1D *) gROOT->FindObject(“catwd;5”)
and this works if I do h1->Draw(). But if I want to make a new Canvas and then TH1D *h2 = (TH1D *) gROOT->FindObject(“catwd;3”), then I can plot h2->Draw() on the new canvas, but the first one disappears? Why? What is the best way to plot these histograms separately?

(I use ROOT version 4.04/02 on a x86_64 computer with SUSE Linux 10.0)

Thanks
Tom

When importing a new object in memory from a disk directory,
a previous object with the same name in the directory in memory
is automatically deleted. You have two ways to solve this problem
-when importing an object in memory, change its name, eg
h1->SetName(“h1”);
-disable the automatic registration of the created/imported objects to the memory directory by calling
TH1::AddDirectory(kFALSE);
but in this case, it is your responsability to mange these objects.

Rene

Thank you for the quick answer. It works.

Cheers
Tom