Maximum-likelihood positioning algorithm for segmented modular detectors