xboa
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Hit Class Reference

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_spill
 Static function returns a list of hit objects found in the spill. More...
 
def new_from_maus_object
 Convert a dict from a maus hit to an xboa hit. 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 read_builtin_formatted
 Read a single event (typically a single line) from a file formatted according to built-in file_type format. More...
 
def write_user_formatted
 Write to a file formatted according to built-in file_type format. More...
 
def read_user_formatted
 Read 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 force_unique_particle_number
 Force all hits in the list to have unique particle numbers. More...
 
def get_maus_tree
 Convert from list of hits to a tree of maus objects. More...
 
def get_maus_dict
 Convert from hit to a maus dict for MAUS IO. 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_bad_pids
 If Hit fails to read a pid, it is stored in list bad_pids for later reference. More...
 
def set_bad_pids
 If Hit fails to read a pid, it is stored in list bad_pids for later reference. More...
 
def 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. More...
 
def set_opal_pid
 Set up opal loss file pid. More...
 
def get_opal_pid
 Get opal loss file pid. More...
 
def set_opal_probes
 Set up opal probe name to station mapping. 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 new_list_from_maus_root_spill = staticmethod(new_list_from_maus_root_spill)
 
tuple new_from_maus_object = staticmethod(new_from_maus_object)
 
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 force_unique_particle_number = staticmethod(force_unique_particle_number)
 
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 get_bad_pids = staticmethod(get_bad_pids)
 
tuple set_bad_pids = staticmethod(set_bad_pids)
 
tuple get_maus_paths = staticmethod(get_maus_paths)
 
tuple set_opal_pid = staticmethod(set_opal_pid)
 
tuple get_opal_pid = staticmethod(get_opal_pid)
 
tuple set_opal_probes = staticmethod(set_opal_probes)
 
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 __read_formatted
 
def __read_opal_loss_file
 
def __read_muon1_csv
 
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 __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', 'g4mice_special_hit', 'g4mice_virtual_hit','mars_1', 'muon1_csv']
 
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 __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 __file_mass_shell
 
dictionary __hit_sort_comparator
 
list __force_unique_particle_number = ['maus_primary']
 
tuple __angular_momentum_centroid = (0.,0.,0.)
 
tuple __angular_momentum_vector = (0.,0.,1.)
 
list __bad_pids = []
 
dictionary __maus_three_vec_conversions
 
dictionary __maus_variable_conversions
 
dictionary __maus_paths
 
dictionary __maus_root_mc_types
 
dictionary __maus_root_recon_types = {}
 
list __opal_ignore_probes = ["RING"]
 
dictionary __opal_probes = {}
 
int __opal_pid = 0
 

Detailed Description

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,

Definition at line 93 of file Hit.py.

Constructor & Destructor Documentation

def __init__ (   self)

Initialise to an empty event.

Alternatively use static initialisers defined below - I prefer static initialisers

Definition at line 99 of file Hit.py.

References Hit.__repr__().

def __del__ (   self)

Clean up.

Definition at line 144 of file Hit.py.

References Hit.new_from_read_builtin.

Referenced by Hit.__ne__().

Member Function Documentation

def __repr__ (   self)

Formatting for print command.

Definition at line 104 of file Hit.py.

References Hit.__deepcopy__().

Referenced by Hit.__init__().

def __copy__ (   self)

Shallow copy i.e.

copy as reference

Definition at line 109 of file Hit.py.

References Hit.__eq__(), and Hit.dict_from_hit().

Referenced by Hit.new_from_maus_object().

def __deepcopy__ (   self,
  target 
)

Deep copy i.e.

copy as data

Definition at line 115 of file Hit.py.

References Hit.__ne__().

Referenced by Hit.__repr__().

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.

References Hit.__eq__(), Bunch.__eq__(), Hit.__getitem__(), Hit.__setitem__(), Hit.get(), and Bunch.get().

