Filling histogram using ttree branch

Hello All,

Traditional way of creating correlation plot using data stored in the NTuple is to fill the TH2D using Fill method, for instance

//... intialization and other non important code 

int entries=tree.getEntry();
for( int i=0;i<entries;i++){

It is possible to replace above code using TTree::Draw() method.

Search for the string “>>” in the TTree::Draw method description.

Wile E. Coyote I cannot find any satisfactory way of calling TTree::Draw().
What I wanted to do is make TH2D contained number of entry.
However TTree::Draw(“chi2:pt>>histogram”) return TProfile contain of one event only and that is not what I want.

Try something like this (put below some reasonable values instead of “MIN/MAX_CHI2/PT”):

TH2D *h = new TH2D("h", "My 2D h;chi2;pt", 30, MIN_CHI2, MAX_CHI2, 30, MIN_PT, MAX_PT); tree->Draw("pt:chi2>>h");