Esempio n. 1
0
def main():

    filenames = sys.argv[1:]

    print("Will open files:")
    for f in filenames:
        print(f)

    data = tbt.chain_pickle_files(filenames)

    mupt = data['mupt']
    muisPF = data['muisPF']
    muist = data['muist']
    muiso04 = data['muiso04']

    ################################################################################
    plt.figure()
    plt.subplot(3, 3, 1)
    lch.hist_err(mupt, bins=100, range=(0, 100), color='k')

    plt.subplot(3, 3, 2)
    lch.hist_err(muiso04[muiso04 > 0], bins=100, range=(0, .20), color='k')

    plt.subplot(3, 3, 5)
    lch.hist_2D(mupt[muiso04 > 0],
                muiso04[muiso04 > 0],
                xbins=100,
                ybins=100,
                xrange=(0, 100),
                yrange=(0, .20))
    #plt.xlim(50,150)
    #plt.ylim(0, 3.2)

    ################################################################################
    # Cut on the wmass
    #index = wmass>70.0
    #index *= wmass<95.0

    plt.show()
Esempio n. 2
0
#lch.hist_err(btags[jetpt>=30],bins=100,range=(0,1.25))
plt.hist(btags[jetpt >= 30], bins=100, range=(0, 1.25))
plt.xlabel("CSV2 b-tag output, jet p$_T >= $ 30", fontsize=18)
plt.savefig("/home/me25hage/Top_BNV/test/images/btagplus30.png")

plt.figure()
#lch.hist_err(btags, range = [0,1.25],bins=100,markersize=5)
plt.hist(btags, range=[0, 1.1], bins=110)
plt.xlabel("CSV2 b-tag output", fontsize=18)
plt.tight_layout()
plt.savefig('/home/me25hage/Top_BNV/test/images/btag.png')

plt.figure()
plt.plot(btags[(btags >= 0) * (jetpt < 100)],
         jetpt[(btags >= 0) * (jetpt < 100)],
         '.',
         alpha=0.1)
#plt.savefig('home/../images/btag.png')

plt.figure()
#plt.plot(btags[(btags>=0)*(jetpt<100)],jetpt[(btags>=0)*(jetpt<100)],'.',alpha=0.1)
lch.hist_2D(btags[(btags >= 0) * (jetpt < 100)],
            jetpt[(btags >= 0) * (jetpt < 100)],
            xbins=100,
            ybins=100,
            xrange=(0, 1),
            yrange=(0, 100))
plt.xlabel(r"b-tagging variable", fontsize=18)

plt.show()
print "Events: ", len(mass0[mass0 > 0])
plt.figure()
lch.hist_err(mass0[mass0 > 0], bins=125, range=(0, 1000))
plt.xlabel("mass0")

# plot of highest pt
plt.figure()
lch.hist_err(pt0_max[pt0_max > 0], bins=125, range=(0, 1000))
plt.xlabel("pt0_max")

plt.figure()
lch.hist_err(mass1[mass1 > 0], bins=125, range=(0, 1000))
plt.xlabel("mass1")

plt.figure()
lch.hist_2D(mass0, mass1, xbins=100, ybins=100, xrange=(0, 500), yrange=(0, 500))
plt.xlabel("mass0")
plt.ylabel("mass1")

plt.figure()
lch.hist_2D(mass0, pt0_max, xbins=100, ybins=100, xrange=(0, 500), yrange=(0, 500))
plt.xlabel("mass0")
plt.ylabel("pt0_max")

#######################
# plot all of the masses in column one
plt.figure()
lch.hist_err(unique_m0[unique_m0 > 0], bins=125, range=(0, 1000))
plt.xlabel("unique_m0")

