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
18from contextlib
import redirect_stdout
24 """Use ANSI sequence to show string in bold"""
25 return '\x1b[1m' + text +
'\x1b[0m'
30 print(
"FEI: printReporting - DEBUG: ", p.particle.identifier)
31 monitoring.MonitorROCPlot(p, monitoring.removeJPsiSlash(p.particle.identifier +
'_ROC'))
32 monitoring.MonitorDiagPlot(p, monitoring.removeJPsiSlash(p.particle.identifier +
'_Diag'))
33 monitoring.MonitorSigProbPlot(p, monitoring.removeJPsiSlash(p.particle.identifier +
'_SigProb'))
34 for spectator
in p.particle.mvaConfig.spectators.keys():
35 monitoring.MonitorSpectatorPlot(
36 p, spectator, monitoring.removeJPsiSlash(
37 p.particle.identifier +
'_' + spectator +
'_Money'), p.particle.mvaConfig.spectators[spectator])
38 except Exception
as e:
39 print(
'FEI-printReporting Error: Could not create plots for particle', p.particle.identifier, e)
40 print(
"FEI: printReporting - DEBUG: finished plots")
41 print(bold(p.particle.identifier))
42 print(
'Total cpu time spent reconstructing this particle: ',
43 p.module_statistic.particle_time + sum(p.module_statistic.channel_time.values()))
44 print(
'Total amount of Monte Carlo particles in training sample: ', p.mc_count)
45 print(
'Number of decay channels: ', p.reconstructed_number_of_channels,
'/', p.total_number_of_channels)
47 print(
'UserCut', p.particle.preCutConfig.userCut)
48 print(
'BestCandidateCut', p.particle.preCutConfig.bestCandidateVariable,
49 p.particle.preCutConfig.bestCandidateCut, p.particle.preCutConfig.bestCandidateMode)
50 print(
'VertexCut', p.particle.preCutConfig.vertexCut)
51 print(
'Stats before ranking')
52 print(sum(p.before_ranking.values()))
53 print(
'Stats after ranking')
54 print(sum(p.after_ranking.values()))
55 print(
'Stats after vertex')
56 print(sum(p.after_vertex.values()))
57 print(
'Stats after classifier')
58 print(sum(p.after_classifier.values()))
59 print(bold(
'PostCut'))
60 print(
'Absolute', p.particle.postCutConfig.value)
61 print(
'Ranking', p.particle.postCutConfig.bestCandidateCut)
62 print(
'Stats before postcut')
63 print(p.before_postcut)
64 print(
'Stats before ranking postcut')
65 print(p.before_ranking_postcut)
66 print(
'Stats after ranking postcut')
67 print(p.after_ranking_postcut)
68 print(bold(
'Tag unique signal'))
69 print(
'Stats before tag')
71 print(
'Stats after tag')
73 print(bold(
'Multivariate classifier'))
74 print(
'Method', p.particle.mvaConfig.method)
75 print(
'Target', p.particle.mvaConfig.target)
76 print(bold(
'Individual channels'))
77 for channel
in p.particle.channels:
78 print(bold(channel.label))
79 print(
'Stats before ranking')
80 print(p.before_ranking[channel.label])
81 print(
'Stats after ranking')
82 print(p.after_ranking[channel.label])
83 print(
'Stats after vertex')
84 print(p.after_vertex[channel.label])
85 print(
'Stats after classifier')
86 print(p.after_classifier[channel.label])
89if __name__ ==
'__main__':
90 particles, configuration = monitoring.load_config()
92 if len(sys.argv) >= 2:
94 redirect = open(output,
'w')
95 print(
'Output redirected to', output)
99 with redirect_stdout(redirect):
100 for particle
in particles:
101 monitoringParticle = monitoring.MonitoringParticle(particle)
102 print_summary(monitoringParticle)
103 if len(sys.argv) >= 2: