Belle II Software development
CDCDisplayRun Class Reference
Inheritance diagram for CDCDisplayRun:
ReadOrGenerateTrackedEventsRun ReadOrGenerateEventsRun MinimalRun EmptyRun

Public Member Functions

def __init__ (self)
 
def cdc_display_module (self)
 
def create_argument_parser (self, **kwds)
 
def configure (self, arguments)
 
def create_path (self)
 

Static Public Attributes

tempfile output_folder = tempfile.gettempdir()
 Destination folder for displays.
 
bool iteractive = True
 Switch to show the event display after each event.
 
bool show_all_drawoptions = False
 Switch to also show draw command line options only related to the cellular automaton track finder.
 
str filename_prefix = ""
 Prefix of the output files.
 

Protected Attributes

 _cdc_display_module
 Use the CDCSVGDisplay module to draw the CDC and tracks/hits.
 

Detailed Description

Prepare and execute a basf2 job to read generated events or generate new events then display the CDC tracks

Definition at line 16 of file display.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
Constructor

Reimplemented from EmptyRun.

Definition at line 31 of file display.py.

31 def __init__(self):
32 """Constructor"""
33 super().__init__()
34
35 self._cdc_display_module = cdcdisplay.CDCSVGDisplayModule(self.output_folder)
36

Member Function Documentation

◆ cdc_display_module()

def cdc_display_module (   self)
Get the display module

Definition at line 38 of file display.py.

38 def cdc_display_module(self):
39 """Get the display module"""
40 cdc_display_module = self._cdc_display_module
41 return cdc_display_module
42

◆ configure()

def configure (   self,
  arguments 
)
Configure the basf2 job script using the translated command-line arguments

Reimplemented from ReadOrGenerateEventsRun.

Definition at line 121 of file display.py.

121 def configure(self, arguments):
122 """Configure the basf2 job script using the translated command-line arguments"""
123 super().configure(arguments)
124
125 cdc_display_module = self.cdc_display_module
126
127 cdc_display_module.output_folder = arguments.output_folder
128 cdc_display_module.interactive = arguments.interactive
129
130 cdc_display_module.use_python = arguments.use_python
131 cdc_display_module.use_cpp = not arguments.use_python
132 cdc_display_module.use_time_in_filename = arguments.use_time_in_filename
133 cdc_display_module.filename_prefix = arguments.filename_prefix
134
135 if self.show_all_drawoptions:
136 drawoptions = cdc_display_module.all_drawoptions
137 else:
138 drawoptions = cdc_display_module.drawoptions
139
140 for option in drawoptions:
141 try:
142 is_active_option = getattr(arguments, option)
143 except AttributeError:
144 continue
145 else:
146 print('Setting', option, 'to', is_active_option)
147 setattr(cdc_display_module, option, is_active_option)
148

◆ create_argument_parser()

def create_argument_parser (   self,
**  kwds 
)
Translate the command-lne arguments to basf2-job parameter

Reimplemented from ReadOrGenerateTrackedEventsRun.

Definition at line 43 of file display.py.

43 def create_argument_parser(self, **kwds):
44 """Translate the command-lne arguments to basf2-job parameter"""
45 argument_parser = super().create_argument_parser(**kwds)
46
47 argument_parser.add_argument(
48 '-o',
49 '--output-folder',
50 dest='output_folder',
51 default=self.output_folder,
52 help='Folder where the output files are written to. If the folder does not exist create it. '
53 )
54
55 argument_parser.add_argument(
56 '--non-interactive',
57 dest='interactive',
58 action='store_false',
59 help='Run in batch mode and do not show each event.'
60 )
61
62 argument_parser.add_argument(
63 '--use-python',
64 dest='use_python',
65 action='store_true',
66 help='Swtich to activate the legacy implementation written in python'
67 )
68
69 argument_parser.add_argument(
70 "--use_time_in_filename",
71 action='store_true',
72 help='Use the current time in the names of the generated files'
73 )
74
75 argument_parser.add_argument(
76 "-pf",
77 '--filename_prefix',
78 default=self.filename_prefix,
79 help='Prefix to the names of the generated files'
80 )
81
82 argument_parser.add_argument(
83 '-m',
84 '--mc-tracks',
85 action='store_const',
86 dest='finder_module',
87 const='TrackFinderMCTruthRecoTracks',
88 default=self.finder_module,
89 help='Generate the mc tracks using the TrackFinderMCTruthRecoTracks. Short hand for -f TrackFinderMCTruthRecoTracks'
90 )
91
92 subparser_description = \
93 """
94Various options to configure what shall be drawn in the display.
95Note that some options are only relevant, if the cellular automaton finder in the CDC has been run before.
96"""
97 draw_argument_group = argument_parser.add_argument_group(
98 title='Draw options',
99 description=subparser_description
100 )
101
102 cdc_display_module = self.cdc_display_module
103
104 if self.show_all_drawoptions:
105 drawoptions = cdc_display_module.all_drawoptions
106 else:
107 drawoptions = cdc_display_module.drawoptions
108
109 for option in sorted(drawoptions):
110 options_flag = f"--{option.replace('_', '-')} "
111
112 draw_argument_group.add_argument(
113 options_flag,
114 dest=option,
115 action='store_true',
116 default=getattr(cdc_display_module, option)
117 )
118
119 return argument_parser
120

◆ create_path()

def create_path (   self)
Create the basf2 path

Reimplemented from ReadOrGenerateTrackedEventsRun.

Definition at line 149 of file display.py.

149 def create_path(self):
150 """Create the basf2 path"""
151 main_path = super().create_path()
152 main_path.add_module(self.cdc_display_module)
153 return main_path

Member Data Documentation

◆ _cdc_display_module

_cdc_display_module
protected

Use the CDCSVGDisplay module to draw the CDC and tracks/hits.

Definition at line 35 of file display.py.

◆ filename_prefix

str filename_prefix = ""
static

Prefix of the output files.

Definition at line 29 of file display.py.

◆ iteractive

bool iteractive = True
static

Switch to show the event display after each event.

Run in batch mode for false

Definition at line 23 of file display.py.

◆ output_folder

tempfile output_folder = tempfile.gettempdir()
static

Destination folder for displays.

Definition at line 20 of file display.py.

◆ show_all_drawoptions

bool show_all_drawoptions = False
static

Switch to also show draw command line options only related to the cellular automaton track finder.

Definition at line 26 of file display.py.


The documentation for this class was generated from the following file: