Implemented losses per event per asset

See https://bugs.launchpad.net/oq-engine/+bug/1383291 and the companion PR https://github.com/gem/oq-commonlib/pull/45. The tests are running here: https://ci.openquake.org/job/zdevel_oq-engine/766
I prefer the keep the ugliness as it is, because the plan is to move the checks here from the engine into commonlib. Having a ugly series of `ifs` increases the likeness of cleaning this sooner ;-)