can this whole loop on r be reduced to one line?
`out = bkgd if bkgd else np.empty(nreco)+ np.dot(truth, resmat)`