| |
- __builtin__.object
-
- Hitcore.Hitcore
- Hit
- exceptions.IOError(exceptions.EnvironmentError)
-
- BadEventError
class Hit(__builtin__.object) |
|
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)
- **x** transverse horizontal position
- **y** transverse vertical position
- **z** longitudinalposition
- **t** time
- **px** transverse horizontal component of momentum
- **py** transverse vertical component of momentum
- **pz** longitudinal component of momentum
- **energy** total energy
- **local_weight** local statistical weight (for a particular hit)
- **mass** particle mass
- **bx** horizontal component of magnetic field
- **by** vertical component of magnetic field
- **bz** longitudinal component of magnetic field
- **ex** x component of electric field
- **ey** y component of electric field
- **ez** z component of electric field
- **sx** x component of spin vector
- **sy** y component of spin vector
- **sz** z component of spin vector
- **path_length** total distance traversed by a particle
- **proper_time** proper time of the particle
- **e_dep** energy deposited, as registered by a Monte Carlo code
- **charge** particle charge, in units of electron charge
- **station** output plane index
- **pid** PDG particle ID (am I an electron? am I a proton?)
- **status** is the particle track okay? (code dependent)
- **spill** indexes the spill (for MICE)
- **event_number** indexes the event
- **particle_number** indexes the particle track within the event
Additionally,
- global_weight is a global statistical weight (for a particular particle).
All hits with the same (spill, event_number, particle_number) will register
the same global weight. |
|
Methods defined here:
- __copy__(self)
- Shallow copy i.e. copy as reference
- __deepcopy__(self, target)
- Deep copy i.e. copy as data
- __del__(self)
- Clean up
- __eq__(self, target, float_tolerance=1e-09)
- Test for equality of data values between self and target
- __getitem__(self, variable)
- Mimic some aspects of dict
- __init__(self)
- Initialise to an empty event. Alternatively use static initialisers defined below - I prefer static initialisers
- __ne__(self, target, float_tolerance=1e-09)
- Test for inequality of data values between self and target
- __repr__(self)
- Formatting for print command
- __setitem__(self, variable, value)
- Mimic some aspects of dict
- 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
- rotation_list = list of variables to be rotated
- rotation_matrix = matrix R
- translation_dict = dict of strings from set_variables() to floats. Becomes O
- mass_shell_variable = string from list mass_shell_variables()
- origin_dict = dict of strings from set_variables() to floats. Becomes t
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
- check(self, tolerance_float=0.001)
- Return True if mass shell condition is obeyed and pid is correct for the mass else return False
- copy(self)
- Return a shallow copy of self (copying data as references)
- deepcopy(self)
- Return a deep copy of target (deep copying target's data to self as well)
- 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
- get(self, key)
- Return the value referenced by key
- key = string which should be one of the list get_variables()
- get_ct(self)
- Returns speed_of_light*t of the hit
- get_ek(self)
- Returns total energy - mass, ie kinetic energy of the hit
- get_global_weight(self)
- Returns global weight for this Hit
- get_l_kin(self)
- Returns kinetic angular momentum about the z-axis.
To use a different axis, you will have to perform your own transformation
- get_local_weight(self)
- Returns local weight for this Hit
- get_maus_dict(self, type_name)
- Convert from hit to a maus dict for MAUS IO
- type_name = name of the maus type to generate
Returns a tuple of (maus_dict, spill_number)
- get_p(self)
- Returns total momentum of the hit
- get_phi(self)
- Returns transverse angle (i.e. in x,y space) in range (-pi, pi); phi = 0. is positive y and phi = pi/2 is positive x
- get_pphi(self)
- Returns transverse angle of momentum (i.e. in px,py space) in range (-pi, pi); phi = 0. is positive py and phi = pi/2 is positive px
- get_pt(self)
- Returns transverse momentum of the hit
- get_r(self)
- Returns transverse distance (i.e. in x,y space) from 0,0
- get_rP(self)
- Returns dr/dz = pt/pz of the hit
- get_r_squared(self)
- Returns x divergence i.e. px/pz of the hit
- get_spin(self)
- Returns absolute value of the spin
- get_tP(self)
- Returns t 'divergence' i.e. E/pz of the hit
- 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
- get_variable_list = list of variable strings from get_variables()
- origin_dict = dict of variable strings to origin value; if not set, assumes 0
e.g. transverse_vector = myHit.get_vector(['x', 'y', 'px', 'py'])
- get_weight(self)
- Returns total weight for this Hit
- get_xP(self)
- Returns x divergence i.e. px/pz of the hit
- get_yP(self)
- Returns y divergence i.e. py/pz of the hit
- mass_shell_condition(self, variable_string, float_tolerance=1e-06)
- Change variable represented by variable_string to force E^2 = p^2 + m^2
- variable_string = string which should be one of the list mass_shell_variables().
- read_builtin_formatted(self, format, filehandle)
- Read a single event (typically a single line) from a file formatted according to built-in file_type format
- format = string from file_types
- file_handle = file handle made using e.g. open() command
e.g. aHit.read_builtin_formatted('icool_for009', for009_dat) would read aHit in icool_for009 format from for009_dat
- read_user_formatted(self, format_list, format_units_dict, file_handle)
- Read to a file formatted according to built-in file_type format
- format_list = ordered list of strings from get_variables()
- format_units_dict = dict of formats from format_list to units
- file_handle = file handle made using e.g. open() command
e.g. aHit.write_user_formatted('icool_for009', for009_dat) would write aHit in icool_for009 format to for009_dat
- set(self, key, value)
- Set the value referenced by key
- key = string which should be one of the list get_variables()
- value = float
- set_ct(self, value_float)
- Sets t = value_float/c_light
- set_ek(self, value_float)
- Sets kinetic energy = total energy - mass of the hit
- set_global_weight(self, value)
- Set global weight for this Hit to be value
- set_local_weight(self, value)
- Set local weight for this Hit to be value
- set_p(self, value_float)
- Set p to value_float keeping momentum direction constant
- set_tP(self, value_float)
- Set t' (dt/dz=-E/pz) to value_float keeping pz constant; note sign of pz may change
- set_xP(self, value_float)
- Set x' to value_float keeping pz constant
- set_yP(self, value_float)
- Set y' to value_float keeping pz constant
- 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()
- value = get_ct(self)
- write_builtin_formatted(self, format, file_handle)
- Write to a file formatted according to built-in file_type format
- format = string from file_types
- file_handle = file handle made using e.g. open() command
e.g. aHit.write_builtin_formatted('icool_for009', for009_dat) would write aHit in icool_for009 format to for009_dat
- write_user_formatted(self, format_list, format_units_dict, file_handle, separator=' ')
- Write to a file formatted according to built-in file_type format
- format_list = ordered list of strings from get_variables()
- format_units_dict = dict of formats from format_list to units
- file_handle = file handle made using e.g. open() command
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.002@0.001@0.002 in some_file
Static methods defined here:
- clear_global_weights()
- Set all global weights to 1
- delete_global_weights()
- Clear memory allocated to global weights - also resets global weights to 1
- 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
- file_types()
- Static function returns a list of available file types
- force_unique_particle_number(list_of_hits)
- Force all hits in the list to have unique particle numbers
- list_of_hits = list of hits to check for particle numbers
Returns list_of_hits with particle numbers updated to ensure they are unique
Starts adding new particle numbers indexed from 0
- get_bad_pids()
- If Hit fails to read a pid, it is stored in list bad_pids for later reference. Returns the list
- get_maus_paths()
- Returns a dict of <maus_type>:<path> where <maus_type> is a string type name and <path> is a list
that tells how data is stored in maus json dicts.
- get_maus_tree(list_of_hits, type_name)
- Convert from list of hits to a tree of maus objects
- list_of_hits = list of hits to be converted
- type_name = maus type, used to define position in the maus tree
Return value is a list of maus spills (each of which is a data tree)
- get_opal_pid()
- Get opal loss file pid
- get_variables()
- Static function returns a list of variable suitable for get calls
- 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
- mass_shell_variables()
- Static function returns a list of variables suitable for mass_shell_condition calls
- 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' )
- new_from_maus_object(type_name, maus_dict, event_number)
- Convert a dict from a maus hit to an xboa hit
- type_name = name of the maus type
- maus_dict = dict containing maus data
- event_number = indexes the originating spill
- new_from_read_builtin(format, filehandle)
- Static function returns a new hit object, read from filehandle with a built-in format
- format = string from the list file_types() that defines the format of the input
- filehandle = filehandle from which the hit object will be read
e.g. myHit = Hit.new_from_read_builtin('zgoubi', myfile)
Note that this will read one event, typically corresponding to one line in <filehandle>
- new_from_read_user(format_list, format_units_dict, filehandle)
- 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
- format_list = ordered list of variables from get_variables() that contains the particle variables on each line of your input file
- format_units_dict = dict of variables:units that are used to transform to internal system of units
- filehandle = file handle, created using e.g. filehandle = open('for009.dat')
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)
- new_list_from_maus_root_spill(maus_types, root_spill, spill_number)
- Static function returns a list of hit objects found in the spill
- maus_types = list of types to take from the maus file. Types which are not maus_root_types are ignored
- root_spill = maus spill data
- spill_number = maus spill number (used as the event number)
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
- 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
- set_bad_pids(bad_pid_list)
- If Hit fails to read a pid, it is stored in list bad_pids for later reference. Set the list
- set_g4bl_unit(unit)
- g4beamline_track_file can take different units for length - set the unit here
- unit = string that is a unit of length
e.g. set_g4bl_unit('m') would set the length unit to metres
- set_opal_pid(pid)
- Set up opal loss file pid
- pid = (int) pdg particle id of particles in the opal_loss file
- set_opal_probes(probes)
- Set up opal probe name to station mapping
- probes = Dict mapping probe name to station number. Stations should be
numbered sequentially from 1. Station number will be calculated
like hit['station'] = probe_index+n_probes*turn_number. In any
case, xboa will add any unrecognised probe commands as a new
station...
- set_variables()
- Static function returns a list of variable suitable for set calls
- 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
- format = string from file_types
- file_handle = file handle made using e.g. open() command
- user_comment = comment included in some output formats (e.g. problem title, etc)
e.g. aHit.write_builtin_formatted('icool_for009', for009_dat) would write aHit in icool_for009 format to for009_dat
Data and other attributes defined here:
- key = 'ct'
|
class Hitcore(__builtin__.object) |
|
Hitcore objects |
|
Methods defined here:
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- get(...)
- Get variable data
- set(...)
- Set variable data
Static methods defined here:
- clear_global_weights(...)
- Set all global weights to 1
- get_variables(...)
- List of <var> strings appropriate for calls to get(<var>)
- get_weight_dict(...)
- Get the dictionary containing global weights - please don't edit unless you know what you are doing
- integrity_test(...)
- Internal integrity check for Hitcore
- set_variables(...)
- List of <var> strings appropriate for calls to get(<var>)
Data descriptors defined here:
- bx
- x magnetic field
- by
- y magnetic field
- bz
- z magnetic field
- charge
- particle charge
- e_dep
- energy deposited
- energy
- energy
- event_number
- event number
- ex
- x electric field
- ey
- y electric field
- ez
- z electric field
- local_weight
- local_weight
- mass
- mass
- particle_number
- particle number (>0 if more than one particle in each event)
- path_length
- path length
- pid
- PDG particle ID
- proper_time
- proper time
- px
- x momentum
- py
- y momentum
- pz
- z momentum
- spill
- spill number
- station
- station or region
- status
- status - has particle stopped, died, decayed, etc
- sx
- x spin
- sy
- y spin
- sz
- z spin
- t
- time
- x
- x position
- y
- y position
- z
- z position
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
| |