I have an histo h giving the energy distribution in a given material. On the x axis I have the energy value and on the Y axis the corresponding number of occurrence. If I want to get the total energy, how should I do? Should I take the integral, namely h->Integral()?

Another good idea would be (sensitive to user’s changes to the current x-axis range):

// change the x-axis range, if desired, and then ...
Double_t stats[(TH1::kNstat)]; // sums of w, w^2, w*x, w*x^2, ...
h->GetStats(stats);
std::cout << stats[2] << "\n"; // sum of w*x