chain->Draw("var:chain->GetTreeNumber()")

Hello

Is there a way to use TTree::Draw to plot a variable vs the tree index inside its chain? for instance, if I have 10 TTree’s inside the chain, then the X axis should run from 0…9.

This was actually asked here but I did not find the follow up.

Thank you very much

tree->Draw("X:LocalEntry$");

Excuse me, I was probably not very clear.

If I have 10 trees with 9999 entries each, I want to plot a variable of the chain vs the number of the tree.

chain->Draw(“Power:NumberOfTree”,“”,“prof”)

So the variable NumberOfTree would evaluate between 0 and 9 and not between 0-9999. The variable NumberOfTree should be just an index that expresses the position of the tree in the chain.

This is useful to monitor the value of variable across each tree that takes part of the chain.

You can use the This identifier to access the TChain object and call any function on it (in your case you want TChain::GeTreeNumber. For example (Draw and Scan use the same syntax), the following prints the px (on of the branch) and the NumberOfTree for the first 10 entries of each of the TTrees.

ch.Scan("px:This->GetTreeNumber()","LocalEntry$<10")

Awesome, thank you very much!