Belle II Software development
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 def preparePathValidation(self, path):
65 """The default way to add the validation module to the path.
66
67 Derived classes can overload this method modify the validation module
68 or add more than one validation steps.
69 """
70
71 if self.extended:
72 expert_level = None
73 if self.saveFullTrees:
74 expert_level = 200
75
76 trackingValidationModule = CombinedTrackingValidationModule(
77 name=self.name,
78 contact=self.contact,
79 output_file_name=self.output_file_nameoutput_file_name,
80 expert_level=expert_level
81 )
82 else:
83 # Validation module generating plots
84 trackingValidationModule = ExpertTrackingValidationModule(
85 self.name,
86 contact=self.contact,
87 fit=self.use_fit_information or self.fit_tracks,
88 pulls=self.pulls,
89 resolution=self.resolution,
90 output_file_name=self.output_file_nameoutput_file_name,
91 use_expert_folder=self.use_expert_folder,
92 exclude_profile_mc_parameter=self.exclude_profile_mc_parameter,
93 exclude_profile_pr_parameter=self.exclude_profile_pr_parameter
94 )
95 trackingValidationModule.trackCandidatesColumnName = "RecoTracks"
96
97 # tell the module which are the shifter (aka non-experts) plots
98 trackingValidationModule.non_expert_parameters = self.non_expert_parameters
99
100 path.add_module(trackingValidationModule)
101
102 def create_argument_parser(self, **kwds):
103 """Create command line argument parser"""
104 argument_parser = super().create_argument_parser(**kwds)
105
106 # Left over from earlier parameter settings. Overwrites the more fundamental simulation_only parameter
107 argument_parser.add_argument(
108 '-o',
109 '--output',
110 dest='simulation_output',
111 default=argparse.SUPPRESS,
112 help='Output file to which the simulated events shall be written.'
113 )
114
115 argument_parser.add_argument(
116 '-e',
117 '--extended',
118 dest='extended',
119 action='store_true',
120 default=argparse.SUPPRESS,
121 help='Use the extended validation with more plots and whistles'
122 )
123
124 return argument_parser
125
126 def create_path(self):
127 """Create path from parameters"""
128 # Sets up a path that plays back pregenerated events or generates events
129 # based on the properties in the base class.
130 path = super().create_path()
131
132 # add the validation module to the path
133 self.preparePathValidation(path)
134
135 if self.root_output_file:
136 path.add_module("RootOutput", outputFileName=self.root_output_file)
137
138 return path
139
140
141def main():
142 trackingValiddationRun = TrackingValidationRun()
143 trackingValiddationRun.configure_and_execute_from_commandline()
144
145
146if __name__ == '__main__':
147 logging.basicConfig(level=logging.INFO)
148 main()
None 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.
def create_argument_parser(self, **kwds)
Definition: run.py:102
list non_expert_parameters
List of parameters which should be used as shifter plots (all plots with these x-labels)
Definition: run.py:62
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
TRACKING_MAILING_LIST contact
Default contact email address for the validation results.
Definition: run.py:29
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
str output_file_name
Name of the output file for the validation results.
Definition: run.py:32
bool resolution
Include the residual plots of the fit parameters in the validation.
Definition: run.py:41
None root_output_file
Optional file name as a destination of all event data which is discarded otherwise.
Definition: run.py:35
Definition: main.py:1