Draw and nested loops with two arrays (a better description)

Hi. I decided to post this problem again because I was no clear in the previous post. I guess “nested loop” is a better description of my problem than “multiple loops”.

I have a branch with an object Spectrometer, which has two object of type Detector. The Detector has 2 arrays *fX and fY with fNhits elements. I need to plot a TH2F histogram where for each X[i] all the Y[j] (j=0;j<fNhit) are plotted. I have looked at the TTree::Draw documentation and the forum but could not find anything that seems quick and easy to use. The closest solution I found seems to be using MakeProxy, but we don’t want (if possible) to have separate files with scripts spread around.
The Draw(“Y:X”) doesn’t do what I need, because it plots the pairs X[0]:Y[0], X[1]:Y[1] and so on, but I need X[0]:Y[0], X[0]:Y[1], X[0]:Y[2],…,X[1]:Y[0], X[2]:Y[1], and so on.

Thanks.

Luiz

Hi Luiz,

Indeed TTree::Draw does not have syntax (expect if using a separate scrip) to implement what you need directly.

The closest should be the following (inefficient) trick:

for (int i=0;i<max_x_size,++i) { tree->Draw(Form("X[%d]:Y>>+myhist",i)); }

Cheers,
Philippe.