Belle II Software prerelease-11-00-00a
run.py
1#!/usr/bin/env python3
2
3
10
11
12import logging
13import argparse
14
15from tracking.run.tracked_event_generation import ReadOrGenerateTrackedEventsRun
16from tracking.run.mixins import BrowseTFileOnTerminateRunMixin
17from tracking.validation.hit_module import ExpertTrackingValidationModule
18from tracking.harvesting_validation.combined_module import CombinedTrackingValidationModule
19
20
21TRACKING_MAILING_LIST = 'software-tracking@belle2.org'
22
23
25 """Run setup to compose a path to validate the the tracking procedures from pre-simulated events
26 or from events simulated on the fly. Considering parameters from the commandline."""
27
28
29 contact = TRACKING_MAILING_LIST
30
31
32 output_file_name = 'TrackingValidation.root' # Also specification for BrowseTFileOnTerminateRunMixin
33
34
35 root_output_file = None
36
37
38 pulls = True
39
40
41 resolution = False
42
43
44 use_expert_folder = True
45
46
47 exclude_profile_mc_parameter = []
48
49
50 exclude_profile_pr_parameter = []
51
52
53 use_fit_information = False
54
55
56 extended = False
57
58
59 saveFullTrees = False
60
61
62 non_expert_parameters = ['p_{t}']
63
64
65 plotTrackQualityIndicator = True
66
67 def preparePathValidation(self, path):
68 """The default way to add the validation module to the path.
69
70 Derived classes can overload this method modify the validation module
71 or add more than one validation steps.
72 """
73
74 if self.extended:
75 expert_level = None
76 if self.saveFullTrees:
77 expert_level = 200
78
79 trackingValidationModule = CombinedTrackingValidationModule(
80 name=self.name,
81 contact=self.contact,
82 output_file_name=self.output_file_name,
83 expert_level=expert_level
84 )
85 else:
86 # Validation module generating plots
87 trackingValidationModule = ExpertTrackingValidationModule(
88 self.name,
89 contact=self.contact,
90 fit=self.use_fit_information or self.fit_tracks,
91 pulls=self.pulls,
92 resolution=self.resolution,
93 output_file_name=self.output_file_name,
94 use_expert_folder=self.use_expert_folder,
95 exclude_profile_mc_parameter=self.exclude_profile_mc_parameter,
96 exclude_profile_pr_parameter=self.exclude_profile_pr_parameter,
97 plotTrackQualityIndicator=self.plotTrackQualityIndicator
98 )
99 trackingValidationModule.trackCandidatesColumnName = "RecoTracks"
100
101 # tell the module which are the shifter (aka non-experts) plots
102 trackingValidationModule.non_expert_parameters = self.non_expert_parameters
103
104 path.add_module(trackingValidationModule)
105
106 def create_argument_parser(self, **kwds):
107 """Create command line argument parser"""
108 argument_parser = super().create_argument_parser(**kwds)
109
110 # Left over from earlier parameter settings. Overwrites the more fundamental simulation_only parameter
111 argument_parser.add_argument(
112 '-o',
113 '--output',
114 dest='simulation_output',
115 default=argparse.SUPPRESS,
116 help='Output file to which the simulated events shall be written.'
117 )
118
119 argument_parser.add_argument(
120 '-e',
121 '--extended',
122 dest='extended',
123 action='store_true',
124 default=argparse.SUPPRESS,
125 help='Use the extended validation with more plots and whistles'
126 )
127
128 return argument_parser
129
130 def create_path(self):
131 """Create path from parameters"""
132 # Sets up a path that plays back pregenerated events or generates events
133 # based on the properties in the base class.
134 path = super().create_path()
135
136 # add the validation module to the path
137 self.preparePathValidation(path)
138
139 if self.root_output_file:
140 path.add_module("RootOutput", outputFileName=self.root_output_file)
141
142 return path
143
144
145def main():
146 trackingValiddationRun = TrackingValidationRun()
147 trackingValiddationRun.configure_and_execute_from_commandline()
148
149
150if __name__ == '__main__':
151 logging.basicConfig(level=logging.INFO)
152 main()
output_file_name
There is no default for the name of the output TFile.
Definition mixins.py:60
bool fit_tracks
By default, do not add the track fitting to the execution.
list non_expert_parameters
List of parameters which should be used as shifter plots (all plots with these x-labels)
Definition run.py:62
contact
Default contact email address for the validation results.
Definition run.py:29
bool extended
Switch to use the extended harvesting validation instead.
Definition run.py:56
bool use_fit_information
Do not fit the tracks but access the fit information for pulls etc.
Definition run.py:53
bool use_expert_folder
Use the "expert" folder in the validation file as the destination of the pull and residual plots.
Definition run.py:44
list exclude_profile_mc_parameter
Exclude some of the perigee parameters from the mc side plots.
Definition run.py:47
list exclude_profile_pr_parameter
Exclude some of the perigee parameters from the pr side plots.
Definition run.py:50
bool pulls
Include the pull plots of the fit parameters in the validation.
Definition run.py:38
bool saveFullTrees
Only works in extended mode.
Definition run.py:59
bool resolution
Include the residual plots of the fit parameters in the validation.
Definition run.py:41
bool plotTrackQualityIndicator
Draw validation plots for track quality indicator.
Definition run.py:65