Referenced by Hit.__copy__(), and Hit.__eq__().

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.__del__(), and Hit.set().

Referenced by Hit.__deepcopy__().

def __getitem__ (   self,
  variable 
)

Mimic some aspects of dict.

Definition at line 134 of file Hit.py.

References Hit.__hitcore, and Hit.new_from_dict.

Referenced by Hit.__eq__().

def __setitem__ (   self,
  variable,
  value 
)

Mimic some aspects of dict.

Definition at line 139 of file Hit.py.

Referenced by Hit.__eq__().

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.

def 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>

Definition at line 176 of file Hit.py.

def 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)

Definition at line 195 of file Hit.py.

def 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

Definition at line 212 of file Hit.py.

References Hit.new_from_maus_object.

def 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

Definition at line 244 of file Hit.py.

References Bunch.__copy__(), Hit.__copy__(), Hit.copy(), Hit.deepcopy(), and Hit.get_vector().

def copy (   self)

Return a shallow copy of self (copying data as references)

Definition at line 265 of file Hit.py.

Referenced by Hit.new_from_maus_object().

def deepcopy (   self)

Return a deep copy of target (deep copying target's data to self as well)

Definition at line 270 of file Hit.py.

References Hit.get(), Bunch.get(), Hit.mass_shell_condition(), Hit.set(), and Hit.translate().

Referenced by Hit.new_from_maus_object().

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.

  • 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'])

Definition at line 286 of file Hit.py.

References Hit.abelian_transformation(), and Hit.get_vector().

Referenced by Hit.get_vector(), and Hit.new_from_maus_object().

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 302 of file Hit.py.

References Hit.mass_shell_condition(), and Hit.set().

Referenced by Hit.deepcopy().

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

  • 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

Definition at line 321 of file Hit.py.

References Hit.get(), Bunch.get(), and Hit.set().

Referenced by Hit.get_vector().

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 342 of file Hit.py.

References Hit.__get_variables, Hit.__mass_shell_variables, Hit.__set_variables, Hit.get(), and Hit.set().

Referenced by Hit.__read_formatted(), Hit.deepcopy(), Hit.file_header(), Hit.get_global_weight(), and Hit.translate().

def get (   self,
  key 
)
def set (   self,
  key,
  value 
)
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 406 of file Hit.py.

References Hit.__file_formats, Hit.__file_units, Hit.__write_formatted(), Hit.get(), Bunch.get(), and Hit.set().

Referenced by Hit.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 423 of file Hit.py.

References Hit.get(), Bunch.get(), Hit.set(), and Hit.write_list_builtin_formatted.

Referenced by Hit.__copy__(), and Hit.set().

def 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

Definition at line 440 of file Hit.py.

Referenced by 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.

  • 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

Definition at line 465 of file Hit.py.

References Hit.file_header, and Hit.open_filehandle_for_writing.

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 519 of file Hit.py.

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 537 of file Hit.py.

References Hit.__bad_pids, Hit.__file_mass_shell, Hit.get(), Bunch.get(), and Hit.mass_shell_condition().

def 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

Definition at line 552 of file Hit.py.

References Hit.__read_formatted(), Hit.__write_formatted(), Hit.file_types(), Hit.force_unique_particle_number, Hit.get(), Bunch.get(), Hit.read_user_formatted(), and Hit.set().

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.

  • 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.nosp@m.@0.0.nosp@m.02@0.001.nosp@m.@0.0.nosp@m.02 in some_file

Definition at line 591 of file Hit.py.

def 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

Definition at line 605 of file Hit.py.

References Hit.get_maus_tree.

Referenced by Hit.read_builtin_formatted().

def file_types ( )

Static function returns a list of available file types.

Definition at line 611 of file Hit.py.

Referenced by Hit.read_builtin_formatted().

def 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

Definition at line 624 of file Hit.py.

def 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)

Definition at line 649 of file Hit.py.

References Hit.set_variables().

def 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)

