Procedure for short-lived particle detection in the OPERA experiment and its application to charm decays