In my analysis code, I set up all tools in the beginning and then run over multiple xAODs, both MC and data. I use the PMGTruthWeightTool to retrieve MC event weights (and I obviously don't call the
getWeight(...) method for data events).
The tool causes a crash in the
beginEvent() method, when it tries to retrieve mcEventWeights from the EventInfo object of data events. The additional return statement makes sure that the mcEventWeights are never retrieved for data events.
I tested the changed version locally and it runs fine.