UFO energy per layer fix
This MR fixes an occasional segfault produced by !56971 (merged) which caused certain ART tests to fail, by making sure that otherObject() exists before checking its type. Marking as urgent because this is needed for JETM1.
I have now tested on more events to make sure that I do not run into any issues.
Tagging @mleblanc @mswiatlo @camacho @cdelitzs @haweber @mspalla