26 MausRootHitFactory reads hits of a specified type from a root spill
28 def __init__(self, root_tree, format, entry = 0):
30 Initialise the hit factory
31 - root_tree: a object of type ROOT.TTree that should contain a branch
32 called "Data" containing a list of MAUS.ROOT.TTrees
33 - format: format of data to be extracted from the ROOT document
34 - entry: entry that will be read to get the ROOT data
37 raise KeyError(
"Did not recognise format "+str(format))
45 data = ROOT.MAUS.Data()
46 self.tree.SetBranchAddress(
"data", data)
47 if self.
entry >= self.tree.GetEntries():
48 raise IndexError(
"Out of entries")
49 self.tree.GetEntry(self.
entry)
50 self.
spill = data.GetSpill()
57 Return the next hit from the given spill document
60 while len(self.
hits) == 0:
62 return self.hits.pop(0)
64 raise xboa.hit.BadEventError(
"Run out of events")
68 Read a MAUS spill, converting to MAUS objects
70 if self.
format ==
'virtual_hit':
72 elif self.
format ==
'primary':
77 Read virtuals from the Spill
79 for event, mc_event
in enumerate(self.spill.GetMCEvents()):
80 for virtual_hit
in mc_event.GetVirtualHits():
82 hit[
"x"] = virtual_hit.GetPosition().x()
83 hit[
"y"] = virtual_hit.GetPosition().y()
84 hit[
"z"] = virtual_hit.GetPosition().z()
85 hit[
"px"] = virtual_hit.GetMomentum().x()
86 hit[
"py"] = virtual_hit.GetMomentum().y()
87 hit[
"pz"] = virtual_hit.GetMomentum().z()
88 hit[
"bx"] = virtual_hit.GetBField().x()
89 hit[
"by"] = virtual_hit.GetBField().y()
90 hit[
"bz"] = virtual_hit.GetBField().z()
91 hit[
"ex"] = virtual_hit.GetEField().x()
92 hit[
"ey"] = virtual_hit.GetEField().y()
93 hit[
"ez"] = virtual_hit.GetEField().z()
94 hit[
"pid"] = virtual_hit.GetParticleId()
95 hit[
"station"] = virtual_hit.GetStationId()
96 hit[
"particle_number"] = virtual_hit.GetTrackId()
97 hit[
"t"] = virtual_hit.GetTime()
98 hit[
"mass"] = virtual_hit.GetMass()
99 hit[
"charge"] = virtual_hit.GetCharge()
100 hit[
"proper_time"] = virtual_hit.GetProperTime()
101 hit[
"path_length"] = virtual_hit.GetPathLength()
103 hit[
"event_number"] = event
104 hit.mass_shell_condition(
'energy')
105 self.hits.append(hit)
109 Read primaries from the Spill
111 for event, mc_event
in enumerate(self.spill.GetMCEvents()):
113 primary = mc_event.GetPrimary()
114 hit[
"x"] = primary.GetPosition().x()
115 hit[
"y"] = primary.GetPosition().y()
116 hit[
"z"] = primary.GetPosition().z()
117 hit[
"px"] = primary.GetMomentum().x()
118 hit[
"py"] = primary.GetMomentum().y()
119 hit[
"pz"] = primary.GetMomentum().z()
120 hit[
"pid"] = primary.GetParticleId()
121 hit[
"energy"] = primary.GetEnergy()
123 hit[
"event_number"] = event
124 hit[
"t"] = primary.GetTime()
126 hit[
"mass"] = common.pdg_pid_to_mass[abs(hit[
"pid"])]
129 self.bad_pid(hit[
"pid"])
131 hit[
"charge"] = common.pdg_pid_to_charge[hit[
"charge"]]
134 self.bad_pid(hit[
"pid"])
136 self.hits.append(hit)
141 List of file types that can be read by this class
143 return [
"maus_root_virtual_hit",
"maus_root_primary"]
146 "virtual_hit":
"energy",
def _read_virtual_hits
Read virtuals from the Spill.
The hit factory module defines a number of factory classes used for generating hit objects...
def _read_maus_spill
Read a MAUS spill, converting to MAUS objects.
MausRootHitFactory reads hits of a specified type from a root spill.
def make_hit
Return the next hit from the given spill document.
common module defines common utility data and functions that are used elsewhere
def _read_primaries
Read primaries from the Spill.
dictionary _file_mass_shell
def file_types
List of file types that can be read by this class.
def __init__
Initialise the hit factory.