Beispiel #1
0
def draw_conversions(directory):
    from minty.utils.brace_expand import get_expand
    gStyle.SetOptStat(1110)
    #gStyle.SetOptStat(11111111)
    variable = "eta"
    #variable = "mass_wide"
    
    #variable = "deltar"
    hists = get_expand(directory, "conv{1,2,neither,both}/boson/%s" % variable)
    hists = map(meaningful_yaxis, hists)
    conv1, conv2, convn, convb = hists
    
    titles = ["(only) Leading converted", 
              "(only) Subleading converted", 
              "Neither converted", 
              "Both converted"]
    
    for h, t in zip(hists, titles):
        
        h.SetTitle(t)
        #if variable in ["mass_wide", "phi"]:
        #print "Scaling", h
        #h.Scale(convn.Integral() / h.Integral())
        
        if variable == "mass_wide":
            h.Rebin(4000 / 800) # (4000 is original binning, 200 target)
            h.GetXaxis().SetRangeUser(50, 300)
            #h.GetXaxis().SetRangeUser(80, 100)
        if variable == "eta":
            h.Rebin(2)
    
    maxv = max(h.GetMaximum() * 1.1 for h in hists)
    for h in hists:
        h.GetYaxis().SetRangeUser(0, maxv)
    
    canvas = R.TCanvas("mass-conversions", "Mgg conversions")
    canvas.Divide(2,2)
    #strs = canvas.strs = []
    for i, h in enumerate(hists):
        canvas.cd(i+1)
        h.Draw()
        convn.SetLineColor(R.kRed)
        convn.Draw("same hist")
        
        #t = R.TText(0.4, 0.5, h.GetTitle())
        #t.SetNDC()
        #strs.append(t)
        #t.Draw()
        
    
    wait()
    if canvas:
        canvas.Close()
Beispiel #2
0
def multifit(self, params):
    import rootils.uncert as U
    from minty.utils import wait, canvas
    gROOT.SetBatch()
    R.gStyle.SetOptStat(1000000) # Integral only
    R.gStyle.SetOptFit(11)
    
    f = TFile("all.root")
    h = f.Get("corrected/ph/boson/mass_wide")
    
    window_size = 25
    
    bins = array('d', [])
    values = array('d', [])
    errors = array('d', [])
    
    for i in xrange(80, 600, 5):
        h.GetXaxis().SetRangeUser(i - window_size/2, i + window_size/2)
        
        with canvas() as c:
            const, slope = U.from_fitresultp(h.Fit("expo", "LLISQ"))
            c.SaveAs("plots/massfit-{0}GeV.png".format(i))
        
        integral = h.Integral()
        
        bins.append(i)
        values.append(slope.nominal_value)
        errors.append(slope.std_dev())
     
    gROOT.SetBatch(0)
    with canvas() as c:
        g = R.TGraphErrors(len(bins), bins, values, array('d', [0]*len(bins)), errors)
        g.Draw("A*P")
        c.SaveAs("plots/massfit-pieces.png")
        
        wait()