The necessary and sufficient conditions in weighted inequalities for singular integrals and a local Tb theorem with an energy side condition