19 from ROOT
import Belle2
23 return logging.getLogger(__name__)
29 """Configure for a bare-bones basf2 job"""
34 description =
"Empty execution of basf2"
39 raise ValueError(
"Received_unknown unknown argument")
43 """provide name of this object"""
44 return self.__class__.__name__
47 """Configure basf2 job script from command-line arguments then run it"""
52 """Create the basf2 path then run the job"""
60 """Process the basf2 path"""
63 get_logger().info(
'Start processing')
64 basf2.print_path(path)
66 get_logger().info(
"\n%s", str(basf2.statistics))
69 """Convert the command-line arguments to a basf2 job script"""
71 arguments = argument_parser.parse_args()
75 """Save the command-line arguments as key-value pairs"""
78 for (key, value)
in list(vars(arguments).items()):
81 if hasattr(self, key):
82 get_logger().info(
"Setting %s to %s", key, value)
83 setattr(self, key, value)
86 """Parse the command-line arguments to a basf2 job script"""
88 return argument_parser
91 """Create a new basf2 path"""
92 path = basf2.create_path()
96 """Hook that gives the opportunity to check the path for consistency before processing it"""
101 class MinimalRun(EmptyRun):
102 """Configure for a minimal basf2 job"""
105 description =
"Minimally populated execution of basf2"
114 root_input_file =
None
123 """Convert command-line arguments to basf2 argument list"""
125 master_argument_group = argument_parser.add_argument_group(
"Master arguments")
128 master_argument_group.add_argument(
131 default=argparse.SUPPRESS,
132 dest=
'root_input_file',
133 help=
'File path to the ROOT file from which the simulated events shall be loaded.'
136 master_argument_group.add_argument(
142 help=
'Number of events to be generated',
145 master_argument_group.add_argument(
149 default=argparse.SUPPRESS,
151 help=
'The random number generator seed to be set before the processing starts.',
154 master_argument_group.add_argument(
158 default=argparse.SUPPRESS,
160 help=
'The number of parallel processes to be used for processing.',
163 master_argument_group.add_argument(
164 '--n-events-to-skip',
165 dest=
'n_events_to_skip',
166 default=argparse.SUPPRESS,
168 help=
'The number of events to skip',
171 return argument_parser
174 """Create and configure the basf2 path"""
181 environment.setNumberEventsOverride(self.
n_eventsn_events)
186 path.add_module(
'EventInfoSetter',
195 path.add_module(
'RootInput',
200 path.add_module(
'Progress')
204 environment.setNumberProcessesOverride(self.
n_processesn_processes)
static Environment & Instance()
Static method to get a reference to the Environment instance.
def create_argument_parser(self, **kwds)
string description
Description of the run setup to be displayed on command line.
def configure(self, arguments)
def configure_from_commandline(self)
def __init__(self, **kwds)
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.
int n_events_to_skip
By default, do not skip any events at the start of the input ROOT TFile.
root_input_file
By default, there is no input ROOT TFile.
random_seed
By default, the random-number seed is unassigned.
int n_processes
By default, no parallel processing.
bool allow_input
By default, this basf2 job can read events from an input ROOT TFile.