Exemplo n.º 1
0
def getClone(tfile, root_dir, name):
    th1 = getHist(tfile, root_dir, name)
    cloned = th1.Clone()
    cloned.SetDirectory(0)
    cloned.Sumw2()
    ROOT.SetOwnership(cloned, 1)
    return cloned
Exemplo n.º 2
0
def getHist(tfile, root_dir, name):
    readname = ''
    if root_dir != '':
        readname = root_dir + '/'

    readname += name
    #print 'getting ',readname
    th1 = tfile.Get(readname)
    try:
        if th1.IsZombie():
            print 'no such histogram!'
            return None
    except ReferenceError, e:
        print "Failed to read %s" % readname
        return None
    ROOT.SetOwnership(th1, 1)
    return th1


# get a clone of the histogram, considering its location
def getClone(tfile, root_dir, name):
    th1 = getHist(tfile, root_dir, name)
    cloned = th1.Clone()
    cloned.SetDirectory(0)
    cloned.Sumw2()
    ROOT.SetOwnership(cloned, 1)
    return cloned


# substitute the leading part of the name (Top, WJets, etc) by user-defined prefix
# will help to deal with multiple single top templates, for example