You can Draw or Scan the special function Sum$ of the branch. So something like:
t.Draw("Sum$(energy)","eventID==X");
A list of the special “" functions can be found here: [url]http://root.cern.ch/root/html/TTree.html#TTree:Draw@1[/url]. There is no direct link to the actual section that talks about them, so use your browser's search function to look for "Entry” (with the dollar-sign) to find the list.