24 Factory class for line by line reads of output files using a user-defined
27 def __init__(self, format_list, format_units_dict, filehandle, mass_shell_condition):
29 Initialise the factory
30 - format_list = ordered list of strings. Each string should be a valid
32 - format_units_dict = dict of formats mapping from format_list elements
33 to units. Variables that are dimensionless or in natural units should
34 have an empty string to denote natural units. If a variable is not
35 listed at all, a KeyError will be raised
36 - file_handle = file handle made using e.g. open() command
37 - mass_shell_condition = string containing from Hit.mass_shell_variables
38 that determines how the mass shell condition will be calculated (or
40 Returns a new factory class
42 super(LineFactoryBase, self).
__init__()
46 for format
in format_list:
47 err_str =
"Format key '"+str(format)+
"' should be one of: "
48 for var
in xboa.hit.Hit.set_variables():
50 if format
not in xboa.hit.Hit.set_variables():
51 raise KeyError(err_str)
52 if xboa.hit.Hit._default_var_types[format] == float
and format !=
'':
54 raise KeyError(
"Missing unit for variable "+format)
56 if unit
not in common.units:
57 raise KeyError(
"Could not parse unit "+str(unit)+\
58 " for variable "+str(format))
63 Read the next line in the file handle and return a new hit object
70 hit.set(
'mass', common.pdg_pid_to_mass[abs(hit[
'pid'])])
73 hit.set(
'charge', common.pdg_pid_to_charge[hit[
'pid']])
def __init__
Initialise the factory.
The hit factory module defines a number of factory classes used for generating hit objects...
Factory class for line by line reads of output files using a user-defined format. ...
common module defines common utility data and functions that are used elsewhere
Implemented within this module:
def make_hit
Read the next line in the file handle and return a new hit object.