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

Public Member Functions

 __init__ (self)
 
 cdc_display_module (self)
 
 create_argument_parser (self, **kwds)
 
 configure (self, arguments)
 
 create_path (self)
 
 execute (self)
 
 name (self)
 
 configure_and_execute_from_commandline (self)
 
 run (self, path)
 
 configure_from_commandline (self)
 
 adjust_path (self, path)
 

Public Attributes

 cdc_display_module
 

Static Public Attributes

 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.
 
 finder_module = None
 Name of the finder module to be used - can be everything that is accepted by tracking.run.utilities.extend_path.
 
dict tracking_coverage
 States which detectors the finder module covers like as a dictionary like.
 
bool fit_tracks = False
 By default, do not add the track fitting to the execution.
 
bool mc_tracking = True
 By default, do MC track finding and track matching.
 
 generator_module = None
 By default, do not generate events.
 
str detector_setup = "Default"
 By default, use the default detector setup.
 
list bkg_files = []
 By default, no background overlay.
 
 components = None
 By default, do specific components.
 
bool disable_deltas = False
 By default, do not disable delta-ray generation.
 
 simulation_output = None
 By default, do no store the simulation output.
 
bool allow_input = True
 By default, this basf2 job can read events from an input ROOT TFile.
 
int n_events = 10000
 By default, process 10000 events.
 
 root_input_file = None
 By default, there is no input ROOT TFile.
 
 random_seed = None
 By default, the random-number seed is unassigned.
 
int n_processes = 0
 By default, no parallel processing.
 
int n_events_to_skip = 0
 By default, do not skip any events at the start of the input ROOT TFile.
 
str description = "Empty execution of basf2"
 Description of the run setup to be displayed on command line.
 

Protected Attributes

 _cdc_display_module = cdcdisplay.CDCSVGDisplayModule(self.output_folder)
 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__()

__init__ ( self)
Constructor

Definition at line 31 of file display.py.

31 def __init__(self):
32 """Constructor"""
33 super().__init__()
34 ## Use the CDCSVGDisplay module to draw the CDC and tracks/hits
35 self._cdc_display_module = cdcdisplay.CDCSVGDisplayModule(self.output_folder)
36

Member Function Documentation

◆ adjust_path()

adjust_path ( self,
path )
inherited
Hook that gives the opportunity to check the path for consistency before processing it

Reimplemented in HarvestingRunMixin, VXDTF2TrackingValidation, and VXDTF2TrackingValidationBkg.

Definition at line 94 of file minimal.py.

94 def adjust_path(self, path):
95 """Hook that gives the opportunity to check the path for consistency before processing it"""
96
97# Minimal run stub defining some general parameters
98
99

◆ cdc_display_module()

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()

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

◆ configure_and_execute_from_commandline()

configure_and_execute_from_commandline ( self)
inherited
Configure basf2 job script from command-line arguments then run it

Definition at line 45 of file minimal.py.

45 def configure_and_execute_from_commandline(self):
46 """Configure basf2 job script from command-line arguments then run it"""
47 self.configure_from_commandline()
48 self.execute()
49

◆ configure_from_commandline()

configure_from_commandline ( self)
inherited
Convert the command-line arguments to a basf2 job script

Definition at line 67 of file minimal.py.

67 def configure_from_commandline(self):
68 """Convert the command-line arguments to a basf2 job script"""
69 argument_parser = self.create_argument_parser()
70 arguments = argument_parser.parse_args()
71 self.configure(arguments)
72

◆ create_argument_parser()

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()

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

◆ execute()

execute ( self)
inherited
Run the basf2 job

Reimplemented from EmptyRun.

Definition at line 130 of file event_generation.py.

130 def execute(self):
131 """Run the basf2 job"""
132 if not self.simulation_output:
133 super().execute()
134 return
135
136 # Run only simulation
137 path = ReadOrGenerateEventsRun.create_path(self)
138 self.run(path)
139

◆ name()

name ( self)
inherited
provide name of this object

Definition at line 41 of file minimal.py.

41 def name(self):
42 """provide name of this object"""
43 return self.__class__.__name__
44

◆ run()

run ( self,
path )
inherited
Process the basf2 path

Reimplemented in PostProcessingRunMixin.

Definition at line 58 of file minimal.py.

58 def run(self, path):
59 """Process the basf2 path"""
60 # Run basf2 module path #
61
62 get_logger().info('Start processing')
63 basf2.print_path(path)
64 basf2.process(path)
65 get_logger().info("\n%s", str(basf2.statistics))
66

Member Data Documentation

◆ _cdc_display_module

_cdc_display_module = cdcdisplay.CDCSVGDisplayModule(self.output_folder)
protected

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

Definition at line 35 of file display.py.

◆ allow_input

bool allow_input = True
staticinherited

By default, this basf2 job can read events from an input ROOT TFile.

Definition at line 109 of file minimal.py.

◆ bkg_files

list bkg_files = []
staticinherited

By default, no background overlay.

Definition at line 47 of file event_generation.py.

◆ cdc_display_module

cdc_display_module

Definition at line 152 of file display.py.

◆ components

components = None
staticinherited

By default, do specific components.

Definition at line 49 of file event_generation.py.

◆ description

str description = "Empty execution of basf2"
staticinherited

Description of the run setup to be displayed on command line.

Definition at line 33 of file minimal.py.

◆ detector_setup

str detector_setup = "Default"
staticinherited

By default, use the default detector setup.

Definition at line 45 of file event_generation.py.

◆ disable_deltas

bool disable_deltas = False
staticinherited

By default, do not disable delta-ray generation.

Definition at line 51 of file event_generation.py.

◆ filename_prefix

str filename_prefix = ""
static

Prefix of the output files.

Definition at line 29 of file display.py.

◆ finder_module

◆ fit_tracks

bool fit_tracks = False
staticinherited

By default, do not add the track fitting to the execution.

Definition at line 47 of file tracked_event_generation.py.

◆ generator_module

generator_module = None
staticinherited

By default, do not generate events.

Definition at line 43 of file event_generation.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.

◆ mc_tracking

bool mc_tracking = True
staticinherited

By default, do MC track finding and track matching.

Definition at line 50 of file tracked_event_generation.py.

◆ n_events

n_events = 10000
staticinherited

By default, process 10000 events.

Definition at line 111 of file minimal.py.

◆ n_events_to_skip

int n_events_to_skip = 0
staticinherited

By default, do not skip any events at the start of the input ROOT TFile.

Definition at line 119 of file minimal.py.

◆ n_processes

n_processes = 0
staticinherited

By default, no parallel processing.

Definition at line 117 of file minimal.py.

◆ output_folder

output_folder = tempfile.gettempdir()
static

Destination folder for displays.

Definition at line 20 of file display.py.

◆ random_seed

random_seed = None
staticinherited

By default, the random-number seed is unassigned.

Definition at line 115 of file minimal.py.

◆ root_input_file

root_input_file = None
staticinherited

By default, there is no input ROOT TFile.

Definition at line 113 of file minimal.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.

◆ simulation_output

simulation_output = None
staticinherited

By default, do no store the simulation output.

Definition at line 53 of file event_generation.py.

◆ tracking_coverage

dict tracking_coverage
staticinherited
Initial value:
= {
'UsePXDHits': True,
'UseSVDHits': True,
'UseCDCHits': True,
'UseOnlyAxialCDCHits': False,
'UseOnlyBeforeTOP': True,
'UseReassignedHits': True,
'UseNLoops': 1,
'WhichParticles': [],
}

States which detectors the finder module covers like as a dictionary like.

Definition at line 35 of file tracked_event_generation.py.


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