#######################
def main():

    #lumi_file_name = 'lumi_info.pkl'
    #lumi_info = pickle.load( open( lumi_file_name, "rb" ) )

    filenames = sys.argv[1:]

    #data,tot_lumi = tbt.chain_pickle_files(filenames,lumi_info)
    #print("tot_lumi: ",tot_lumi)

    T = ROOT.TChain("T")
    print("Will open files:")
    for f in filenames:
        print(f)
        T.Add(f)

    ntops = []
    topmass = []
    wmass = []
    csvs = []
    angles = []
    dRs = []
    wH = []
    njets = []
    leadmupt = []
    leadmueta = []
    subleadmupt = []
    subleadmueta = []
    metpt = []
    triggers = [[], [], [], []]

    nentries = T.GetEntries()
    for i in range(nentries):
        T.GetEntry(i)

        njets.append(T.njet)
        ntop = T.ntop
        ntops.append(ntop)
        for n in range(ntop):
            topmass.append(T.topmass[n])
            wmass.append(T.wmass[n])
            dRs.append(T.wdR[n])
            wH.append(T.wH[n])
            angles.append(T.wangle[n])

        for n in range(T.njet):
            csvs.append(T.jetcsv[n])

        leadmupt.append(T.leadmupt)
        leadmueta.append(T.leadmueta)
        subleadmupt.append(T.subleadmupt)
        subleadmueta.append(T.subleadmueta)
        metpt.append(T.METpt)

        triggers[0].append(T.trig_HLT_IsoMu24_accept)
        triggers[1].append(T.trig_HLT_IsoTkMu24_accept)
        triggers[2].append(T.trig_HLT_IsoMu22_eta2p1_accept)
        triggers[3].append(T.trig_HLT_IsoTkMu22_eta2p1_accept)

    ntops = np.array(ntops)
    topmass = np.array(topmass)
    wmass = np.array(wmass)
    csvs = np.array(csvs)
    angles = np.array(angles)
    dRs = np.array(dRs)
    wH = np.array(wH)
    njets = np.array(njets)
    leadmupt = np.array(leadmupt)
    leadmueta = np.array(leadmueta)
    subleadmupt = np.array(subleadmupt)
    subleadmueta = np.array(subleadmueta)
    metpt = np.array(metpt)
    triggers[0] = np.array(triggers[0])
    triggers[1] = np.array(triggers[1])
    triggers[2] = np.array(triggers[2])
    triggers[3] = np.array(triggers[3])
    '''
    for a in zip(topmass, wmass, csvs, angles, dRs, njets):
        print(a)
        a = np.array(a)
    '''

    ################################################################################
    plt.figure()
    plt.subplot(3, 3, 1)
    lch.hist_err(topmass, bins=100, range=(0, 600), color='k')
    plt.xlabel('Top Mass (GeV)')

    plt.subplot(3, 3, 2)
    lch.hist_err(wmass, bins=100, range=(0, 300), color='k')
    plt.xlabel('W Mass (GeV)')

    plt.subplot(3, 3, 3)
    lch.hist_err(csvs, bins=110, range=(-11, 1.1), color='k')
    plt.xlabel('CSV variable')

    plt.subplot(3, 3, 4)
    lch.hist_err(angles, bins=100, range=(0, 3.2), color='k')
    plt.xlabel('Angles')

    plt.subplot(3, 3, 5)
    #plt.plot(wmass,angles,'.',markersize=0.5,alpha=0.2)
    lch.hist_2D(wmass,
                angles,
                xbins=100,
                ybins=100,
                xrange=(0, 300),
                yrange=(0, 3.14))
    plt.xlim(50, 150)
    plt.ylim(0, 3.2)
    plt.xlabel('W Mass')
    plt.ylabel('Angles')

    plt.subplot(3, 3, 6)
    lch.hist_err(dRs, bins=100, range=(0, 3.2), color='k')
    plt.xlabel('dRs')

    plt.subplot(3, 3, 7)
    lch.hist_2D(dRs,
                angles,
                xbins=100,
                ybins=100,
                xrange=(0, 6.28),
                yrange=(0, 3.14))
    plt.xlabel('dRs')
    plt.ylabel('Angles')

    plt.subplot(3, 3, 8)
    lch.hist_err(wH, bins=100, range=(0, 250), color='k')
    plt.xlabel('scalar H')

    plt.subplot(3, 3, 9)
    lch.hist_err(ntops, bins=6, range=(0, 6), color='k')
    plt.xlabel('ntops')

    plt.tight_layout()

    ################################################################################
    # Cut on the wmass
    index = wmass > 70.0
    index *= wmass < 95.0
    #index = (np.abs(angles - dRs)<=0.45)

    plt.figure()
    plt.title('W Mass Cuts')
    plt.subplot(3, 3, 1)
    lch.hist_err(topmass[index], bins=100, range=(0, 600), color='k')
    plt.xlabel('Top Mass (GeV)')

    plt.subplot(3, 3, 2)
    lch.hist_err(wmass[index], bins=100, range=(0, 300), color='k')
    plt.xlabel('W Mass (GeV)')

    plt.subplot(3, 3, 4)
    lch.hist_err(angles[index], bins=100, range=(0, 3.2), color='k')
    plt.xlabel('Angles')

    plt.subplot(3, 3, 5)
    #plt.plot(wmass[index],angles[index],'.',markersize=0.5,alpha=0.2)
    lch.hist_2D(wmass[index],
                angles[index],
                xbins=100,
                ybins=100,
                xrange=(0, 300),
                yrange=(0, 3.14))
    plt.xlim(50, 150)
    plt.ylim(0, 3.2)
    plt.xlabel('W Mass')
    plt.ylabel('Angles')

    plt.subplot(3, 3, 6)
    lch.hist_err(dRs[index], bins=100, range=(0, 3.2), color='k')
    plt.xlabel('dRs')

    plt.subplot(3, 3, 7)
    lch.hist_2D(dRs[index],
                angles[index],
                xbins=100,
                ybins=100,
                xrange=(0, 6.28),
                yrange=(0, 3.14))
    plt.xlabel('dRs')
    plt.ylabel('Angles')

    plt.subplot(3, 3, 8)
    lch.hist_err(wH[index], bins=100, range=(0, 250), color='k')
    plt.xlabel('scalar H')

    plt.tight_layout()

    ############################################################################
    # Muons
    ############################################################################
    plt.figure()
    plt.subplot(3, 3, 1)
    lch.hist_err(leadmupt, bins=100, range=(0, 250), color='k')
    plt.xlabel(r'Leading muon p$_{T}$ (GeV/c)')

    plt.subplot(3, 3, 2)
    lch.hist_err(leadmueta, bins=100, range=(-3.0, 3.0), color='k')
    plt.xlabel(r'Leading muon $\eta$ (GeV/c)')

    plt.subplot(3, 3, 4)
    lch.hist_err(subleadmupt, bins=100, range=(0, 250), color='k')
    plt.xlabel(r'Sub-leading muon p$_{T}$ (GeV/c)')

    plt.subplot(3, 3, 5)
    lch.hist_err(subleadmueta, bins=100, range=(-3.0, 3.0), color='k')
    plt.xlabel(r'Sub-leading muon $\eta$ (GeV/c)')

    plt.subplot(3, 3, 7)
    lch.hist_err(metpt, bins=100, range=(0.0, 100.0), color='k')
    plt.xlabel(r'Missing E$_T$ (GeV)')

    plt.tight_layout()
    '''
    # For talk
    plt.figure()
    lch.hist_err(topmass[index],bins=100,range=(0,600),color='k')
    plt.hist(topmass[index],bins=100,range=(0,600),color='grey',alpha=0.2)
    plt.xlabel(r'Top candidate with W-mass cut (GeV/c$^2$)',fontsize=14)
    plt.tight_layout()
    plt.savefig('top.png')

    plt.figure()
    lch.hist_err(wmass,bins=100,range=(0,300),color='k')
    plt.hist(wmass,bins=100,range=(0,300),color='grey',alpha=0.2)
    plt.xlabel(r'W candidate (GeV/c$^2$)',fontsize=14)
    plt.tight_layout()
    plt.savefig('W.png')

    plt.figure()
    lch.hist_err(csvs,bins=110,range=(0,1.1),color='k')
    plt.hist(csvs,bins=100,range=(0,1.1),color='grey',alpha=0.2)
    plt.xlabel(r'CSVv2 variable',fontsize=14)
    plt.tight_layout()
    plt.savefig('csvv2.png')
    '''

    ############################################################################
    # Triggers
    ############################################################################
    plt.figure()
    plt.subplot(5, 4, 1)
    lch.hist_err(triggers[0], bins=2, range=(0, 2), color='k')
    plt.xlabel(r'Trigger 0')

    plt.subplot(5, 4, 2)
    lch.hist_err(triggers[1], bins=2, range=(0, 2), color='k')
    plt.xlabel(r'Trigger 1')

    plt.subplot(5, 4, 3)
    lch.hist_err(triggers[2], bins=2, range=(0, 2), color='k')
    plt.xlabel(r'Trigger 2')

    plt.subplot(5, 4, 4)
    lch.hist_err(triggers[3], bins=2, range=(0, 2), color='k')
    plt.xlabel(r'Trigger 3')

    for i in range(0, 4):
        for j in range(0, 4):
            plt.subplot(5, 4, 5 + i * 4 + j)
            lch.hist_err(triggers[i][triggers[j] == 1], bins=2, range=(0, 2))

    plt.tight_layout()

    plt.show()
