Belle II Software  release-05-01-25
printReporting.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # Thomas Keck 2017
5 
6 """
7  Call this "python3 fei/printReporting.py"
8  in a directory containing the monitoring output of the FEI
9  It will print out a summary and create some plots
10 """
11 
12 
13 import fei.monitoring as monitoring
14 
15 
16 def bold(text):
17  """Use ANSI sequence to show string in bold"""
18  return '\x1b[1m' + text + '\x1b[0m'
19 
20 
21 def print_summary(p):
22  try:
23  monitoring.MonitorROCPlot(p, monitoring.removeJPsiSlash(p.particle.identifier + '_ROC'))
24  monitoring.MonitorDiagPlot(p, monitoring.removeJPsiSlash(p.particle.identifier + '_Diag'))
25  if p.particle.identifier in ['B+:generic', 'B0:generic']:
26  monitoring.MonitorMbcPlot(p, monitoring.removeJPsiSlash(p.particle.identifier + '_Money'))
27  if p.particle.identifier in ['B+:semileptonic', 'B0:semileptonic']:
28  monitoring.MonitorCosBDLPlot(p, monitoring.removeJPsiSlash(p.particle.identifier + '_Money'))
29  except:
30  pass
31  print(bold(p.particle.identifier))
32  print('Total cpu time spent reconstructing this particle: ',
33  p.module_statistic.particle_time + sum(p.module_statistic.channel_time.values()))
34  print('Total amount of Monte Carlo particles in training sample: ', p.mc_count)
35  print('Number of decay channels: ', p.reconstructed_number_of_channels, '/', p.total_number_of_channels)
36  print(bold('PreCut'))
37  print('UserCut', p.particle.preCutConfig.userCut)
38  print('BestCandidateCut', p.particle.preCutConfig.bestCandidateVariable,
39  p.particle.preCutConfig.bestCandidateCut, p.particle.preCutConfig.bestCandidateMode)
40  print('VertexCut', p.particle.preCutConfig.vertexCut)
41  print('Stats before ranking')
42  print(sum(p.before_ranking.values()))
43  print('Stats after ranking')
44  print(sum(p.after_ranking.values()))
45  print('Stats after vertex')
46  print(sum(p.after_vertex.values()))
47  print('Stats after classifier')
48  print(sum(p.after_classifier.values()))
49  print(bold('PostCut'))
50  print('Absolute', p.particle.postCutConfig.value)
51  print('Ranking', p.particle.postCutConfig.bestCandidateCut)
52  print('Stats before postcut')
53  print(p.before_postcut)
54  print('Stats before ranking postcut')
55  print(p.before_ranking_postcut)
56  print('Stats after ranking postcut')
57  print(p.after_ranking_postcut)
58  print(bold('Tag unique signal'))
59  print('Stats before tag')
60  print(p.before_tag)
61  print('Stats after tag')
62  print(p.after_tag)
63  print(bold('Multivariate classifier'))
64  print('Method', p.particle.mvaConfig.method)
65  print('Target', p.particle.mvaConfig.target)
66  print(bold('Individual channels'))
67  for channel in p.particle.channels:
68  print(bold(channel.label))
69  print('Stats before ranking')
70  print(p.before_ranking[channel.label])
71  print('Stats after ranking')
72  print(p.after_ranking[channel.label])
73  print('Stats after vertex')
74  print(p.after_vertex[channel.label])
75  print('Stats after classifier')
76  print(p.after_classifier[channel.label])
77 
78 
79 if __name__ == '__main__':
80  particles, configuration = monitoring.load_config()
81  for particle in particles:
82  monitoringParticle = monitoring.MonitoringParticle(particle)
83  print_summary(monitoringParticle)
fei.monitoring
Definition: monitoring.py:1