Ejemplo n.º 1
0
def profile_plots(pt_array, ntrk_array, weight, gluon_pt_array,
                  gluon_ntrk_array, gluon_weight_array, quark_pt_array,
                  quark_ntrk_array, quark_weight_array, islogpt):
    #gStyle.SetOptFit()
    print 'total events: ' + str(len(pt_array))
    print 'gluons: ' + str(len(gluon_pt_array))
    print 'quarks: ' + str(len(quark_pt_array))
    c1 = TCanvas('c1', '', 200, 10, 700, 500)
    fittype = 'pol1'
    if islogpt:
        ptmin = 4
        ptmax = 7
        nbins = 10
    else:
        ptmin = 0
        ptmax = 1300
        nbins = 10
    hquark = TProfile('hquark', 'Quark Profile of nTrk vs ln(pt)', nbins,
                      ptmin, ptmax, ntrkmin, ntrkmax)
    weighted_hquark = TProfile('weighted_hquark',
                               'Quark Weighted Profile of nTrk vs ln(pt)',
                               nbins, ptmin, ptmax, ntrkmin, ntrkmax)
    count = 0
    for i, j, k in zip(quark_pt_array, quark_ntrk_array, quark_weight_array):
        count += 1
        if count % 100000 == 0:
            print 'processed ' + str(count)
        hquark.Fill(i, j)
        weighted_hquark.Fill(i, j, k)

    draw_hist_with_tag_eff(hquark, "quark", quark_pt_array, quark_ntrk_array,
                           gluon_pt_array, gluon_ntrk_array)
    draw_hist_with_tag_eff(weighted_hquark, "weightedquark", quark_pt_array,
                           quark_ntrk_array, gluon_pt_array, gluon_ntrk_array)

    hgluon = TProfile('hgluon', 'Gluon Profile of nTrk vs ln(pt)', nbins,
                      ptmin, ptmax, ntrkmin, ntrkmax)
    weighted_hgluon = TProfile('weighted_hgluon',
                               'Gluon Weighted Profile of nTrk vs ln(pt)',
                               nbins, ptmin, ptmax, ntrkmin, ntrkmax)
    for i, j, k in zip(gluon_pt_array, gluon_ntrk_array, gluon_weight_array):
        hgluon.Fill(i, j)
        weighted_hgluon.Fill(i, j, k)

    draw_hist_with_tag_eff(hgluon, "gluon", quark_pt_array, quark_ntrk_array,
                           gluon_pt_array, gluon_ntrk_array)
    draw_hist_with_tag_eff(weighted_hgluon, "weightedgluon", quark_pt_array,
                           quark_ntrk_array, gluon_pt_array, gluon_ntrk_array)

    c3 = TCanvas('c3', '', 200, 10, 700, 500)
    weighted_hquark.SetMaximum(30)
    weighted_hquark.Draw("HIST")
    weighted_hgluon.Draw("HIST SAME")
    weighted_hquark.SetLineColor(2)

    c3.SaveAs(settings.outputdir + '/overlay.pdf')
Ejemplo n.º 2
0
Y = Y
Data = np.sum(X, axis=(1, 2, 3))

for j in np.arange(num_events):
    Eprof.Fill(Y[j], Data[j] / Y[j])
Eprof.SetTitle("Ratio of Ecal and Ep")
Eprof.GetXaxis().SetTitle("Ep")
Eprof.GetYaxis().SetTitle("Ecal/Ep")
Eprof.Draw()
Eprof.Fit('pol6')
c.Update()
Eprof.GetFunction("pol6").SetLineColor(color[0])
c.Update()
Eprof.SetStats(0)
Eprof.GetYaxis().SetRangeUser(0, 0.04)
Eprof.SetLineColor(color[0])
legend = TLegend(0.7, 0.7, 0.9, 0.9)
legend.AddEntry(Eprof, "Data", "l")
Gprof = []
for i, gweight in enumerate(gweights):
    Gprof.append(TProfile("Gprof" + str(i), "Gprof" + str(i), 100, 0, 500))
    #Gprof[i].SetStates(0)
    #Generate events
    g.load_weights(gweight)
    noise = np.random.normal(0, 1, (num_events, latent))
    generator_in = np.multiply(np.reshape(Y / 100, (-1, 1)), noise)
    generated_images = g.predict(generator_in, verbose=False, batch_size=100)
    GData = np.sum(generated_images, axis=(1, 2, 3)) / scales[i]
    print GData.shape
    for j in range(num_events):
        Gprof[i].Fill(Y[j], GData[j] / Y[j])