Definition at line 664 of file Hit.py.

References Hit.get_maus_paths(), Hit.set_bad_pids, and Hit.set_opal_pid.

Referenced by Hit.__read_muon1_csv().

def mass_shell_variables ( )

Static function returns a list of variables suitable for mass_shell_condition calls.

Definition at line 682 of file Hit.py.

def get_variables ( )

Static function returns a list of variable suitable for get calls.

Definition at line 688 of file Hit.py.

def set_variables ( )

Static function returns a list of variable suitable for set calls.

Definition at line 694 of file Hit.py.

Referenced by Hit.get_maus_tree().

def get_bad_pids ( )

If Hit fails to read a pid, it is stored in list bad_pids for later reference.

Returns the list

Definition at line 702 of file Hit.py.

def 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

Definition at line 710 of file Hit.py.

def 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.

Definition at line 719 of file Hit.py.

References Hit.get_phi().

Referenced by Hit.get_maus_dict().

def set_opal_pid (   pid)

Set up opal loss file pid.

  • pid = (int) pdg particle id of particles in the opal_loss file

Definition at line 730 of file Hit.py.

def get_opal_pid ( )

Get opal loss file pid.

Definition at line 738 of file Hit.py.

def 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...

Definition at line 752 of file Hit.py.

References Hit.get_spin().

def get_p (   self)

Returns total momentum of the hit.

Definition at line 760 of file Hit.py.

References Hit.get(), Bunch.get(), Hit.get_ek(), and Hit.set_ek().

Referenced by Hit.get_pphi(), and Hit.get_pt().

def get_r (   self)

Returns transverse distance (i.e.

in x,y space) from 0,0

Definition at line 765 of file Hit.py.

References Hit.get(), Bunch.get(), and Hit.get_l_kin().

def 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

Definition at line 770 of file Hit.py.

References Hit.set_ct().

Referenced by Hit.get_maus_paths().

def get_pt (   self)

Returns transverse momentum of the hit.

Definition at line 775 of file Hit.py.

References Hit.get_p(), and Hit.set_p().

def 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

Definition at line 780 of file Hit.py.

References Hit.get_p(), and Hit.set().

def get_r_squared (   self)

Returns x divergence i.e.

px/pz of the hit

Definition at line 785 of file Hit.py.

References Hit.set_xP().

def get_xP (   self)

Returns x divergence i.e.

px/pz of the hit

Definition at line 790 of file Hit.py.

References Hit.set_yP().

def get_yP (   self)

Returns y divergence i.e.

py/pz of the hit

Definition at line 795 of file Hit.py.

References Hit.set_tP().

def get_tP (   self)

Returns t \'divergence\' i.e.

E/pz of the hit

Definition at line 800 of file Hit.py.

References Hit.get(), and Bunch.get().

def get_rP (   self)

Returns dr/dz = pt/pz of the hit.

Definition at line 805 of file Hit.py.

References Hit.get(), Bunch.get(), and Hit.get_weight().

def get_spin (   self)

Returns absolute value of the spin.

Definition at line 810 of file Hit.py.

References Hit.clear_global_weights().

Referenced by Hit.set_opal_probes().

def get_ct (   self)

Returns speed_of_light*t of the hit.

Definition at line 815 of file Hit.py.

References Hit.delete_global_weights().

def get_ek (   self)

Returns total energy - mass, ie kinetic energy of the hit.

Definition at line 820 of file Hit.py.

References Hit.get(), Bunch.get(), Hit.get_local_weight(), and Hit.set_local_weight().

Referenced by Hit.get_p().

def set_ek (   self,
  value_float 
)

Sets kinetic energy = total energy - mass of the hit.

Definition at line 825 of file Hit.py.

References Hit.get(), Bunch.get(), Hit.get_global_weight(), and Hit.set().

Referenced by Hit.get_p().

def 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

Definition at line 831 of file Hit.py.

