Created
June 11, 2019 14:01
-
-
Save magnusross/e9d636a316c45812ded796dd8fa609d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# In[1]: | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
pathqcd='/Users/mr16064/Documents/Data/ROC_1006/QCD_HT1500to2000/tbl_event.txt' | |
pathT1='/Users/mr16064/Documents/Data/ROC_1006/T1tttt_1950_500/tbl_event.txt' | |
qcd=pd.read_fwf(pathqcd) | |
t1=pd.read_fwf(pathT1) | |
# In[96]: | |
bin_edge=np.arange(0,np.pi,0.05) | |
qcd['minChi_bins']=pd.cut(qcd.minChi,bin_edge,False) | |
t1['minChi_bins']=pd.cut(t1.minChi,bin_edge,False) | |
hist=pd.DataFrame() | |
hist=t1.groupby(['minChi_bins']).size().reset_index() | |
hist['qcd_counts']=qcd.groupby(['minChi_bins']).size().reset_index().loc[:,0] | |
hist['t1_sum']=hist.loc[::-1, 0].cumsum()[::-1] | |
hist['qcd_sum']=hist.loc[::-1, 'qcd_counts'].cumsum()[::-1] | |
hist['t1_eff']=hist['t1_sum']/hist.loc[0,'t1_sum'] | |
hist['qcd_eff']=hist['qcd_sum']/hist.loc[0,'qcd_sum'] | |
# In[105]: | |
x,y=hist['qcd_eff'].tolist(),hist['t1_eff'].tolist() | |
plt.plot(x,y) | |
plt.xscale('log') | |
plt.ylim(0.2,1) | |
plt.savefig('pandasroc.png') | |
plt.show() | |
# In[ ]: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment