Irreproducible behavior in TTree::Draw

I’m using root 5.26/00 on mac os-x 10.6 processing a tree created also under mac os-x. My tree has a branch created from an std::vector of a simple struct, which CINT has converted into a set of TClonesArrays, one for each field in the struct. I find that, when I use TTree::Draw() to display the struct variables subject to a condition based on other branches, the histogram produced changes depending on the history of other TTree::Draw commands. For instance, using the TFile located at: dnbmac3.lbl.gov/~brownd/Draw_Problem.root
The macro
dnbmac3.lbl.gov/~brownd/Draw_Problem.C
will produce a canvas showing the problem: projection of the same quantity giving different results on subsequent calls, as shown in
dnbmac3.lbl.gov/~brownd/Draw_Problem.png
I find I can get back the ‘original’ plot if I change the conditional, then change it back. I’ve tried variations like explicitly using the struct name and [], they do not affect the results. I also tried including the proper pragmas to avoid the runtime warning “Warning in TClass::TClass: no dictionary for class PacSimHitInfo is available”, again that does not affect the results. Any guidance on how to get accurate results from this Draw would be appreciated.

(addendum) I find that Ttree::Scan works fine with these exact same arguments, producing the same (correct) values every time, regardless of the command history.

Hi,

[quote]My tree has a branch created from an std::vector of a simple struct, which CINT has converted into a set of TClonesArrays, one for each field in the struct.[/quote]I do not understand what you mean. CINT will never convert a vector into a TClonesArray unless explicitly asked to … Can you be more explicit?

Philippe.

[quote=“pcanal”]Hi,

[quote]My tree has a branch created from an std::vector of a simple struct, which CINT has converted into a set of TClonesArrays, one for each field in the struct.[/quote]I do not understand what you mean. CINT will never convert a vector into a TClonesArray unless explicitly asked to … Can you be more explicit?

Philippe.[/quote]

What I mean is that CINT separated each field of the struct into a separate branch, which to me looks like a TClonesArray, but perhaps it is something else.

Dave

(addendum) I upgraded to 5.26.00e after seeing the patch build log refer to a fix in TTree::Draw related to std::vector. Unfortunately I still see this irreproducible behavior.

[quote]What I mean is that CINT separated each field of the struct into a separate branch, which to me looks like a TClonesArray, but perhaps it is something else.[/quote]Humm … CINT is not involved in this operation :slight_smile:. The TTree is capable of splitting both TClonesArray and collection of objects. It store them on file in a very similar fashion but does not transform one into the other. We usually refer to this operation as ‘splitting’ the collection.

Cheers,
Philippe.

quote I upgraded to 5.26.00e after seeing the patch build log refer to a fix in TTree::Draw related to std::vector. Unfortunately I still see this irreproducible behavior.[/quote]Indeed, I can reproduce this issue with the trunk. A fix should be available shortly.

Cheers,
Philippe.

Hi,

The problem is fixed by revision 36672 of the trunk. Note that this problem exist if and only if you plot exactly one entry of the TTree and the data is part of a collection and the collection is not part of the selection.

Cheers,
Philippe.

Hi Philippe,

I confirm root (5.27) trunk revision 36672 fixes this problem.

Thanks, Dave