A method for automatic collimator alignment in microdensity measurements