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()?

Try (sensitive to user’s changes to the current x-axis range): std::cout << h->GetMean() * h->Integral() << "\n";
and/or (valid only for the “entire” x-axis range): std::cout << h->GetMean() * h->GetSumOfWeights() << "\n";