File with 2 TTrees with high number of entries

Good morning,
I’ve noticed a strange behaviour when I create a TTrre object with a .cxx code.
If the number of entries is >=2,5M, I’ll find 2 trees in the output file. This happens only in this case. These 2 trees have the same number of entries, and when I’ve superimposed 2 histograms, generated from them, they are perfectly identical.
Is it nornal?

Thanks.

Tina

[quote]If the number of entries is >=2,5M, I’ll find 2 trees in the output file.[/quote]This is expected. See root.cern.ch/root/html/TTree.htm … ChangeFile for the details and some very important notes.

[quote] These 2 trees have the same number of entries, and when I’ve superimposed 2 histograms, generated from them, they are perfectly identical.
Is it nornal? [/quote]This is probably NOT normal and it likely to be due to a problem in the script writing the file(s). Please read carefully the documentation for ChangeFile.

Cheers,
Philippe.

I think the problem is different.
Using my script, I’ve found only one file containing two Trees and not 2 files … I’ve seen in the documentation for ChangeFile that it creates two files, like “my_file1.root” , “my_file2.root” and so on. This is not my case.
I’ve found in my file 2 trees, like "h1;1"and “h1;2” with the same number of entries.
Also my output file doesn’t reach fgMaxTreeSize.

Thanks,
Ti na.

[quote]I’ve found in my file 2 trees, like "h1;1"and “h1;2” with the same number of entries. [/quote]Ah. This is not a problem per se. Re-read carefully the chapter 11 of the User’s Guide (Input/Output). h1;1 is actually a backup copy of h1;2 (and because of the way TTree is designed only contains the meta data for the TTree). You should only use h1;2 (or never specify any ;x). You can also ‘avoid’ having those 2 copy by removing the tree->Write() from your code that probably look like:tree->Write(); file->Write();

Cheers,
Philippe.

[quote] You can also ‘avoid’ having those 2 copy by removing the tree->Write() from your code that probably look like:
Code:
tree->Write();
file->Write();
[/quote]

In my script I have :

.......
tree->Fill();   // in loop
.....
...
file->Write();    // out of loop

If I remove the 1st line, my script won’t work correctly… so do I have to remove the 2nd one, in order to have only one copy of my tree?

Cheers,
Tina.

[quote]If I remove the 1st line, my script won’t work correctly… so do I have to remove the 2nd one, in order to have only one copy of my tree? [/quote]No, you need both those line. The only one you could remove is tree->Write (that you have not listed). What is the reason you want to strip the backup copy (aka is it really worth the extra complexity?). See the documentation for TFile::Write for another means of ‘removing’ the backup copy.

Cheers,
Philippe.