Drawing only a certain part of a tree / chain

Hi all

One certainly dumb question:
I have a chain, containaing only one tree, with approx. 9 millions events.

I’d like to draw histograms using event #0 to event #99999, and then, the same histograms using #100000 to #199999, and so on…

I am currently using a branch called ID, which is incremented each time I Fill my tree:

ch->Draw("T0-T6>>h,“T2>100 && T10<100>=0 && ID<1000000”

But it seems very slow to me, and not very elegant.
Is there a way to do something like this:

ch[0:99999]->Draw("… ); ??

Thanks a lot!
Best regards,


In TTree::Draw (and TChain::Draw) you have arguments to specify
the number of events and the first event to be processed


Thanks Rene,
I am so sorry… It is a shame I did not read documentation up to the end.
But, one good thing is that it lead me to another question:
How can I fill an histogram up to a certain number of events ?

ch->Draw(“T0-T6+1000>>h”,“T2>100 && T10<100”)
up to, say, 1,000,000 events in the histogram.

(Eventually, I’d like to split my data in histograms, used a fixed number of entries in each histogram)


simply do:
ch->Draw(“T0-T6>>h,“T2>100 && T10<100>=0”,”",1000000);

see documentation of TTree::Draw


Well… the previous command will process the first 1,000,000 events in the chain, and fill the histogram according to the cuts I gave. I ended with h containing 518126 entries.

What I’d like to have is exactly 1,000,000 entries in the histogram, without specifying the numbers of events needed.
Maybe it’s impossible, I don’t know…


Indeed, this is not supported directly by TTree::Draw. However you can use the ‘proxy’ mechanism where you pass to TTree::Draw a small script (see TTree::Draw documentation) or you can use directly TTree::MakeProxy or TTree::MakeSelector.