18class CDCDisplayRun(ReadOrGenerateTrackedEventsRun):
19 """Prepare and execute a basf2 job to read generated events or generate new events then display the CDC tracks"""
22 output_folder = tempfile.gettempdir()
28 show_all_drawoptions =
False
36 ## Use the CDCSVGDisplay module to draw the CDC and tracks/hits
37 self._cdc_display_module = cdcdisplay.CDCSVGDisplayModule(self.output_folder)
40 def cdc_display_module(self):
41 """Get the display module"""
42 cdc_display_module = self._cdc_display_module
43 return cdc_display_module
45 def create_argument_parser(self, **kwds):
46 """Translate the command-lne arguments to basf2-job paramete
r"""
47 argument_parser = super().create_argument_parser(**kwds)
49 argument_parser.add_argument(
53 default=self.output_folder,
54 help='Folder where the output files are written to. If the folder does not exist create it. '
57 argument_parser.add_argument(
61 help='Run in batch mode and do not show each event.'
64 argument_parser.add_argument(
68 help='Swtich to activate the legacy implementation written in python'
71 argument_parser.add_argument(
72 "--use_time_in_filename",
74 help='Use the current time in the names of the generated files'
77 argument_parser.add_argument(
80 default=self.filename_prefix,
81 help='Prefix to the names of the generated files'
84 argument_parser.add_argument(
89 const='TrackFinderMCTruthRecoTracks',
90 default=self.finder_module,
91 help='Generate the mc tracks using the TrackFinderMCTruthRecoTracks. Short hand for -f TrackFinderMCTruthRecoTracks'
94 subparser_description = \
96Various options to configure what shall be drawn in the display.
97Note that some options are only relevant, if the cellular automaton finder in the CDC has been run before.
99 draw_argument_group = argument_parser.add_argument_group(
100 title='Draw options',
101 description=subparser_description
104 cdc_display_module = self.cdc_display_module
106 if self.show_all_drawoptions:
107 drawoptions = cdc_display_module.all_drawoptions
109 drawoptions = cdc_display_module.drawoptions
111 for option in sorted(drawoptions):
112 options_flag = f"--{option.replace('_', '-')} "
114 draw_argument_group.add_argument(
118 default=getattr(cdc_display_module, option)
121 return argument_parser
123 def configure(self, arguments):
124 """Configure the basf2 job script using the translated command-line arguments"""
125 super().configure(arguments)
127 cdc_display_module = self.cdc_display_module
129 cdc_display_module.output_folder = arguments.output_folder
130 cdc_display_module.interactive = arguments.interactive
132 cdc_display_module.use_python = arguments.use_python
133 cdc_display_module.use_cpp = not arguments.use_python
134 cdc_display_module.use_time_in_filename = arguments.use_time_in_filename
135 cdc_display_module.filename_prefix = arguments.filename_prefix
137 if self.show_all_drawoptions:
138 drawoptions = cdc_display_module.all_drawoptions
140 drawoptions = cdc_display_module.drawoptions
142 for option in drawoptions:
144 is_active_option = getattr(arguments, option)
145 except AttributeError:
148 print('Setting', option, 'to', is_active_option)
149 setattr(cdc_display_module, option, is_active_option)
151 def create_path(self):
152 """Create the basf2 path"""
153 main_path = super().create_path()
154 main_path.add_module(self.cdc_display_module)