SELECT
    magic_ds_id,
    exp_id,
    re_place,
    rawImfile.camera,
    stage,
    stage_id,
    component,
    outroot,
    rawImfile.uri AS path_base,
    NULL AS cam_path_base,
    bytes,
    md5sum
FROM magicDSRun
    JOIN magicDSFile using(magic_ds_id)
    JOIN rawImfile ON (stage_id = exp_id AND component = class_id)
    JOIN summitImfile ON (rawImfile.exp_name = summitImfile.exp_name 
                      AND rawImfile.tmp_class_id = summitImfile.class_id)
WHERE magicDSRun.stage = 'raw'
    AND (magicDSRun.state = 'new' OR magicDSRun.state = 'censored')
    AND magicDSFile.fault > 0
