tree->Draw(“matrix[ ] : matrix[ ] >> hist2D”) draws a 45 degree line

What I would like is the draw to loop over the matrix elements twice: one for each occurrence of matrix[ ]

My desired output is a 2D histogram with points at

matrix[0] : matrix[0]

matrix[1] : matrix[0]

matrix[2] : matrix[0]

…

matrix[0] : matrix[1]

matrix[1] : matrix[1]

matrix[2] : matrix[1]

…

…

I haven’t found a clear way to do this yet, can someone point me to the post that solves this?

-Leo

Hi Leo,

unfortunately the TTree::Draw syntax does not yet support nested loops.

Cheers,

Danilo

You could call several times Draw on the same histogram using the + option.

```
TH2* h2 = new TH2F("hist2D","title", <set your binning>);
tree->Draw("matrix[ ] : matrix[0] >> hist2D");
tree->Draw("matrix[ ] : matrix[1] >>+ hist2D");
tree->Draw("matrix[ ] : matrix[2] >>+ hist2D");
```