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

Public Member Functions

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

Static Public Attributes

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.
 

Detailed Description

Generate, simulate and reconstruct events

Definition at line 243 of file tracked_event_generation.py.

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

◆ configure()

configure ( self,
arguments )
inherited
Configure for basf2 job; disable ROOT input if simulating events

Reimplemented from EmptyRun.

Definition at line 122 of file event_generation.py.

122 def configure(self, arguments):
123 """Configure for basf2 job; disable ROOT input if simulating events"""
124 super().configure(arguments)
125 if self.simulation_output:
126 get_logger().info("Requested to simulation run. Deactivate input file")
127
128 self.root_input_file = None
129

◆ 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 )
inherited
Convert command-line arguments to basf2 argument list

Reimplemented from ReadOrGenerateEventsRun.

Reimplemented in TrackingValidationRun.

Definition at line 52 of file tracked_event_generation.py.

52 def create_argument_parser(self, **kwds):
53 """Convert command-line arguments to basf2 argument list"""
54 argument_parser = super().create_argument_parser(**kwds)
55
56 tracking_argument_group = argument_parser.add_argument_group("Tracking setup arguments")
57
58 tracking_argument_group.add_argument(
59 '-f',
60 '--finder',
61 choices=utilities.NonstrictChoices(finder_modules_by_short_name.keys()),
62 default=self.finder_module,
63 dest='finder_module',
64 help='Name of the finder module to be evaluated.',)
65
66 tracking_argument_group.add_argument(
67 '--fit',
68 action="store_true",
69 default=self.fit_tracks,
70 dest='fit_tracks',
71 help='Apply the fitting to the found tracks'
72 )
73
74 return argument_parser
75

◆ create_path()

create_path ( self)
inherited
Sets up a path that plays back pregenerated events or generates events
   based on the properties in the base class.

Reimplemented from ReadOrGenerateEventsRun.

Reimplemented in TrackingValidationRun.

Definition at line 76 of file tracked_event_generation.py.

76 def create_path(self):
77 """Sets up a path that plays back pregenerated events or generates events
78 based on the properties in the base class."""
79 path = super().create_path()
80
81 # setting up fitting is only necessary when testing
82 # track finding comonenst ex-situ
83 if self.fit_tracks:
84 if 'SetupGenfitExtrapolation' not in path:
85 # Prepare Genfit extrapolation
86 path.add_module('SetupGenfitExtrapolation')
87
88 if self.finder_module is not None:
89 # Setup track finder
90 utilities.extend_path(path,
91 self.finder_module,
92 finder_modules_by_short_name,
93 allow_function_import=True)
94
95 # determine which sub-detector hits will be used
96 tracking_coverage = dict(self.tracking_coverage)
97
98 matching_coverage = {key: value for key, value in tracking_coverage.items()
99 if key in ('UsePXDHits', 'UseSVDHits', 'UseCDCHits', 'MinimalEfficiency', 'MinimalPurity')}
100 # Removing minimal efficiency and purity as they are only parameters of the matching
101 if "MinimalEfficiency" in tracking_coverage:
102 tracking_coverage.pop("MinimalEfficiency")
103 if "MinimalPurity" in tracking_coverage:
104 tracking_coverage.pop("MinimalPurity")
105
106 # Include the mc tracks if the monte carlo data is presentx
107 if self.mc_tracking and 'MCRecoTracksMatcher' not in path:
108 # Reference Monte Carlo tracks
109 track_finder_mc_truth_module = basf2.register_module('TrackFinderMCTruthRecoTracks')
110
111 # Track matcher
112 mc_track_matcher_module = basf2.register_module('MCRecoTracksMatcher')
113
114 path.add_module(IfMCParticlesPresentModule(track_finder_mc_truth_module))
115 path.add_module(IfMCParticlesPresentModule(mc_track_matcher_module))
116
117 # this ensures that the parameters are set in both cases (if the modules have been added or are already in the path)
118 # only check for containment to also cope with the "IfMCParticlesPresentModule" cases correctly
119 for module in path.modules():
120 if 'MCRecoTracksMatcher' in module.name():
121 module.param({
122 'mcRecoTracksStoreArrayName': 'MCRecoTracks',
123 'MinimalPurity': 0.66,
124 'prRecoTracksStoreArrayName': "RecoTracks",
125 **matching_coverage
126 })
127 if 'TrackFinderMCTruthRecoTracks' in module.name():
128 module.param({
129 'RecoTracksStoreArrayName': 'MCRecoTracks',
130 **tracking_coverage
131 })
132
133 if self.fit_tracks:
134 # Fit tracks
135 gen_fitter_module = basf2.register_module('DAFRecoFitter')
136 gen_fitter_module.param({'pdgCodesToUseForFitting': [211]})
137 path.add_module(gen_fitter_module)
138 trackbuilder = basf2.register_module('TrackCreator', pdgCodes=[211])
139 path.add_module(trackbuilder)
140
141 return path
142
143

◆ 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

◆ finder_module()

finder_module ( self,
path )
Add track reconstruction to the basf2 path

Reimplemented from ReadOrGenerateTrackedEventsRun.

Definition at line 248 of file tracked_event_generation.py.

248 def finder_module(self, path):
249 """Add track reconstruction to the basf2 path"""
250 tracking.add_tracking_reconstruction(path, components=self.components)

◆ 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

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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: