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