References Hit.set(), and Hit.set_global_weight().

Referenced by Hit.get_r().

def set_ct (   self,
  value_float 
)

Sets t = value_float/c_light.

Definition at line 836 of file Hit.py.

References Hit.set_g4bl_unit.

Referenced by Hit.get_phi().

def set_p (   self,
  value_float 
)

Set p to value_float keeping momentum direction constant.

Definition at line 841 of file Hit.py.

Referenced by Hit.get_pt().

def set_xP (   self,
  value_float 
)

Set x\' to value_float keeping pz constant.

Definition at line 852 of file Hit.py.

References Hit.__read_formatted().

Referenced by Hit.get_r_squared().

def set_yP (   self,
  value_float 
)

Set y\' to value_float keeping pz constant.

Definition at line 858 of file Hit.py.

Referenced by Hit.get_xP().

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 864 of file Hit.py.

References Hit.set().

Referenced by Hit.get_yP().

def get_weight (   self)

Returns total weight for this Hit.

Definition at line 874 of file Hit.py.

References Hit.__read_opal_loss_file().

Referenced by Hit.get_rP().

def clear_global_weights ( )

Set all global weights to 1.

Definition at line 879 of file Hit.py.

Referenced by Hit.get_spin().

def delete_global_weights ( )

Clear memory allocated to global weights - also resets global weights to 1.

Definition at line 885 of file Hit.py.

Referenced by Hit.get_ct().

def get_local_weight (   self)

Returns local weight for this Hit.

Definition at line 891 of file Hit.py.

Referenced by Hit.get_ek().

def set_local_weight (   self,
  value 
)

Set local weight for this Hit to be value.

Definition at line 896 of file Hit.py.

Referenced by Hit.get_ek().

def get_global_weight (   self)

Returns global weight for this Hit.

Definition at line 901 of file Hit.py.

References Hit.__read_muon1_csv(), Hit.mass_shell_condition(), and Hit.set().

Referenced by Hit.set_ek().

def set_global_weight (   self,
  value 
)

Set global weight for this Hit to be value.

Definition at line 906 of file Hit.py.

Referenced by Hit.get_l_kin().

def 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

Definition at line 917 of file Hit.py.

def __read_formatted (   self,
  format_list,
  format_units_dict,
  file_handle 
)
private
def __read_opal_loss_file (   self,
  file_handle 
)
private

Definition at line 951 of file Hit.py.

References Hit.__get_maus_root_primary_hits.

Referenced by Hit.get_weight().

def __read_muon1_csv (   self,
  filehandle 
)
private
def __write_formatted (   self,
  format_list,
  format_units_dict,
  file_handle,
  separator = ' ' 
)
private

Definition at line 1015 of file Hit.py.

References Hit.__do_nothing().

Referenced by Hit.__read_formatted(), Hit.check(), and Hit.read_builtin_formatted().

def __get_maus_root_virtual_hits (   mc_event,
  track_number 
)
private

Definition at line 1023 of file Hit.py.

def __get_maus_root_primary_hits (   mc_event,
  track_number 
)
private

Definition at line 1043 of file Hit.py.

def __split_list_by_equality (   a_list,
  sort_attribute 
)
private

Definition at line 1056 of file Hit.py.

def __get_maus_tree_recursive (   list_of_hits,
  maus_path,
  format 
)
private

Definition at line 1066 of file Hit.py.

def __return_one (   self,
  value = '' 
)
private

Definition at line 1086 of file Hit.py.

Referenced by Hit.__read_muon1_csv().

def __do_nothing (   self,
  value = '' 
)
private

Definition at line 1089 of file Hit.py.

Referenced by Hit.__write_formatted().

def __event_cmp (   lhs,
  rhs 
)
private

Definition at line 1175 of file Hit.py.

def __station_cmp (   lhs,
  rhs 
)
private

Definition at line 1179 of file Hit.py.

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 1235 of file Hit.py.

