18from ROOT
import Belle2
22 return logging.getLogger(__name__)
28 """Configure for a bare-bones basf2 job"""
33 description =
"Empty execution of basf2"
38 raise ValueError(
"Received_unknown unknown argument")
42 """provide name of this object"""
43 return self.__class__.__name__
46 """Configure basf2 job script from command-line arguments then run it"""
51 """Create the basf2 path then run the job"""
59 """Process the basf2 path"""
62 get_logger().info(
'Start processing')
63 basf2.print_path(path)
65 get_logger().info(
"\n%s", str(basf2.statistics))
68 """Convert the command-line arguments to a basf2 job script"""
70 arguments = argument_parser.parse_args()
74 """Save the command-line arguments as key-value pairs"""
77 for (key, value)
in list(vars(arguments).items()):
80 if hasattr(self, key):
81 get_logger().info(
"Setting %s to %s", key, value)
82 setattr(self, key, value)
85 """Parse the command-line arguments to a basf2 job script"""
87 return argument_parser
89 def create_path(self):
90 """Create a new basf2 path"""
91 path = basf2.create_path()
95 """Hook that gives the opportunity to check the path for consistency before processing it"""
100class MinimalRun(EmptyRun):
101 """Configure for a minimal basf2 job"""
104 description =
"Minimally populated execution of basf2"
113 root_input_file =
None
122 """Convert command-line arguments to basf2 argument list"""
124 master_argument_group = argument_parser.add_argument_group(
"Master arguments")
127 master_argument_group.add_argument(
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.'
135 master_argument_group.add_argument(
141 help=
'Number of events to be generated',
144 master_argument_group.add_argument(
148 default=argparse.SUPPRESS,
150 help=
'The random number generator seed to be set before the processing starts.',
153 master_argument_group.add_argument(
157 default=argparse.SUPPRESS,
159 help=
'The number of parallel processes to be used for processing.',
162 master_argument_group.add_argument(
163 '--n-events-to-skip',
164 dest=
'n_events_to_skip',
165 default=argparse.SUPPRESS,
167 help=
'The number of events to skip',
170 return argument_parser
172 def create_path(self):
173 """Create and configure the basf2 path"""
174 path = super().create_path()
180 environment.setNumberEventsOverride(self.
n_events)
185 path.add_module(
'EventInfoSetter',
194 path.add_module(
'RootInput',
199 path.add_module(
'Progress')
203 environment.setNumberProcessesOverride(self.
n_processes)
static Environment & Instance()
Static method to get a reference to the Environment instance.
def create_argument_parser(self, **kwds)
def configure(self, arguments)
def configure_from_commandline(self)
def __init__(self, **kwds)
str description
Description of the run setup to be displayed on command line.
def configure_and_execute_from_commandline(self)
def adjust_path(self, path)
def create_argument_parser(self, **kwds)
int n_events
By default, process 10000 events.
None random_seed
By default, the random-number seed is unassigned.
int n_events_to_skip
By default, do not skip any events at the start of the input ROOT TFile.
int n_processes
By default, no parallel processing.
bool allow_input
By default, this basf2 job can read events from an input ROOT TFile.
None root_input_file
By default, there is no input ROOT TFile.