Esempio n. 5
0
def main():

    lumi_file_name = 'lumi_info.pkl'
    lumi_info = pickle.load(open(lumi_file_name, "rb"))

    filenames = sys.argv[1:]

    print("Will open files:")
    for f in filenames:
        print(f)

    data, tot_lumi = tbt.chain_pickle_files(filenames, lumi_info)
    print("tot_lumi: ", tot_lumi)

    topmass = data['topmass']
    wmass = data['wmass']
    csvs = data['csvs']
    angles = data['angles']
    dRs = data['dRs']
    #njets = data['njets']
    njets = data['njets']

    ################################################################################
    plt.figure()
    plt.subplot(3, 3, 1)
    lch.hist_err(topmass, bins=100, range=(0, 600), color='k')
    plt.xlabel('Top Mass (GeV)')

    plt.subplot(3, 3, 2)
    lch.hist_err(wmass, bins=100, range=(0, 300), color='k')
    plt.xlabel('W Mass (GeV)')

    plt.subplot(3, 3, 3)
    lch.hist_err(csvs, bins=110, range=(0, 1.1), color='k')
    plt.xlabel('Isolation Variable')

    plt.subplot(3, 3, 4)
    lch.hist_err(angles, bins=100, range=(0, 3.2), color='k')
    plt.xlabel('Angles')

    plt.subplot(3, 3, 5)
    #plt.plot(wmass,angles,'.',markersize=0.5,alpha=0.2)
    lch.hist_2D(wmass,
                angles,
                xbins=100,
                ybins=100,
                xrange=(0, 300),
                yrange=(0, 3.14))
    plt.xlim(50, 150)
    plt.ylim(0, 3.2)
    plt.xlabel('W Mass')
    plt.ylabel('Angles')

    plt.subplot(3, 3, 6)
    lch.hist_err(dRs, bins=100, range=(0, 3.2), color='k')
    plt.xlabel('dRs')

    plt.subplot(3, 3, 7)
    lch.hist_2D(dRs,
                angles,
                xbins=100,
                ybins=100,
                xrange=(0, 6.28),
                yrange=(0, 3.14))
    plt.xlabel('dRs')
    plt.ylabel('Angles')

    ################################################################################
    # Cut on the wmass
    index = wmass > 70.0
    index *= wmass < 95.0

    plt.figure()
    plt.title('W Mass Cuts')
    plt.subplot(3, 3, 1)
    lch.hist_err(topmass[index], bins=100, range=(0, 600), color='k')
    plt.xlabel('Top Mass (GeV)')

    plt.subplot(3, 3, 2)
    lch.hist_err(wmass[index], bins=100, range=(0, 300), color='k')
    plt.xlabel('W Mass (GeV)')

    plt.subplot(3, 3, 4)
    lch.hist_err(angles[index], bins=100, range=(0, 3.2), color='k')
    plt.xlabel('Angles')

    plt.subplot(3, 3, 5)
    #plt.plot(wmass[index],angles[index],'.',markersize=0.5,alpha=0.2)
    lch.hist_2D(wmass[index],
                angles[index],
                xbins=100,
                ybins=100,
                xrange=(0, 300),
                yrange=(0, 3.14))
    plt.xlim(50, 150)
    plt.ylim(0, 3.2)
    plt.xlabel('W Mass')
    plt.ylabel('Angles')

    plt.subplot(3, 3, 6)
    lch.hist_err(dRs[index], bins=100, range=(0, 3.2), color='k')
    plt.xlabel('dRs')

    plt.subplot(3, 3, 7)
    lch.hist_2D(dRs[index],
                angles[index],
                xbins=100,
                ybins=100,
                xrange=(0, 6.28),
                yrange=(0, 3.14))
    plt.xlabel('dRs')
    plt.ylabel('Angles')
    '''
    # For talk
    plt.figure()
    lch.hist_err(topmass[index],bins=100,range=(0,600),color='k')
    plt.hist(topmass[index],bins=100,range=(0,600),color='grey',alpha=0.2)
    plt.xlabel(r'Top candidate with W-mass cut (GeV/c$^2$)',fontsize=14)
    plt.tight_layout()
    plt.savefig('top.png')

    plt.figure()
    lch.hist_err(wmass,bins=100,range=(0,300),color='k')
    plt.hist(wmass,bins=100,range=(0,300),color='grey',alpha=0.2)
    plt.xlabel(r'W candidate (GeV/c$^2$)',fontsize=14)
    plt.tight_layout()
    plt.savefig('W.png')

    plt.figure()
    lch.hist_err(csvs,bins=110,range=(0,1.1),color='k')
    plt.hist(csvs,bins=100,range=(0,1.1),color='grey',alpha=0.2)
    plt.xlabel(r'CSVv2 variable',fontsize=14)
    plt.tight_layout()
    plt.savefig('csvv2.png')
    '''

    plt.show()

    return data
