def sumW2BinRange(hist, binRange):
    """ Sum bin w2 over the bin range """
    sumw2 = hist.GetSumw2()
    if sumw2.GetSize() == 0:
        raise AssertionError("Asked for sumw2 for a histogram that doesn't have weights")
    return sum( sumw2.At(i) for i in binRange )