Belle II Software development
combined_module.py
1
8
9import ROOT
10from tracking import metamodules
11
12from tracking.harvesting_validation.mc_side_module import MCSideTrackingValidationModule
13from tracking.harvesting_validation.pr_side_module import PRSideTrackingValidationModule
14from tracking.harvesting_validation.eventwise_module import EventwiseTrackingValidationModule
15
16
18 """Harvesting validation module combining eventwise, pr side and mc side tracking valiation parts"""
19
20
21 MCSideModule = MCSideTrackingValidationModule
22
23
24 PRSideModule = PRSideTrackingValidationModule
25
26
27 EventwiseModule = EventwiseTrackingValidationModule
28
29 def __init__(self,
30 name,
31 contact,
32 output_file_name=None,
33 reco_tracks_name='RecoTracks',
34 mc_reco_tracks_name='MCRecoTracks',
35 expert_level=None):
36 """Constructor"""
37
38
39 self.output_file_name = output_file_name or name + 'TrackingValidation.root'
40
41 # First forward the output_file_name to the separate modules
42 # but we open the TFile in the top level and forward it to them on initialize.
43
44 eventwise_module = self.EventwiseModule(name,
45 contact,
46 output_file_name=self.output_file_name,
47 reco_tracks_name=reco_tracks_name,
48 mc_reco_tracks_name=mc_reco_tracks_name,
49 expert_level=expert_level)
50
51 pr_side_module = self.PRSideModule(name,
52 contact,
53 output_file_name=self.output_file_name,
54 reco_tracks_name=reco_tracks_name,
55 mc_reco_tracks_name=mc_reco_tracks_name,
56 expert_level=expert_level)
57
58 mc_side_module = self.MCSideModule(name,
59 contact,
60 output_file_name=self.output_file_name,
61 reco_tracks_name=reco_tracks_name,
62 mc_reco_tracks_name=mc_reco_tracks_name,
63 expert_level=expert_level)
64
65
66 self.modules = [
67 eventwise_module,
68 pr_side_module,
69 mc_side_module,
70 ]
71
72 super().__init__(modules=self.modules)
73
74 def initialize(self):
75 """Initialization signal at the start of the event processing"""
76 super().initialize()
77 output_tfile = ROOT.TFile(self.output_file_name, "RECREATE")
78
79 # Substitute the output file with the common output file opened in this module.
80 for module in self.modules:
81 module.output_file_name = output_tfile
82
83
84 self.output_tfile = output_tfile
85
86 def terminate(self):
87 """Termination signal at the start of the event processing"""
88 self.output_tfile.Flush()
89 self.output_tfile.Close()
90 super().terminate()
EventwiseTrackingValidationModule EventwiseModule
Eventwise side validation module to use.
output_file_name
Output TFile to be opened in the initialize methode.
def __init__(self, name, contact, output_file_name=None, reco_tracks_name='RecoTracks', mc_reco_tracks_name='MCRecoTracks', expert_level=None)
PRSideTrackingValidationModule PRSideModule
PR side validation module to use.
MCSideTrackingValidationModule MCSideModule
MC side validation module to use.