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