xboa
|
Represents a particle at a point in some phase space. More...
Inherits object.
Public Member Functions | |
def | __init__ |
Initialise to an empty event. More... | |
def | __repr__ |
Formatting for print command. More... | |
def | __copy__ |
Shallow copy i.e. More... | |
def | __deepcopy__ |
Deep copy i.e. More... | |
def | __eq__ |
Test for equality of data values between self and target. More... | |
def | __ne__ |
Test for inequality of data values between self and target. More... | |
def | __getitem__ |
Mimic some aspects of dict. More... | |
def | __setitem__ |
Mimic some aspects of dict. More... | |
def | __del__ |
Clean up. More... | |
def | new_from_dict |
Static function returns a new hit object, setting data using string:value dict. More... | |
def | new_from_read_builtin |
Static function returns a new hit object, read from filehandle with a built-in format. More... | |
def | new_from_read_user |
Static function returns a new hit object sets data using string/value pairs from set_dict and forces E^2=p^2+m^2 by changing mass_shell_string. More... | |
def | new_list_from_maus_root |
Static function returns a list of hit objects found in the spill. More... | |
def | new_list_from_maus_json |
Static function returns a list of hit objects found in the spill. More... | |
def | copy |
Return a shallow copy of self (copying data as references) More... | |
def | deepcopy |
Return a deep copy of target (deep copying target's data to self as well) More... | |
def | get_vector |
Return a numpy vector of data values taking data from get_variable_list, relative to some origin. More... | |
def | translate |
Iterate over translation_dict and add the value in the dict to the value stored in Hit. More... | |
def | abelian_transformation |
Perform an abelian transformation about the origin, i.e. More... | |
def | mass_shell_condition |
Change variable represented by variable_string to force E^2 = p^2 + m^2. More... | |
def | get |
Return the value referenced by key. More... | |
def | set |
Set the value referenced by key. More... | |
def | check |
Return True if mass shell condition is obeyed and pid is correct for the mass else return False. More... | |
def | dict_from_hit |
Return a dict that uniquely defines the hit, so that new_from_dict(dict_from_hit(hit)) returns a copy of hit. More... | |
def | write_builtin_formatted |
Write to a file formatted according to built-in file_type format. More... | |
def | write_list_builtin_formatted |
Write a list of hits to a file formatted according to built-in file_type format. More... | |
def | open_filehandle_for_writing |
Open a file handle of the specified type for writing. More... | |
def | file_header |
Return the file_header for the given file_type. More... | |
def | write_user_formatted |
Write to a file formatted according to built-in file_type format. More... | |
def | file_types |
Static function returns a list of available file types. More... | |
def | get_maus_dict |
Convert from hit to a maus dict for MAUS IO. More... | |
def | get_maus_tree |
Convert from list of hits to a tree of maus objects. More... | |
def | mass_shell_variables |
Static function returns a list of variables suitable for mass_shell_condition calls. More... | |
def | get_variables |
Static function returns a list of variable suitable for get calls. More... | |
def | set_variables |
Static function returns a list of variable suitable for set calls. More... | |
def | get_p |
Returns total momentum of the hit. More... | |
def | get_r |
Returns transverse distance (i.e. More... | |
def | get_phi |
Returns transverse angle (i.e. More... | |
def | get_pt |
Returns transverse momentum of the hit. More... | |
def | get_pphi |
Returns transverse angle of momentum (i.e. More... | |
def | get_r_squared |
Returns x divergence i.e. More... | |
def | get_xP |
Returns x divergence i.e. More... | |
def | get_yP |
Returns y divergence i.e. More... | |
def | get_tP |
Returns t \'divergence\' i.e. More... | |
def | get_rP |
Returns dr/dz = pt/pz of the hit. More... | |
def | get_spin |
Returns absolute value of the spin. More... | |
def | get_ct |
Returns speed_of_light*t of the hit. More... | |
def | get_ek |
Returns total energy - mass, ie kinetic energy of the hit. More... | |
def | set_ek |
Sets kinetic energy = total energy - mass of the hit. More... | |
def | get_l_kin |
Returns kinetic angular momentum about the z-axis. More... | |
def | set_ct |
Sets t = value_float/c_light. More... | |
def | set_p |
Set p to value_float keeping momentum direction constant. More... | |
def | set_xP |
Set x\' to value_float keeping pz constant. More... | |
def | set_yP |
Set y\' to value_float keeping pz constant. More... | |
def | set_tP |
Set t\' (dt/dz=-E/pz) to value_float keeping pz constant; note sign of pz may change. More... | |
def | get_weight |
Returns total weight for this Hit. More... | |
def | clear_global_weights |
Set all global weights to 1. More... | |
def | delete_global_weights |
Clear memory allocated to global weights - also resets global weights to 1. More... | |
def | get_local_weight |
Returns local weight for this Hit. More... | |
def | set_local_weight |
Set local weight for this Hit to be value. More... | |
def | get_global_weight |
Returns global weight for this Hit. More... | |
def | set_global_weight |
Set global weight for this Hit to be value. More... | |
def | set_g4bl_unit |
g4beamline_track_file can take different units for length - set the unit here More... | |
def | hit_overview_doc |
Creates some summary documentation for the Hit class. More... | |
Static Public Attributes | |
tuple | new_from_dict = staticmethod(new_from_dict) |
tuple | new_from_read_builtin = staticmethod(new_from_read_builtin) |
tuple | new_from_read_user = staticmethod(new_from_read_user) |
tuple | write_list_builtin_formatted = staticmethod(write_list_builtin_formatted) |
tuple | open_filehandle_for_writing = staticmethod(open_filehandle_for_writing) |
tuple | file_header = staticmethod(file_header) |
tuple | file_types = staticmethod(file_types) |
tuple | get_maus_tree = staticmethod(get_maus_tree) |
tuple | mass_shell_variables = staticmethod(mass_shell_variables) |
tuple | get_variables = staticmethod(get_variables) |
tuple | set_variables = staticmethod(set_variables) |
tuple | clear_global_weights = staticmethod(clear_global_weights) |
tuple | delete_global_weights = staticmethod(delete_global_weights) |
tuple | set_g4bl_unit = staticmethod(set_g4bl_unit) |
tuple | hit_overview_doc = staticmethod(hit_overview_doc) |
Private Member Functions | |
def | __write_formatted |
def | __get_maus_root_virtual_hits |
def | __get_maus_root_primary_hits |
def | __split_list_by_equality |
def | __get_maus_tree_recursive |
def | __split_list_by_equality |
def | __return_one |
def | __do_nothing |
def | __event_cmp |
def | __station_cmp |
Private Attributes | |
__hitcore | |
Static Private Attributes | |
list | __slots__ = ['__hitcore'] |
tuple | __get_maus_root_virtual_hits = staticmethod(__get_maus_root_virtual_hits) |
tuple | __get_maus_root_primary_hits = staticmethod(__get_maus_root_primary_hits) |
tuple | __split_list_by_equality = staticmethod(__split_list_by_equality) |
tuple | __get_maus_tree_recursive = staticmethod(__get_maus_tree_recursive) |
list | __file_types = ['icool_for009', 'icool_for003', 'g4beamline_bl_track_file', 'mars_1'] |
list | __mass_shell_variables = ['', 'p', 'px', 'py', 'pz', 'energy'] |
dictionary | __get_variables |
dictionary | __set_variables = {'p':set_p,'x\'':set_xP,'y\'':set_yP,'t\'':set_tP,'ct':set_ct,'kinetic_energy':set_ek,'':__do_nothing} |
dictionary | _default_var_types |
list | __get_keys = [] |
list | __set_keys = [] |
dictionary | __maus_three_vec_conversions |
dictionary | __maus_variable_conversions |
dictionary | __maus_paths |
dictionary | __maus_root_mc_types |
dictionary | __maus_root_recon_types = {} |
dictionary | __file_formats |
dictionary | __file_units |
dictionary | __file_headers |
string | __default_user_string = 'File generated by X_BOA' |
tuple | __event_cmp = staticmethod(__event_cmp) |
tuple | __station_cmp = staticmethod(__station_cmp) |
dictionary | __hit_sort_comparator |
tuple | __angular_momentum_centroid = (0.,0.,0.) |
tuple | __angular_momentum_vector = (0.,0.,1.) |
list | __bad_pids = [] |
list | __opal_ignore_probes = ["RING"] |
dictionary | __opal_probes = {} |
int | __opal_pid = 0 |
Represents a particle at a point in some phase space.
Hit contains functions for i/o, as well as accessors for rectangular or cylindrical coordinate systems and functions to perform translations, abelian transformations etc.
Hit has the following variables (stored for real in C struct Hitcore)
Additionally,
def __init__ | ( | self | ) |
def __del__ | ( | self | ) |
def __repr__ | ( | self | ) |
Formatting for print command.
Definition at line 104 of file _hit.py.
References Hit.dict_from_hit().
def __copy__ | ( | self | ) |
Shallow copy i.e.
copy as reference
Definition at line 109 of file _hit.py.
Referenced by Hit.copy().
def __deepcopy__ | ( | self, | |
target | |||
) |
def __eq__ | ( | self, | |
target, | |||
float_tolerance = Common.float_tolerance |
|||
) |
Test for equality of data values between self and target.
Definition at line 121 of file _hit.py.
Referenced by Hit.__ne__().
def __ne__ | ( | self, | |
target, | |||
float_tolerance = Common.float_tolerance |
|||
) |
Test for inequality of data values between self and target.
Definition at line 129 of file _hit.py.
References Hit.__eq__(), and Bunch.__eq__().
def __getitem__ | ( | self, | |
variable | |||
) |
Mimic some aspects of dict.
Definition at line 134 of file _hit.py.
References Hit.get(), and Bunch.get().
def __setitem__ | ( | self, | |
variable, | |||
value | |||
) |
def new_from_dict | ( | set_dict, | |
mass_shell_string = '' |
|||
) |
Static function returns a new hit object, setting data using string:value dict.
Then forces E^2=p^2+m^2 by changing mass_shell_string.
- set_dict = dict of string:value pairs where strings are from set_variables() - mass_shell_string = string from list mass_shell_variables that references the value that will be changed to force E^2=p^2+m^2 e.g. myHit = Hit.new_from_dict({'x':5, 'y':0, 'z':100, 'px':0, 'py':5, 'pz':200, 'pid':-13}, 'energy' )
Definition at line 157 of file _hit.py.
References Hit.new_from_dict.
def new_from_read_builtin | ( | format, | |
filehandle | |||
) |
Static function returns a new hit object, read from filehandle with a built-in format.
e.g. myHit = Hit.new_from_read_builtin('zgoubi', myfile) Note that this will read one event, typically corresponding to one line in <filehandle>
Definition at line 176 of file _hit.py.
References Hit.new_from_read_builtin.
def new_from_read_user | ( | format_list, | |
format_units_dict, | |||
filehandle, | |||
mass_shell_condition = '' |
|||
) |
Static function returns a new hit object sets data using string/value pairs from set_dict and forces E^2=p^2+m^2 by changing mass_shell_string.
e.g. myHit = Hit.new_from_read_user(['x','y','z','px','py','pz'], {'x':'mm', 'y':'mm', 'z':'mm', 'px':'MeV/c', 'py':'MeV/c', 'pz':'MeV/c'}, my_input_file)
Definition at line 195 of file _hit.py.
References Hit.new_from_read_user.
def new_list_from_maus_root | ( | cls, | |
format, | |||
root_tree, | |||
entry_number = 0 |
|||
) |
Static function returns a list of hit objects found in the spill.
Returns a list of hit objects. Station number will be taken from the relevant maus_type. event_number will be given by the spill_number. track_number will be given by the index on mc_events or recon_events
def new_list_from_maus_json | ( | cls, | |
format, | |||
filehandle | |||
) |
Static function returns a list of hit objects found in the spill.
Returns a list of hit objects. Station number will be taken from the relevant maus_type. event_number will be given by the spill_number. track_number will be given by the index on mc_events or recon_events.
def copy | ( | self | ) |
Return a shallow copy of self (copying data as references)
Definition at line 240 of file _hit.py.
References Bunch.__copy__(), and Hit.__copy__().
def deepcopy | ( | self | ) |
def get_vector | ( | self, | |
get_variable_list, | |||
origin_dict = {} |
|||
) |
Return a numpy vector of data values taking data from get_variable_list, relative to some origin.
e.g. transverse_vector = myHit.get_vector(['x', 'y', 'px', 'py'])
Definition at line 260 of file _hit.py.
References Hit.get(), and Bunch.get().
Referenced by Hit.abelian_transformation().
def translate | ( | self, | |
translation_dict, | |||
mass_shell_string | |||
) |
Iterate over translation_dict and add the value in the dict to the value stored in Hit.
Then force E^2 = p^2 + m^2
- translation_dict = dict of strings from list set_variables() to floats - mass_shell_string = string from list mass_shell_variables()
Definition at line 276 of file _hit.py.
References Hit.get(), Bunch.get(), UserHitFactory.mass_shell_condition, Hit.mass_shell_condition(), and Hit.set().
def abelian_transformation | ( | self, | |
rotation_list, | |||
rotation_matrix, | |||
translation_dict = {} , |
|||
origin_dict = {} , |
|||
mass_shell_variable = '' |
|||
) |
Perform an abelian transformation about the origin, i.e.
V_out - O = R*(V_in-O) + T. Then force E^2 = p^2 + m^2
e.g. hit.abelian_transformation(['x','px'], array[[1,0.5],[0,1]],{'x':10},'energy') will look like a drift space plus a translation
Definition at line 295 of file _hit.py.
References Hit.get_vector(), UserHitFactory.mass_shell_condition, Hit.mass_shell_condition(), and Hit.set().
def mass_shell_condition | ( | self, | |
variable_string, | |||
float_tolerance = 1.e-6 |
|||
) |
Change variable represented by variable_string to force E^2 = p^2 + m^2.
Definition at line 316 of file _hit.py.
References Hit.__mass_shell_variables, Hit.get(), Bunch.get(), and Hit.set().
Referenced by Hit.abelian_transformation(), and Hit.translate().
def get | ( | self, | |
key | |||
) |
Return the value referenced by key.
Definition at line 351 of file _hit.py.
References Hit.__get_variables.
Referenced by Hit.__getitem__(), Hit.__write_formatted(), Hit.check(), Hit.get_ek(), Hit.get_global_weight(), Hit.get_local_weight(), Hit.get_p(), Hit.get_r(), Hit.get_rP(), Hit.get_spin(), Hit.get_vector(), Hit.get_weight(), Hit.mass_shell_condition(), Hit.set_ek(), Hit.set_tP(), Hit.translate(), and Hit.write_builtin_formatted().
def set | ( | self, | |
key, | |||
value | |||
) |
Set the value referenced by key.
Definition at line 368 of file _hit.py.
References Hit.__set_variables.
Referenced by Hit.__setitem__(), Hit.abelian_transformation(), Hit.mass_shell_condition(), Hit.set_global_weight(), Hit.set_local_weight(), Hit.set_p(), Hit.translate(), and Hit.write_builtin_formatted().
def check | ( | self, | |
tolerance_float = 1e-3 |
|||
) |
Return True if mass shell condition is obeyed and pid is correct for the mass else return False.
Definition at line 380 of file _hit.py.
References Hit.get(), and Bunch.get().
def dict_from_hit | ( | self | ) |
Return a dict that uniquely defines the hit, so that new_from_dict(dict_from_hit(hit)) returns a copy of hit.
Definition at line 397 of file _hit.py.
Referenced by Hit.__deepcopy__(), and Hit.__repr__().
def write_builtin_formatted | ( | self, | |
format, | |||
file_handle | |||
) |
Write to a file formatted according to built-in file_type format.
e.g. aHit.write_builtin_formatted('icool_for009', for009_dat) would write aHit in icool_for009 format to for009_dat
Definition at line 414 of file _hit.py.
References Hit.__file_formats, Hit.__file_units, Hit.__write_formatted(), Hit.get(), Bunch.get(), and Hit.set().
def write_list_builtin_formatted | ( | list_of_hits, | |
file_type_string, | |||
file_name, | |||
user_comment = None |
|||
) |
Write a list of hits to a file formatted according to built-in file_type format.
For example, aHit.write_list_builtin_formatted([hit1, hit2] 'icool_for009', 'for009_dat') would write hit1, hit2 in icool_for009 format to for009_dat
Definition at line 439 of file _hit.py.
References Hit.write_list_builtin_formatted.
def open_filehandle_for_writing | ( | file_type_string, | |
file_name, | |||
user_comment = None |
|||
) |
Open a file handle of the specified type for writing.
Some filehandles need special care, e.g. some are gzipped etc
- file_type_string = open filehandle for this file type - file_name = string name of the file
Definition at line 480 of file _hit.py.
References Hit.open_filehandle_for_writing.
def file_header | ( | file_type_string, | |
user_comment = None |
|||
) |
Return the file_header for the given file_type.
Optionally, can add a user comment
- file_type_string = header returned for this file type. Select from file_types() - user_comment = add a user comment - default is 'File generated by xboa' e.g. Hit.file_header('icool_for009', 'This is my for009 file') would set 'This is my for009 file' as a user comment and return the header string
Definition at line 497 of file _hit.py.
References Hit.file_header.
def write_user_formatted | ( | self, | |
format_list, | |||
format_units_dict, | |||
file_handle, | |||
separator = ' ' |
|||
) |
Write to a file formatted according to built-in file_type format.
e.g. aHit.write_user_formatted(['x','px','y','py'], ['x':'m','y':'m','px':'MeV/c','py':'MeV/c'], some_file, '@') would make output like 0.001@ @0.0 020.001 in some_file @0.0 02
Definition at line 514 of file _hit.py.
References Hit.__write_formatted().
def file_types | ( | ) |
Static function returns a list of available file types.
Definition at line 519 of file _hit.py.
Referenced by MausJsonHitFactory.__init__(), and MausRootHitFactory.__init__().
def get_maus_dict | ( | self, | |
type_name | |||
) |
Convert from hit to a maus dict for MAUS IO.
Returns a tuple of (maus_dict, spill_number)
Definition at line 531 of file _hit.py.
Referenced by Hit.__get_maus_tree_recursive().
def get_maus_tree | ( | list_of_hits, | |
type_name | |||
) |
Convert from list of hits to a tree of maus objects.
Return value is a list of maus spills (each of which is a data tree)
Definition at line 555 of file _hit.py.
References Hit.get_maus_tree.
def mass_shell_variables | ( | ) |
def get_variables | ( | ) |
def set_variables | ( | ) |
def get_p | ( | self | ) |
Returns total momentum of the hit.
Definition at line 586 of file _hit.py.
References Hit.get(), and Bunch.get().
Referenced by Hit.set_p().
def get_r | ( | self | ) |
Returns transverse distance (i.e.
in x,y space) from 0,0
Definition at line 591 of file _hit.py.
References Hit.get(), and Bunch.get().
def get_phi | ( | self | ) |
def get_pphi | ( | self | ) |
def get_r_squared | ( | self | ) |
def get_xP | ( | self | ) |
def get_yP | ( | self | ) |
def get_tP | ( | self | ) |
def get_rP | ( | self | ) |
Returns dr/dz = pt/pz of the hit.
Definition at line 631 of file _hit.py.
References Hit.get(), and Bunch.get().
def get_spin | ( | self | ) |
Returns absolute value of the spin.
Definition at line 636 of file _hit.py.
References Hit.get(), and Bunch.get().
def get_ek | ( | self | ) |
Returns total energy - mass, ie kinetic energy of the hit.
Definition at line 646 of file _hit.py.
References Hit.get(), and Bunch.get().
def set_ek | ( | self, | |
value_float | |||
) |
Sets kinetic energy = total energy - mass of the hit.
Definition at line 651 of file _hit.py.
References Hit.get(), and Bunch.get().
def get_l_kin | ( | self | ) |
def set_ct | ( | self, | |
value_float | |||
) |
def set_p | ( | self, | |
value_float | |||
) |
Set p to value_float keeping momentum direction constant.
Definition at line 667 of file _hit.py.
References Hit.get_p(), and Hit.set().
def set_xP | ( | self, | |
value_float | |||
) |
def set_yP | ( | self, | |
value_float | |||
) |
def set_tP | ( | self, | |
value_float | |||
) |
Set t\' (dt/dz=-E/pz) to value_float keeping pz constant; note sign of pz may change.
Definition at line 690 of file _hit.py.
References Hit.get(), and Bunch.get().
def get_weight | ( | self | ) |
Returns total weight for this Hit.
Definition at line 700 of file _hit.py.
References Hit.get(), and Bunch.get().
def delete_global_weights | ( | ) |
def get_local_weight | ( | self | ) |
Returns local weight for this Hit.
Definition at line 717 of file _hit.py.
References Hit.get(), and Bunch.get().
def set_local_weight | ( | self, | |
value | |||
) |
def get_global_weight | ( | self | ) |
Returns global weight for this Hit.
Definition at line 727 of file _hit.py.
References Hit.get(), and Bunch.get().
def set_global_weight | ( | self, | |
value | |||
) |
def set_g4bl_unit | ( | unit | ) |
g4beamline_track_file can take different units for length - set the unit here
e.g. set_g4bl_unit('m') would set the length unit to metres
Definition at line 743 of file _hit.py.
References Hit.set_g4bl_unit.
|
private |
Definition at line 750 of file _hit.py.
References Hit.get(), and Bunch.get().
Referenced by Hit.write_builtin_formatted(), and Hit.write_user_formatted().
|
private |
Definition at line 758 of file _hit.py.
References Hit.__get_maus_root_virtual_hits.
|
private |
Definition at line 778 of file _hit.py.
References Hit.__get_maus_root_primary_hits.
|
private |
Definition at line 791 of file _hit.py.
References Hit.__split_list_by_equality.
|
private |
Definition at line 801 of file _hit.py.
References Hit.__get_maus_tree_recursive, and Hit.get_maus_dict().
|
private |
Definition at line 824 of file _hit.py.
References Hit.__split_list_by_equality.
|
private |
Definition at line 936 of file _hit.py.
References Hit.__event_cmp.
|
private |
Definition at line 940 of file _hit.py.
References Hit.__station_cmp.
def hit_overview_doc | ( | verbose = False | ) |
Creates some summary documentation for the Hit class.
If verbose is True then will also print any functions or data not included in summary
Definition at line 973 of file _hit.py.
References Hit.hit_overview_doc.
|
static |
Definition at line 164 of file _hit.py.
Referenced by Hit.new_from_dict().
|
static |
Definition at line 183 of file _hit.py.
Referenced by Hit.new_from_read_builtin().
|
static |
Definition at line 202 of file _hit.py.
Referenced by Hit.new_from_read_user().
|
static |
Definition at line 471 of file _hit.py.
Referenced by Hit.write_list_builtin_formatted().
|
static |
Definition at line 485 of file _hit.py.
Referenced by Hit.open_filehandle_for_writing().
|
static |
Definition at line 501 of file _hit.py.
Referenced by Hit.file_header().
|
static |
Definition at line 521 of file _hit.py.
Referenced by MausJsonHitFactory.__init__(), and MausRootHitFactory.__init__().
|
static |
Definition at line 560 of file _hit.py.
Referenced by Hit.get_maus_tree().
|
static |
|
static |
|
static |
|
static |
Definition at line 747 of file _hit.py.
Referenced by Hit.set_g4bl_unit().
|
staticprivate |
Definition at line 776 of file _hit.py.
Referenced by Hit.__get_maus_root_virtual_hits().
|
staticprivate |
Definition at line 788 of file _hit.py.
Referenced by Hit.__get_maus_root_primary_hits().
|
staticprivate |
Definition at line 798 of file _hit.py.
Referenced by Hit.__split_list_by_equality().
|
staticprivate |
Definition at line 821 of file _hit.py.
Referenced by Hit.__get_maus_tree_recursive().
|
staticprivate |
|
staticprivate |
Definition at line 853 of file _hit.py.
Referenced by Hit.mass_shell_condition().
|
staticprivate |
Definition at line 854 of file _hit.py.
Referenced by Hit.get().
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
Definition at line 899 of file _hit.py.
Referenced by Hit.write_builtin_formatted().
|
staticprivate |
Definition at line 909 of file _hit.py.
Referenced by Hit.write_builtin_formatted().
|
staticprivate |
|
staticprivate |
|
staticprivate |
Definition at line 938 of file _hit.py.
Referenced by Hit.__event_cmp().
|
staticprivate |
Definition at line 942 of file _hit.py.
Referenced by Hit.__station_cmp().
|
staticprivate |
|
staticprivate |
|
static |
Definition at line 1016 of file _hit.py.
Referenced by Hit.hit_overview_doc().
|
private |
Definition at line 100 of file _hit.py.
Referenced by Hit.__del__().