You might find this post related to your problem, and a very clean solution is included
[url]TH3F "4D" histogram