print "Making the plots....."

plt.figure()
<<<<<<< HEAD
#lch.hist_2D(theta,top_momentum[top_momentum>-999], xbins=50,ybins=50)
#lch.hist_2D(top_mass[top_mass>-999],top_momentum[top_momentum>-999], xbins=50, ybins=50)
#lch.hist_2D(theta,second_top_mass,xbins=10,ybins=10)
'''
hist,xedges,yedges = np.histogram2d(top_momentum[top_momentum>-999],theta,bins=(25,50))
extent = [xedges[0],xedges[-1],yedges[0],yedges[-1]]
plt.imshow(hist,extent=extent,interpolation='nearest',origin='lower')
'''
top_momentum = top_momentum[top_momentum>-999]
theta = np.array(theta)

lch.hist_2D(top_momentum,theta,xrange=(0,50),yrange=(0,3.2),xbins=50,ybins=50)
#lch.hist_2D(top_momentum,theta,xbins=50,ybins=50)

plt.show()




=======
lch.hist_2D(top_momentum[top_momentum>-999],theta[theta>-999],xbins=25,ybins=50,xrange=(0,35),yrange=(0,3.2))
plt.title("%s: Theta vs. Top Momentum" % (tag))
>>>>>>> dafd5f4d19be935ee76309b719ffe9ed78513fdf

