SELECT DISTINCT
    detNormalizedImfile.*
FROM detNormalizedImfile
JOIN detRun
    USING(det_id)
JOIN detRunSummary
    ON detNormalizedImfile.det_id = detRunSummary.det_id
    AND detNormalizedImfile.iteration = detRunSummary.iteration
WHERE
    detRun.state = 'stop'
    AND detRun.mode  = 'master'
    AND detRunSummary.accept = 1
