An investigation is under way after a semi-automatic gun was left in coffee shop by a firearms officer.