Member Data Documentation

list __slots__ = ['__hitcore']
staticprivate

Definition at line 95 of file Hit.py.

tuple new_from_dict = staticmethod(new_from_dict)
static

Definition at line 164 of file Hit.py.

Referenced by Hit.__getitem__().

tuple new_from_read_builtin = staticmethod(new_from_read_builtin)
static

Definition at line 183 of file Hit.py.

Referenced by Hit.__del__().

tuple new_from_read_user = staticmethod(new_from_read_user)
static

Definition at line 199 of file Hit.py.

tuple new_list_from_maus_root_spill = staticmethod(new_list_from_maus_root_spill)
static

Definition at line 234 of file Hit.py.

tuple new_from_maus_object = staticmethod(new_from_maus_object)
static

Definition at line 261 of file Hit.py.

Referenced by Hit.new_list_from_maus_root_spill().

tuple write_list_builtin_formatted = staticmethod(write_list_builtin_formatted)
static

Definition at line 510 of file Hit.py.

Referenced by Hit.dict_from_hit().

tuple open_filehandle_for_writing = staticmethod(open_filehandle_for_writing)
static

Definition at line 525 of file Hit.py.

Referenced by Hit.write_list_builtin_formatted().

tuple file_header = staticmethod(file_header)
static

Definition at line 541 of file Hit.py.

Referenced by Hit.write_list_builtin_formatted().

tuple file_types = staticmethod(file_types)
static

Definition at line 613 of file Hit.py.

tuple force_unique_particle_number = staticmethod(force_unique_particle_number)
static

Definition at line 638 of file Hit.py.

Referenced by Hit.read_builtin_formatted().

tuple get_maus_tree = staticmethod(get_maus_tree)
static

Definition at line 654 of file Hit.py.

Referenced by Hit.read_user_formatted().

tuple mass_shell_variables = staticmethod(mass_shell_variables)
static

Definition at line 684 of file Hit.py.

tuple get_variables = staticmethod(get_variables)
static

Definition at line 690 of file Hit.py.

tuple set_variables = staticmethod(set_variables)
static

Definition at line 696 of file Hit.py.

tuple get_bad_pids = staticmethod(get_bad_pids)
static

Definition at line 704 of file Hit.py.

tuple set_bad_pids = staticmethod(set_bad_pids)
static

Definition at line 712 of file Hit.py.

Referenced by Hit.get_maus_dict().

tuple get_maus_paths = staticmethod(get_maus_paths)
static

Definition at line 721 of file Hit.py.

tuple set_opal_pid = staticmethod(set_opal_pid)
static

Definition at line 732 of file Hit.py.

Referenced by Hit.get_maus_dict().

tuple get_opal_pid = staticmethod(get_opal_pid)
static

Definition at line 740 of file Hit.py.

tuple set_opal_probes = staticmethod(set_opal_probes)
static

Definition at line 754 of file Hit.py.

tuple clear_global_weights = staticmethod(clear_global_weights)
static

Definition at line 881 of file Hit.py.

tuple delete_global_weights = staticmethod(delete_global_weights)
static

Definition at line 887 of file Hit.py.

tuple set_g4bl_unit = staticmethod(set_g4bl_unit)
static

Definition at line 921 of file Hit.py.

Referenced by Hit.set_ct().

tuple __get_maus_root_virtual_hits = staticmethod(__get_maus_root_virtual_hits)
staticprivate

Definition at line 1041 of file Hit.py.

Referenced by Hit.__read_formatted().

tuple __get_maus_root_primary_hits = staticmethod(__get_maus_root_primary_hits)
staticprivate

Definition at line 1053 of file Hit.py.

Referenced by Hit.__read_opal_loss_file().

tuple __split_list_by_equality = staticmethod(__split_list_by_equality)
staticprivate

Definition at line 1063 of file Hit.py.

Referenced by Hit.__read_muon1_csv().

tuple __get_maus_tree_recursive = staticmethod(__get_maus_tree_recursive)
staticprivate

Definition at line 1084 of file Hit.py.

Referenced by Hit.__read_muon1_csv().

list __file_types = ['icool_for009', 'icool_for003', 'g4beamline_bl_track_file', 'g4mice_special_hit', 'g4mice_virtual_hit','mars_1', 'muon1_csv']
staticprivate

Definition at line 1094 of file Hit.py.

list __mass_shell_variables = ['', 'p', 'px', 'py', 'pz', 'energy']
staticprivate

Definition at line 1106 of file Hit.py.

Referenced by Hit.mass_shell_condition().

dictionary __get_variables
staticprivate
Initial value:
1 = {'p':get_p,'r':get_r,'phi':get_phi,'pt':get_pt,'pphi':get_pphi,'x\'':get_xP,'y\'':get_yP,'t\'':get_tP, 'ct\'':get_tP,'r\'':get_rP,'spin':get_spin,
2  'weight':get_weight,'ct':get_ct,'r_squared':get_r_squared,'z\'':__return_one,'kinetic_energy':get_ek,
3  'l_kin':get_l_kin,'':__do_nothing}

Definition at line 1107 of file Hit.py.

Referenced by Hit.mass_shell_condition().

dictionary __set_variables = {'p':set_p,'x\'':set_xP,'y\'':set_yP,'t\'':set_tP,'ct':set_ct,'kinetic_energy':set_ek,'':__do_nothing}
staticprivate

Definition at line 1110 of file Hit.py.

Referenced by Hit.mass_shell_condition().

dictionary __default_var_types
staticprivate
Initial value:
1 = {'x':float,'y':float,'z':float,'t':float,'px':float,'py':float,'pz':float,'energy':float,'bx':float,'by':float,'bz':float,
2  'ex':float,'ey':float,'ez':float,'eventNumber':int, 'event_number':int, 'particleNumber':int, 'particle_number':int, 'pid':int,'status':int,'station':int,'local_weight':float,
3  'sx':float,'sy':float,'sz':float,'mass':float,'path_length':float,'proper_time':float,'e_dep':float, 'charge':float}

Definition at line 1111 of file Hit.py.

list __get_keys = []
staticprivate

Definition at line 1115 of file Hit.py.

list __set_keys = []
staticprivate

Definition at line 1116 of file Hit.py.

dictionary __file_formats
staticprivate
Initial value:
1 = {
2  'icool_for009' : ['eventNumber', 'particleNumber', 'pid', 'status', 'station', 't', 'x', 'y', 'z', 'px', 'py', 'pz', 'bx', 'by', 'bz', 'local_weight',
3  'ex', 'ey', 'ez', '', 'sx', 'sy', 'sz'],
4  'icool_for003' : ['eventNumber', 'particleNumber', 'pid', 'status', 't', 'local_weight', 'x', 'y', 'z', 'px', 'py', 'pz', 'sx', 'sy', 'sz'],
5  'g4beamline_bl_track_file' : ['x','y','z','px','py','pz','t','pid','eventNumber','particleNumber', '','local_weight'],
6  'ZGoubi' : [],
7  'Turtle' : [],
8  'MadX' : [],
9  'g4mice_special_hit': ['', 'station','','','','','particleNumber','','pid','mass','x','y','z','t','px','py','pz','energy','e_dep','bx','by','bz','ex','ey','ez',
10  '','','', '','','', '','','', '','','','path_length','proper_time'],
11  'g4mice_virtual_hit': ['', 'station','particleNumber','pid','mass','','x','y','z','t','px','py','pz','energy','bx','by','bz','ex','ey','ez','',''],
12  'mars_1' : ['eventNumber','pid','x','y','z','px','py','pz','energy','ct','local_weight']
13  }

Definition at line 1130 of file Hit.py.

Referenced by Hit.check().

