if not options.out: raise RuntimeError
    outdir = os.path.basename(options.out)
    if outdir:
        if not os.path.exists(outdir):
            os.system("mkdir -p "+outdir)
            if os.path.exists("/afs/cern.ch"): os.system("cp /afs/cern.ch/user/g/gpetrucc/php/index.php "+outdir)
    outfile = ROOT.TFile(options.out, "RECREATE")
    ROOT.gROOT.ProcessLine(".x tdrstyle.cc")
    ROOT.gStyle.SetOptStat(0)
    
    alleffs = []
    for i,arg in enumerate(args):
        filename,pattern,processes = arg.split(":")
        processes = processes.split(",")
        graphs = readGraphs(filename, pattern, processes)
        for p in processes:
            opts = attrs(filename, p)
            setattrs(graphs[p], opts, options.xtitle)
            alleffs.append( ( opts['Label'], graphs[p] ) )
            graphs[p].order = opts['#']
            outfile.WriteTObject(graphs[p], opts['key'])
    alleffs.sort(key = lambda (l,g) : g.order)
    stackEffs(options.out,None,alleffs,options)
    shortEffs = [ (l,g) for (l,g) in alleffs if g.order == 0 ]
    cdata = combine([ g for (l,g) in alleffs if 'data' in g.GetName() ], options.combMode)
    setattrs(cdata, { 'Color':ROOT.kBlack, 'key':'data_comb', 'Label':'Data, comb.' }, options.xtitle)
    outfile.WriteTObject(cdata)
    shortEffs.append( ( 'Data, comb.', cdata) )
    stackEffs(options.out.replace(".root","_one.root"),None,shortEffs,options)
    
 for lep, h2d, h2dtt, h2tt_norm, xcuts in (("el", h2d_el, h2d_el_tt,
                                            h2d_el_tt_norm, [30]),
                                           ("mu", h2d_mu, h2d_mu_tt,
                                            h2d_mu_tt_norm, [20, 45])):
     for ieta, eta in enumerate(["barrel", "endcap"]):
         effs = [(n, graphFromXSlice(h, ieta + 1))
                 for (n, h) in zip(["MC ttbar"], h2dtt)]
         effs += [(n, graphFromXSlice(h, ieta + 1))
                  for (n, h) in zip(Xnices, h2d)]
         styles(effs)
         options.xlines = xcuts
         savErrorLevel = ROOT.gErrorIgnoreLevel
         ROOT.gErrorIgnoreLevel = ROOT.kWarning
         stackEffs(PlotOut + "/fr_%s_%s_%s.root" % (lep, eta, year),
                   None,
                   effs,
                   options,
                   legHeader="%s %s, %s" % (lep, eta, year))
         ROOT.gErrorIgnoreLevel = savErrorLevel
     variants = makeVariants(
         h2d[-1], norm=(h2tt_norm[0] if options.norm else None))
     for v in variants:
         outfile.WriteTObject(v, v.GetName())
     for ieta, eta in enumerate(["barrel", "endcap"]):
         effs = [('nominal', graphFromXSlice(h2d[-1], ieta + 1))]
         for v in variants:
             label = v.GetName().rsplit("_", 1)[1]
             effs.append((label, graphFromXSlice(v, ieta + 1)))
         styles(effs)
         options.xlines = xcuts
         savErrorLevel = ROOT.gErrorIgnoreLevel
Exemplo n.º 3
0
        for h in h2d_el_tt + h2d_mu_tt:
            outfile.WriteTObject(h)

        # Plot
        if options.outdir:
            for lep, h2d, h2dtt, xcuts in (("el", h2d_el, h2d_el_tt, [30]),
                                           ("mu", h2d_mu, h2d_mu_tt, [20,
                                                                      45])):
                for ieta, eta in enumerate(["barrel", "endcap"]):
                    effs = [(n, graphFromXSlice(h, ieta + 1))
                            for (n, h) in zip(["MC ttbar"], h2dtt)]
                    effs += [(n, graphFromXSlice(h, ieta + 1))
                             for (n, h) in zip(Xnices, h2d)]
                    styles(effs)
                    options.xlines = xcuts
                    stackEffs(options.outdir + "/fr_%s_%s.root" % (lep, eta),
                              None, effs, options)
                variants = makeVariants(h2d[1])
                for v in variants:
                    outfile.WriteTObject(v, v.GetName())
                for ieta, eta in enumerate(["barrel", "endcap"]):
                    effs = [('nominal', graphFromXSlice(h2d[1], ieta + 1))]
                    for v in variants:
                        label = v.GetName().rsplit("_", 1)[1]
                        if label in ('b1', 'b2') and eta == "endcap": continue
                        if label in ('ec1', 'ec2') and eta == "barrel":
                            continue
                        effs.append((label, graphFromXSlice(v, ieta + 1)))
                    styles(effs)
                    options.xlines = xcuts
                    stackEffs(
                        options.outdir + "/variants_fr_%s_%s.root" %