Belle II Software development
plotting.py
1#!/usr/bin/env python3
2
3
10
11# You can use the basf2_mva_evaluation.py tool as well
12
13from basf2_mva_util import chain2dict, calculate_auc_efficiency_vs_background_retention
14from basf2_mva_evaluation import plotting
15import ROOT
16
17if __name__ == "__main__":
18 rootchain = ROOT.TChain("variables")
19 rootchain.Add('ntuple.root')
20
21 variables = ['extraInfo__boFull__bc', 'extraInfo__boOrdinary__bc', 'extraInfo__boPdf__bc', 'extraInfo__boSPlot__bc',
22 'extraInfo__boSPlotCombined__bc', 'extraInfo__boSPlotBoosted__bc', 'extraInfo__boSPlotCombinedBoosted__bc',
23 'isSignal']
24 data = chain2dict(rootchain, variables, variables)
25
27 p.set_plot_options(dict(linestyle='-', lw=6))
28 p.set_errorband_options(None)
29 p.set_errorbar_options(None)
30 p.add(data, 'extraInfo__boFull__bc', data['isSignal'] == 1, data['isSignal'] == 0)
31 p.add(data, 'extraInfo__boOrdinary__bc', data['isSignal'] == 1, data['isSignal'] == 0)
32 p.add(data, 'extraInfo__boPdf__bc', data['isSignal'] == 1, data['isSignal'] == 0)
33 p.add(data, 'extraInfo__boSPlot__bc', data['isSignal'] == 1, data['isSignal'] == 0)
34 p.add(data, 'extraInfo__boSPlotCombined__bc', data['isSignal'] == 1, data['isSignal'] == 0)
35 p.add(data, 'extraInfo__boSPlotBoosted__bc', data['isSignal'] == 1, data['isSignal'] == 0)
36 p.add(data, 'extraInfo__boSPlotCombinedBoosted__bc', data['isSignal'] == 1, data['isSignal'] == 0)
37 p.finish()
38 p.save('evaluation.png')
39
40 print('AUC (Ordinary)', calculate_auc_efficiency_vs_background_retention(data['extraInfo__boOrdinary__bc'], data['isSignal']))
41 print('AUC (Full)', calculate_auc_efficiency_vs_background_retention(data['extraInfo__boFull__bc'], data['isSignal']))
42 print('AUC (Pdf)', calculate_auc_efficiency_vs_background_retention(data['extraInfo__boPdf__bc'], data['isSignal']))
43 print('AUC (SPlot)', calculate_auc_efficiency_vs_background_retention(data['extraInfo__boSPlot__bc'], data['isSignal']))
44 print(
45 'AUC (SPlotCombined)',
46 calculate_auc_efficiency_vs_background_retention(
47 data['extraInfo__boSPlotCombined__bc'],
48 data['isSignal']))
49 print(
50 'AUC (SPlotBoosted)',
51 calculate_auc_efficiency_vs_background_retention(
52 data['extraInfo__boSPlotBoosted__bc'],
53 data['isSignal']))
54 print('AUC (SPlotCombinedBoosted)', calculate_auc_efficiency_vs_background_retention(
55 data['extraInfo__boSPlotCombinedBoosted__bc'], data['isSignal']))