dictionary __file_units
staticprivate
Initial value:
1 = {
2  'icool_for009' : {'eventNumber':'', 'particleNumber':'', 'pid':'', 'status':'', 'station':'', 't':'s', 'x':'m', 'y':'m', 'z':'m', 'px':'GeV/c', 'py':'GeV/c',
3  'pz':'GeV/c', 'bx':'T', 'by':'T', 'bz':'T', 'local_weight':'',
4  'ex':'GV/m', 'ey':'GV/m', 'ez':'GV/m', 'sx':'', 'sy':'', 'sz':'', '':''},
5  'icool_for003' : {'eventNumber':'', 'particleNumber':'', 'pid':'', 'status':'', 't':'s', 'local_weight':'', 'x':'m', 'y':'m', 'z':'m', 'px':'GeV/c', 'py':'GeV/c', 'pz':'GeV/c', 'sx':'', 'sy':'', 'sz':''},
6  'g4beamline_bl_track_file' : {'x':'mm','y':'mm','z':'mm','px':'MeV/c','py':'MeV/c','pz':'MeV/c','t':'ns','pid':'','eventNumber':'','station':'','local_weight':'', 'particleNumber':''},
7  'ZGoubi' : {},
8  'Turtle' : {},
9  'MadX' : {},
10  'g4mice_special_hit': {'':'', 'station':'','':'','':'','':'','':'','particleNumber':'','':'','pid':'','mass':'MeV/c2','x':'mm','y':'mm','z':'mm','t':'ns','px':'MeV/c','py':'MeV/c','pz':'MeV/c','energy':'MeV','e_dep':'MeV','bx':'kT','by':'kT','bz':'kT','ex':'GV','ey':'GV','ez':'GV',
11  '':'','':'','':'', '':'','':'','':'', '':'','':'','':'', '':'','':'','':'','path_length':'mm','proper_time':'ns'},
12  'g4mice_virtual_hit': {'':'','station':'','particleNumber':'','':'','pid':'','mass':'MeV/c2','x':'mm','y':'mm','z':'mm','t':'ns','px':'MeV/c','py':'MeV/c','pz':'MeV/c','energy':'MeV','':'','bx':'kT','by':'kT','bz':'kT','ex':'GV','ey':'GV','ez':'GV'},
13  'mars_1' : {'eventNumber':'','pid':'','x':'mm','y':'mm','z':'mm','px':'GeV/c','py':'GeV/c','pz':'GeV/c','energy':'GeV','ct':'cm','local_weight':''},
14  'maus_virtual_hit': {},
15  'maus_primary': {},
16  }

Definition at line 1143 of file Hit.py.

Referenced by Hit.check().

dictionary __file_headers
staticprivate
Initial value:
1 = {
2  'icool_for003':'<user>\n0. 0. 0. 0. 0. 0. 0. 0.\n',
3  'icool_for009':'#<user>\n# units = [s] [m] [GeV/c] [T] [V/m]\nevt par typ flg reg time x y z Px Py Pz Bx By Bz wt Ex Ey Ez arclength polX polY polZ\n',
4  'g4beamline_bl_track_file':'#BLTrackFile <user>\n#x y z Px Py Pz t PDGid EvNum TrkId Parent weight\n',
5  'ZGoubi':'',
6  'Turtle':'',
7  'MadX':'',
8  'g4mice_special_hit':'',
9  'g4mice_virtual_hit':'',
10  'mars_1':'',
11  'maus_virtual_hit':'',
12  'maus_primary':'',
13  }

Definition at line 1160 of file Hit.py.

string __default_user_string = 'File generated by X_BOA'
staticprivate

Definition at line 1173 of file Hit.py.

tuple __event_cmp = staticmethod(__event_cmp)
staticprivate

Definition at line 1177 of file Hit.py.

tuple __station_cmp = staticmethod(__station_cmp)
staticprivate

Definition at line 1181 of file Hit.py.

