Suggestion

Hello :smiley:

I think that the ROOT User’s Guide or the comments to the ROOT functions
(Reference Manual) should be expanded significantly to explain the very
important moments while using the functions. ROOT does a lot of things
without asking a user. So I often try to use some new functions from ROOT
but end up with throwing out my code and doing things in the very direct
and stupid manner just because I do not understand why my programs crash
and how to use properly the functions and what to keep in mind.
The present documentation is definitely not enough.

At least it would be nice to do that for the very important types like TTree.

ROOT would became much more useful :exclamation:

Sincerely yours,
Sergei.

Sergei,

I agree with you that we have many deficiencies in the Guide and the
Reference Manual. Wherethe doc is not complete, we try to illustrate
the functionality as much as possible via examples by pointing to the tutorials or the test directory.
The improvements in the doc can also come by suggestions and contributions from users. It would be interesting to know from you the concrete places where you had difficulties and would like to see improvements.

Rene

Dear Rene,

Yes, of course I can provide some examples from my recent experience
where I would like to see some improvements.

  1. I think that TTree::CopyTree is a very useful function but sometimes
    it works properly for me (for NTuples) and sometimes it crashes my
    programs although I do my best trying to use it just the same way
    (for Trees where one brunch is an integer number and the other
    is an NTuple associated with it). I do not understand why :cry: neither
    the other people do to whom I showed my code. And also nevertheless
    the created tree is associated with the mother tree one have to
    delete it with subTree->Delete(“ALL”) to avoid memory leakage if the
    function is used in a loop.

  2. I do not understand why I have to read the Tree described above
    in completely different way in the following two situations:

    a) just reading one Tree
    b) reading a TChain made of many such Trees

My assumption is that Trees and Chains should be read the same way
but it is definitely not so.

  1. I do not understand how to use properly

TChain::Merge(TFile* file, Int_t basketsize, Option_t* option)

function. I am successful merging files with Ntuples but while I try to
read the Tree described above my program crashes.

  1. It would be nice to reveal in more details how the function

TTree::Reset

works. For example I spent a lot of time trying to understand why my
program does not work only to find out that this function does not
reset branch addresses :frowning:

  1. All the addresses stuff is a miracle to me in many cases. So to make
    my programs work I often have to create and destroy my objects in
    a loop into which I read some Trees saved in a Tree.

  2. I do not understand the difference between

“delete tree” and “tree->Delete(“ALL”);”

There should be some difference because sometimes it is critical to
choose the correct version of the two to make the program work.

  1. Just a pair of concrete suggestions how to improve ROOT documentation:

    a) I think that for the most important types there should be small
    macros showing how to use properly their functions with short
    comments. At the moment many functions do not have any
    examples. We have only the very basic examples of using
    ROOT. May be there should be another sub-folder named
    "advanced_examples" so that people could do “grep” in the folder
    to find out places where some function is used to have a
    look “how”.

    b) In most cases while using some ROOT function the first thing that
    people do is to look at the Reference Manual.
    The same thing they do when they want to do something and
    try to find a proper function. So there should information in the
    Manual about function usage for all the functions (at least
    for the very important types).

    c) It would be nice to have some general story about what happens
    inside of ROOT, about its philosophy. I think in many cases I
    would really help to understand how to use anything.

Sorry for the long writing :smiley: Emtions…

And as to me I do not mind to make some contribution in creating some
additional peaces of ROOT documentation :slight_smile: But I am not sure that it would
be a correct documentation :wink:

Sincerely yours,
Sergei.

[quote]1) I think that TTree::CopyTree is a very useful function but sometimes
it works properly for me (for NTuples) and sometimes it crashes my
programs[/quote]
Which version of ROOT are you using? The latest version should not be presenting such problem? Did you send us an example to reproduce this problem?

[quote]2) I do not understand why I have to read the Tree described above
in completely different way in the following two situations:
[/quote]
What’s the difference? What is your case?

[quote]6) I do not understand the difference between
"delete tree" and “tree->Delete(“ALL”);” [/quote]
Do not use tree->Delete, it should be reserved only for some rare implementation cases.

Cheers,
Philippe.

Dear Philippe,

I use ROOT version 3.05/07 because it is my experiment (Phobos, RHIC)
standard.

No, I did not. But I could if you suppose that this problem is not solved yet.

The case is the following: a Tree has one brunch that is an integer number
and the other is a one-variable-NTuple associated with it. The examples
how I read the two different cases now are attached. Neither of them
works for both TChain and TTree. And I am completely unable to read such
Tree after merging several files with function

TChain::Merge(TFile* file, Int_t basketsize, Option_t* option)

because my program crashes :frowning:

Why? It is a public function and it works in my program. And why is
it not said in the Reference Manual: "Hey, people, do not use this function!
Use “delete” instead!!!

Sincerely yours,
Sergei.
read_mixedEvents_KpKm_invMass_63GeV.C (1.31 KB)
read_finalResult_KpKm_invMass_63GeV.C (1.92 KB)

[quote]I use ROOT version 3.05/07 because it is my experiment (Phobos, RHIC)
standard. [/quote]
CloneTree (and Merge) should be working in this release. Please send an example I can run demonstrating the problem.

[quote]TNtuple* ntpl = new TNtuple();
t->SetBranchAddress(“InvMassNTupleBranch”, &ntpl);[/quote]
This is a surprising combination.
An ntuple should be not stored as a branch of a tree! At the very least I never tried this combination! I am surprised it even remotely works. There are issues about which files is going to be the location of the data of the ntuple (by default it is the current ROOT directory, which might or might not be set properly for Merge to work in your case).

Anyway, indenpendently of wether it works or not, it is unlikely that having a tree of ntuple is the efficient way of achieving what you are trying to do (can you specify what you need?)

[quote]Why? It is a public function and it works in my program.
[/quote]
Yes it is public … but this does not mean it is not an ‘advanced’ method.
This particular function should be used only after careful reading the information that is available in its documentation and code. I meants to say that it is very very unlikely that you need to use it in your code.

[quote] And why is
it not said in the Reference Manual: "Hey, people, do not use this function!
Use “delete” instead!!!
[/quote]
Can you remind me which page in the User’s Guide, TObject;:Delete is described. If it is not there already a duplicate of TOject::Delete documentation needs to be copied there. Specifically it says “// Normally use “delete” operator when object has been allocated on the heap.”

Did you save a TChain in that file or is it the result of TChain::Merge?
If it is the result of TChain::Merge, it is a TTree and not a TChain.

The major difference I can think of between the TTree and TChain case,
is that the setting

ntpl->SetBranchAddress("invMass", &im);
which refer to the ntuple which is inside the TTree is not carried over between tree (it might be that the object is recreated between each TTree). In which case you would need to call it, after each file is processed (you can detect that when TChain->GetTreeNumber changes).

However, you method using ntup->Draw is probably failing because the htmp histogram is created in the current directory (which is the file being read) and deleted when the file is closed. In which case you might be need to move the htmp directory around (for example use htmp->SetDirectory).

Cheers,
Philippe.