Inferring causal connectivity from pairwise recordings and optogenetics