Ejemplo n.º 1
0
def getNominalUpDown(file):
    finder = utils.ObjFinder("TH1D")
    names = finder.findRecursive(file)
    nomRegex  = re.compile('^histo_([^_]+)$')
    systRegex = re.compile('^histo_([^_]+)_(.+)(Up|Down)$')

    nominals = {}
    nomupdown = {}
    for name in names:
        if not nomRegex.match(name):
            continue
        h = getHist(file,name)
        nominals[name.replace('histo_','')] = h

    for name in names:
        m = systRegex.match(name)
        if not m: continue
        
        process,syst,var = m.group(1,2,3)

        if process not in nomupdown:
            nomupdown[process] = {}
        
        if not syst in nomupdown[process]:
            v =  variation()
            v.Nom = nominals[process]
            nomupdown[process][syst] = v

        hUpDown = getHist(file,name)
        setattr(nomupdown[process][syst],var,hUpDown)


    return nomupdown
Ejemplo n.º 2
0
def GetHistPaths( path ):
    rootFile = ROOT.TFile.Open(path)

    finder = utils.ObjFinder('TH1D')

    names = finder.findRecursive(rootFile)

    plist = rootFile.Get('processes')
    processes = [ p.GetName() for p in plist ] if plist.__nonzero__() else None

    return rootFile,names,processes
Ejemplo n.º 3
0
def getNominals(file):
#     rootFile = ROOT.TFile.Open(file)
    finder = utils.ObjFinder("TH1D")
    names = finder.findRecursive(file)
    nomRegex  = re.compile('^histo_([^_]+)$')

    nominals = {}
    for name in names:
        if not nomRegex.match(name):
            continue
        h = getHist(file,name)
        nominals[name.replace('histo_','')] = h
                 
    return nominals
Ejemplo n.º 4
0
    def match(self, rootfile):
        finder = utils.ObjFinder('TH1')
        paths = set(finder.find(rootfile))

        notFound = []
        self.plots = {}

        for name, metaPlot in self.metaPlots.iteritems():
            #             print name
            matches = fnmatch.filter(paths, name)
            if len(matches) == 0:
                notFound.append(name)
            for m in matches:
                p = copy.copy(metaPlot)
                p.name = m
                self.plots[m] = p


#         print '\n'.join(self.plots.iterkeys())
        if len(notFound):
            raise RuntimeError('Histograms not found! ' + ','.join(notFound))

        return self.plots