Fix conflicting checks.

The if statement would never be true.
With this fix the functionality is preserved with some more information in case of error.
Merged refs/pull/5634/head from repository cms-sw
make Vladimirs change const correct
Merge pull request #5643 from davidlange6/fix_SimG4CoreGenerators

Fix sim g4 core generators