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