TTree::Draw question

Dear Rooters,

I have a question about using TTree::Draw. I’d like to create a 2d plot of a variable held in a tree but with different conditions on the x and y axes (same variable on x and y).

I have attached a script that will produce a simple tree to help illustrate my question (will hopefully work with “> root example.cxx++”).

For example, for event 2 below, I’d like to do fEnergy(detector7) vs fEnergy(detector4) which would plot 8 vs 27.

root [] tv__tree->Show(2)
======> EVENT:2
THits = NULL
THits.fDetector = 2, 7, 3, 4
THits.fEnergy = 4.000000, 8.000000, 9.000000, 27.000000

I’ve not found a way to do this type of plot (unless, obviously, I change the tree structure, which I’d rather not do). Is it possible (I feel I’m missing something obvious!)? I’m running x86 Gentoo with ROOT version 4.03.02.

Thanks,

Jonty.
example.cxx (1.3 KB)

Hi,

This pushes the limit of what TTree::Draw can do and it would be better to use MakeSelector (or MakeProxy or a passing a script to TTree::Draw … except that stl containers are not yet support for those last 2).

However you can still find a (less efficient) way to use TTree::Draw to do what you need:

Cheers,
Philippe

Hi Philippe,

After upgrading to root version 4.04/02b your suggestion works fine.

Thanks very much,

Jonty.