18 \namespace xboa::tracking::_maus_tracking
20 Should be imported directly from the xboa::tracking namespace
25 import maus_cpp.globals
26 import maus_cpp.simulation
30 from xboa
import common
33 from _tracking_base
import TrackingBase
37 Provides an interface to MAUS tracking routines for use by xboa.algorithms
39 def __init__(self, datacards=None, seed=0):
41 Ensure MAUS is initialised, ready for tracking
42 - datacards json document containing datacards that will be used for
43 initialise MAUS. If datacards is None, TrackingMAUS will not
44 attempt to initialise MAUS and will not check that MAUS is
46 - seed initial random seed; each time a particle is fired, the seed
48 Raises an ImportError if maus is not installed or maus environment is
52 TrackingBase.__init__(self)
53 if type(datacards) == type({})
or type(datacards) == type([]):
54 datacards = json.dumps(datacards)
56 if maus_cpp.globals.has_instance():
57 maus_cpp.globals.death()
58 maus_cpp.globals.birth(datacards)
64 Track a hit and return a list of output hits
65 - hit initial Hit - particle to be tracked (of Hit type)
67 Track a hit and return a list of output hits. The output hits should
68 correspond to e.g. particle crossings over cell ends, depending on the
69 usage of the Tracking object; see algorithm documentation.
71 Spill number will increment by one for each call to track_one or
79 Track many hits and return a list of list of output hits
80 - list_of_hits list of Hits - initial particles to be tracked
82 Track many hits and return a list containing a list of output hits,
83 one for each track. This provides a hook for tracking codes that have
84 significant set up and tear down times, or which simulate collective
85 effects that need to be taken into account by the algorithm
87 Spill number will increment by one for each call to track_one or
91 primary_str = json.dumps(primary_list)
92 mc_events_str = maus_cpp.simulation.track_particles(primary_str)
93 mc_events = json.loads(mc_events_str)
95 for i, event
in enumerate(mc_events)]
97 return hit_list_of_lists
101 Make a list of data from a MAUS mc event
105 if "virtual_hits" in mc_event:
107 for vhit
in mc_event[
"virtual_hits"]]
112 Fill hit data from a MAUS virtual hit
113 - virtual_hit json object corresponding to the hit
114 - event integer event number
117 pid = virtual_hit[
"particle_id"]
118 for key
in 'x',
'y',
'z':
119 hit[key] = virtual_hit[
'position'][key]
120 hit[
"p"+key] = virtual_hit[
'momentum'][key]
122 hit[
"t"] = virtual_hit[
"time"]
123 hit[
"mass"] = common.pdg_pid_to_mass[abs(pid)]
124 hit[
"charge"] = common.pdg_pid_to_charge[pid]
125 hit[
"particle_number"] = virtual_hit[
"track_id"]
126 hit[
"event_number"] = event
127 hit[
"spill"] = self.
spill
128 hit[
"station"] = virtual_hit[
"station_id"]
129 hit.mass_shell_condition(
"energy")
134 Fill hit data from a MAUS primary
137 pid = primary[
"particle_id"]
138 for key
in 'x',
'y',
'z':
139 hit[key] = primary[
'position'][key]
140 hit[
"p"+key] = primary[
'momentum'][key]
142 hit[
"energy"] = primary[
"energy"]
143 hit[
"t"] = primary[
"time"]
144 hit[
"mass"] = common.pdg_pid_to_mass[abs(pid)]
145 hit[
"charge"] = common.pdg_pid_to_charge[pid]
146 hit[
"particle_number"] = particle
147 hit[
"event_number"] = event
148 hit[
"spill"] = self.
spill
154 Fill primary data from a hit
156 primary = {
'primary':
158 'position':{
'x':hit[
"x"],
'y':hit[
"y"],
'z':hit[
"z"]},
159 'momentum':{
'x':hit[
"px"],
'y':hit[
"py"],
'z':hit[
"pz"]},
160 'particle_id':hit[
"pid"],
161 'energy':hit[
"energy"],
def track_one
Track a hit and return a list of output hits.
def track_many
Track many hits and return a list of list of output hits.
Provides an interface to MAUS tracking routines for use by xboa.algorithms.
def _mc_event_to_hit_list
Make a list of data from a MAUS mc event.
def _virtual_hit_to_xboa_hit
Fill hit data from a MAUS virtual hit.
Implemented within this module:
def _primary_to_xboa_hit
Fill hit data from a MAUS primary.
def _hit_to_primary
Fill primary data from a hit.