add lots of const, and, in two exceptional cases, const_cast
to be applied in conjunction with LHCb!2852 (merged)