Belle II Software development
MinimalRun Class Reference
Inheritance diagram for MinimalRun:
EmptyRun ReadOrGenerateEventsRun StandardEventGenerationRun ReadOrGenerateTrackedEventsRun BackgroundClusterFilterTrainingRun FeasibleAxialSegmentPairFilterTrainingRun FeasibleSegmentPairFilterTrainingRun FeasibleSegmentRelationFilterTrainingRun FeasibleTrackRelationFilterTrainingRun RealisticAxialSegmentPairFilterTrainingRun RealisticSegmentPairFilterTrainingRun RealisticSegmentPairRelationFilterTrainingRun RealisticSegmentRelationFilterTrainingRun RealisticTrackRelationFilterTrainingRun SegmentTrackFilterTrainingRun TrackFilterTrainingRun

Public Member Functions

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

Static Public Attributes

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

Configure for a minimal basf2 job

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

◆ configure()

configure ( self,
arguments )
inherited
Save the command-line arguments as key-value pairs

Reimplemented in CDCDisplayRun, and ReadOrGenerateEventsRun.

Definition at line 73 of file minimal.py.

73 def configure(self, arguments):
74 """Save the command-line arguments as key-value pairs"""
75 # Simply translate the arguments that have
76 # the same name as valid instance arguments
77 for (key, value) in list(vars(arguments).items()):
78 if value is None:
79 continue
80 if hasattr(self, key):
81 get_logger().info("Setting %s to %s", key, value)
82 setattr(self, key, value)
83

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

Reimplemented from EmptyRun.

Reimplemented in ClusterFilterValidationRun, CDCDisplayRun, ElossHarvestingRun, LegendreBinningValidationRun, SegmentFitValidationRun, SegmentPairFitValidationRun, SegmentPairCreationValidationRun, ReadOrGenerateEventsRun, ReadOrGenerateTrackedEventsRun, TrackingValidationRun, and FacetFilterTrainingRun.

Definition at line 121 of file minimal.py.

121 def create_argument_parser(self, **kwds):
122 """Convert command-line arguments to basf2 argument list"""
123 argument_parser = super().create_argument_parser(**kwds)
124 master_argument_group = argument_parser.add_argument_group("Master arguments")
125
126 if self.allow_input:
127 master_argument_group.add_argument(
128 '-i',
129 '--input',
130 default=argparse.SUPPRESS,
131 dest='root_input_file',
132 help='File path to the ROOT file from which the simulated events shall be loaded.'
133 )
134
135 master_argument_group.add_argument(
136 '-n',
137 '--events',
138 dest='n_events',
139 default=self.n_events,
140 type=int,
141 help='Number of events to be generated',
142 )
143
144 master_argument_group.add_argument(
145 '-r',
146 '--random-seed',
147 dest='random_seed',
148 default=argparse.SUPPRESS,
149 type=str,
150 help='The random number generator seed to be set before the processing starts.',
151 )
152
153 master_argument_group.add_argument(
154 '-p',
155 '--processes',
156 dest='n_processes',
157 default=argparse.SUPPRESS,
158 type=int,
159 help='The number of parallel processes to be used for processing.',
160 )
161
162 master_argument_group.add_argument(
163 '--n-events-to-skip',
164 dest='n_events_to_skip',
165 default=argparse.SUPPRESS,
166 type=int,
167 help='The number of events to skip',
168 )
169
170 return argument_parser
171

◆ create_path()

create_path ( self)
Create and configure the basf2 path

Reimplemented from EmptyRun.

Reimplemented in ClusterFilterValidationRun, CDCDisplayRun, FitValidation, ElossHarvestingRun, LegendreBinningValidationRun, SegmentFitValidationRun, SegmentPairFitValidationRun, SegmentQuadTreeRun, SegmentPairCreationValidationRun, ReadOrGenerateEventsRun, ReadOrGenerateTrackedEventsRun, TrackingValidationRun, BackgroundClusterFilterTrainingRun, FacetFilterTrainingRun, FacetRelationFilterTrainingRun, FeasibleAxialSegmentPairFilterTrainingRun, FeasibleSegmentPairFilterTrainingRun, FeasibleSegmentRelationFilterTrainingRun, FeasibleTrackRelationFilterTrainingRun, RealisticAxialSegmentPairFilterTrainingRun, RealisticSegmentPairFilterTrainingRun, RealisticSegmentPairRelationFilterTrainingRun, RealisticSegmentRelationFilterTrainingRun, RealisticTrackRelationFilterTrainingRun, SegmentTrackFilterTrainingRun, and TrackFilterTrainingRun.

Definition at line 172 of file minimal.py.

172 def create_path(self):
173 """Create and configure the basf2 path"""
174 path = super().create_path()
175
176 if self.random_seed is not None:
177 basf2.set_random_seed(self.random_seed)
178
179 environment = Belle2.Environment.Instance()
180 environment.setNumberEventsOverride(self.n_events)
181
182 # If there is no input file is the EventInfoSetter as master module
183 if not self.root_input_file:
184 # Master module: EventInfoSetter
185 path.add_module('EventInfoSetter',
186 evtNumList=[self.n_events],
187 runList=[1],
188 expList=[0],
189 skipNEvents=self.n_events_to_skip
190 )
191
192 else:
193 # Master module: RootInput
194 path.add_module('RootInput',
195 inputFileName=self.root_input_file,
196 skipNEvents=self.n_events_to_skip)
197
198 # Progress module
199 path.add_module('Progress')
200
201 if self.n_processes:
202 environment = Belle2.Environment.Instance()
203 environment.setNumberProcessesOverride(self.n_processes)
204
205 return path
static Environment & Instance()
Static method to get a reference to the Environment instance.

◆ execute()

execute ( self)
inherited
Create the basf2 path then run the job

Reimplemented in ReadOrGenerateEventsRun.

Definition at line 50 of file minimal.py.

50 def execute(self):
51 """Create the basf2 path then run the job"""
52 # Create path and run #
53
54 path = self.create_path()
55 self.adjust_path(path)
56 self.run(path)
57

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

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

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

◆ n_events

n_events = 10000
static

By default, process 10000 events.

Definition at line 111 of file minimal.py.

◆ n_events_to_skip

int n_events_to_skip = 0
static

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
static

By default, no parallel processing.

Definition at line 117 of file minimal.py.

◆ random_seed

random_seed = None
static

By default, the random-number seed is unassigned.

Definition at line 115 of file minimal.py.

◆ root_input_file

root_input_file = None
static

By default, there is no input ROOT TFile.

Definition at line 113 of file minimal.py.


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