However, I do not understand, why this should be done in an access function.
Shouldn't it (determination of "newBestTrack") rather go to the pat::Muon::embedWhateverTrack functions? In case the embedding is switched off, one can (has to) still fix it in the PATMuonProducer directly.