See “Drawing a user function accessing the TTree data directly” in the TTree::Draw method description.