plt.figure()
lch.hist_2D(top_momentum[top_momentum>-999],top_mass[top_momentum>-999],xbins=50,ybins=50,xrange=(0,35),yrange=(0,300))
plt.title("%s: Top Mass vs. Top Momentum" % (tag))
Esempio n. 7
0
print('elecCut', elecCut)
print('muonCut', muonCut)
print('nentries', nentries)
print('Test', test)
print('electrons', electrons)

plt.figure()
plt.hist(differencesElectron, bins=100)  #,range = (0,1))
plt.xlabel("Difference in pt")

plt.figure()
plt.hist(differencesElectron, bins=100, range=(0, 10))
plt.xlabel("Difference in pt")

plt.figure()
plt.hist(distance, bins=100, range=(0, .005))
plt.xlabel("Distance between electrons in eta-phi space")

plt.figure()
lch.hist_2D(distance, differencesElectron)

plt.figure()
plt.plot(etaElectrons, phiElectrons, 'ro', alpha=0.1, label="Electrons")
plt.plot(etaWchildren, phiWchildren, 'b*', alpha=0.1, label="MC Truth")
plt.xlabel('eta')
plt.ylabel('phi')

plt.legend()

plt.show()
'''plt.figure(2)
plt.subplot(2, 1, 1)
#plt.hist(del_R_mu_other_b,bins=50)
lkn.hist_err(minimal_dR,bins=100)
plt.title("Bottom")
plt.xlabel(r"Abs($\delta$R)")

plt.subplot(2, 1, 2)
#plt.hist(del_R_mu_b,bins=50)
lkn.hist_err(minimal_pt,bins=100)
plt.xlabel("Abs(pt)")'''

plt.figure(3)

#plt.hist(del_R_mu_other_b,bins=50)
lkn.hist_2D(minimal_dR,pt_jet,xbins=80,ybins=80,xrange=(0,3), yrange=(400,600))
plt.title(r"$Jet$ $vs$ $\Delta$$R$")
plt.xlabel(r"$\Delta$R")
plt.ylabel(r"$Jet$ $p$$_t$")


plt.figure(4)
#plt.hist(del_R_mu_b,bins=50)
lkn.hist_2D(minimal_dR,pt_top,xbins=80,ybins=80,xrange=(0,3), yrange=(400,600))
plt.title(r"$t$ $\bar{t}$ $vs$ $\Delta$$R$")
plt.xlabel(r"$\Delta$R")
plt.ylabel(r"$t$ $\bar{t}$ $p$$_t$")

plt.show()

#python2.7-32 assigning_jets.py small_file.txt