dictionary __file_mass_shell
staticprivate
Initial value:
1 = {'icool_for009':'energy', 'icool_for003':'energy', 'g4beamline_bl_track_file':'energy', 'zgoubi':'', 'Turtle':'', 'MadX':'',
2  'g4mice_special_hit':'', 'g4mice_virtual_hit':'','mars_1':'energy', 'maus_virtual_hit':'energy', "maus_primary":"p",
3  'opal_loss':'', 'muon1_csv':''}

Definition at line 1183 of file Hit.py.

Referenced by Hit.file_header().

dictionary __hit_sort_comparator
staticprivate
Initial value:
1 = {
2  'icool_for009': __event_cmp,
3  'icool_for003': __event_cmp,
4  'g4beamline_bl_track_file': __event_cmp,
5  'ZGoubi': __event_cmp,
6  'Turtle': __event_cmp,
7  'MadX': __event_cmp,
8  'g4mice_special_hit': __station_cmp,
9  'g4mice_virtual_hit': __station_cmp,
10  'maus_virtual_hit': __event_cmp,
11  'maus_primary': __event_cmp,
12  'mars_1': __event_cmp,
13  'muon1_csv': __event_cmp,
14  }

Definition at line 1187 of file Hit.py.

list __force_unique_particle_number = ['maus_primary']
staticprivate

Definition at line 1202 of file Hit.py.

tuple __angular_momentum_centroid = (0.,0.,0.)
staticprivate

Definition at line 1204 of file Hit.py.

tuple __angular_momentum_vector = (0.,0.,1.)
staticprivate

Definition at line 1205 of file Hit.py.

list __bad_pids = []
staticprivate

Definition at line 1206 of file Hit.py.

Referenced by Hit.file_header().

dictionary __maus_three_vec_conversions
staticprivate
Initial value:
1 = { # maus three vectors are sub-dicts of virtual_hit
2  "maus_virtual_hit":{"position":"", "momentum":"p", "b_field":"b", "e_field":"e"},
3  "maus_primary":{"position":"", "momentum":"p"}
4  }

Definition at line 1208 of file Hit.py.

dictionary __maus_variable_conversions
staticprivate
Initial value:
1 = {
2  "maus_virtual_hit":{"station_id":"station", "particle_id":"pid", "track_id":"particle_number", "time":"t", "mass":"mass", "charge":"charge", "proper_time":"proper_time", "path_length":"path_length"},
3  "maus_primary":{"particle_id":"pid", "time":"t", "energy":"energy"} # we also force "mass" from "pid"
4  }

Definition at line 1213 of file Hit.py.

dictionary __maus_paths
staticprivate
Initial value:
1 = {
2  "maus_virtual_hit":["mc_events", ["particle_number"], "virtual_hits", ["station"]],
3  "maus_primary":["mc_events", ["particle_number"], "primary"],
4  }

Definition at line 1218 of file Hit.py.

dictionary __maus_root_mc_types
staticprivate
Initial value:
1 = {
2  "maus_root_virtual_hit": lambda x, y: Hit.__get_maus_root_virtual_hits(x, y),
3  "maus_root_primary": lambda x, y: Hit.__get_maus_root_primary_hits(x, y)
4  }

Definition at line 1223 of file Hit.py.

dictionary __maus_root_recon_types = {}
staticprivate

Definition at line 1227 of file Hit.py.

list __opal_ignore_probes = ["RING"]
staticprivate

Definition at line 1229 of file Hit.py.

dictionary __opal_probes = {}
staticprivate

Definition at line 1230 of file Hit.py.

int __opal_pid = 0
staticprivate

Definition at line 1231 of file Hit.py.

tuple hit_overview_doc = staticmethod(hit_overview_doc)
static

Definition at line 1278 of file Hit.py.

__hitcore
private

Definition at line 100 of file Hit.py.

Referenced by Hit.__getitem__().


The documentation for this class was generated from the following file: