CMS 3D CMS Logo

Classes | Functions | Variables
ROC_plotter Namespace Reference

Classes

class  MTD_Ele_Iso
 

Functions

def __init__
 
def Calculate_efficiencies (self)
 
def main ()
 
def Plot_ROC_curves
 
def Plot_ROC_curves_vs_dz_noMTD
 
def Read_hists (self)
 

Variables

 Bkg_hists
 
 Bkg_iso_eff
 
 cut_type
 
 directory_path
 
 dz_cut_description
 
 filename_bkg
 
 filename_sig
 
 ROC_plots_directory
 
 Sig_hists
 
 Sig_iso_eff
 
 Tree_Bkg
 
 Tree_Sig
 

Function Documentation

◆ __init__()

def ROC_plotter.__init__ (   self,
  filename_Sig 
)

Definition at line 24 of file ROC_plotter.py.

24  def __init__(self,filename_Sig: str, filename_Bkg: str,dz_cut: str,dtSignif_cut: bool):
25 
26  self.filename_sig = directory_path + filename_Sig
27  self.filename_bkg = directory_path + filename_Bkg
28 
29  self.cut_type = dtSignif_cut # True if dt_significance is used, false if absolute dt cut is used.
30  self.dz_cut_description = dz_cut
31 
32  self.Tree_Sig = up.open(self.filename_sig)["DQMData/Run 1/MTD/Run summary/ElectronIso;1"]
33  self.Tree_Bkg = up.open(self.filename_bkg)["DQMData/Run 1/MTD/Run summary/ElectronIso;1"]
34 
35  self.Sig_hists = {} # Dictionary that will hold all Signal histograms
36  self.Bkg_hists = {} # Dictionary that will hold all Bakcground histograms
37 
38  self.Sig_iso_eff = {} # Dictionary that will hold isolation efficiency values for all iso cut values in different timing cuts (Signal)
39  self.Bkg_iso_eff = {} # Dictionary that will hold isolation efficiency values for all iso cut values in different timing cuts (Bakcground)
40 

◆ Calculate_efficiencies()

def ROC_plotter.Calculate_efficiencies (   self)

Definition at line 91 of file ROC_plotter.py.

References FastTimerService_cff.range.

91  def Calculate_efficiencies(self): # Scan through ch_iso_sum bin values (iso cuts), to calculate the efficiency for full cut range.
92 
93  efficiency_Sig_noMTD_EB , efficiency_Bkg_noMTD_EB , efficiency_Sig_noMTD_EE , efficiency_Bkg_noMTD_EE = [],[],[],[]
94 
95  if self.cut_type == True:
96 
97  efficiency_Sig_4sigma_EB , efficiency_Bkg_4sigma_EB , efficiency_Sig_4sigma_EE , efficiency_Bkg_4sigma_EE = [],[],[],[]
98  efficiency_Sig_3sigma_EB , efficiency_Bkg_3sigma_EB , efficiency_Sig_3sigma_EE , efficiency_Bkg_3sigma_EE = [],[],[],[]
99  efficiency_Sig_2sigma_EB , efficiency_Bkg_2sigma_EB , efficiency_Sig_2sigma_EE , efficiency_Bkg_2sigma_EE = [],[],[],[]
100 
101  for i in range( len(self.Sig_hists['Sig_noMTD_EB'][0]) ):
102 
103  efficiency_Sig_noMTD_EB.append( sum(self.Sig_hists['Sig_noMTD_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_noMTD_EB'][0]) )
104  efficiency_Sig_4sigma_EB.append( sum(self.Sig_hists['Sig_4sigma_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_4sigma_EB'][0]) )
105  efficiency_Sig_3sigma_EB.append( sum(self.Sig_hists['Sig_3sigma_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_3sigma_EB'][0]) )
106  efficiency_Sig_2sigma_EB.append( sum(self.Sig_hists['Sig_2sigma_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_2sigma_EB'][0]) )
107 
108  efficiency_Bkg_noMTD_EB.append( sum(self.Bkg_hists['Bkg_noMTD_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_noMTD_EB'][0]) )
109  efficiency_Bkg_4sigma_EB.append( sum(self.Bkg_hists['Bkg_4sigma_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_4sigma_EB'][0]) )
110  efficiency_Bkg_3sigma_EB.append( sum(self.Bkg_hists['Bkg_3sigma_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_3sigma_EB'][0]) )
111  efficiency_Bkg_2sigma_EB.append( sum(self.Bkg_hists['Bkg_2sigma_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_2sigma_EB'][0]) )
112 
113 
114  efficiency_Sig_noMTD_EE.append( sum(self.Sig_hists['Sig_noMTD_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_noMTD_EE'][0]) )
115  efficiency_Sig_4sigma_EE.append( sum(self.Sig_hists['Sig_4sigma_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_4sigma_EE'][0]) )
116  efficiency_Sig_3sigma_EE.append( sum(self.Sig_hists['Sig_3sigma_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_3sigma_EE'][0]) )
117  efficiency_Sig_2sigma_EE.append( sum(self.Sig_hists['Sig_2sigma_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_2sigma_EE'][0]) )
118 
119  efficiency_Bkg_noMTD_EE.append( sum(self.Bkg_hists['Bkg_noMTD_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_noMTD_EE'][0]) )
120  efficiency_Bkg_4sigma_EE.append( sum(self.Bkg_hists['Bkg_4sigma_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_4sigma_EE'][0]) )
121  efficiency_Bkg_3sigma_EE.append( sum(self.Bkg_hists['Bkg_3sigma_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_3sigma_EE'][0]) )
122  efficiency_Bkg_2sigma_EE.append( sum(self.Bkg_hists['Bkg_2sigma_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_2sigma_EE'][0]) )
123 
124 
125  self.Sig_iso_eff['Sig_noMTD_EB'] , self.Bkg_iso_eff['Bkg_noMTD_EB'] = efficiency_Sig_noMTD_EB , efficiency_Bkg_noMTD_EB
126  self.Sig_iso_eff['Sig_4sigma_EB'] , self.Bkg_iso_eff['Bkg_4sigma_EB'] = efficiency_Sig_4sigma_EB , efficiency_Bkg_4sigma_EB
127  self.Sig_iso_eff['Sig_3sigma_EB'] , self.Bkg_iso_eff['Bkg_3sigma_EB'] = efficiency_Sig_3sigma_EB , efficiency_Bkg_3sigma_EB
128  self.Sig_iso_eff['Sig_2sigma_EB'] , self.Bkg_iso_eff['Bkg_2sigma_EB'] = efficiency_Sig_2sigma_EB , efficiency_Bkg_2sigma_EB
129 
130  self.Sig_iso_eff['Sig_noMTD_EE'] , self.Bkg_iso_eff['Bkg_noMTD_EE'] = efficiency_Sig_noMTD_EE , efficiency_Bkg_noMTD_EE
131  self.Sig_iso_eff['Sig_4sigma_EE'] , self.Bkg_iso_eff['Bkg_4sigma_EE'] = efficiency_Sig_4sigma_EE , efficiency_Bkg_4sigma_EE
132  self.Sig_iso_eff['Sig_3sigma_EE'] , self.Bkg_iso_eff['Bkg_3sigma_EE'] = efficiency_Sig_3sigma_EE , efficiency_Bkg_3sigma_EE
133  self.Sig_iso_eff['Sig_2sigma_EE'] , self.Bkg_iso_eff['Bkg_2sigma_EE'] = efficiency_Sig_2sigma_EE , efficiency_Bkg_2sigma_EE
134 
135  else:
136 
137  efficiency_Sig_cut1_EB , efficiency_Bkg_cut1_EB , efficiency_Sig_cut1_EE , efficiency_Bkg_cut1_EE = [],[],[],[]
138  efficiency_Sig_cut2_EB , efficiency_Bkg_cut2_EB , efficiency_Sig_cut2_EE , efficiency_Bkg_cut2_EE = [],[],[],[]
139  efficiency_Sig_cut3_EB , efficiency_Bkg_cut3_EB , efficiency_Sig_cut3_EE , efficiency_Bkg_cut3_EE = [],[],[],[]
140  efficiency_Sig_cut5_EB , efficiency_Bkg_cut5_EB , efficiency_Sig_cut5_EE , efficiency_Bkg_cut5_EE = [],[],[],[]
141 
142  for i in range( len(self.Sig_hists['Sig_noMTD_EB'][0]) ):
143 
144  efficiency_Sig_noMTD_EB.append( sum(self.Sig_hists['Sig_noMTD_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_noMTD_EB'][0]) )
145  efficiency_Sig_cut1_EB.append( sum(self.Sig_hists['Sig_cut1_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_cut1_EB'][0]) )
146  efficiency_Sig_cut2_EB.append( sum(self.Sig_hists['Sig_cut2_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_cut2_EB'][0]) )
147  efficiency_Sig_cut3_EB.append( sum(self.Sig_hists['Sig_cut3_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_cut3_EB'][0]) )
148  efficiency_Sig_cut5_EB.append( sum(self.Sig_hists['Sig_cut5_EB'][0][0:i+1])/sum(self.Sig_hists['Sig_cut5_EB'][0]) )
149 
150  efficiency_Bkg_noMTD_EB.append( sum(self.Bkg_hists['Bkg_noMTD_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_noMTD_EB'][0]) )
151  efficiency_Bkg_cut1_EB.append( sum(self.Bkg_hists['Bkg_cut1_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut1_EB'][0]) )
152  efficiency_Bkg_cut2_EB.append( sum(self.Bkg_hists['Bkg_cut2_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut2_EB'][0]) )
153  efficiency_Bkg_cut3_EB.append( sum(self.Bkg_hists['Bkg_cut3_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut3_EB'][0]) )
154  efficiency_Bkg_cut5_EB.append( sum(self.Bkg_hists['Bkg_cut5_EB'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut5_EB'][0]) )
155 
156 
157  efficiency_Sig_noMTD_EE.append( sum(self.Sig_hists['Sig_noMTD_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_noMTD_EE'][0]) )
158  efficiency_Sig_cut1_EE.append( sum(self.Sig_hists['Sig_cut1_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_cut1_EE'][0]) )
159  efficiency_Sig_cut2_EE.append( sum(self.Sig_hists['Sig_cut2_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_cut2_EE'][0]) )
160  efficiency_Sig_cut3_EE.append( sum(self.Sig_hists['Sig_cut3_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_cut3_EE'][0]) )
161  efficiency_Sig_cut5_EE.append( sum(self.Sig_hists['Sig_cut5_EE'][0][0:i+1])/sum(self.Sig_hists['Sig_cut5_EE'][0]) )
162 
163  efficiency_Bkg_noMTD_EE.append( sum(self.Bkg_hists['Bkg_noMTD_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_noMTD_EE'][0]) )
164  efficiency_Bkg_cut1_EE.append( sum(self.Bkg_hists['Bkg_cut1_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut1_EE'][0]) )
165  efficiency_Bkg_cut2_EE.append( sum(self.Bkg_hists['Bkg_cut2_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut2_EE'][0]) )
166  efficiency_Bkg_cut3_EE.append( sum(self.Bkg_hists['Bkg_cut3_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut3_EE'][0]) )
167  efficiency_Bkg_cut5_EE.append( sum(self.Bkg_hists['Bkg_cut5_EE'][0][0:i+1])/sum(self.Bkg_hists['Bkg_cut5_EE'][0]) )
168 
169 
170  self.Sig_iso_eff['Sig_noMTD_EB'] , self.Bkg_iso_eff['Bkg_noMTD_EB'] = efficiency_Sig_noMTD_EB , efficiency_Bkg_noMTD_EB
171  self.Sig_iso_eff['Sig_cut1_EB'] , self.Bkg_iso_eff['Bkg_cut1_EB'] = efficiency_Sig_cut1_EB , efficiency_Bkg_cut1_EB
172  self.Sig_iso_eff['Sig_cut2_EB'] , self.Bkg_iso_eff['Bkg_cut2_EB'] = efficiency_Sig_cut2_EB , efficiency_Bkg_cut2_EB
173  self.Sig_iso_eff['Sig_cut3_EB'] , self.Bkg_iso_eff['Bkg_cut3_EB'] = efficiency_Sig_cut3_EB , efficiency_Bkg_cut3_EB
174  self.Sig_iso_eff['Sig_cut5_EB'] , self.Bkg_iso_eff['Bkg_cut5_EB'] = efficiency_Sig_cut5_EB , efficiency_Bkg_cut5_EB
175 
176  self.Sig_iso_eff['Sig_noMTD_EE'] , self.Bkg_iso_eff['Bkg_noMTD_EE'] = efficiency_Sig_noMTD_EE , efficiency_Bkg_noMTD_EE
177  self.Sig_iso_eff['Sig_cut1_EE'] , self.Bkg_iso_eff['Bkg_cut1_EE'] = efficiency_Sig_cut1_EE , efficiency_Bkg_cut1_EE
178  self.Sig_iso_eff['Sig_cut2_EE'] , self.Bkg_iso_eff['Bkg_cut2_EE'] = efficiency_Sig_cut2_EE , efficiency_Bkg_cut2_EE
179  self.Sig_iso_eff['Sig_cut3_EE'] , self.Bkg_iso_eff['Bkg_cut3_EE'] = efficiency_Sig_cut3_EE , efficiency_Bkg_cut3_EE
180  self.Sig_iso_eff['Sig_cut5_EE'] , self.Bkg_iso_eff['Bkg_cut5_EE'] = efficiency_Sig_cut5_EE , efficiency_Bkg_cut5_EE
181 
def Calculate_efficiencies(self)
Definition: ROC_plotter.py:91

◆ main()

def ROC_plotter.main ( )

Definition at line 286 of file ROC_plotter.py.

References Plot_ROC_curves_vs_dz_noMTD().

286 def main():
287 
288  #obj = MTD_Ele_Iso(Signal_DQM_file,Bakcground_DQM_file,dz_cut description,dt_significance_check(False if abs(dt) check))
289  dz010_cut_obj = MTD_Ele_Iso('DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Sig_dz010_v5.root','DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Bkg_dz010_v5.root','dz_1mm',True)
290  dz020_cut_obj = MTD_Ele_Iso('DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Sig_dz020_v5.root','DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Bkg_dz020_v5.root','dz_2mm',True)
291  dz030_cut_obj = MTD_Ele_Iso('DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Sig_dz030_v5.root','DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Bkg_dz030_v5.root','dz_3mm',True)
292  dz040_cut_obj = MTD_Ele_Iso('DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Sig_dz040_v5.root','DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Bkg_dz040_v5.root','dz_4mm',True)
293  dz050_cut_obj = MTD_Ele_Iso('DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Sig_dz050_v5.root','DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_Bkg_dz050_v5.root','dz_5mm',True)
294 
295  dz010_cut_obj.Read_hists()
296  dz020_cut_obj.Read_hists()
297  dz030_cut_obj.Read_hists()
298  dz040_cut_obj.Read_hists()
299  dz050_cut_obj.Read_hists()
300 
301  dz010_cut_obj.Calculate_efficiencies()
302  dz020_cut_obj.Calculate_efficiencies()
303  dz030_cut_obj.Calculate_efficiencies()
304  dz040_cut_obj.Calculate_efficiencies()
305  dz050_cut_obj.Calculate_efficiencies()
306 
307  # .Plot_ROC_curves(xmin,xmax,ymix,ymax,savePlot) -> Saves plot for BTL and ETL parts
308  dz010_cut_obj.Plot_ROC_curves(0.75,1.0,0.05,0.4,True)
309  dz020_cut_obj.Plot_ROC_curves(0.75,1.0,0.05,0.4,True)
310  dz030_cut_obj.Plot_ROC_curves(0.75,1.0,0.05,0.4,True)
311  dz040_cut_obj.Plot_ROC_curves(0.75,1.0,0.05,0.4,True)
312  dz050_cut_obj.Plot_ROC_curves(0.75,1.0,0.05,0.4,True)
313 
314 
315  # This function usually works, but sometimes??? it gives errors -> no idea why. (python version issue?)
316  Plot_ROC_curves_vs_dz_noMTD(0.75,1.0,0.05,0.4,True,dz010_cut_obj,dz020_cut_obj,dz030_cut_obj,dz040_cut_obj,dz050_cut_obj)
317 
318 
def Plot_ROC_curves_vs_dz_noMTD
Definition: ROC_plotter.py:253

◆ Plot_ROC_curves()

def ROC_plotter.Plot_ROC_curves (   self,
  xmin,
  xmax,
  ymin,
  ymax,
  save 
)

Definition at line 182 of file ROC_plotter.py.

References ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets.if().

182  def Plot_ROC_curves(self,xmin,xmax,ymin,ymax,save: bool):
183 
184  if self.cut_type == True:
185 
186  plt.plot(self.Sig_iso_eff['Sig_noMTD_EB'],self.Bkg_iso_eff['Bkg_noMTD_EB'], label = 'noMTD')
187  plt.plot(self.Sig_iso_eff['Sig_4sigma_EB'],self.Bkg_iso_eff['Bkg_4sigma_EB'], label = '4sigma cut')
188  plt.plot(self.Sig_iso_eff['Sig_3sigma_EB'],self.Bkg_iso_eff['Bkg_3sigma_EB'], label = '3sigma cut')
189  plt.plot(self.Sig_iso_eff['Sig_2sigma_EB'],self.Bkg_iso_eff['Bkg_2sigma_EB'], label = '2sigma cut')
190  plt.legend(loc='best')
191  plt.ylim(ymin,ymax)
192  plt.xlim(xmin,xmax)
193  plt.grid()
194  plt.xlabel("Signal efficiency")
195  plt.ylabel("Background efficiency")
196  plt.title(f'ROC curves for BTL, {self.dz_cut_description}')
197  if(save):
198  plt.savefig(ROC_plots_directory+f'ROC_curve_BTL_dtsignif_{self.dz_cut_description}')
199  plt.show()
200 
201  plt.plot(self.Sig_iso_eff['Sig_noMTD_EE'],self.Bkg_iso_eff['Bkg_noMTD_EE'], label = 'noMTD')
202  plt.plot(self.Sig_iso_eff['Sig_4sigma_EE'],self.Bkg_iso_eff['Bkg_4sigma_EE'], label = '4sigma cut')
203  plt.plot(self.Sig_iso_eff['Sig_3sigma_EE'],self.Bkg_iso_eff['Bkg_3sigma_EE'], label = '3sigma cut')
204  plt.plot(self.Sig_iso_eff['Sig_2sigma_EE'],self.Bkg_iso_eff['Bkg_2sigma_EE'], label = '2sigma cut')
205  plt.legend(loc='best')
206  plt.ylim(ymin,ymax)
207  plt.xlim(xmin,xmax)
208  plt.grid()
209  plt.xlabel("Signal efficiency")
210  plt.ylabel("Background efficiency")
211  plt.title(f'ROC curves for ETL, {self.dz_cut_description}')
212  if(save):
213  plt.savefig(ROC_plots_directory+f'ROC_curve_ETL_dtsignif_{self.dz_cut_description}')
214  plt.show()
215 
216  else:
217  # Check the cut definitions in mtdEleIsoValidation.cc file (These are default ones)
218 
219  plt.plot(self.Sig_iso_eff['Sig_noMTD_EB'],self.Bkg_iso_eff['Bkg_noMTD_EB'], label = 'noMTD')
220  plt.plot(self.Sig_iso_eff['Sig_cut1_EB'],self.Bkg_iso_eff['Bkg_cut1_EB'], label = 'cut1 - 300ps')
221  plt.plot(self.Sig_iso_eff['Sig_cut2_EB'],self.Bkg_iso_eff['Bkg_cut2_EB'], label = 'cut2 - 270ps')
222  plt.plot(self.Sig_iso_eff['Sig_cut3_EB'],self.Bkg_iso_eff['Bkg_cut3_EB'], label = 'cut3 - 240ps')
223  plt.plot(self.Sig_iso_eff['Sig_cut5_EB'],self.Bkg_iso_eff['Bkg_cut5_EB'], label = 'cut5 - 180ps')
224  plt.legend(loc='best')
225  plt.ylim(ymin,ymax)
226  plt.xlim(xmin,xmax)
227  plt.grid()
228  plt.xlabel("Signal efficiency")
229  plt.ylabel("Background efficiency")
230  plt.title(f'ROC curves for BTL, {self.dz_cut_description}')
231  if(save):
232  plt.savefig(ROC_plots_directory+f'ROC_curve_BTL_abs_dt_{self.dz_cut_description}')
233  plt.show()
234 
235  plt.plot(self.Sig_iso_eff['Sig_noMTD_EE'],self.Bkg_iso_eff['Bkg_noMTD_EE'], label = 'noMTD')
236  plt.plot(self.Sig_iso_eff['Sig_cut1_EE'],self.Bkg_iso_eff['Bkg_cut1_EE'], label = 'cut1 - 300ps')
237  plt.plot(self.Sig_iso_eff['Sig_cut2_EE'],self.Bkg_iso_eff['Bkg_cut2_EE'], label = 'cut2 - 270ps')
238  plt.plot(self.Sig_iso_eff['Sig_cut3_EE'],self.Bkg_iso_eff['Bkg_cut3_EE'], label = 'cut3 - 240ps')
239  plt.plot(self.Sig_iso_eff['Sig_cut5_EE'],self.Bkg_iso_eff['Bkg_cut5_EE'], label = 'cut5 - 180ps')
240  plt.legend(loc='best')
241  plt.ylim(ymin,ymax)
242  plt.xlim(xmin,xmax)
243  plt.grid()
244  plt.xlabel("Signal efficiency")
245  plt.ylabel("Background efficiency")
246  plt.title(f'ROC curves for ETL, {self.dz_cut_description}')
247  if(save):
248  plt.savefig(ROC_plots_directory+f'ROC_curve_ETL_abs_dt_{self.dz_cut_description}')
249  plt.show()
250 
251 
252 
def Plot_ROC_curves
Definition: ROC_plotter.py:182
if(threadIdxLocalY==0 &&threadIdxLocalX==0)

◆ Plot_ROC_curves_vs_dz_noMTD()

def ROC_plotter.Plot_ROC_curves_vs_dz_noMTD (   xmin,
  xmax,
  ymin,
  ymax,
  save 
)

Definition at line 253 of file ROC_plotter.py.

References ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets.if().

Referenced by main().

253 def Plot_ROC_curves_vs_dz_noMTD(xmin,xmax,ymin,ymax,save:bool,*objects):
254 
255  for i in objects:
256  plt.plot(i.Sig_iso_eff['Sig_noMTD_EB'],i.Bkg_iso_eff['Bkg_noMTD_EB'],label=f'noMTD {i.dz_cut_description}')
257  plt.legend(loc='best')
258  plt.ylim(ymin,ymax)
259  plt.xlim(xmin,xmax)
260  plt.grid()
261  plt.xlabel("Signal efficiency")
262  plt.ylabel("Background efficiency")
263  plt.title('ROC curves for BTL, no MTD case')
264  if(save):
265  plt.savefig(ROC_plots_directory+'ROC_curve_BTL_noMTD_dzCuts')
266  plt.show()
267 
268  for i in objects:
269  plt.plot(i.Sig_iso_eff['Sig_noMTD_EE'],i.Bkg_iso_eff['Bkg_noMTD_EE'],label=f'noMTD {i.dz_cut_description}')
270  plt.legend(loc='best')
271  plt.ylim(ymin,ymax)
272  plt.xlim(xmin,xmax)
273  plt.grid()
274  plt.xlabel("Signal efficiency")
275  plt.ylabel("Background efficiency")
276  plt.title('ROC curves for ETL, no MTD case')
277  if(save):
278  plt.savefig(ROC_plots_directory+'ROC_curve_ETL_noMTD_dzCuts')
279  plt.show()
280 
281 
282 
283 
284 # object.Sig_hists['Sig_noMTD_EB'][1] # -> Array of ch_iso_sum bin values. (cuts for iso efficiency)
285 
def Plot_ROC_curves_vs_dz_noMTD
Definition: ROC_plotter.py:253
if(threadIdxLocalY==0 &&threadIdxLocalX==0)

◆ Read_hists()

def ROC_plotter.Read_hists (   self)

Definition at line 41 of file ROC_plotter.py.

41  def Read_hists(self):
42 
43  self.Sig_hists['Sig_noMTD_EB'] = self.Tree_Sig['Ele_chIso_sum_Sig_EB;1'].to_numpy()
44  self.Sig_hists['Sig_noMTD_EE'] = self.Tree_Sig['Ele_chIso_sum_Sig_EE;1'].to_numpy()
45  self.Bkg_hists['Bkg_noMTD_EB'] = self.Tree_Bkg['Ele_chIso_sum_Bkg_EB;1'].to_numpy()
46  self.Bkg_hists['Bkg_noMTD_EE'] = self.Tree_Bkg['Ele_chIso_sum_Bkg_EE;1'].to_numpy()
47 
48  if self.cut_type == True: # dt significance cut case
49 
50  self.Sig_hists['Sig_4sigma_EB'] = self.Tree_Sig['Ele_chIso_sum_MTD_4sigma_Sig_EB;1'].to_numpy()
51  self.Sig_hists['Sig_3sigma_EB'] = self.Tree_Sig['Ele_chIso_sum_MTD_3sigma_Sig_EB;1'].to_numpy()
52  self.Sig_hists['Sig_2sigma_EB'] = self.Tree_Sig['Ele_chIso_sum_MTD_2sigma_Sig_EB;1'].to_numpy()
53 
54  self.Sig_hists['Sig_4sigma_EE'] = self.Tree_Sig['Ele_chIso_sum_MTD_4sigma_Sig_EE;1'].to_numpy()
55  self.Sig_hists['Sig_3sigma_EE'] = self.Tree_Sig['Ele_chIso_sum_MTD_3sigma_Sig_EE;1'].to_numpy()
56  self.Sig_hists['Sig_2sigma_EE'] = self.Tree_Sig['Ele_chIso_sum_MTD_2sigma_Sig_EE;1'].to_numpy()
57 
58  self.Bkg_hists['Bkg_4sigma_EB'] = self.Tree_Bkg['Ele_chIso_sum_MTD_4sigma_Bkg_EB;1'].to_numpy()
59  self.Bkg_hists['Bkg_3sigma_EB'] = self.Tree_Bkg['Ele_chIso_sum_MTD_3sigma_Bkg_EB;1'].to_numpy()
60  self.Bkg_hists['Bkg_2sigma_EB'] = self.Tree_Bkg['Ele_chIso_sum_MTD_2sigma_Bkg_EB;1'].to_numpy()
61 
62  self.Bkg_hists['Bkg_4sigma_EE'] = self.Tree_Bkg['Ele_chIso_sum_MTD_4sigma_Bkg_EE;1'].to_numpy()
63  self.Bkg_hists['Bkg_3sigma_EE'] = self.Tree_Bkg['Ele_chIso_sum_MTD_3sigma_Bkg_EE;1'].to_numpy()
64  self.Bkg_hists['Bkg_2sigma_EE'] = self.Tree_Bkg['Ele_chIso_sum_MTD_2sigma_Bkg_EE;1'].to_numpy()
65 
66  else: # absolute dt cut case #optional
67 
68  # Can redifine how many of the 7 cuts defined in the EleIsoValidation code to plot. (Here they are numbered in the star position -> 'Ele_chIso_sum_MTD_*_Sig_EB;1')
69  # The cut values themselves are defined in the Validaton code, here we just plot the ROC curves.
70 
71  self.Sig_hists['Sig_cut1_EB'] = self.Tree_Sig['Ele_chIso_sum_MTD_1_Sig_EB;1'].to_numpy()
72  self.Sig_hists['Sig_cut2_EB'] = self.Tree_Sig['Ele_chIso_sum_MTD_2_Sig_EB;1'].to_numpy()
73  self.Sig_hists['Sig_cut3_EB'] = self.Tree_Sig['Ele_chIso_sum_MTD_3_Sig_EB;1'].to_numpy()
74  self.Sig_hists['Sig_cut5_EB'] = self.Tree_Sig['Ele_chIso_sum_MTD_5_Sig_EB;1'].to_numpy()
75 
76  self.Sig_hists['Sig_cut1_EE'] = self.Tree_Sig['Ele_chIso_sum_MTD_1_Sig_EE;1'].to_numpy()
77  self.Sig_hists['Sig_cut2_EE'] = self.Tree_Sig['Ele_chIso_sum_MTD_2_Sig_EE;1'].to_numpy()
78  self.Sig_hists['Sig_cut3_EE'] = self.Tree_Sig['Ele_chIso_sum_MTD_3_Sig_EE;1'].to_numpy()
79  self.Sig_hists['Sig_cut5_EE'] = self.Tree_Sig['Ele_chIso_sum_MTD_5_Sig_EE;1'].to_numpy()
80 
81  self.Bkg_hists['Bkg_cut1_EB'] = self.Tree_Bkg['Ele_chIso_sum_MTD_1_Bkg_EB;1'].to_numpy()
82  self.Bkg_hists['Bkg_cut2_EB'] = self.Tree_Bkg['Ele_chIso_sum_MTD_2_Bkg_EB;1'].to_numpy()
83  self.Bkg_hists['Bkg_cut3_EB'] = self.Tree_Bkg['Ele_chIso_sum_MTD_3_Bkg_EB;1'].to_numpy()
84  self.Bkg_hists['Bkg_cut5_EB'] = self.Tree_Bkg['Ele_chIso_sum_MTD_5_Bkg_EB;1'].to_numpy()
85 
86  self.Bkg_hists['Bkg_cut1_EE'] = self.Tree_Bkg['Ele_chIso_sum_MTD_1_Bkg_EE;1'].to_numpy()
87  self.Bkg_hists['Bkg_cut2_EE'] = self.Tree_Bkg['Ele_chIso_sum_MTD_2_Bkg_EE;1'].to_numpy()
88  self.Bkg_hists['Bkg_cut3_EE'] = self.Tree_Bkg['Ele_chIso_sum_MTD_3_Bkg_EE;1'].to_numpy()
89  self.Bkg_hists['Bkg_cut5_EE'] = self.Tree_Bkg['Ele_chIso_sum_MTD_5_Bkg_EE;1'].to_numpy()
90 
def Read_hists(self)
Definition: ROC_plotter.py:41

Variable Documentation

◆ Bkg_hists

ROC_plotter.Bkg_hists

Definition at line 36 of file ROC_plotter.py.

◆ Bkg_iso_eff

ROC_plotter.Bkg_iso_eff

Definition at line 39 of file ROC_plotter.py.

◆ cut_type

ROC_plotter.cut_type

Definition at line 29 of file ROC_plotter.py.

◆ directory_path

ROC_plotter.directory_path

Definition at line 19 of file ROC_plotter.py.

Referenced by SiStripTFile.addDevice().

◆ dz_cut_description

ROC_plotter.dz_cut_description

Definition at line 30 of file ROC_plotter.py.

◆ filename_bkg

ROC_plotter.filename_bkg

Definition at line 27 of file ROC_plotter.py.

◆ filename_sig

ROC_plotter.filename_sig

Definition at line 26 of file ROC_plotter.py.

◆ ROC_plots_directory

ROC_plotter.ROC_plots_directory

Definition at line 20 of file ROC_plotter.py.

◆ Sig_hists

ROC_plotter.Sig_hists

Definition at line 35 of file ROC_plotter.py.

◆ Sig_iso_eff

ROC_plotter.Sig_iso_eff

Definition at line 38 of file ROC_plotter.py.

◆ Tree_Bkg

ROC_plotter.Tree_Bkg

Definition at line 33 of file ROC_plotter.py.

◆ Tree_Sig

ROC_plotter.Tree_Sig

Definition at line 32 of file ROC_plotter.py.